pax_global_header00006660000000000000000000000064147400035660014517gustar00rootroot0000000000000052 comment=c64b4abf7f5e9ca28c1afa3a4609efca961cee02 CGNS-4.5.0/000077500000000000000000000000001474000356600122575ustar00rootroot00000000000000CGNS-4.5.0/.gitattributes000066400000000000000000000000161474000356600151470ustar00rootroot00000000000000*.docx binary CGNS-4.5.0/.github/000077500000000000000000000000001474000356600136175ustar00rootroot00000000000000CGNS-4.5.0/.github/CODEOWNERS000066400000000000000000000002761474000356600152170ustar00rootroot00000000000000# Lines starting with '#' are comments. # Each line is a file pattern followed by one or more owners. # These owners will be the default owners for everything in the repo. * @brtnfld @MicK7CGNS-4.5.0/.github/codeql.yml000066400000000000000000000001551474000356600156120ustar00rootroot00000000000000query-filters: - exclude: id: cpp/toctou-race-condition - exclude: id: cpp/short-global-name CGNS-4.5.0/.github/workflows/000077500000000000000000000000001474000356600156545ustar00rootroot00000000000000CGNS-4.5.0/.github/workflows/codeql.yml000066400000000000000000000051701474000356600176510ustar00rootroot00000000000000name: "CodeQL" on: push: branches: [ "develop", "master" ] pull_request: branches: [ "develop" ] schedule: - cron: "16 7 * * 0" env: hdf5_vers: 1_10_8 jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ cpp ] steps: - name: Install Dependencies (Linux) run: | sudo gem install apt-spy2 sudo apt-spy2 check sudo apt-spy2 fix --commit sudo apt update sudo apt upgrade sudo apt-get install openmpi-bin openmpi-common mpi-default-dev #sudo apt install mpich sudo apt-get install -y libxmu-dev tk-dev tcl-dev sudo apt install libgl1-mesa-dri mesa-utils libgl1-mesa-dev libglu1-mesa-dev # Set env vars echo "OS_NAME=linux" >> $GITHUB_ENV echo "CC=mpicc" >> $GITHUB_ENV echo "FC=mpif90" >> $GITHUB_ENV echo "F77=mpif90" >> $GITHUB_ENV mpiexec_cmd="mpiexec --use-hwthread-cpus -n 4" echo "MPIEXEC=$mpiexec_cmd" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v3 ################################## # INSTALL HDF5 ################################## - name: install HDF5 run: | git clone https://github.com/HDFGroup/hdf5.git --branch hdf5-${{ env.hdf5_vers }} --single-branch hdf5_${{ env.hdf5_vers }} export HOME_DIR=$(echo ~) cd hdf5_${{ env.hdf5_vers }} ./configure --without-zlib --without-szlib --disable-fortran --disable-hl \ --disable-tests --disable-tools \ --prefix=$HOME_DIR/hdf5 \ --enable-parallel make -j 8 install shell: bash ################################## # CONFIGURE CGNS (CMake) ################################## - name: configure CGNS run: | bash .github/workflows/config-cgns.sh cmake \ "--enable-parallel --without-fortran --with-hdf5 --enable-cgnstools" shell: bash - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} config-file: ./.github/codeql.yml queries: +security-and-quality - name: Build run: | cd cbuild cmake --build . --config Release ctest -C Release shell: bash - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: category: "/language:${{ matrix.language }}" CGNS-4.5.0/.github/workflows/codespell.yml000066400000000000000000000010311474000356600203440ustar00rootroot00000000000000# GitHub Action to automate the identification of common misspellings in text files # https://github.com/codespell-project/codespell # https://github.com/codespell-project/actions-codespell name: codespell on: [push, pull_request] jobs: codespell: name: Check for spelling errors runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: codespell-project/actions-codespell@master with: ignore_words_list: inout,patchs,parm,fo,nnumber,nd,celcius,msdos,te,nin,childs,sav,tesselate,hist CGNS-4.5.0/.github/workflows/config-cgns.sh000077500000000000000000000057071474000356600204210ustar00rootroot00000000000000#!/bin/bash NO_COLOR="\033[0m" OK_COLOR="\033[32;01m" WARN_COLOR="\033[33;01m" ERROR_COLOR="\033[31;01m" NOTE_COLOR="\033[36;01m" # # Configure CGNS. # set -e SRC_DIR=$PWD BUILD=$1 OPTS=$2 HDF5_DIR=$HOME/hdf5 OPTS_CMAKE="" if [[ "$OPTS" == *"with-fortran"* ]]; then OPTS_CMAKE="$OPTS_CMAKE -D CGNS_ENABLE_FORTRAN:BOOL=ON" else OPTS_CMAKE="$OPTS_CMAKE -D CGNS_ENABLE_FORTRAN:BOOL=OFF" fi if [[ "$OPTS" == *"with-hdf5"* ]]; then OPTS_CMAKE="$OPTS_CMAKE -D CMAKE_PREFIX_PATH=$HDF5_DIR -D CGNS_ENABLE_HDF5:BOOL=ON -D HDF5_NEED_ZLIB:BOOL=OFF -D HDF5_NEED_SZIP:BOOL=OFF" else OPTS_CMAKE="$OPTS_CMAKE -D CGNS_ENABLE_HDF5:BOOL=OFF" fi if [[ "$OPTS" == *"enable-cgnstools"* ]]; then OPTS="$OPTS --with-tcl=/usr/lib/x86_64-linux-gnu --with-tk=/usr/lib/x86_64-linux-gnu" OPTS_CMAKE="$OPTS_CMAKE -D CGNS_BUILD_CGNSTOOLS:BOOL=ON" else OPTS_CMAKE="$OPTS_CMAKE -D CGNS_BUILD_CGNSTOOLS:BOOL=OFF" fi if [[ "$OS_NAME" = "linux" ]]; then export FLIBS="-Wl,--no-as-needed -ldl" export LIBS="-Wl,--no-as-needed -ldl" # See note in src/ptests/pcgns_ftest.F90 concerning CGNS-109 and Github Actions export FCFLAGS="-D DISABLE_CGNS109" # Do a different test set-up than the autotools build OPTS_CMAKE="$OPTS_CMAKE -D CGNS_ENABLE_LEGACY:BOOL=ON -D CGNS_ENABLE_64BIT:BOOL=OFF" else OPTS_CMAKE="$OPTS_CMAKE -D CMAKE_OSX_ARCHITECTURES:STRING=arm64" fi if [[ "$BUILD" == "cmake" ]]; then ########################## # CMAKE CONFIG ########################## printf "%b\n" "$NOTE_COLOR" printf "%b" "$NOTE_COLOR" " ________ ______ __ __ ______\n" printf "%b" "$NOTE_COLOR" " / ____/ |/ / | / //_// ____/\n" printf "%b" "$NOTE_COLOR" " / / / /|_/ / /| | / ,< / __/ \n" printf "%b" "$NOTE_COLOR" " / /___/ / / / ___ |/ /| |/ /___ \n" printf "%b" "$NOTE_COLOR" " \____/_/ /_/_/ |_/_/ |_/_____/ \n\n" printf "%b\n" "$NO_COLOR" cd $SRC_DIR mkdir cbuild cd cbuild cmake \ ${OPTS_CMAKE} \ -D CMAKE_C_COMPILER:PATH=$CC \ -D CMAKE_C_FLAGS:STRING="$CFLAGS" \ -D CMAKE_BUILD_TYPE:STRING="Debug" \ -D CMAKE_STATIC_LINKER_FLAGS:STRING="" \ -D CGNS_ENABLE_TESTS:BOOL=ON \ -D CGNS_ENABLE_LFS:BOOL=ON \ -D CMAKE_INSTALL_PREFIX:PATH="./" \ -D CMAKE_EXE_LINKER_FLAGS:STRING="$CMAKE_EXE_LINKER_FLAGS" \ .. else ########################## # AUTOTOOLS CONFIG ########################## printf "%b" "$NOTE_COLOR" " ___ __ ____________ __________ ____ __ _____\n" printf "%b" "$NOTE_COLOR" " / | / / / /_ __/ __ \/_ __/ __ \/ __ \/ / / ___/\n" printf "%b" "$NOTE_COLOR" " / /| |/ / / / / / / / / / / / / / / / / / / / \__ \ \n" printf "%b" "$NOTE_COLOR" " / ___ / /_/ / / / / /_/ / / / / /_/ / /_/ / /______/ / \n" printf "%b" "$NOTE_COLOR" " /_/ |_\____/ /_/ \____/ /_/ \____/\____/_____/____/ \n\n" printf "%b\n" "$NO_COLOR" cd src echo "AUTOTOOLS DIR $PWD" ./configure $OPTS \ --prefix=$PWD/cgns_build \ --with-hdf5=$HOME/hdf5 \ --enable-lfs \ --enable-64bit \ --disable-shared \ --enable-debug fiCGNS-4.5.0/.github/workflows/intel.yml000066400000000000000000000151651474000356600175220ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022 Intel Corporation # # SPDX-License-Identifier: MIT name: Intel permissions: read-all on: push: branches: [ develop, master ] pull_request: branches: [ develop, master ] env: # Update urls accordingly for oneapi found at: # https://github.com/oneapi-src/oneapi-ci/blob/master/.github/workflows/build_all.yml SHORTGEN: "vs17" WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ae29263e-38b9-4d43-86c3-376d6e0668e7/intel-oneapi-base-toolkit-2025.0.1.47_offline.exe WINDOWS_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/a37c30c3-a846-4371-a85d-603e9a9eb94c/intel-oneapi-hpc-toolkit-2025.0.1.48_offline.exe LINUX_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/dfc4a434-838c-4450-a6fe-2fa903b75aa7/intel-oneapi-base-toolkit-2025.0.1.46_offline.sh LINUX_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/b7f71cf2-8157-4393-abae-8cea815509f7/intel-oneapi-hpc-toolkit-2025.0.1.47_offline.sh LINUX_AIKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/491d5c2a-67fe-48d0-884f-6aecd88f5d8a/ai-tools-2025.0.0.75_offline.sh WINDOWS_CPP_COMPONENTS: intel.oneapi.win.cpp-dpcpp-common WINDOWS_FORTRAN_COMPONENTS: intel.oneapi.win.ifort-compiler WINDOWS_DPCPP_COMPONENTS: intel.oneapi.win.cpp-dpcpp-common LINUX_CPP_COMPONENTS: intel-oneapi-dpcpp-cpp-compiler LINUX_FORTRAN_COMPONENTS: intel-oneapi-compiler-fortran LINUX_DPCPP_COMPONENTS: intel-oneapi-compiler-dpcpp-cpp LINUX_CPP_COMPONENTS_WEB: intel.oneapi.lin.dpcpp-cpp-compiler LINUX_FORTRAN_COMPONENTS_WEB: intel.oneapi.lin.ifort-compiler LINUX_DPCPP_COMPONENTS_WEB: intel.oneapi.lin.dpcpp-cpp-compiler CACHE_NUMBER: 5 SAMPLES_TAG: 2025.0.0 AI_SAMPLES_TAG: 2025.0.0 COMPILER_VERSION: 2025.0.4 TBB_VERSION: 2022.0.0 VS_VER: vs2022 jobs: build_windows_cpp_fortran: runs-on: windows-latest defaults: run: shell: bash steps: - uses: actions/checkout@v3 - name: Install Core Dependencies run: | choco install -y make choco install -y ninja - name: cache install id: cache-install uses: actions/cache@v4 with: path: | C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat C:\Program Files (x86)\Intel\oneAPI\compiler key: install-${{ env.CACHE_NUMBER }}-${{ env.WINDOWS_HPCKIT_URL }}-${{ env.WINDOWS_CPP_COMPONENTS }}-${{ env.WINDOWS_FORTRAN_COMPONENTS }}-compiler-${{ hashFiles('**/.github/workflows/scripts/cache_exclude_windows.sh') }} - name: install Intel Kit if: steps.cache-install.outputs.cache-hit != 'true' run: .github/workflows/scripts/install_windows.bat $WINDOWS_HPCKIT_URL $WINDOWS_CPP_COMPONENTS:$WINDOWS_FORTRAN_COMPONENTS - name: install HDF5 shell: pwsh run: | mkdir 1.14 cd 1.14 mkdir hdf cd hdf curl -O https://support.hdfgroup.org/releases/hdf5/v1_14/v1_14_5/downloads/hdf5-1.14.5-win-vs2022_intel.msi msiexec /i hdf5-1.14.5-win-vs2022_intel.msi /quiet /qn /norestart /log install.log #type install.log cd ..\.. - name: Configure with Intel Compiler, Build and Test shell: pwsh run: | $intelPath = "C:\Program Files (x86)\Intel\oneAPI\compiler\" $latestVersions = Get-ChildItem -Path $intelPath -Name | Where-Object { $_ -notmatch 'latest' } | Sort-Object $INTEL_LATEST_VERSION = $latestVersions $Env:INTEL_VARS_BAT="C:\Program Files (x86)\Intel\oneAPI\compiler\${INTEL_LATEST_VERSION}\env\vars.bat" if(!(Test-Path "$Env:INTEL_VARS_BAT" -PathType Leaf)) { Write-Host "Intel env vars.bat doesn't exist in expected locations." } & $Env:comspec "/C" '"%INTEL_VARS_BAT%" > nul && pwsh -C "Get-ChildItem env: | Select-Object name,value | ConvertTo-Json"' | ConvertFrom-json | write-output | ForEach-Object {Set-Item "env:$($_.Name)" "$($_.Value)"} $CGNS_SRC="$pwd" mkdir ../CGNS_BUILD cd ../CGNS_BUILD $Env:HDF5_DIR="/Program Files/HDF_Group/HDF5/1.14.5/cmake" $Env:HDF5_ROOT="/Program Files/HDF_Group/HDF5/1.14.5" $Env:CC="icx" $Env:FC="ifx" $Env:CXX="icx" & cmake -G "Ninja" ` -D CGNS_BUILD_SHARED:BOOL=ON -D CGNS_USE_SHARED:BOOL=ON ` -D CGNS_ENABLE_64BIT:BOOL=ON ` -D CMAKE_C_FLAGS:STRING="" ` -D CMAKE_BUILD_TYPE:STRING=Debug ` -D CMAKE_C_COMPILER=icx ` -D CMAKE_Fortran_COMPILER=ifx ` -D HDF5_NEED_ZLIB:BOOL=ON ` -D CMAKE_STATIC_LINKER_FLAGS:STRING="" ` -D CGNS_ENABLE_HDF5:BOOL=ON ` -D HDF5_DIR:PATH="C:\Program Files\HDF_Group\HDF5\1.14.5\cmake" ` -D CMAKE_PREFIX_PATH:PATH="C:\Program Files\HDF_Group\HDF5\1.14.5\cmake" ` -D CGNS_ENABLE_TESTS:BOOL=ON ` -D CGNS_ENABLE_LFS:BOOL=OFF ` -D CGNS_BUILD_CGNSTOOLS:BOOL=OFF ` -D CGNS_ENABLE_SCOPING:BOOL=OFF ` -D CGNS_ENABLE_FORTRAN:BOOL=ON ` -D CGNS_ENABLE_PARALLEL:BOOL=OFF ` -D CMAKE_INSTALL_PREFIX:PATH='.' ` $CGNS_SRC & cmake --build . --config Debug & ctest #.github/workflows/build_windows.bat fortran $VS_VER $SAMPLES_TAG #- name: build # run: scripts/build_windows.bat c++ $VS_VER $SAMPLES_TAG #- name: build fortran # run: scripts/build_windows.bat fortran $VS_VER $SAMPLES_TAG - name: exclude unused files from cache if: steps.cache-install.outputs.cache-hit != 'true' shell: bash run: .github/workflows/scripts/cache_exclude_windows.sh # build_linux_cpp_fortran: # runs-on: ubuntu-latest # defaults: # run: # shell: bash # steps: # - uses: actions/checkout@v3 # - name: cache install # id: cache-install # uses: actions/cache@v4 # with: # path: | # /opt/intel/oneapi/compiler # key: install-${{ env.CACHE_NUMBER }}-${{ env.LINUX_HPCKIT_URL }}-${{ env.LINUX_CPP_COMPONENTS_WEB }}-${{ env.LINUX_FORTRAN_COMPONENTS_WEB }}-compiler-${{ hashFiles('**/.github/workflows/scripts/cache_exclude_linux.sh') }} # # - name: install # if: steps.cache-install.outputs.cache-hit != 'true' # run: .github/workflows/scripts/install_linux.sh $LINUX_HPCKIT_URL # - name: build # run: .github/workflows/scripts/build_linux.sh c++ $SAMPLES_TAG # - name: build fortran # run: .github/workflows/scripts/build_linux.sh fortran $SAMPLES_TAG # # - name: exclude unused files from cache # if: steps.cache-install.outputs.cache-hit != 'true' # run: .github/workflows/scripts/cache_exclude_linux.sh CGNS-4.5.0/.github/workflows/main.yml000066400000000000000000000113521474000356600173250ustar00rootroot00000000000000name: cgns # Controls when the action will run. #Triggers the workflow on push or pull requests. on: push: branches: [ develop, master ] pull_request: branches: [ develop, master ] #on: # push: # pull_request: env: hdf5_vers: 1_14_4 # A workflow run is made up of one or more jobs that # can run sequentially or in parallel jobs: # This workflow contains a single job called "build" build: strategy: matrix: name: ["Ubuntu Latest GCC", "macOS Latest Clang"] include: - name: "Ubuntu Latest GCC" artifact: "Linux.tar.xz" os: ubuntu-latest fortran: with parallel: enable hdf5: with tools: enable - name: "macOS Latest Clang" artifact: "macOS.tar.xz" os: macos-latest parallel: disable fortran: with hdf5: with tools: disable name: ${{ matrix.name }} # The type of runner that the job will run on. runs-on: ${{ matrix.os }} if: "!contains(github.event.head_commit.message, 'skip-ci')" # Steps represent a sequence of tasks that will be executed # as part of the job. steps: - name: Install Dependencies (Linux) if: matrix.os == 'ubuntu-latest' run: | sudo apt update sudo apt upgrade sudo apt-get install openmpi-bin openmpi-common mpi-default-dev # sudo apt-get install mpich sudo apt-get install -y libxmu-dev tk-dev tcl-dev sudo apt install libgl1-mesa-dri mesa-utils libgl1-mesa-dev libglu1-mesa-dev # Set env vars echo "OS_NAME=linux" >> $GITHUB_ENV echo "CC=mpicc" >> $GITHUB_ENV echo "FC=mpif90" >> $GITHUB_ENV echo "F77=mpif90" >> $GITHUB_ENV mpiexec_cmd="mpiexec --use-hwthread-cpus -n 4" echo "MPIEXEC=$mpiexec_cmd" >> $GITHUB_ENV - name: Install Dependencies (macOS) if: matrix.os == 'macos-latest' run: | # Set env vars unset HOMEBREW_NO_INSTALL_FROM_API unset HOMEBREW_NO_AUTO_UPDATE echo "OS_NAME=macOS" >> $GITHUB_ENV # Use the newest stable gcc compiler brew update-reset brew cleanup #brew upgrade gcc brew install gcc brew unlink gcc && brew link gcc echo "FC=gfortran" >> $GITHUB_ENV echo "F77=gfortran" >> $GITHUB_ENV # Set CC version to latest gcc based on gfortran main version #gfortranversion=$( echo "__GNUC__" | gfortran -E -P - | sed 's/ //g' ) #echo "CC=gcc-$gfortranversion" >> $GITHUB_ENV echo "CC=gcc" >> $GITHUB_ENV # Checks-out the repository under $GITHUB_WORKSPACE so the job can access it. - name: Get Sources uses: actions/checkout@v3 ################################## # INSTALL HDF5 ################################## - name: install HDF5 run: | git clone https://github.com/HDFGroup/hdf5.git --branch hdf5_${{ env.hdf5_vers }} --single-branch hdf5_${{ env.hdf5_vers }} export HOME_DIR=$(echo ~) cd hdf5_${{ env.hdf5_vers }} ./configure --without-zlib --without-szlib --disable-fortran --disable-hl \ --disable-tests --disable-tools \ --prefix=$HOME_DIR/hdf5 --disable-nonstandard-feature-float16 \ --${{ matrix.parallel }}-parallel make -j 8 install shell: bash ################################## # DO CMAKE FIRST SINCE AUTOTOOLS # BUILDS IN-PLACE, WHICH AFFECTS # THE CMAKE BUILD ################################## ################################## # CONFIGURE CGNS (CMake) ################################## - name: configure CGNS run: | bash .github/workflows/config-cgns.sh cmake \ "--${{ matrix.parallel }}-parallel --${{ matrix.fortran }}-fortran --${{ matrix.hdf5 }}-hdf5 --${{ matrix.tools }}-cgnstools" shell: bash ################################## # TEST CGNS (CMAKE) ################################## - name: CMake test CGNS run: | cd cbuild cmake --build . --config "Debug" --parallel 8 ctest -C "Debug" -VV --output-on-failure shell: bash ################################## # CONFIGURE CGNS (Autotools) ################################## - name: configure CGNS run: | bash .github/workflows/config-cgns.sh autotools \ "--${{ matrix.parallel }}-parallel --${{ matrix.fortran }}-fortran --${{ matrix.hdf5 }}-hdf5 --${{ matrix.tools }}-cgnstools" shell: bash ################################## # TEST CGNS ################################## - name: test CGNS run: | cd src make -j 8 make test shell: bash # - name: Setup tmate session # if: ${{ failure() }} # uses: mxschmitt/action-tmate@v3 CGNS-4.5.0/.github/workflows/scripts/000077500000000000000000000000001474000356600173435ustar00rootroot00000000000000CGNS-4.5.0/.github/workflows/scripts/README.md000066400000000000000000000002211474000356600206150ustar00rootroot00000000000000# Intel OneAPI build scripts The scripts in this directory can be updated from: CGNS-4.5.0/.github/workflows/scripts/build_linux.sh000077500000000000000000000021421474000356600222170ustar00rootroot00000000000000#!/bin/bash # SPDX-FileCopyrightText: 2020 Intel Corporation # # SPDX-License-Identifier: MIT LANGUAGE=$1 SAMPLES_TAG=$2 git clone --depth 1 --branch "$SAMPLES_TAG" https://github.com/oneapi-src/oneAPI-samples.git #shellcheck disable=SC2010 LATEST_VERSION=$(ls -1 /opt/intel/oneapi/compiler/ | grep -v latest | sort | tail -1) # shellcheck source=/dev/null source /opt/intel/oneapi/compiler/"$LATEST_VERSION"/env/vars.sh sycl-ls case $LANGUAGE in c++) cd oneAPI-samples/DirectProgramming/C++/CompilerInfrastructure/Intrinsics make && make run && make clean && make CC='icx -msse3' && make run ;; fortran) cd oneAPI-samples/DirectProgramming/Fortran/CombinationalLogic/openmp-primes make && make run && make clean && make FC=ifx && make run ;; dpc++) cd oneAPI-samples/DirectProgramming/C++SYCL/DenseLinearAlgebra/simple-add mkdir build && cd build && cmake .. && make cpu-gpu # Sample has additional HW prerequisites. Please check sample Readme for details. Uncomment the following if the prerequisites are met. # mkdir build && cd build && cmake .. && make cpu-gpu && ./simple-add-buffers esac CGNS-4.5.0/.github/workflows/scripts/cache_exclude_linux.sh000077500000000000000000000010011474000356600236650ustar00rootroot00000000000000#!/bin/bash # SPDX-FileCopyrightText: 2020 Intel Corporation # # SPDX-License-Identifier: MIT #shellcheck disable=SC2010 LATEST_VERSION=$(ls -1 /opt/intel/oneapi/compiler/ | grep -v latest | sort | tail -1) sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/compiler/lib/ia32_lin sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/bin/ia32 sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/emu sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/oclfpga CGNS-4.5.0/.github/workflows/scripts/cache_exclude_windows.sh000077500000000000000000000014221474000356600242270ustar00rootroot00000000000000#!/bin/bash # SPDX-FileCopyrightText: 2020 Intel Corporation # # SPDX-License-Identifier: MIT #shellcheck disable=SC2010 LATEST_VERSION=$(ls -1 "C:\Program Files (x86)\Intel\oneAPI\compiler" | grep -v latest | sort | tail -1) rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\compiler\lib\ia32_win" rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\bin\intel64_ia32" rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\emu" rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\oclfpga" rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\ocloc" rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\x86" CGNS-4.5.0/.github/workflows/scripts/install_linux.sh000077500000000000000000000012661474000356600225740ustar00rootroot00000000000000#!/bin/bash # SPDX-FileCopyrightText: 2020 Intel Corporation # # SPDX-License-Identifier: MIT URL=$1 COMPONENTS=$2 curl --output webimage.sh --url "$URL" --retry 5 --retry-delay 5 chmod +x webimage.sh ./webimage.sh -x -f webimage_extracted --log extract.log rm -rf webimage.sh WEBIMAGE_NAME=$(ls -1 webimage_extracted/) if [ -z "$COMPONENTS" ]; then sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --eula=accept --log-dir=. installer_exit_code=$? else sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --log-dir=. installer_exit_code=$? fi rm -rf webimage_extracted exit $installer_exit_code CGNS-4.5.0/.github/workflows/scripts/install_windows.bat000066400000000000000000000014371474000356600232600ustar00rootroot00000000000000REM SPDX-FileCopyrightText: 2022 Intel Corporation REM REM SPDX-License-Identifier: MIT set URL=%1 set COMPONENTS=%2 curl.exe --output %TEMP%\webimage.exe --url %URL% --retry 5 --retry-delay 5 start /b /wait %TEMP%\webimage.exe -s -x -f webimage_extracted --log extract.log del %TEMP%\webimage.exe if "%COMPONENTS%"=="" ( webimage_extracted\bootstrapper.exe -s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=. ) else ( webimage_extracted\bootstrapper.exe -s --action install --components=%COMPONENTS% --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=. ) set installer_exit_code=%ERRORLEVEL% rd /s/q "webimage_extracted" exit /b %installer_exit_code% CGNS-4.5.0/.gitignore000066400000000000000000000011221474000356600142430ustar00rootroot00000000000000# Compiled source # ################### # Object files *.o *.ko *.obj *.elf # Precompiled Headers *.gch *.pch # Libraries *.lib *.a *.la *.lo # Shared objects (inc. Windows DLLs) *.dll *.so *.so.* *.dylib # Executables *.exe *.out *.app *.i*86 *.x86_64 *.hex # Debug files *.dSYM/ *.su # Fortran files *.mod *.MOD # Editor generated files *~ *# **/*~ **/*.bak **/*.sw[abcdefghijklmnop] #CGNS test files *.cgns !src/tests/testfiles/*.cgns #cmake CMakeCache.txt CMakeFiles CMakeScripts Makefile !src/tests/testfiles/Makefile cmake_install.cmake install_manifest.txt CTestTestfile.cmake CGNS-4.5.0/.lgtm.yml000066400000000000000000000014501474000356600140230ustar00rootroot00000000000000########################################################################################## # Customize file classifications. # # Results from files under any classifier will be excluded from LGTM # # statistics. # ########################################################################################## ######################################################################################### # Use the `queries` block to change the default display of query results. # ######################################################################################### queries: - exclude: cpp/toctou-race-condition - exclude: cpp/short-global-name CGNS-4.5.0/CMakeLists.txt000066400000000000000000000402531474000356600150230ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif() if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10") cmake_policy(SET CMP0015 NEW) endif() if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13") cmake_policy(SET CMP0081 NEW) endif() # Macro to handle muticonfig generator macro (SET_CGNS_BUILD_TYPE) get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) set(CGNS_CFG_NAME ${CMAKE_BUILD_TYPE}) set(CGNS_BUILD_TYPE ${CMAKE_CFG_INTDIR}) set(CGNS_CFG_BUILD_TYPE \${CMAKE_INSTALL_CONFIG_NAME}) else() set(CGNS_CFG_BUILD_TYPE ".") if(CMAKE_BUILD_TYPE) set(CGNS_CFG_NAME ${CMAKE_BUILD_TYPE}) set(CGNS_BUILD_TYPE ${CMAKE_BUILD_TYPE}) else() set(CGNS_CFG_NAME "Release") set(CGNS_BUILD_TYPE "Release") endif() endif() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") message (VERBOSE "Setting build type to 'Release' as none was specified.") endif() 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" "MinSizeRel" "RelWithDebInfo") endif() endmacro () SET_CGNS_BUILD_TYPE() project("cgns" C) if (WIN32) set(${CMAKE_INSTALL_LIBDIR} "lib") set(${CMAKE_INSTALL_DATADIR} "share") set(${CMAKE_INSTALL_INCLUDEDIR} "include") set(${CMAKE_INSTALL_BINDIR} "bin") message(STATUS "Setting installation destination on Windows to: ${CMAKE_INSTALL_PREFIX}") else() include(GNUInstallDirs) endif() # Determine CGNS_VERSION from src/cgnslib.h for file (READ ${PROJECT_SOURCE_DIR}/src/cgnslib.h _cgnslib_h_contents) string (REGEX REPLACE ".*#define[ \t]+CGNS_DOTVERS[ \t]+([0-9]*)\\.([0-9])[0-9]*.*$" "\\1.\\2" CGNS_VERSION ${_cgnslib_h_contents}) # Allow for building a package set(CPACK_PACKAGE_VERSION "${CGNS_VERSION}") set(CPACK_PACKAGE_INSTALL_DIRECTORY "cgns-${CGNS_VERSION}") set(CPACK_GENERATOR "STGZ;TGZ;ZIP") set(CPACK_SOURCE_GENERATOR "STGZ;TGZ;ZIP") include(CPack) CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") # if this is cygwin, turn off win32 flag if (CYGWIN) set(WIN32 "NO") endif () ############## # build mode # ############## include(CheckIncludeFile) check_include_file(stdint.h HAVE_STDINT_H) check_include_file(inttypes.h HAVE_INTTYPES_H) if (NOT HAVE_STDINT_H) message(FATAL_ERROR "stdint.h is not found") endif () if (NOT HAVE_INTTYPES_H) message(FATAL_ERROR "inttypes.h is not found") endif () # get some type sizes include(CheckTypeSize) CHECK_TYPE_SIZE(long SIZEOF_LONG) CHECK_TYPE_SIZE(off_t SIZEOF_OFF_T) CHECK_TYPE_SIZE("int64_t" SIZEOF_INT64_T) CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG) if ("${SIZEOF_OFF_T}" LESS 8) option(CGNS_ENABLE_LFS "Enable or disable large file support" "OFF") endif () if ("${CMAKE_SIZEOF_VOID_P}" GREATER 4) option(CGNS_ENABLE_64BIT "Enable or disable 64-bit code building" "ON") else () set(CGNS_ENABLE_64BIT "OFF") endif () option(CGNS_ENABLE_LEGACY "Enable or disable building legacy code (3.0 compatible)" "OFF") option(CGNS_ENABLE_SCOPING "Enable or disable scoping of enumeration values" "OFF") option(CGNS_ENABLE_BASE_SCOPE "Enable or disable base scoped families or connectivities" "OFF") option(CGNS_ENABLE_MEM_DEBUG "Enable or disable memory debugging" "OFF") set(CGNS_BUILD_SHARED "ON" CACHE BOOL "Build a shared version of the library") if (CGNS_ENABLE_LEGACY) set(CGNS_ENABLE_64BIT "OFF") mark_as_advanced(FORCE CGNS_ENABLE_64BIT) else () mark_as_advanced(CLEAR CGNS_ENABLE_64BIT) endif () if (CGNS_ENABLE_64BIT) set(CGNS_ENABLE_LEGACY "OFF") mark_as_advanced(FORCE CGNS_ENABLE_LEGACY) else () mark_as_advanced(CLEAR CGNS_ENABLE_LEGACY) endif () if (CGNS_ENABLE_LFS) include(CheckSymbolExists) if (WIN32) # Windows does not have an _open64 function set(HAVE_OPEN64 0) check_symbol_exists(_lseeki64 "io.h" HAVE_LSEEK64) else () check_symbol_exists(open64 "sys/types.h;sys/stat.h;unistd.h" HAVE_OPEN64) check_symbol_exists(lseek64 "sys/types.h;unistd.h" HAVE_LSEEK64) endif () if (HAVE_OPEN64) add_compile_definitions(HAVE_OPEN64) endif () if (HAVE_LSEEK64) add_compile_definitions(HAVE_LSEEK64) endif () else () remove_definitions(-DHAVE_OPEN64 -DHAVE_LSEEK64) endif () option(CGNS_ENABLE_TESTS "Enable test programs" "OFF") if (CGNS_ENABLE_TESTS) enable_testing() endif () ########### # Fortran # ########### # Allow fortran support to be toggled option(CGNS_ENABLE_FORTRAN "Enable or disable the use of Fortran" "OFF") if (NOT DEFINED FORTRAN_NAMING) set(FORTRAN_NAMING "UNKNOWN") endif () # If we are using fortran, enable it and configure the C-Fortran interface # It would be nice to automatically detect this setting if(CGNS_ENABLE_FORTRAN) enable_language("Fortran" OPTIONAL) #----------------------------------------------------------------------------- # Detect name mangling convention used between Fortran and C #----------------------------------------------------------------------------- set(F2CLIST "LOWERCASE" "LOWERCASE_" "LOWERCASE__" "UPPERCASE" "UPPERCASE_" "UPPERCASE__") set(FORTRAN_NAMING_HELP "Configures how to link the Fortran components into the C library. Options are: LOWERCASE LOWERCASE_ LOWERCASE__ UPPERCASE UPPERRCASE_ UPPERRCASE__ LOWERCASE_ is known to work with gfortran. If this setting does not work with your compiler, try the others until one does. ") include(FortranCInterface) set(FortranCInterface_GLOBAL_SYMBOLS mysub mysub_ mysub__ MYSUB MYSUB_ MYSUB__) FortranCInterface_HEADER(${CMAKE_BINARY_DIR}/FCMangle.h MACRO_NAMESPACE "CGNS_FC_" SYMBOL_NAMESPACE "CGNS_FC_") file (STRINGS ${CMAKE_BINARY_DIR}/FCMangle.h CONTENTS REGEX "CGNS_FC_GLOBAL\\(.*,.*\\) +(.*)") string (REGEX MATCH "CGNS_FC_GLOBAL\\(.*,.*\\) +(.*)" RESULT ${CONTENTS}) set (CGNS_FC_FUNC "${CMAKE_MATCH_1}") file(REMOVE ${CMAKE_BINARY_DIR}/FCMangle.h) if(CGNS_FC_FUNC MATCHES "^NAME(.*)") set (FORTRAN_NAMING "UPPERCASE") elseif(CGNS_FC_FUNC MATCHES "^name(.*)") set (FORTRAN_NAMING "LOWERCASE") endif() if(CGNS_FC_FUNC MATCHES "(.*)__$") set (FORTRAN_NAMING "${FORTRAN_NAMING}__") elseif(CGNS_FC_FUNC MATCHES "(.*)_$") set (FORTRAN_NAMING "${FORTRAN_NAMING}_") endif() message(STATUS "Fortran name mangling convention: ${FORTRAN_NAMING}") # check that FORTRAN_NAMING is valid if (FORTRAN_NAMING STREQUAL "UNKNOWN") if (WIN32) set(FORTRAN_NAMING "UPPERCASE" CACHE STRING ${FORTRAN_NAMING_HELP}) else () set(FORTRAN_NAMING "LOWERCASE_" CACHE STRING ${FORTRAN_NAMING_HELP}) endif () if (${CMAKE_MAJOR_VERSION} GREATER 2 OR ${CMAKE_MINOR_VERSION} GREATER 7) set_property(CACHE FORTRAN_NAMING PROPERTY STRINGS ${F2CLIST}) endif (${CMAKE_MAJOR_VERSION} GREATER 2 OR ${CMAKE_MINOR_VERSION} GREATER 7) else () list(FIND F2CLIST "${FORTRAN_NAMING}" ListIndex) if (ListIndex LESS 0) message(SEND_ERROR "invalid FORTRAN_NAMING value. Must be empty or one of: LOWERCASE LOWERCASE_ LOWERCASE__ UPPERCASE UPPERRCASE_ UPPERRCASE__") endif () endif () if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0) SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch") endif() # Warn about a gfortran 10.2.0 bug (GCC Bug 100149) which # causes cg_goto_f to segfault, other versions are fine. if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER "10.1" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS "10.3") message (WARNING "Fortran mapping (cg_goto_f) is broken for the specified gfortran version. !!! IT'S ADVISABLE TO AVOID VERSION 10.2 !!!") endif() endif (CGNS_ENABLE_FORTRAN) # this forces cmake to set up the required Fortran variables if (CGNS_ENABLE_FORTRAN AND HAS_FORTRAN) enable_language("Fortran") endif () ######## # HDF5 # ######## option(CGNS_ENABLE_HDF5 "Enable or disable HDF5 interface" "ON") if (CGNS_ENABLE_HDF5) if (CGNS_BUILD_SHARED) set (CG_HDF5_LINK_TYPE "shared") set (CG_HDF5_LINK_TYPE_UPPER "SHARED") else () set (CG_HDF5_LINK_TYPE "static") set (CG_HDF5_LINK_TYPE_UPPER "STATIC") set(HDF5_USE_STATIC_LIBRARIES ON) endif () set (FIND_HDF_COMPONENTS C ${CG_HDF5_LINK_TYPE}) message (STATUS "HDF5 find comps: ${FIND_HDF_COMPONENTS}") set (SEARCH_PACKAGE_NAME "hdf5") # If the first `find_package` below does not succeed, then the legacy `find_package` # is tried (the `else` below). The legacy find_package uses `HDF5_ROOT`. But if # this is set, then CMake will issue warning and mistakenly say that `HDF5_ROOT` is # not used even though it might be. This can confuse user, so set policy to not # issue that warning. if (${CMAKE_VERSION} VERSION_GREATER "3.13") cmake_policy(SET CMP0074 NEW) endif() find_package (HDF5 NAMES ${SEARCH_PACKAGE_NAME} COMPONENTS ${FIND_HDF_COMPONENTS}) message (STATUS "HDF5 C libs:${HDF5_FOUND} static:${HDF5_static_C_FOUND} and shared:${HDF5_shared_C_FOUND}") if (HDF5_FOUND) if (NOT HDF5_static_C_FOUND AND NOT HDF5_shared_C_FOUND) if (CG_HDF5_LINK_TYPE STREQUAL "shared") set(CG_HDF5_LINK_TYPE "static") set(CG_HDF5_LINK_TYPE_UPPER "STATIC") else() set(CG_HDF5_LINK_TYPE "shared") set(CG_HDF5_LINK_TYPE_UPPER "SHARED") endif() set (FIND_HDF_COMPONENTS C ${CG_HDF5_LINK_TYPE}) find_package (HDF5 NAMES ${SEARCH_PACKAGE_NAME} COMPONENTS ${FIND_HDF_COMPONENTS} REQUIRED) message (STATUS "HDF5 libs:${HDF5_FOUND} C:${HDF5_C_${CG_HDF5_LINK_TYPE_UPPER}_LIBRARY}") endif() set(LINK_LIBS ${HDF5_C_${CG_HDF5_LINK_TYPE_UPPER}_LIBRARY}) else () find_package (HDF5) # Legacy find #Legacy find_package does not set HDF5_TOOLS_DIR, so we set it here set(HDF5_TOOLS_DIR ${HDF5_LIBRARY}/../bin) #Legacy find_package does not set HDF5_BUILD_SHARED_LIBS, so we set it here set(GUESS_SHARED "${HDF5_LIBRARY}/libhdf5${CMAKE_SHARED_LIBRARY_SUFFIX}") foreach (ITEM ${HDF5_LIBRARIES}) if (ITEM MATCHES "(.*)hdf5${CMAKE_SHARED_LIBRARY_SUFFIX}") set(GUESS_SHARED "${ITEM}") break() endif() endforeach() if (CGNS_BUILD_SHARED AND EXISTS "${GUESS_SHARED}") set (HDF5_BUILD_SHARED_LIBS 1) set (CG_HDF5_LINK_TYPE "shared") set (CG_HDF5_LINK_TYPE_UPPER "SHARED") else () set (HDF5_BUILD_SHARED_LIBS 0) set (CG_HDF5_LINK_TYPE "static") set (CG_HDF5_LINK_TYPE_UPPER "STATIC") endif () set (LINK_LIBS ${HDF5_LIBRARIES}) endif () set (HDF5_PACKAGE_NAME ${SEARCH_PACKAGE_NAME}) if (HDF5_FOUND) if (NOT DEFINED HDF5_INCLUDE_DIRS) set (HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR}) endif() set (HDF5_HAVE_H5PUBCONF_H 1) set (HDF5_HAVE_HDF5 1) set (HDF5_HDF5_HEADER "h5pubconf.h") message (STATUS "HDF5-${HDF5_VERSION} found: INC=${HDF5_INCLUDE_DIRS} TOOLS=${HDF5_TOOLS_DIR} HDF5_BUILD_SHARED_LIBS=${HDF5_BUILD_SHARED_LIBS}") set (HDF5_LIBRARY ${LINK_LIBS}) message (STATUS "HDF5 link libs: ${LINK_LIBS}") else () message (FATAL_ERROR " HDF5 was specified but was not found") endif () set(HDF5_NEED_ZLIB "OFF" CACHE BOOL "Does the HDF5 library require linking to zlib?") if(HDF5_NEED_ZLIB) find_library(ZLIB_LIBRARY z) mark_as_advanced(CLEAR ZLIB_LIBRARY) else () mark_as_advanced(FORCE ZLIB_LIBRARY) endif() set(HDF5_NEED_SZIP "OFF" CACHE BOOL "Does the HDF5 library require linking to szip?") if (HDF5_NEED_SZIP) find_library(SZIP_LIBRARY NAMES szip sz) mark_as_advanced(CLEAR SZIP_LIBRARY) else () mark_as_advanced(FORCE SZIP_LIBRARY) endif () # Check if HDF5 version is 1.8 or greater if (HDF5_VERSION VERSION_LESS "1.8.0") message (FATAL_ERROR "HDF5 ${HDF5_VERSION}: version must be greater than 1.8.0") endif () set(HDF5_NEED_MPI "OFF" CACHE BOOL "Does the HDF5 library require linking to mpi? (Only true if using parallel HDF5)") set(MPI_INC) set(MPI_LIBS) if (HDF5_NEED_MPI) if (NOT MPI_FOUND) include(FindMPI) endif () # MPI variable names changed with cmake 2.8.5 if (DEFINED MPI_C_COMPILER) mark_as_advanced(CLEAR MPI_C_COMPILER MPI_C_INCLUDE_PATH MPI_C_LIBRARIES) mark_as_advanced(FORCE MPI_LIBRARY MPI_EXTRA_LIBRARY) set(MPI_INC ${MPI_C_INCLUDE_PATH}) set(MPI_LIBS ${MPI_C_LIBRARIES}) else () mark_as_advanced(CLEAR MPI_COMPILER MPI_INCLUDE_PATH MPI_LIBRARY MPI_EXTRA_LIBRARY) set(MPI_INC ${MPI_INCLUDE_PATH}) if (MPI_EXTRA_LIBRARY) set(MPI_LIBS ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) else () set(MPI_LIBS ${MPI_LIBRARY}) endif () endif () mark_as_advanced(CLEAR MPIEXEC) else () mark_as_advanced(FORCE MPI_C_COMPILER MPI_C_INCLUDE_PATH MPI_C_LIBRARIES) mark_as_advanced(FORCE MPI_COMPILER MPI_INCLUDE_PATH MPI_LIBRARY MPI_EXTRA_LIBRARY MPIEXEC) endif () mark_as_advanced(CLEAR HDF5_NEED_ZLIB HDF5_NEED_SZIP HDF5_NEED_MPI) #Modern Target Library import if not defined if (NOT TARGET hdf5-${CG_HDF5_LINK_TYPE}) add_library(hdf5-${CG_HDF5_LINK_TYPE} INTERFACE IMPORTED) string(REPLACE "-D" "" _hdf5_definitions "${HDF5_DEFINITIONS}") set_target_properties(hdf5-${CG_HDF5_LINK_TYPE} PROPERTIES INTERFACE_LINK_LIBRARIES "${HDF5_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIRS}" INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") if (CG_HDF5_LINK_TYPE STREQUAL "shared") set_target_properties(hdf5-${CG_HDF5_LINK_TYPE} PROPERTIES INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB) else() set_target_properties(hdf5-${CG_HDF5_LINK_TYPE} PROPERTIES INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_STATIC_LIB) endif() endif () else () mark_as_advanced(FORCE HDF5_NEED_ZLIB HDF5_NEED_SZIP HDF5_NEED_MPI) mark_as_advanced(FORCE ZLIB_LIBRARY SZIP_LIBRARY) mark_as_advanced(FORCE MPI_C_COMPILER MPI_C_INCLUDE_PATH MPI_C_LIBRARIES) mark_as_advanced(FORCE MPI_COMPILER MPI_INCLUDE_PATH MPI_LIBRARY MPI_EXTRA_LIBRARY MPIEXEC) endif () ################# # Parallel CGNS # ################# if (CGNS_ENABLE_HDF5 AND HDF5_NEED_MPI) set(CGNS_ENABLE_PARALLEL "OFF" CACHE BOOL "Enable or disable parallel interface ?") mark_as_advanced(CLEAR CGNS_ENABLE_PARALLEL) # Check that HDF5 has parallel support if (NOT (HDF5_IS_PARALLEL OR HDF5_ENABLE_PARALLEL)) message(FATAL_ERROR "HDF5 has been found, but is missing parallel support.") endif() else () set(CGNS_ENABLE_PARALLEL "OFF") mark_as_advanced(FORCE CGNS_ENABLE_PARALLEL) endif () #################### # RPATH Management # #################### if (CGNS_BUILD_SHARED) # use, i.e. don't skip the full RPATH for the build tree set(CMAKE_SKIP_BUILD_RPATH FALSE) # when building, don't use the install RPATH already # (but later on when installing) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # the RPATH to be used when installing set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}; ${CMAKE_INSTALL_PREFIX}/lib") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_MACOSX_RPATH TRUE) endif() else() set(CMAKE_SKIP_RPATH TRUE) endif() #----------------------------------------------------------------------------- # Dashboard and Testing Settings #----------------------------------------------------------------------------- option (CGNS_BUILD_TESTING "Build CGNS Testing" OFF) if (CGNS_BUILD_TESTING) set (DART_TESTING_TIMEOUT "600" CACHE STRING "Timeout in seconds for each test (default 600=10minutes)" ) enable_testing () include (CTest) include (${PROJECT_SOURCE_DIR}/CTestConfig.cmake) endif () ######## # CGNS # ######## # Include the src directory add_subdirectory(src) CGNS-4.5.0/CTestConfig.cmake000066400000000000000000000027311474000356600154340ustar00rootroot00000000000000## This file should be placed in the root directory of your project. ## Then modify the CMakeLists.txt file in the root directory of your ## project to incorporate the testing dashboard. ## # The following are required to uses Dart and the Cdash dashboard ## ENABLE_TESTING() ## INCLUDE(CTest) set (CTEST_PROJECT_NAME "CGNS") set (CTEST_NIGHTLY_START_TIME "20:00:00 CST") set (CTEST_DROP_METHOD "http") if (CDASH_LOCAL) set (CTEST_DROP_SITE "10.10.10.82") set (CTEST_DROP_LOCATION "/submit.php?project=CGNS") else (CDASH_LOCAL) set (CTEST_DROP_SITE "10.10.10.82") set (CTEST_DROP_LOCATION "/submit.php?project=CGNS") endif (CDASH_LOCAL) set (CTEST_DROP_SITE_CDASH TRUE) set (UPDATE_TYPE git) set (VALGRIND_COMMAND "/usr/bin/valgrind") set (VALGRIND_COMMAND_OPTIONS "-v --tool=memcheck --leak-check=full --track-fds=yes --num-callers=50 --show-reachable=yes --track-origins=yes --malloc-fill=0xff --free-fill=0xfe") set (CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") set (CTEST_MEMORYCHECK_COMMAND_OPTIONS "-v --tool=memcheck --leak-check=full --track-fds=yes --num-callers=50 --show-reachable=yes --track-origins=yes --malloc-fill=0xff --free-fill=0xfe") set (CTEST_TEST_TIMEOUT "600" CACHE STRING "Maximum time allowed before CTest will kill the test.") set (DART_TESTING_TIMEOUT "600" CACHE STRING "Maximum time allowed before CTest will kill the test." FORCE) set (CTEST_SUBMIT_RETRY_DELAY "20" CACHE STRING "How long to wait between timed-out CTest submissions.") CGNS-4.5.0/README.md000066400000000000000000000110661474000356600135420ustar00rootroot00000000000000# CGNS [![Actions Status](https://github.com/CGNS/CGNS/workflows/cgns/badge.svg)](https://github.com/CGNS/CGNS/actions) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/jux83kxj0r234oy6?svg=true)](https://ci.appveyor.com/project/brtnfld/cgns) Coverity Scan Build Status ## About The CFD General Notation System (CGNS) provides a standard for recording and recovering computer data associated with the numerical solution of fluid dynamics equations. ## Bugs/Feature and issue tracking https://cgnsorg.atlassian.net ## Installation ### Installation Instructions using `cmake` 1. Install HDF5 on your system. - HDF5 can use the standard GNU autotools, so `./configure`, `make`, `sudo make install` should install HDF5 without problems on most systems. 2. Unpack the tar ball containing the source code into some directory. 3. Create a new directory in which to build the library. 4. Use `cmake` to initialize the build tree. ```shell user@hostname:build_path$ cmake /path/to/cgns/sources/ ``` 5. Use `ccmake` to edit the control variables as needed. ```shell user@hostname:build_path$ ccmake . ``` - The path to the HDF5 library should be specified with `CMAKE_PREFIX_PATH=$HDF_DIR` for linking with a specific HDF5 version. - If HDF5 is built with parallel-IO support via MPI, the `HDF5_NEED_MPI` flag must be set to `true`. - If HDF5 is built with `zlib` and `szip` support, these need to be flagged with `HDF5_NEED_ZLIB` and `HDF5_NEED_SZIP` as well as the paths for those libraries. - Fortran can be enabled by toggling the `CGNS_ENABLE_FORTRAN` variable. - A view of the attempt to autodetect the correct interface between Fortran and C is show, setting the value of `FORTRAN_NAMING`. - For `gfortran` and `pgf90` the value of `FORTRAN_NAMING` should be `LOWERCASE_`. - The build system must be reconfigured after variable changes by pressing `c`. Variables who's value has changed are marked with a `*` in the interface. - After configuration, the `Makefile`s must be generated by pressing `g`. 6. Use `make` to build the library. ```shell user@hostname:build_path$ make ``` - A colorized review of the build process should follow. 7. Installation of the library is accomplished with the `install` target of the makefile. ```shell user@hostname:build_path$ make install ``` - You must have permissions to alter the directory where CGNS will be installed. ### Installation Instructions using `make` 1. Install HDF5 on your system. - HDF5 can use the standard GNU autotools, so `./configure`, `make`, `sudo make install` should install HDF5 without problems on most systems. 2. Typically the standard `./configure`, `make`, `make install` will suffice. 3. Sample scripts for building parallel CGNS can be found in `src/SampleScripts`. ## Usage ## License The distribution and use of the CGNS software is covered by the following license: ----------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ---------------------------------------------------------------------- This license is borrowed from the zlib/libpng License: http://www.opensource.org/licenses/zlib-license.php and supersedes the GNU Lesser General Public License (LGPL) which previously governed the use and distribution of the software. For details on the policy governing the distribution of the CGNS standard and software see: http://www.grc.nasa.gov/www/cgns/charter/principles.html ## Development CGNS uses the branching/release model as summarized at: http://nvie.com/posts/a-successful-git-branching-model/ ![image](https://github.com/CGNS/cgns.github.io/blob/master/git-model.png) CGNS-4.5.0/appveyor.yml000066400000000000000000000127301474000356600146520ustar00rootroot00000000000000# Notes: # - Minimal appveyor.yml file is an empty file. All sections are optional. # - Indent each level of configuration with 2 spaces. Do not use tabs! # - All section names are case-sensitive. # - Section names should be unique on each level. #---------------------------------# # general configuration # #---------------------------------# # version format version: 4.5.{build} image: - Visual Studio 2022 - Visual Studio 2019 # branches to build branches: # whitelist only: - develop # blacklist # except: # - gh-pages # Do not build on tags (GitHub only) skip_tags: true #---------------------------------# # environment configuration # #---------------------------------# environment: global: 1_8: &1_8 1.8.23 1_10: &1_10 1.10.11 1_12: &1_14 1.14.3 HDF5_1_8_VER: *1_8 HDF5_1_10_VER: *1_10 HDF5_1_14_VER: *1_14 matrix: - build_opt: -D CGNS_BUILD_SHARED:BOOL=OFF -D CGNS_USE_SHARED:BOOL=OFF -D CGNS_ENABLE_64BIT:BOOL=OFF HDF5_VER: *1_8 HDF_DIR: "/Program Files/HDF_Group/HDF5/%HDF5_VER%/cmake" - build_opt: -D CGNS_BUILD_SHARED:BOOL=OFF -D CGNS_USE_SHARED:BOOL=OFF -D CGNS_ENABLE_64BIT:BOOL=ON HDF5_VER: *1_10 HDF_DIR: "/Program Files/HDF_Group/HDF5/%HDF5_VER%/cmake" - build_opt: -D CGNS_BUILD_SHARED:BOOL=ON -D CGNS_USE_SHARED:BOOL=ON -D CGNS_ENABLE_64BIT:BOOL=ON HDF5_VER: *1_10 HDF_DIR: "/Program Files/HDF_Group/HDF5/%HDF5_VER%/cmake" - build_opt: -D CGNS_BUILD_SHARED:BOOL=OFF -D CGNS_USE_SHARED:BOOL=OFF -D CGNS_ENABLE_64BIT:BOOL=ON HDF5_VER: *1_14 HDF_DIR: "/Program Files/HDF_Group/HDF5/%HDF5_VER%/cmake" - build_opt: -D CGNS_BUILD_SHARED:BOOL=ON -D CGNS_USE_SHARED:BOOL=ON -D CGNS_ENABLE_64BIT:BOOL=ON HDF5_VER: *1_14 HDF_DIR: "/Program Files/HDF_Group/HDF5/%HDF5_VER%/cmake" for: - matrix: only: - image: Visual Studio 2019 environment: GENERATOR: "Visual Studio 16 2019" ARCH: "x64" SHORTGEN: "vs16" - matrix: only: - image: Visual Studio 2017 environment: GENERATOR: "Visual Studio 15 2017" ARCH: "x64" SHORTGEN: "vs15" - matrix: only: - image: Visual Studio 2022 environment: GENERATOR: "Visual Studio 17 2022" ARCH: "x64" SHORTGEN: "vs17" # scripts that are called at very beginning, before repo cloning init: - git config --global core.autocrlf input # clone directory clone_folder: c:\projects\CGNS # scripts that run after cloning repository install: # by default, all script lines are interpreted as batch #- echo This is batch # to run script as a PowerShell command prepend it with ps: #- ps: Write-Host 'This is PowerShell' # batch commands start from cmd: #- cmd: echo This is batch again #- cmd: set MY_VAR=12345 # install hdf5 - set PATH=C:\Program Files\Git\mingw64\bin;%PATH% - mkdir 1.8 - cd 1.8 - set HDF5_1_8_VER=%HDF5_1_8_VER% - curl -O https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.23/bin/windows/hdf5-%HDF5_1_8_VER%-Std-win10_64-%SHORTGEN%.zip - ps: Expand-Archive hdf5-$($env:HDF5_1_8_VER)-Std-win10_64-$($env:SHORTGEN).zip -DestinationPath . - cd hdf - msiexec /i HDF5-%HDF5_1_8_VER%-win64.msi /quiet /qn /norestart /log install.log - type install.log - cd ..\.. - mkdir 1.10 - cd 1.10 - set HDF5_1_10=%HDF5_1_10_VER% - curl -O https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.11/bin/windows/hdf5-%HDF5_1_10_VER%-Std-win10_64-%SHORTGEN%.zip - ps: Expand-Archive hdf5-$($env:HDF5_1_10_VER)-Std-win10_64-$($env:SHORTGEN).zip -DestinationPath . - cd hdf - msiexec /i HDF5-%HDF5_1_10_VER%-win64.msi /quiet /qn /norestart /log install.log - type install.log - cd ..\.. - mkdir 1.14 - cd 1.14 - set HDF5_1_14=%HDF5_1_14_VER% - curl -O https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.3/bin/windows/hdf5-%HDF5_1_14_VER%-Std-win10_64-%SHORTGEN%.zip - ps: Expand-Archive hdf5-$($env:HDF5_1_14_VER)-Std-win10_64-$($env:SHORTGEN).zip -DestinationPath . - cd hdf - msiexec /i HDF5-%HDF5_1_14_VER%-win64.msi /quiet /qn /norestart /log install.log - type install.log - cd ..\.. #---------------------------------# # build configuration # #---------------------------------# # build platform, i.e. x86, x64, Any CPU. This setting is optional. platform: Any CPU # to add several platforms to build matrix: #platform: # - x86 # - Any CPU # build Configuration, i.e. Debug, Release, etc. configuration: - Release # scripts to run before build before_build: - echo Running cmake... - mkdir c:\projects\CGNS_BUILD - cd c:\projects\CGNS_BUILD - cmake --version - SET HDF5_DIR=/Program Files/HDF_Group/HDF5/%HDF5_VER%/cmake - cmake -G "%GENERATOR%" -A "%ARCH%" ^ %build_opt% ^ -D CMAKE_C_FLAGS:STRING="" ^ -D CMAKE_BUILD_TYPE:STRING=Release ^ -D HDF5_NEED_ZLIB:BOOL=ON ^ -D CMAKE_STATIC_LINKER_FLAGS:STRING="" ^ -D CGNS_ENABLE_HDF5:BOOL=ON ^ -D CGNS_ENABLE_TESTS:BOOL=ON ^ -D CGNS_ENABLE_LFS:BOOL=OFF ^ -D CGNS_BUILD_CGNSTOOLS:BOOL=OFF ^ -D CGNS_ENABLE_SCOPING:BOOL=OFF ^ -D CGNS_ENABLE_FORTRAN:BOOL=OFF ^ -D CGNS_ENABLE_PARALLEL:BOOL=OFF ^ -D CMAKE_INSTALL_PREFIX:PATH="." c:\projects\CGNS build_script: - cmd: cmake --build . --config "%configuration%" test_script: - cmd: set PATH=C:\projects\CGNS_BUILD\src\%configuration%;%PATH% - cmd: set PATH=C:\Program Files\HDF_Group\HDF5\%HDF5_VER%\bin;%PATH% - cmd: ctest -C %configuration% after_test: - cmd: cmake --install . --config "%configuration%" CGNS-4.5.0/cmake_uninstall.cmake.in000066400000000000000000000016531474000356600170440ustar00rootroot00000000000000IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) STRING(REGEX REPLACE "\n" ";" files "${files}") FOREACH(file ${files}) MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") IF(EXISTS "$ENV{DESTDIR}${file}") EXEC_PROGRAM( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) IF(NOT "${rm_retval}" STREQUAL 0) MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") ENDIF(NOT "${rm_retval}" STREQUAL 0) ELSE(EXISTS "$ENV{DESTDIR}${file}") MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") ENDIF(EXISTS "$ENV{DESTDIR}${file}") ENDFOREACH(file)CGNS-4.5.0/license.txt000066400000000000000000000026461474000356600144520ustar00rootroot00000000000000The distribution and use of the CGNS software is covered by the following license: ----------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ----------------------------------------------------------------------- This license is borrowed from the zlib/libpng License: http://www.opensource.org/licenses/zlib-license.php and supersedes the GNU Lesser General Public License (LGPL) which previously governed the use and distribution of the software. For details on the policy governing the distribution of the CGNS standard and software see: http://www.grc.nasa.gov/www/cgns/charter/principles.html CGNS-4.5.0/release_docs/000077500000000000000000000000001474000356600147075ustar00rootroot00000000000000CGNS-4.5.0/release_docs/CGNS_TestingSpecs.docx000066400000000000000000004260631474000356600210260ustar00rootroot00000000000000PK!¸+Ìã™G[Content_Types].xml ¢( ´•MOÂ@†ï&þ‡f¯¦]ð`Œ¡pP<*‰ÏËv «Ýì,_ÿÞi P¼”å}ßgf;C§·ÐE4Êš”µ“‹ÀH›)3NÙûð9¾ga2QX)[²^÷úª3\:ÀˆÔS6 Á=pŽrZ`b:É­×"Уs'ä—¿mµî¸´&€ q(=X·ó¹˜!ê/èë ÉYô¸ú]•2á\¡¤ÊËS¾Wç¡À#™Évèâ5YBÊÊ'ÊáÍá„Oã¥ËÒª¢z¥vz•A4>¼Mì|n}Æ3+§šêNŽ·‡Ñæ¹’PëK7ç­Dº']$õ‰ÊlØr˜©'ååAjëF Ëðò+ßã?T˜ôó$½¥Í—¢1.;Ÿ¬"¶´Íiõû”Ÿ³7Ý<®æ0zû7Š-óFœ†z(FœÐñ_6£¶n„´¨€WŸí³9*›c‘4žoÒâó({³¡JuLsïÀõŽÚ7çu"mͳëƒr-gíÉæÕß@÷ÿÿPK!ÇÂ'¼ ß _rels/.rels ¢( ¬’ÁNÃ0 †ïH¼Cäûšn „ÐÒ]Òn•0‰×Ú$J<ØÞž°ÃJ¥QMbÇÄΟï÷ïåj×wâ“b²Þ)˜%rÚë¯õÓìDbt;ïHÁž¬ªë«å uÈùQjmH"«¸¤ eR&ÝR©ð\®l|ì‘ó162 þÀ†ä¢,ïdü­ÕHS¬‚¸67 ê}È?ÿG[öÄhQjib&‹l³Qclˆ¯Ÿóu:t™äi Ûóüfc5=z½íÉñ Ï’vLΙF¦ˆæ—$3óùòÑÈ<¤ƒ•)šÅù4/÷ÛþÍ¡í”cTÇZñ¨ù LŽÖ²úÿÿPK!yø— Ý|word/_rels/document.xml.rels ¢( ¼–ÍnÔ0€ïH¼Cä{ãM–¢f{€‚z€]Գ㌳ŽmÙ“¥y{&Yvɪl (Ú‹¥+3ßüx&×7I6¢v6gYº` XéJm«œ}[}<{Ë’ˆÂ–Â8 9ë ²›åË×_Á¤b­}LÈŠ9«ý;Σ¬¡1u,Ý($†Š{!×¢~¾X\ð0¶Á–6“»2gá®Ì2–¬:O®ÿnÜ)¥%|p²mÀâ|ðš,£íšŒŠPnÍÆzcÓºTUp­PI(1r ­]SHA{’à!Xavßv%¡Ýî´üHçs¡œÅ•( ì r¶W¥”ovŒâÕœH5 "ÎlbNÛ6êÕߙث¦ f-GÄÎЫØ7ÔVžr¬–ÁE§0•®áÛnî»øòð¥ð­‡õ­R ñ‰óÑÕÇë9k‘*1fù¥™Bx3'Â(îŸPŒ”S s‚LŒ™ŠªÖCßúrÏûc×;ÿ6L.OD*+id§ˆQ ›ZÀç¡Òò8Íì–D'í1Ý[Ü÷þeð>гþxùÕ‰È1ˆ&@=¬œÿ숌¶öIòL˜Âû t.Œ³Ì‹€V™rHöñ<óƒ†åOÿÿPK!—e¹P$ aDword/document.xmlì][s£H–~߈ý„ç¥'¢]†äî{‚k•#jº*ìêí}ëÀ¶™B T.÷Óü‡}Ú¿7¿dÏÉD"$¡›%wÑíÉ%óäwî'3ÿö÷ï“Xøfy”&WgÒ;ñL“Q:Ž’Ç«³_¿øçÆ™A2â4 ¯Î^Âüìï×ÿù{¾§£Ù$L ^‘ä—ÏÓÑÕÙSQL//.òÑS8 òw“h”¥yúP¼¥“‹ôá!…Ïi6¾ ¢$ÒM³tæ9|Ï ’oA~V¾n’ö{Û$U/&¢h\L‚(©ß±Ø£t&Ð߇4›Eþ.Íá‰ìëlz=œEtÅQñýµú5ß®ÎfYrYŽê¼>s ¸ü6‰«›¡ÛËïe¸dª'²…vt’=â–$§Ý»ÈÂ:œ&ùS4ÓmÛ·=žª.­pc°ÏSIYø^Mž>“îfÁ3Ì}õáçéÂë:ˆ1fMbFÔFí7JbÁWÔ}èÓþ›UOšà{ÞŽ4s$=Owa¨÷Y:›Ö£šF»½í&ùZ¿ %Á=5ÊêÍ¡å½`AVÜ=ÓðL˜Œ.o“4 îcèP\@Dž]ƒtºOÇ/øw*ÀåËi7ã«3U”EU# Ôðj~/ðªèI†©Z\½I8¾…K¢£ÊŽ.Õ—Üð!˜ÅÅbËçÆ%úÁÏýsW¼Ä!¼ð[_}‰Š8<»À†Žª‹#ža†W/ Ÿì±û4ýŠé®²nŒ°{؉$˜ÀŸÚÁè+{Su¯—Œë;é'hŠkçý/wJßç …qø-ŒÓ)•ØQòy‘ÍFÅ, ñóí<ˆ]Y¤›fjšd¹.O7½ü¯&RƒÐ#JÊ^t£½ægJt‰d(Ú¡¾ˆC,ÉtNÓ<*Òìå²%TÓ#’äé¢Ä¼_Á=íåÓË4Ìâ(ù*dÙÍÔÓóåS”cÇAsŸÑ'+ª¥"¬UI)[¼2•ª·–ÌØMÅ5òvzü1*žf÷TŽ#˜.ðmÕ][†UtUË7ýQ¬;²hûŠª!…\¾7´ÎçèÚž= E :¬zdÅÕ$W=$zJARÎ%?áY õóIX`¿€J &N2~倠Dƒ•GŠ­I˜ ¿„ÏÂm: À®z¾än_.Šè™K2Æ]ëPŒ”X@1%ðZÀï£Ç(û*¼“LÂwA`“É»$,6¼îz¾«ú¨NÖÁO”dUsmaÉ·,Q2Gžän]¡+¾è¸"ªÎÆð5OWÓ¶ë±¢€âyÛÐ|Ëi4e–¦^–Áü K¯ÎòiÇTw—<µʇgE¶“‚oþ ‡áeý;â$zàe> F@Ðiæaö-<»‚$ˆ_ò(ï#gUÅW-Ò¶WTKv,âðv´5,oÆY-åì”Ó¨A[ó1 ¦OŒ˜ÉlÂDY‹(Ôë¶´Ýè5¯KÕ™»A.WöÁÜê@ËyA^Ã%*¾˜ÕÑ Qç8«ãB<Ü•À§¶ °é?ÃQ‘_ |?Çÿqü4¯GºÌˆÑdÙEMñ†P“-M%º¦öj–®è>ÕxH.*ÔÄÚ PÒ›µ :Añ:â$sDH-NÚPèð~DK1UÕlYmªjÁ䛼Fã§ø–㈊MjŽ¿}@DÃe~D|JâЇ\pˆ{öq†%UuÑÁ‰oÈ‚½º§aÄ/±ï…òâöN`¿æÐÓÙ7«Ú« ô–$ý`ƒi ž56'é³_U¬¾Zÿ}‘&ðÞ·ãWA—²r—5X Dwi]5;®P:¿xïW‰Ðߪ›E=¬Õž»žÑBH`š:È-ZªN,ôV°ÒºŸ‹fJŠ.²(L1%$$ Wÿ!1ûO ¥=N75éx\Îm‡=„’æohnN67W_÷ Ü{«–í–àY|¢là SVdBŒÎÁp), dhCÂq~JÚ#Ê]#®6%aa#$üá)YSŠB~ÞX °ä $ýÐ^)9*Eå( ''2t%±ø½šÃ!¶g´+øJA‹Ä«YÀ×dŸÞÈ.5ÔßBÕA¡sÉQ‹RöiX×PÏ¿·)Ùù–æ|Lb!ÔÀ4% CQKEEGAm2J­8zL*¸rÛ€uXt=DJñÆp5×uEW04é¸Dµç9óù:Üòv½Td],›þ Ræ²÷Õ´•ºåÞÁ-“æ›z"èˆå©MÕtlÍÑZÕu][U泇Ê£ô–E:ù¹l‚šofdt]RMZÍý‘8o Ûip·RK˜žºœìÜ‚éu"Û QZNŒ(2æ ÍéhZì•é‰c›’ÔÿK®!Ê’U{]Jk`ú‹Lχ`ú1=º {Ðôš¦Y TJñšž¨XñT#¼¤¯T}Ò¥ ö•m«2ÍØÐ–A1l¤J¥ÛÊ®Q÷¥æ¨äÆ’»ÁîŽÐ`ÉŸšfè½CM¿Êk”=õ%£å5ª¦ï©Š‡ƒMÿ`?Ìà •Ÿ´h T-¼k 4ÜØ]%òöÞD‰¤a¡œÓ%ª.KžÜÚµª%J§ãW»Ãa.58a½éfzâæ†P¡ÆëÑmGñÝéÈÇ@-2½r<¦‡i,Ó\¤@„­ê Htp˜žÅ¤ç¼Sdzv”°¿•N—tSt%š€4ýi0½z<¦— ǶÒª†&®%k¢80}™:¤á·gM¯ù–N%S#ÞKLX¯PÙ>0ýi0½¶œéÁ,(X!kºcuM!‹ìÀiPŽÎf»rñˆ©X2¡¾ÚÉëÞ‰Á:—ÿ@3 rzÀEÄŸ¥«Sþ¢U:«nç.ôNgÑ$Õ1f éßJ ÒZÉ¥G°l˜ܘ”HèíIçáH„¬òY›å%ض¤¶²m/xÖlÁx¥á–òIÌ"®fÉ.MŽ—¹¬2“ÿø¦ É`yáüy\†]f¥w7lùŠi9Åxÿ¯(^ŸŸs²":íÃ`ÓøI³Âlß=À’°>}˜Wªí»kI°p~¾{Kˆpû®ud ý(逘è“ô¡ü¹kÒ‡¨²oCÕ4ÓÕUbKÒT¨œÙ8ýû#ê’-¸~.LÖ²úråû:,£XÙÊ{É_J†fhž‚©Ìž¤ÿåv…UiÑñQLZJóAyO¡tÝTa ]Æ4@¹ôæ¥G´ðw€r?µ¾'i°½ ±œ> æxÓö–3?+khµ%<ÈÂA‚ÇQ–jÖµˆ{‚²¨›²h¶7›,Ôªfxô8Nú²°‡3zRêž L<È”itqÄ Öÿ$jýD¡ ÖÆNÑ`ªÂW_c@,‘Ð=åvkmºa$ÔÓ-Y”û¬DÛÝþóà¤B‡í‘0DBáðu>Ä‹±Ø0ÁíÝ6œ@Ô·²½9ƒ|{­Ø]ÿwŽÙŸ8ã®"@”!å’%üî‚·§Å&°¨­lòIx,‰ù«WKg1 ³ƒ×ÏÙÕä½þDIQdb½Ž°ÛÍÙD#‚ëbý´'»\áˆ?ÇkÕ< ¨±Hú͹˜¯ ƒ†äãz‰Swì tŠHTaÝ¥oaíÜ …ÈÀÛ´N4207êËM.ªZ›})SG¶t‡nŠ;@y€òi‹ÞñÖè îRò¨Â¦°ç÷š}$–¹Ú»üˆe*C ï¸>ÅT4âl³1 Wª‚M«½†(…íø5ú:}'Pò[o³4dOÁ<¢ÈœGÑZ3x’®4ÛnéUƒyæÊ•=ó$ÅM¶ð?}OhÐãc0ó=‰ÐZ[•NØ“ÿ!j–ê«t}ò©û€zèu¥‰îZ°ÅñPÑÜD¿õ2Ðʢ᫊;Ø…Ý›™¾M»ð…²¢Úìõbõƒñ¶ Œ]œ²©IÄ„ üW:SKœCpï¸Á=Ñ0<§ßñ@ÛUñaY×ÉëŒä@ÉÞõ¹¦ÜGü9yèR¿Úâ`Í DóMkµø8‰•CYÃÛÖtóØP++½§°¢èQõè±1§ ÜÊýdážÂŠªèº’+ E¦±˜¡Bg±è벆¥²pOPV`+_×’pÎYø'©ÐyUY(Û¢nÀ^€æÛ=ÏãÒƒ,|C²Ø")jýO¤Ö9Y?vªÔ<Ç‘EzÂÑ e¹4„6Ô"ý‡m÷²»û–‹Uß ¢)®&k#r>‚È)—NžÄÊßëó8| F/ÜòcNF.u8öT(Y–¡(d¨éêT²Cò÷5ìÅ=Å(MÅöA8C}+CöÛ„r?Y¸§à‹LlG“ì×Ù£x·ÅêCõ@Ï@ôZ£û¾u]CyâŸH­¿ª,T|8jƶßBq…=eá«Htl8ŸD}  €zèD•)àz§8¢j‰ža;êêœÉÒ8âC;n)žD|BtuÍôíP 5ÄÐN;†ÆEÏ:dÔÁO‰ò^}Øðèš­ÜõÍsmËUÞBIüP]õ¶õðŠXõ^6ÔNÂs1’µ"ß·ƒ /·Z gHퟠÜʯê“ÕTM¢ÎR(O›YñemØÖ°¬íßÂVÂ­Ç ·ê¶¤¸†w8'j·žv¸uÞϹxg?'~O‹šéJŽæ U:æâÛ,óêÚ·O@G©°Å©'‡1÷T±H|Ç”Ü7áÄ9òžæâ[ƒòž<U2 U7·a¡ÕÊ”èÊ•çâNiB Ï[»_éšI ßz G Pî å~êžd!ìËãÉ–FÞ@žrPOý jöŒ'Qµþ'r¶8YˆZÎiÁ?÷1¼pºPrtÑ1Õ>ζ£)>]‹}™åÑø¶q\ßB«+ÊK”ùxíK\ÏÔdâõžü{›_4ÕðiÍ ö¥ùEêFâÿŠëOÓ"J“våVVš4uZ~Þß}J«ÄÏÁK.@Ù(zˆÂ±ðÓ(H„ûP=É#üŽƒ"ÌþzÙ0™Â[õY‘ÔÖæ/2ì3­X>„QB§¢ ûOS¿±±mMm÷ŒÎ.Ë{L8„~ `‡½Q^|ã\îéÓ“d6awFñ·¸ºO¬ÛnÆÕ5 ¯zÊ[ìÁšŽì0SU‹D\\ŸŸsÔè![«±w¼l廞àËwn]ßÖ”r/=&y‘¦qeÓ,M¼ ‰Ä üèKËúÀÆ Ã8×é+–€°Õevð¹¤Íy{¿£zr¶|5Pd3Tâ“1Ú¼ùS…c®·ˆŠLŽdÓ$"¬ŒЯ+õ²ˆ(ÑmT+¬;;§¼½Á [D•*˜W/e'ü)óŠ÷1ÇaN§ÙÃ,¾{ ÆQòxnFaRPÞ¡‚÷7 (Ô†4 >ƒY‘2vûç)Ÿâ3aƮ§näBxì\7ð„æIãïA}ËÇà%uÓCô=ÏÓôkõjQ±èÇ«J8)ßX¦gÊžÑFÊl’4Ú« ôù$ýÐДIZî©]I‰&ÞgÑgáþÂ;àk0CTq—UÕèº*™WAØáU˜øZõ‘‚C¼¤Ê*ÜÅ!Ž`= ×èr€­¹;l©(ÑÓÞL„Ö]IÖu„¥tDÂs„…‚€æþäxækó÷IÔ ,dæ´r.» ŒóSmÅP=Âx§MIQ,i “sˆÖ”‚„Xˆ€’tJ«~í£ˆ¨ÞM„ò š«GÒuF.DÅ‘4I.‘]„ß Ï(—À#ñ¨i†R»f‚o¡¶“Ü"1¢T-¿EÉ8}浆´sTîs³ZY¹÷€dPœÃXµLˆkÚ2}ϲ15à¸Dí¶I;FYÞÜÐ m(þxLsZÚstN¯ÿ"uhïµs‚º÷œÃþ²­–Ëû”˜Ä£œ¶lÎ.GÇô6@\i˜ÞÅé%[L/jÜÞÓ+Y’lûn‹¥ ¬…@ ™õ‘Q.Q¡­ý»az[ûX1¨Å½+ŽD&fÒ=[1 -óŒó*l.»ží8ú“½·ÅL'&q•z-ý Ë´6 ¶3 ¨ˆAûªiÉV_÷£¬e˜U-ûPûû±“€r›¬¶H·#ýÚqV[›ÙIšïxšÙkgI^‘ܶ࿡ñT1#Ó¨ùkêØ±M–ž/ó?–U½6uÅœ¬+ª§[’Bc;[ø±Àò×Îû_î~÷~±ìÞïþ§Û/·Ö/œØ8:³{—.íOŸ>öéÄbÀd_T¹úÄS'€9•«ÎIì2naŽ­8zLªÉž{ñ(q;íxÕ± ¦¡¯ñEi„òøìCÏ—mkéGÐ[°Øœsb~']â¤vØì[@Y„ZQÃtúì/8@™+‹â°¶Æå.ÿd(bùf¯­Õ(¿(sjõñ.&©>qô5Éò¥ÐBø”°èv—:¦]-s \œmQKσVƒWP%:­.ˆLˆ¢o«@¦u9§Cð÷N9㽂FÞz‹×¶½‚®ÏÇ 6v vïÏÎ.Áî]8ªK «²®8v+lÖ¹¹í!ÀÙ%ƒ–¹]I¯:&³$US·¿¹ÄüU¹œòA_¥M*±^&…÷dˆkªaÀѸ֑¤Û ¼XX·GÝОÌ_YuÜ4œ,´>`‰6D»ê¨3Òµ'Ú®†¸d)†"CõÁJKn©!¾hC£Jû±Rƒ3² ­ÁÄ.³N‹‘™²OQñ¾eŠB²¡N¤1¸·îŒ4*î¶ÐumgDSì›/Ô8ª=.Z*]‡¼ZÄ !úF5à×D,cZ‹™zkÃC{2q%ÙW‡lS«ózÊ#–l!-7s-÷ä8rÔ5ýcÎ6q-,#nõña´b‹/Õ3Á3€Ê5ç¢,õ «ø¸V1ì=äÁ1_[DA7­ ÝØ•ì®à£ñ–¯:pºÀüÒ¬Ñùèßõ)¹+‚¬` ¤½wgç`üî¹úÔ"µ©¶˜5GÇ,õ‘‰oÈÆ+ z59„ð©ï¾¾y¾GYØ~ji4ÑÕ\¯×bìVhSé7`åÑú5©–º—ûòæ©£ó¾.|Z.©L¶èø–öJ¸Ý‹¹™òhw]7eÙó¬>“ü6k6@(o¦“…ÿ«7@ØçŠã[ªlé<݉äÚ6x^pu¾ºVöy.Žr¡ˆž¥»ItE·© ]Òý[°M%íÎ]åö¯7ÝßñŸ_ f}G˼1EÅõÎF6÷¶«O¾ß¶˜+ÒãzÐûn2Ð|Ü…â™­…íJÚ”‹ ¾xw_îVDìÛ ['é¾cõQË1䪰Ý®!¤èb¼ËG…«±à1ô!¤‹ó«µê³ù¶Æã· ba”N¦QfÂC-Št2ÿ‡ØJL¬„¹|ýf°¿%[9ý¦°›LýóqVПå×F°g<“OƒQÈî¡§#ÜRZâ( ?GÅ:)×;®0bЀÈ}:~¡ÿ€GfعæúÿÿÿPK!!Z¢„!Ûword/theme/theme1.xmlìYOoE¿#ñF{/±'M¢:UìØ ´i£Ø-êq¼;öN3»³š'ñ µG$$DA¨Ä*µ—òiEP¤~ÞÌì®wâq“”4‡Ö;û{oÞû½?óg¯\=J: BRž6ƒú{µ‘4äMGÍàv¿{i5@Rá4ÂŒ§¤Lˆ ®n¼ûμ®b’ò©\ÇÍ V*[_X! cùÏH ï†\$XÁ£-D‚Þ„-,Öj+ ¦i€Rœ€Ú[Ã! êk•ÁF¡¼Ãà1UR„Lô´jâHl´_×9‘m&ÐfÍæ‰øaŸ©1,¼h5ó,l\YÀë¹Ssd+r]ó—ËåÑþ¢™SŒå¤õncíòV©ß˜šÅu:v§^ê3†à©µ¥ª³Ñ]­· ý9«»][®5\|EÿÒŒÍk­Vky-·Å*5 û³1ƒ_­­46¼Yüò ¾ÑÚl·W¼YüÊ ¾{ym¥áâ (f4ÝŸAë€v»¹ö2älÛ _øj-‡OQ evé)†~þå'¿}ûÐßxP…÷iB$ºIÑOÀ1Êk9ˆóIôcL«›éHâëY<ú;*vÐ7'˜a®E\ïh>àµñ=Çà^,Æ*·ãÙõ8q€;œ³^®ë¹*4÷ÇéÈ?¹Wq{øænãÔ‰ogœAߤ>•í˜8fî2œ*<")QH¿ãû„xøºK©Ãë —|¨Ð]ŠZ˜z)éÓ“MS¡mš@\&>!Þ7;wP‹3Ÿ×[äÀEBU`æ1¾O˜Cã5VDôâè ØXìa?pªý‰¨„Û SÐú®Ö4Ûæ•Û[óNS½Ð28;ŽYã¼[ê«™¢â,Üô“ÒóT1|óÚnœ;¿+ºâ/Ê•jÿÏ\ÑË\,E:!Üì Œt¥4.TÌ¡ e1 »Ö}Ó; [àz^ùp¿lþä@ÿokÎê0e g@µGGHPXNT,Ù…¶d²ïeõ|é±*Y®ÈdTÅ\™Y³䀰¾î+º(†T7Ý$ow2ÿÜ缂#½G©Ö›ÓÉÊ¥ÓÖÀ?½q±Å NØKèü-ø/M,W÷éêgåx±FVÑ/¦»¤FQÎâ·¶–Oõš&œe®¬µ¶cÍx¼¸\QœõËýLW@Hÿë!³+ô‚Úç{Ð[|{°ü!ÈêKº«Aéi `ßcm2iU–Ú|ç£Y+ë Þ¨–óž [[v–xŸ“ìråNçÔâE’3ìpmÇæR ‘=Y¢04,Î!&0æ+WõC܃@oÁ•ÿ˜ÙOS2ƒ'SÙ®0Ù5àÑ$ÿɤ]pmÖé3ŒF²t ŽŠóGÉ„-!ûy¤Ø"´Ó‰V .ù ®`Ž×¢vµ,…O.%ÌÌвKas—æSÇòÆ­v€·MÖz­‹«`Š¥…²3ï§Ì{ò9+eö øÊ@½eêèÕ”åLy³‰Ÿ7†£WÏô_Xtl¦›”ÝøÿÿPK !9YÖ<¨¤¨¤docProps/thumbnail.jpegÿØÿàJFIFHHÿátExifMM*>F(‡iNHH ‹ ÿí8Photoshop 3.08BIM8BIM%ÔŒÙ²é€ ˜ìøB~ÿâ¸ICC_PROFILE¨appl mntrRGB XYZ Ù  acspAPPLapplöÖÓ-appl descodscmxlcprtä8wtptrXYZ0gXYZDbXYZXrTRClchad|,bTRClgTRCldescGeneric RGB ProfileGeneric RGB Profilemluc skSK(xhrHR( caES$ÈptBR&ìukUA*frFU(Vaeobecný RGB profilGeneri ki RGB profilPerfil RGB genèricPerfil RGB Genérico030;L=89 ?@>D09; RGBProfil générique RVBu( RGB ‚r_icÏðProfilo RGB genericoGenerisk RGB-profilÇ|¼ RGB Õ¸\Ó Ç|Obecný RGB profiläèÕäÙÜ RGB ÛÜÜÙAllgemeines RGB-ProfilÁltalános RGB profilfn RGB cÏðe‡NöN‚, RGB 0×0í0Õ0¡0¤0ëProfil RGB generic“µ½¹ºÌ ÀÁ¿Æ¯» RGBPerfil RGB genéricoAlgemeen RGB-profielB#D%L RGB 1H'DGenel RGB ProfiliYleinen RGB-profiiliUniwersalny profil RGB1I89 ?@>D8;L RGBEDA *91JA RGB 'D9'EGeneric RGB ProfileGenerel RGB-beskrivelsetextCopyright 2007 Apple Inc., all rights reserved.XYZ óRÏXYZ tM=îÐXYZ Zu¬s4XYZ (Ÿ¸6curvÍsf32 BÞÿÿó&’ý‘ÿÿû¢ÿÿý£ÜÀlÿÀ‹ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÛCÿÛCÿÝ2ÿÚ ?þþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÐþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÑþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÒþþ( € ( € ( € (x“íâðŠëú+x²=?ÉáªXŸÇáéodÓb×_ER]]F)l#ÕÕlžö)-Vs:2Uû:žÏÚòOÙsû?iË/gíyœ9íË΢ԹoÍÊïk;“ÏgÍ~^~NeÏÈݹ¹~.[«sZ×ÓKUP@ wHÑä‘Ö8ÑYÝÝ‚¢"‚Yݘ…UP f$$Œf€#·¸·»·‚îÒxn­n¡ŠâÚæÞTšÞâÞdY!ž £fŽXe–H¥™$FVF*AfÓM¦ši´ÓVi­iêš{§úi¤Óºz¦¶kºß_¼šR—RÓ¡¿´Ò濲‹S¿·¼»±Ó¥º‚;ûÛ]=­SP¹´³iÅͽ‹ßX¥äÐÆñÚµåªÌÈnaßJ2qrQ“ŒZR’O–.WåM윹]“ÞÎÛ1]]F뙦Ҿ­+]¥»K™_M.¯k¢íH€ ( € (  mÄ~ñö¯ü#Úö®ÿ`ëWÞ×?±µKSûÄ:g”u-UûóÿgkZx¸ƒíÚ]ß“}içEöˆ#ó5ÎJ|¾Ò‡<#Rñ”yéÊü³Ò愬ùd¯gg£&3„ù¹%rÉÂ\²RåšÞ2³v’Òñvjú£f   € ( € ( € ( € ÿÓþþ( € (äïÛ»ãö·û,~ÆŸ´×íá2×Xñ?Áÿƒ:ñ·†4ëøÞ]:ãĺV‰t|Nø_û0k³÷¿þÖž8ý«ÿl/Œ?¼ ðŸ[øÁñzËYøá«êÿ ¾3jKðãTñˆ<-Á=BÆ÷ᧃ<#§<³xÏá÷‡|1­øq,th»¨ÆºŠj®#0†;<®ŽY•ápÕñPÂa¥ a‰Â¯¬Fœ*¼Teõj¸ÙVu¥R÷Ÿ&‹—‚–XjÇOŽ­Z b+FX‰J…wì¥9SöôãÛöjœiÊVníŸZxÂú?ì‘ðCöæý¶¿jïø(µŸÄ/Ú/ᦓûCj?ÿe-cã˜ýŸÿfÏø¦ËÃþ(Ѽmðûávâƒ^ð…t_è~žëã?‡|[¨øú÷L×õ]ZóPßqmiìòTže‹Ê2œ³!t0åT3(a7:n¤'Uׯ8bªT©:s¨¾«:Q£«XóÛŒp”qØünií1TÖ%ÕÁʺÃá£.YFš§J2£NŒ£íTý¤¹ž­ßíkûH~Ðß³ÿüÆ<3ñ#ÇÞ%ý–foÙö\ñGí#ðÝBûºÁoÿþ>xKâGÇ ÂP!µâÁ« ø#â íõ•­þ¥ðÿDñ†5Ìvj–õ†[€Ác²X:”(ÓÌ1øüžãÔŽ/ G R†u_½ì1*u¨¤æã²§%.VkŒÅbpùœñ0©Rx\. ,N98¼=yÕ…Jñ¦­kI¨TÑ)8)'(Á4Gâ_þ×þ~ÞW_ümñwâu·‚?ઉo­øá7ĸ´/‹Þ!ýŒ´o‡üQ㟆?³?ŽõNÞÏÂzί¦ë“k^AÖôÔ,ï|AeáÝV×Xñ´“ºt²Ì&7'Ž6ŽêðÚösÄÐçÂÃ6|]:Uñô”yÊ.5eR3´•75ÁÊ*SÆâpÙƒÃU­UC8’’£UªòÀÆN–¥ß#jJPPpÓ›–îJ'é7üŸâÀO|ñ\_~&þО5°ðÏÄgFñ¿?jü@×¾:|ñ²iö—Â?Z|Wóþ"húTqìéºn¿«øŽÖGÖ¯®ô_h³Z%¯ƒŸQÆRÅRxÌ>‹Ê•l¶`ñ´¹¥ËЦðö£7;òÊQ…7hÇžœeñz¹eL<èMaëbª(Õ’©O9ˇŸ,S£/kz‘J×JRšær´žÇðCöûñ_ÅÏÚ[öƒøY«øoà‡ÃÏþÏ~/øá?ø[Å?¼CcûVÛh­üí3ãc|ºøoo¢ê_~"(Š÷ºމãkåMPÓ5iu ËÙ®4;]ñ™%,6_Ħ2½|u,=ZU)a©Ë-sÄI'„úÒ¬ç U µR).iÅÅF)sáó*•±xª2†•,,ëBpi¬g-%u]Qt¹eF¦Ž2Œ“MÞö—•øþ YñÏSÐeÿÚâìÓà¿~Ç?¶Å_‡ß >ø›KøÁ©kß|Æ}BçJø!ñâ§Ã¹~éž¶ðßÄK᢮¡£xSâ6·­øé’ê-«Ki¨ÛÅÑ[ Á)f,>aV®i•á«bq0–0ÁVú¬T±T0Õ½´«{J7’Œêaã ÎQQM8çO5ĸáq5°”éà±µ©Ñ¢Õw,E?lÜhÔ­gìùj4Ÿ,*·+¶Úä—åõÆ·ûUø/Dÿ‚ØþÞºoÃ/ÙïNý¦þ øÏã7¯ |~ÿ…¹ñÄ~>øaàßü&ø/¬¹øá¿|ŸÁúÏ<' ´>;ðÍ®³о!ø“©éºî—§éÊž!Ÿè]<¶¤¸S'–#,*†,ÕhS£‰©WŠJ½z´ñ*¬+TéUPsP¢£(NSr„|•,lVu˜*Xu‰¡Z½ˆöµ]J1„(Þ(J›§8F š—#sÞ-$åûaûu|Mø3â_^ý°>ü8ðM¯ÅÙ—ãïÆ³ñá¯Ä=Æ^‹ÄŸ³Î›áßkÞ’|<ð%Â]ë_µ}Oâ —Ú(¬u øƒF±‡S±µMZ¾^Y6 elªµz¯ ˜àðn†"„)MSÇNtiÕ¼+ÖVŽ**‚ZóFp›q“ä²³*´%‡†:(F¶ˆUiTœ×61©(ZT©êè7QûËÞ‹I[Xðß³ü7Rý¥|1ûç|o ü[ý§>'üzðWņZ¿Š.Úçà‡ÿg?ëz×Ä {R½ÿ„v)µBI/þÙhú]ÝŽ‰òüRÓ ×ñý™GS6”±Nx\¿ƒ­†¯qÿk©Ž©t`—´²ŠqĹÊ.M,;j.íÊ0™ÃÅÇ£EF¾*¶"jno÷ÂÅʬ®à›mJ‹Ši_Ú¥xØ›àÿü¯Å¾&ý±~þÊÿô_ÙVòóãE¯ÅäÐ-¿fÿÚ‘>;x÷àçˆþø{þÝCÂß|>~x?OÒ§×´85[{-SÃz…õ¶â]ëB»µ%‹QSÃô©åxŒÇ,É,#¹Ë—}NŽ.ž&§²UpröõdÔ&âÜj+ʜԕ¬Ðèf³ž6ެpmâ=·*Ââþ±<<¨ÃÚ8bW²„S’RQpzJ-Yë#ɼ-ÿoø½ìu©~Üÿfχ?þ xžÿÃÿþhÒ|~i4|ñ…>!^øŸJ†ÂÛÄš·„<¬øwÇÖ<+weâ? jú[µÆŸ¨è~ Ó.¤²Ô^ÞÓÎÎrOìÚ\]?®B–&¥j.†a†ŽJ¥ ]Â5jÂ¥*°¨¥ Å«8Êœ—4S:òìËë•kЛÃÊ¥Ó©í0•¥^„áQÉYJTéÊ3ƒIJ2WwRZ3Ëÿk¯Úóã׉!êðN/ÙÛã—ˆ¼eûSüq¸øðÇOðŒÞ ðïƒ<-áOê:Wƒ¼s¯x£Çþ1Ö4Ü%¬ze†ám B—VÕïoP±Ó›ÒÄd/Ï3 ±ÇN„sÌvrì,qX‡UT©V­Y©U¥ t)FPW¼§Rs劜¥ÉK5ú®,ÂSxeQå˜lDªc+ºT9#S,')U¨ã'f”cÝ·{büÿ‚«xKâÖ­ðOYñ—ÃÖøGð“ãÏìyñ3ö˜ð޼AâtÔËÆ³çn<7ûD|)»† "ÒÃR‡ÀúÚ_޼;ã>ù ño…TÕ“HÓ¡·[ËÆðÕL,qp£_ëX¬i‡ÀU£ |ªTqÔcS‰»“quª7Ft¤Ÿ³©h¹ÈíÃg®ðò©OØÐÄ`ªâ¡RS½ªa§(âi==åN+ÚF¢åR‡½e~Xø­ÿŽñ!ÒgÏ~Î~-|gý›¬ÿkMnËö¦ý£n¾ü<ð§ÂßøËZÐþ ø3I×ô$ñŠ>+üAðî–Þ$Ö´ßøGô} áýµµÙÔïõS=…¼ý°áZnxéªØü^ þ̓˰1Äb*â)QŒñU¥ V„)áèTnœZ”çYÙG—YÒÏ*[ O ‡­_ õÉ!øƒCÖeMFûÂpøOWý ñ•‹^ÙE:í¦¨x{YM7Z²·‚ßÄl𵥬_GÊë`rþ ʹãZ¬3l’„'v5}ªÅº/•·Èårƒrörn.RåæãiâqYN:Î9`³³OÞpTÕ%Q]%Ì“„­%yYÙ^Ç´|=ÿ‚Ž|}¼¶ý‘þ2|]ý™üà/Ù_öâø…à?‡µÿ|bÔ¼Wñ·Àš‡ÆM#SÖ¾k|?ýÁöú_Ä«[/­|ãÝ~óÀwºþ›mª¶ªb¼x¹+ä8$ó<.0­[1Ê(VÄb¡S xJÑÂÊ1Åà [Ûʯ6·­ZU¹[*|ÑÞ–i‰ÿc­_ N–V;w:ð•e'BU¡ì•;TQ½¡?Ýó$Üš´¸wþ ›ñûÃÞ ø·ûCê?²¯‚ ý“gÚ³Æß³WÅÏ·Ç É>-êZW†>=‘Ÿâ¿Ã¯‡ÿ%Ñ/4 Ü_蚯‰ôøÛB×u)¿·­¼=éÚ]–¯«íÀήƳÌñÙu~—ÕWÕ¡*˜O­}^½wUMNj3P•:S„W#›r“„by¾&¯Š–ŸÔ°¸º˜ZÓöïÛIGìUZTý—+Œ9¢åI96Ô\bœã¥ñóþ }ñÿáF¯ûlø›Â?²·ƒ¼ið3öø…á ã/Œ5/²øwÇ~7ð·‰>|2ñ樿 ü€5]:ãÆ>Ó¼}qªjVþ3ñO†|9©iÖze†¬Ýê×Ú’hуáì&L*æ5©c3šg…¥"U)Ö¯M}b·¶‹öUû8Jq›”¤¡¥*Äf¸ªRÆÊJsÃ`*Â5êJ»IÂq¦ß²¤©ÉsßšNsŒ\t½ÍËë>ÿ‚„|JðGį>ý¯~xgàì?¿cýsöèðÝ÷ÃO‰·nàÇ„õ«ý Æ~ ñ´w~ðU¥—Å ÜÁ§M,>ºñƒu‘ª˜tʶêï ¹¶ _+ÆTÅ{|Ò5O¬áÖ}n¤éV¥jµ¤ðÕííT+G—Þ…Ý£¤3:´ê×¥ÃÆ³ÀË1‹¥WÛZ„%Ë:u/KÛE¯°å ^ÊJÉËÆ?eŸø+ÄŸ~-ü$øuâ_ þÏÒÃûCü4øñáÞð#ö†oŒ¾;øKyà/[|C~Òšð†tß ëºß„å¿Úÿ…5hv^-ÐuO L—ËaªÜuæ<.°x\N"Lwû"… òÆ`–Ž*5ë}_Ûà'íjJ¤!V×…HÂnœãU6›„pÂgX­Fœá†ÿi¥V­(áñ>Ú¥NŸµöx¥ìâ£)A;JQS‹ƒ½Í?Ùçþ iûC|Sö$ñÿÄÏÙkÀ_ > ~Þ?oð‡Â}kGøã{ã/ˆ^ø‘kð¿Åt;¿øZ?†úN‰gðÿǶ^ñ¦q¢ø›YñNƒé—ž)Ñìo/gÑì³Çpþ ý­G˜×ÄbòŽZ¸˜O Tg‡•jtd¨Ï딫Qö°u9¡ S~í94”åx|ÓWêS­„¥J†>ôèÉbê*ªœçR>Î1Têr>^YJQZÊír›ÿÀøëûd|r¶ý¥îÿi?á4¾ðíQûH|0ð¶±à¯k:ψt}CÀ¯´øWpè“|+ðF—yðÿÁÚlGN𯎯õ™¼eâkh`¸ñ‡të™etçâUƒþÏY{Ī•òì"¤*Ò„a8Ö¡Íõ‡5‰¬ã^¬—5J1Š¥M·ìç%©¦QˆÆâ>¶ñ^ÅÆž3F.“”eN­$½”#*0WTê7í$¬çwÏþ5~Û~Ì>=ÿ‚®|QÒ¾x¿Ç×ì¿ðûö5ñ5߇µŸŒþ%¸ð¿ábèÞ&²´Ó¼à­VÂ÷Âÿ/, ó¹}áØnÇÚ£Yj!kY¬’uéÂe0¡ÃXyW§JlÞ pÂÓUi}^pmÕª¤§‰Rir*œ¾Æ7Œ.š2¯ú¥\ê²§9Ë ½òμÝ9ûh´¹)òÊ49oï8©:Y%o{£Õ?m/Úî~гߎ¿gß„¿ ¾<éß²»ûX| ›Eøé¯xÇÁÒxJÇÅàOøOâWˆàøO§Þh< ©Ýéz‡Ÿá-ž ñ·‘[éºÄ¶×‹ç £+tð8êìN#,ÖžY‹çÁ•WYÓöÔêP¦ñ2RÃÖŠqýìéU¦•ÜjKRÅaªa¨ÑÄÇ,mZò©?g(U—²Ò­94ï*sz+%Í/‚¿aOŠ?ÿc_ØËþ ù¡üý’¾ø·ãÏüoT‡WºÕ4ÿ޾0Ómü)¿øUf5Ÿø^Ö5˜ü<|_¬èZ§ôŸ ß_Eiá¹®`¶O/+áì.lœpÕsW*³ÄF†%å‘ú…%KÚº0Æb%òÔ­Nsö0œh΢çiJ=˜ÜÚ¾§ZžÐVŒq—ÅTsäU%‡¢éEòS”¥gRIÔŒ9¹c~SÛõ?Û“Ç·?·¾¿ûhø!á‹Aðêúâ_ŒÿHÓÇÕúÄ*P•}%N^Ï•BQ—¿wyf5^e, a‡‚§ì[uëJlDjÇ™Ï fáQRÕM9ó9E¤¡«>8ø'û|~Ú^ý›¿à¥ß´wíà„^=ðçì›ñ§ö¥Ò¼#£øKâN¸ºøÕ¾x‹G†ßá”R|ð¾Ÿ7ýK¹º‹Ãÿµ[ÛŸëw k~´ n-ýLfM”ÖÇd \U™–/YT¡ E9¿­Iýeµˆœ¢JJŒÜ*Éèqaó|0Ù®' 5#„Äâáª4ã:S‚TWîRt`›å«/ÞKiF7RÚwí…ûBøSWý‘4_<ð÷^ý¯?h/ü8Ð|=áO‹zŽo¾ü;µø ã_Œš«ã BOøJ¿øŒš—ƒn¼)âoøvkï Ú F©£ø»U@°7“,¯V9œðXÚØˆe˜(WJ˜xÒzïO 5I{YIP䨪SœÔj7îÊš³g|q¸˜¼ÄaéÒxÜD¡³¨éRö¬\ß$"êó' (·ndåuñÿà¥zÏ„'ý ¼+ |µñ_Ä¿þÜ? ÿaO~“Ç ¡èß¾#|Zø[ð÷âV•â?øŽO ê-à øwOñ_‰oüC%†•â«¿ì“§Á>£ªEmÔ2UX*“źt*åŒãSÙsËC ˆ«Bp¥O{j“p¦ ¤é®iÝè‘\ÖTþ±ÐS« }§,jÕ­N3‹œù³ŠNMÚ3Ò6Õ³Êl?Ú?þ Wð»ÃŸ±ÜZoÃÙ×á÷¾ ~Ý>ø)âø4O>'ñ?€þ&x_ľÕµo éVZž±ð¼MáOx¾òÛÄ:wŽ5 ô x?Pðnqáˆ#ñ?Å #âåçˆ<#§I¨xcH»·Ðü=¨|/û.‘â+‹Q¬Yê¿k¼Ðt© ûùË)}[/ÄÒ¯RPÌ1ø¼$JQŒ©Ó¡<±§kÚÆ›ð÷ÄÞ!ñ&šëñhšDú‡†«u¯É£Iw§Yh§WÔl=/ì,íz¸Ü~"• ¯3Yzö8XÕ­‰röê.1•h½%9sÏ“‘M))¸F\ßÚxª¿P† Nuq¸?­?iYÂmìܹš§)J>ûŠq‹nN>êJLòŠßð[má÷ÄŒQéþøð»ö{øëÀˆ>Ö¾?#ö°ñÞ¹¤ø‹Ã¾øãŸƒàð.¡¦kþðˆuÛøtí;_ñ–¯ü@Óü%â-CG‹HC¦Ã{׆á â0ø[ϱ8ì×(U†2ËhFTçWCŠuc(U­N ÊTéÎeVœZÛ9ëgñ¥V¿»†tp¸‡‡«ˆ¶6¤¡(­Je r“²•E*ªk–ü±ý﯊>Œ( € ( ÿÔþþ( € (Šø“ðïÁ¿¾xçáWÄMÛÄÞø‘á/øÆ~¼2-¶³áéWZ.·¦Ë$/ð‹½:ò⸷–›wežÞh¦D‘6Ã׫…¯GBn¨U…jSV|µ)ÉNÎéÚI]4ÓZ5$ìgV•:ôªQ«zua*s‹ºæ„×,•ÕšºoTî·Vhø_à?ì5ñ‡àÍï€ü'­þÝÿ~*þÎÿ ­?²< ð?Åþ ø1mw©xbÓD½ðîá‹4ŸA㯉þðþ“v±Ags6ƒu«Ï§isxŽûYKF‚gœaqJµZy6 ľjØÊu±RQ¨æªN® *ÞËRr_ö–R—/'3qó°Ù~"ƒ§ f8ŠØZ*Ôðó§B-ÅG–0­YSu*ÁGìÚ7v½ÒŒaà%ÿ‚Dê×_ |Wû'øöØøáàØkÆGQ±¾ýšÀÿ¼iáOë:Ïöæ©ðßá§ÆøSPñ÷„¼—eàдA¼Oá­1ÿ³t^ eE®Ê|Oˆ§˜ÖÊ0•³ŠVqÌ=¶&ŒjTŒ9#Z¾”áF­gŽqtÔž®*ÑG<òY:RÂSÇ×§—Í»á]:5båÎéÒÄN2©_áOžÛ9;ÉËï}?öRðM¿íñ{ãÆ©¨]xŠ/Œ¿³÷Ã/ÙßÄ¿õ½;M¼ð©ðÃ}oâ~­çÌeŽKIüMoñ?QÒµ>ùÄÙØDíSªøÒÌ«<ªo ¯Ž§^”j*µãB)+[“Ùº Q”]îúXôVŸÖkדçUðÔðÒ¥(§H:—¿~u;8½,·wJ?%|ÿ‚`Þ~É?<]ð?öZý¬¾2|'ºÖh{㿇|q¨xsá×Ä{ÍGÕ|!¢x Lø5âÆÚ£¦øËá-áíËMžY´oGu£h÷kößbkyý+|Mý•¿e¯ˆZÄßÙëöoñ…~i°øWÄ^¸Ôn¾Xxß⮢[øëâW…þÜjMsà}R“I u¥ør_^ø4+X£ÄjªÆV¥—aðù–cBx|v>kËÚÓ¬¢±ŽRtpõ1 )Uœy¥>NG6Ì©eN¦6µ\¬ka°²…8òÎÝ%V´W´­nMÆ/•idÔm/r“öøy¨|%ý»> ë¾0ñ^¥áÛËâÅoxêæÞ=3NÕ¼/ņ^øg¨é¾¹Kkˆ']ÓºΗw«ZÝ;j2C{ ŬJÅýµ]br|TiSLŸ†¡I7'Ë ^­xÊ¢÷Zçu\$£-•×+mË£û:Ÿ±Ì(:“qÌ*Ö«6’N›­N0jº|¼¼ÑºßG{{Þ=ñßþ •/íGû/|!ýŸ>?þÒ~=ñ‡‹~øöÛÄö¿<9àŸxÅšï„&ð÷ˆþx«áîƒáûQ¡ÚøsÇ ¼W­øÅ70o¾Ô¢»þÕ˜¼È–©×ƒâ—æ8¬v /£F–&‹¦ðs­Zµ8Vç…zx…:ŽRs¥ˆ§´×º¡ðŧï˜b2—‹ÁÑÃb1u':59•xÓ…9º|’§*<°´TeJN-¶îÒrŒìàzgïø'gÂχ?µÿí û\é¾)ñ]Æ£ñïÁð‡EðÍ~ŧx3áν¤xGø¡âŸKb‘jV> ø£Âï‡7!»ób{{Ÿ DöŒè¤õóÜM|³–Ê;`«{_nï*¸g:ÓÃÓªÓ…¬VQW’jzÙ§Í­<®ñƒô øÿÆ–š}õÃxÚþîÄêSiÓÜ^è'UÖõZï¯Ä‹C1¥¾• Ù¯Õ¥Ä,N&´¥S Z¢èÓ«RP£I¸É{(§e%i¨Â–\áªá',\êÃë,=/cFšQ­Ntåí%OZ“÷”œß-Üv¼¤ÏSÓ¿à› m¿a_~Ãw|4øI¢øV 5o…ÜÖzwtó¨êº¦¼×P>«w­k·¶0:Ñ4M'GG½ûW;ƒÄ:SË「9ÜÿÚ±©Õrµ¯*ÎÑŒ|ª‹|ÏËÝqéÂÐÄÑçxŒ[Å9ròþâÁ+ÞÊž²rº»“¶žêß7Ìß¿àžZ—ÄŸŒþ)ü2ý§þ+~Ïš_íCðÿ¿¿iÿøÃuáñ3Mð6­xKÂÚ÷…¼Oã=YÖ>xÂk·~Õµï ¥ÓjZ¾šÖÖº^·¦Úk‘z<ö8|.ˆË°ØéeÕª×˪֩^ŸÕåZq«R5)Ò’Ž&Ÿµ‚©T·,¯yJ ÀäÄe’«^½Z8º¸hâéž2áJn²§ Sƒ„ç*2P“‹qæºìÚqÁ_ø&ÅÿbýžXÉrÉ{Òò—ªÏ ‹ž¾ Oêº4ëFµ vqS¥SE%;Î2ƒ‹Ü_4tEû[Á8ô/Û;àwÁ¯…?¾8|Goü)ñ êzÆßèþ ðÏüwáïøS_ðÆjš_‡4=º„¾.øÄú·…¼C¦ø{G³ŽÎÉ4É [›<µÆyf}<«‹ÄaptLc„œëT£FtªÂ¶ª•YT©R¦­58ʤ›o™®[ÅŒÊÖ7BlEOkFM¼DcÔ©ÂTëÓj „kBN-F6VŠjI5.·ãWìGªx³ã'…ÿhOÙëã–µû2|[Ñ>Úü×nôŸ‡^øà_|!Ò¼C7Šü1áÍ_À~4´[M;Wð^½w©]xOĺ©¥ÞXÙêú®¨ÛjÚ]ÊZAž8<-L?Ç Gðúëž%Ó¼#¤øHЦ‚%­Ž‘á3NÓE®­4N¥­’IsY³¥C‡Ãaéá¡‹Æ`ñtù*U›ÂËë:q¦êÊr©wZîU%{ÆöWJ6ð*¥L5JÕ¥ZT(b(Oš¶X…9ISQŒ,¢ÒŒck>–¼¾{øOÿ¹ð.¡û>xWÇŸµGÅŒŸ³Ÿì‰âÝÆß³?ÀOøWáÞƒõÿi:¦ðºoüIðî‡gãŠV¿ ´mbæßÀ–zƒhqCwi£ê>!ÿ„‚çJ¶jîÄñ jÇS–a°˜üΔèæÚukÔuaZQ–#ØáæÝ,;ÄÊ7¬Ó›iÉG—šñ棔¸K¸ÊÕð¸:‘©„ÃN(û9ÓN4J°JU}’»MA'k©$—>ÿÁ2~0|MÐ~;øGãÿÆß‹žýž>!þßÿ´ÇO~Ê¿Ø? /´Š>²ý£õ‰? õ ;â2i×Þ<ðwÃϾ%ñƒ¬µI&×ÌWÞo ¾³«Ãuèâøƒ †– ¦ †­¡’àp”ó/iˆSÃTx%G PæT*×£ÏRêÙr^ÒUTTNJ9MzßY†#Zž®c‰¯<%'ÑX‡Rœ•V½¤)Ô´e('ïZñåmó}×ñþ ßàψß?oÿ‡—¿üU¦ÙþßÞ%²ñ/‹µM/F–ëáäö_ þü-Ž×Ã1LžN§ Ù|<´ÕÝõl¿Úµ+›aˆ`‰ÛÆ¡žU¡_%¬°ôäòjs¥N.RJºjõ››ZÅþùÇÝþTúòÇЫ–B­,Æ“«$³ ©Iò¯ÝÚáh«ûßõqÞɯŠ>ãïØ§áÏÄÿŽ"ø¿ã}[XÖ´¿~ÆÞ4ýмWðí⵷е¯‡~<ñ}—Š|A«Éª[ùz½¶³s¬Ú"Ço*[Giw%Ì{.£G¬(æõðø*xJ0„eK6¥›Ó¯«”kѤéÓ‡#¼\jz»¶¬î®iS/§[:õ%)*˜ åó¥d£*u'Ï)s-Tš¼l•­®–8ÿÙÓöAøÑð2ÛDðOˆ?lŸüYø)àŸOðÛÀŸ|Cð‹àÞ®ÛøvÛFƒÃ¾“Ǽ=áÈ ü*K?A‹}.ÞâËâÖ°ï¤1.´ëkdýÌÒº•³Êµ±9Ö%Ц¥œÒ•‘æ“T«Ñ­x=šö*:¤½înœ²!–Ârê^ÖMeõ#V2åIÔjHY®ou?i}9¶µ•Óû5þɺ¿ìÕñ'ö‚×´~&ñ?Â_Ž?üuñ³Oø/®øKÂÛ|;ø—ñK_Äÿµm'ÇÚ}œ+×4}[W2hþÕßìº ·1 µ¼öøæœ3 >œð”éâ°xz8G‹…Z­×ÃáàáB¡&éÂQ޳©¹µ¢ŠmápRÂÖÄÊ5å*ŠÕ+ª§ìëV’•Y*‰)É7ðÁÙE3\Ç—|rÿ‚qø+ãˆý¹†«ñ+źü77…?gï x¯û7KÑ.?áƒö~QF¼ðßÚÐÿhÍâímV=T:[yJ,öWýˇ§?ìj˜éÒæ”×¶xës*–ø}›^ï.ýv0ÄePÄhÞ´ãý£,gh§ì¾«ðòëïsõ½­Ñ½9}£Ç_²_‡|uûEk_´Uß‹õÛ k[ý’üoû%Íá»[=:M*øßÇ:_Žn¼_ÔÊo»cw¥¥…½›–Ó¤¶•¤•|ÕÉG4©CO©BP§šQÍFä¤êR¢èªM-9|ͯy?Sz˜ÔÅOç$ç©pIYFu=§:{ó'¥šk®–j^}àߨ+Â> пàžZ·üM{üÏG—GðuÄún“Ÿ£›à¹ð¦ñJF»t¹—­¿ˆ•trûFÝ-m]™v«T©,òN„öäÔê%)?«µŒŽ1(mÏïG“Þ¶šënYD2øÁe©U“þ΋Œ}ÕûÛÐt=åöt|Ú7Û[§ÿh_ø$ÝŸÇOþÕZgí1ãlkïø“ã_€´o‡_ |G­ê/øwáï xoÃÒh³×õk+Žü<,¹K/¥ˆÄej¬0•å‰ÄÓ„iWITSÃS”iJ·ïgÖiéËÍ ¸EË—“}fx¶±u)Rƺr¯N4hÎNt”9kJõ#r-ÓZ^é8¦ãsøëû x—öˆøÙðûÆÿ?hïê?þübøqñãÁŸ!ø_ðª KþI¦j:>ø×€¿toê¾ Ò`Ö+øsBðïŠî4/i¾ñ€õK?xCÅÒè^(ð׉üâÍGÖ´yÞÂVk«k»Kûi-¿[™ýB¦+Úa©ã0ØêÃâ°ÓœésÓu!V.aïÓ© Œ£5Íetâîœz±x/¬Ó ¡^xzØZ‘«B´aòÉAÁ©S›åœeÓÖ¶÷šRŒ¾_‹þ K Ëðïâ·­þÒ¿¼Cñâ7íKàÛCÃÿ´£¦ø ?|:ý¡þx;Á¾ÑдŸ„:V‹kàû¿¦‘s¬G©hZÕö§«êz®½©ê÷^#vkkK\(g8l..¥\>UBž¾¶_ˆÁ,N%ʵ òç©9â§7QVrQJq„cAASvç4«—V­‡„+cªÔÄÒÄÓÅÒĺ4b©Ô§X(ЊPtÔnÜ%&å96ç«E‹_ðOO|EøŸ«|Uð¯ísñgáˆ~+|ðwìóûNËàŸü1¸Ÿãw†<ÿ <š7Š4{úœ|xdñÇŒme×|k-½¶•­­¦“¦é·úu–¯asÊXzÃÔÊðبa±µq¹r«[–¥_gÍNJ_Z¢½•6¡VQr”o78·VË*U¨êCZŒ«aá‡Æ8R£þÑ)%8ó'ì*>i{кŠiEFÜç{ðCö ð‡ÁþÉž,Ò|}â]nÙ7öAÖd/Ùjv•ooâßëŸ ®ßÆÓÛ:Ç[·o…1ÇcbÍ`ë¬]—%­¡fçÆg51”³*R¡N 1Ìã™ÉÆRn”â±öQ¿Å±æ–·Ž‘W|ºÐËáB¦¢©)<& àÒqIN-Ó|ï[§û»[U®YórÚWì%ñ áÇʼn.ýŸkOüø[ñ—ã¥ñÛâWÁÔøQð‹âOñÅSis|DÔ<ã¯xR×|¦|C›JŽÿ\ÑîlüMo¦ëú¶«áy4)ï¶E´³ªðØzX쮎/„ÂLJÅ}gC÷¹½‚­F…H¬¨ó5®W(Æ*¯5­,–[V•zµ0¸Ùáè×®ñ¨{ oVm:®Z‘r¦ªY]Z\®î6ºGèíx¬P@PÿÕþþ( € (Ê5ß|e»Õï®<=ñ?ÁZ.‹,Á´ý+RøO¨k·ÖPùh W:¼_´XïœÊ$Jš]˜ë”Joc‰ÈáFœq9V>½xÆÕkRÎ)P§RWz‹ʫ:jÖ\®­MS|ÎíGÍ­G5•Yʆa„¥I»ÂLºu§e¤ª¬u%7{»û8ïkis'þoßôXþá’Õ?ùñVß[áßúæ_ø}£ÿÎc?«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ƒþoßôXþá’Õ?ùñQõ¾ÿ¡.eÿ‡Ú?üæ«ç_ô4Àÿᦧÿ<ޝÂ:7ÄÝ:þâ_xóÂÞ*Ó^ÐÇke¡ü=¼ðͽéš&[©oî|w⤹€@³DmÊÝŒ’¤ßj#ñãkåUiÆ8 ¿„ª§yÔÄfPÆÂTùd¹(åøG98ËÚ{I+EÇ“ÞæN–a Éâñ˜|E7FpRÃJ3º|ÎoˆRVºååZ´ù•š—¡Wšv…P@ÿÖþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿ×þþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÐþþ( € (òö¯ýžkÏþÖ«ñãö~µÓ×Lð¿Ãï‚Úg††£ã$ðèÕx‚/…Ú/ÂMCø¡âhÞ;Ò¯®üEâ¼?À©´Ïj¶~øŠmî?`!ßäÅænó<¸üÍþ^ýûFýþWî·nÎï/÷yÎÏ—%P@P@P@P@P@P@P@P@P@PÿÑþþ( € ( € üø³âÏÛŸÂ~>Ùü+°ñµßÃ{⟇µï jmðÚóÇ×þð·…´ØV6¹âUÒ5MÆZ.µûQG‚lt;[£â¿ k:—†ï£×/aŽÿûCƒro£æwÁžWâüNACŠ2îÌòì㸦‡a³œß7Æý!'’ÿ¬K/Êž7 ™dxü„sž}ˆÇÖ£ýœ`p™¥ eô',?ZxøVÄ**§³•XÊöN«„a7³¼¹\*Eâv¢½èIÆJM³‰ðÇí)ûwé­¾je¿Œügaÿ ŒõÄ?o4ËÉþ\þÒß<o­ kÂþ8Òtm?@Ñ> é^ñ¯ƒ§ŠÊûSñþ¹§Áq.·¨ÞKoïfþ}1¼'Wpغ™G‰þÍȰ8ì³Ä ºøš—…\%ÄU0?P͸ŽÄfXþ:Æf™yNxŒ>†ð¯íÊ”¡—á¨F®qÅfª¨ÛÚT\õ%P³öY«NüÑ© ¨¨Î›ÕÔk‘9JIÇÛí~-þÓ>1øOáO‡Þ>Óu†ß~6ëžøiay¡x;Sð¼Þ·½ñ¯ÅKŸŠ?ü'â»ß5é‡HøðöóÅ~²Ö<àßxgWÔ|wâ›eÖ9ɸ{ý_Ï%R¤0ô³Œ=hÏêÕðøÙk:ùOuÑ©IFtçÍNœÝ£íéhí5íW±œý¥4£ðY«©£Óõ/ÿ·Œþð¬šÀÒ~!Y~Ïsø£Ä4¾½Ö|/ãÚÃÃ0êšßØ5ˆ|}džð¥²êZ]߆µ›ýKXOøŠ-wÀֺȻÐf¾½ù,/‡GzyÎqOˆñÆpÕ©å9n:Ÿað¶Gáž'5žÄõ03áÜD¸‡8¨ð¸Ê9®…ÁË)Ë'—gõ°>Ç0††²Äæ1åøÔXw)'JRŒñ*)ºwö‘öp³N-¹sIJš“q÷¹üpÿ‚ý²¼3ð×L·Ò¼NÞÇS¿ø!â]Vû]Ó¥ñwí1¥xoÅšŽ™Ä}ü%¬\xKÀß5ý_Áwé-Í•÷Ä ~Õý— š6‹íe\ô_ö–kÅXª¸Î|%LF ÇùV —â¡’øSŒÍ2|..|-YÖžsÄ"eØ,ó*t«áønŸ±úìðÒÆæ'Èr¯²Ü㈣<¦41^e_·„#·Õ¼%ã_Œ× yãûÿjä~$Ѽaáψðø•u¿ëÚ%}–WSÁ\¿¹Ý|_‚™¦Y•K,Æq/â²\4éño¬W‰Õ8à ³©ÕÀç9Rt8sÃø|%åxì“4áz™SÀç¹v>¹“xËN<˜Îi7ìæç4¡Cý—ÙsF>ì«5í=£R…E5Wšñ”T6¼-®þÙ>ñOïüx·ø™g§xcâgÅiþ5xsJ×Ç*ÿ‰~Âñg†ã|ÓÂ|~AÄ•²Ì¯áLƒF^`_‹¼Bò<ûðS©ˆã†á¼E˜q} fžuŠðû8ÄdY• üG„ÃâégþÝ(CÙG ÅK™×©Qª’xjN¥Õ—³÷ÝHR·<UÏM+®_°?d‹_ÚÃâïÄk_ŠƒâLj<%'‚ü?u¡x¯âïˆt+]_IìôÍOáÇü!úާªøOÅÒØ®™7‰|9ñÀ¦Þkµq¡|MÓfñ…•¾³ª~%ã=o ñ<øCýMËs˜ç¹•,Ç'áºfc[1ËeN¶/ ÅÛx\&9Éaˆx¨eY§q ÅQÀæ8 y‡ ba’Wž ׂú­QUUåg§UÎ*2½% JQ’æj|¼Ñ•ª'7xþ‰Wó)é…P@P@P@P@P@P@PÿÒþþ( € ( € ù·Å±Ïì¥ã¯êþ/ñŸìëðsÅ)ñ䚆¹âwÀÔµ}ZúP«%æ¡u¦Íqupá4³HîÁ@$ãåýK'ñ¿ÆË0Y.GâoeF[B8l¿-Ëø“4Â`°xx6ãG †£Z4¨Ò‹“jJ*únÎiàð““œðÔe);ÊR§Û}[ÒïúÖ×9¯ø`Ø—ÎûGü2À´Ä&ãþw„|óbâ?öGšbKˆ³å‡%ÀÜI¯Wþ&/Ç®Oeÿ‹ÄeÏí=Ÿúß{?h×+Ÿ'Ö¹9ÜR7'7*·=—)?PÁÐ%_eøqçö ýŠK+ÙWà!eÎÖ? |&Yw 6Ö:P+¸pØûÜb¥}"|xIÅxÁâ*R·2\]œÚVÕ]}a'gªºvémCê/ú¡ÿ‚£ý}ÄþÀ?°üË Mû%þÏs%´ÑÜ[$ß <*[\C“ źI£ºÁ£‚ÿ Zø*!ÿ ûÿÑ«üÿÃgá_þTÑÿã¿ýï?ñ-Î?ùx}Gÿ@´?ðTCþ7ö+ÿ£Wø ÿ†Ï¿ü©£þ&#Çú;Þ"â[œòðúŽ þhਈ?`¿Ø©FöUø£,Ø_†>Q¹Ø»¶Is»3»uwffË4ßÒ'džîü_ñ»%wŹËvŠQŠ×-#£¢QI$’J'Ô0_ô CÿD_ø`ߨ¯þ_à7þ? ÿò¦—üLGŽÿôw¼DÿÄ·8ÿåáõýÐÿÁQ¿`¿Ø¥Õ•ÿe_€Ž¬ ²?à ²²‘‚¬­¤•e`H*Ãpr 5ô‰ñâ-J>0x‹&š”x·9M5ªi¬Bi§ªi¦žÍnPÁÐ-üáƒb¿ú5€ßølü+ÿÊ£üÿ:_ñ1;ÿÑÞñÿÜãÿ—‡Ôp_ô CÿD?áƒb¿ú5€ßølü+ÿÊš?âbYCOGžg˜üË KJ•j4ñTèbªÎœkÂŽ"½(ÕQçP«R)¥))iK ‡£.jTiÓ“N.P‚‹³iµuÒé?—“=ƾÜ( € ( € ( € ( € ( € ( € ( €?ÿÓþþ( € (óKö•ý¿uOÙÃö†‡á~«ðÒßÄl¼-ðkÄÞ$ñ…¶§­Øê–ÿ.¿i;g†Þy¼;/­õm)¿gÁoá øƒÅº©ñ'Zñ}¯‡¼7,:ž²ô´Ðà£?üSãïü5ðׇ>,k~'ñ׌,¼§Åcá4ÚéÍ{¤ø?]"Õ&ŸÄ–îþ°Òøñ PÖnþ#éØ^:ß|0,-µ‹k]Y£Ôf•ìŶ}s›x¿þ “ð¨ü+ñ'Ä߆~ñv·¦|>ñÃ/Šš§‰´›;ü4Òü_ñþo‚úý·‰nt]TÕïµûkoøçZðëx+Hñ–¨Í¥è‘]ê°C®Z—Ô½ÿ‚¡ü"Юn'ñÃÿŠvÚ-Æ‘áoé’i?‡5½SMð–»ð“CøÍâoGeâÆÑ¬ôÝ/ÁºÚêA|3­øªöæ->öÒ+6ÕŸNÓ¯À>‡ø3û_x㿎|_àŸø/⹇Á^!Õ¼1«ø×Wð•ÿµô]GÅšMý˜Õ!×o5>òCÁÚ¼šV½¤húÕ¿Û´¯4Ëk}sNžàêê( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÔþþ( € (Ìuß‚Ÿ¼Qã8~"ø—áoÃïøöÛN²Ò ñ޹á Uñ$:^ššêiº|z½ýŒ÷«k§GâŸÇaRÉ¥x´]CH5ðÆ‘¦øGÆk®øfÊ %=Úëöxø }©x³X½ø/ð¶ëUñ凊ô¿jðÌ·~-Ó|yƒì£Ëª-Ôšu« Â÷Äߨ;á¯>)øÅß³ƒôü$ñçþèÖ~øž*½ñ­‡ˆüWû:üIÓ5Ï O¡x&;¦ð·Æ/Ú‡ÀÞ"Ö|7¥}âÄW×¾?µ²™õ_µKûÞSôwã^"È8/‰8‘â²®-á¬ëˆ1¬Ï:Éò:\=[$­â|ªeÙ¢ÆæoN9Ž]á?cr¬Ö¦•âëÁe²ÄÑÅR¨pÏJœëS¨¦¥J¤aÆ2›¨¤°þô-Vâñ0R¦¥Î–©Kš*0èŸÿà˜WºmŒ7ÿü à»M^_øj-?Åß³·¡YE¥hÞ?Ôg+ÇÔ®WáýÆ£x_Yñmœ_tgÕu+-Gû_FðÂCÅôZJçŽú6ø±…«‰§„ÊrLíap™f.¤ò>/á\|§,σ°Ü{  ý¯GÇa8S<ã†Ááq ‚Áã±mˆ–"BÌp®ÜÓœ.åñÒ¨´_cÌÚ*‹¨¹4“æi;I¸|ð÷ìgðÁ>9ý£~hþ*ø©xŽÇCñw„ßXÒuˆoüO®|Oñßü)àËo‡ú·ˆ|-¡ØËâ/‹^;ñN§á½GƳM«ø³Äº-×…n|[®ê¾²ð£¯…‡ðgŒ)q¦‚ø†żË5Ágx¬Fe–fá¼?dô8ŠqÙ¶,Çb±4!ÃÙ iæÚU!Js©‡Åeôù±Ø\MgŸ²­Êù%ÍÈâ£/oFÒ“å~Ö 5{š?·O쵩iz&·cñ=ntÙZêz6¥„|rl®ô½ST:‡õF¹ÿ„hCi§x¯ÄK'†~.áqxü#„,nW^¶…žuÃê½^³Ë _Ú¼õ±Y>Y(fÙÝ ­LŸ'«‡Íó‡ËqX|Uwý¡„j/Úé-Sä©k7Ëß.ŠR÷aŽk–7š”MO~Ù¿³§Ä¯x+Àþ ñ¶«©xŸâ›¯á=.ïáçÄ­õ .ãA×+ JžYbêãk`3|Ï•æPÀÃ,»VxLo°­C:xÜ5Yœ*7:ŠðN•hÝ8¹§yB)'å.^h««¦™å_?à¢|#¹ká;OüCñ7‡ôïj®‡càïxnÓF>Ö> Ùx—Mñ6·â/ZÁáSûã×€|C Ç«ÚÁa®Ú_­œz•µôöÑKö3ôdñ:©—ÖÎkd\5•fX¬› ƒÇâ3¼—4­Ž\A‚ãÊùV+*Àe™Z™¶ëÞqY˜Ë^xŒ¾¶×–®'ªæT!¸)Ô”›,¡nYQRRrе£^MÅAÝ'(ÊQëûf~Î1x˜ø2_ˆÅâåñ¥çÃ÷ðÌÞ ñÜ:âxšÃDÒ|M{i“xj+Ïìë_ëzv»>º°4†»ÔN¢,ô½V[/Žž(O*Yì8nœòYd48’9­<ó‡ªeòÊq9†3*ÃÔX¸f’£õªÙž—ÓËÜ–>XÕC °Ò¯ŒÂC«Æá”¹=£ççtù=E.d”žœ—²Œ”¹µ-ÝÝš#íñû6M¤êþ/>1¾O‡GÃÿ |Ixæ]& øÃWø‹¥ØëÉg…ÛQO Ÿ üC}'Šž¡´ jIÞŸÚ©ôsñNÌJ²L;âŒog\-þÚáøc)ç& †1xŒºU盬+ͧ.+Ë0ñÉÔ¿´IJNЧÎý£…Ö\ïÙÆœ*{OgRÎ3•X§nNn_ÝIóë—M®nî×ö»ýŸo øÉsŽnR€:‹¼QñU®¼ã«/øGü;àxçÁþ2Ö4ñwላ¬<9âo†¾7Ñu)ü5õŽ÷Bš4Þ/4ãuóÕ¼ñ&…N¥>¥)ø˜ä¹GªYçWþÒÌø‹*áüï#Àâ]Ö¢Éq9žSÅ9? O=ys• Æœ¥ÊèâU 3ý·ïûÃÁÞ2O˜þAñ.oh¯á]OAÓu=7Ä’?Áï‰vú®Ç¤Ï¯Ká-Iô¶žÔAq?ÓdÿFosœ~]ƒ¡Âôha³<׆rªÞ#<ÈåÃüÜYS…a”ããœa3V•ÆÇûO'…ÓÅ ø½mñÆëÇéñ4]&©añÕ#ëVZ¶»kâê¨ú…¯~(x‡Ç÷:µºG¬ë>+°ð½Î±¨ÞÚx_D·²ùüWŒþfTøŽYÊñ‹5̸‹‡£Âï9©ÿ˘åy3¥Âøø<¾¶[øIG W!á,·†é`êJXMˆÍèàp”kføúØK“ê‘:ž×’ø§O÷­9sMݩՕK¤¥)¨¶ä ¢Kcû(þÕ‘éº"kÿ²¶³â¯üEø‹ñWLøƒ?¼/ãüPÔu«ÏÞixSÆš;Üè÷~°žÿ„SR}GÃ7^ÑÿÁ8¿h…žÓü=ªëß³Äxô)4øEæñ&¥ûNØÅá{m#^øEãO#EµÓþ(3DÚ·Ä_‚ø¬´÷s[?Š4ÙâÒ,´o ÝÏáçû®6úPøgÅù¦'3ÁåÞ(p¼³ãµ©åxO ëË7«Ë¸Ó!ö¸úØžJkÃÄœ1TèB´rœU*˜ÜF;4£O2ŽrÌM¨¹aªZܼÓÅ®D¥FnÉUVæ©BI|K™Y(ÁÚ^•oû üX¶•§‹áïìfng¼ŸQÔ®æºý¨®ouýJmR-v-SÅW—?&ºñn©¦ø‚üG ê^&›V¾ðï‰<Ïè3éšÌ²ßËòµ>|V*œø—Ç5Jxl-Rð’• · $òùá2ЏRrl&+-œ²ÌÇ •C ‡Ìò¾\³1§‹ÀBsU—Ö_òïvÛmËÜ›w¼Û©yµ/~.m¸OÞ¤ï.J?Ø'ö«µø¹¡üQÓh¶ð‚þØøEÔi]+HoxÃzŸ‡ü1àë½VÃâU½ýï‡m.ïí¼Wto!¸ñV¡â}MkßOá×Ô|9¨{SúEx?[‚óÅðÿ‰8üNeÄYïb8‡†ð¯\GÄ™®2ͳÊ8+N\ì¨c!Šãž.œ±”iSÄÕ‡f4*Õ ª”ieÕb¹U<Zè§WRT“O÷®êÔihô\‘i'vhi?°wÅm Ëý•àOÙÑ'ñn‡ã¹mƹûYËg'Œ|/>sá=Œÿe³:Ÿ†gÒté<9?“ ì‘.”,Ð:¿.3éÁù‚‡×8‡ÆºÒ§“f= ¯/ðnã’fôñT³|±b)ð|+¬&kOŠŽiKÚ?ím7Œu¤¢ËêÇá§‚^ôgnle¹áðJέ¯.].ËwWÿ‚uøë^°¾Ó5†?±Åíž©õ¾«ëµ¢Iª®«/Ä™õiµK˜~+Ãs¨Þjó|_ø“&­{=Åö¨þ*½7÷gÓŧ~ é7ÃÙv'‹Áq_Žzø:˜z¸9GàÌ£„x8pµ<0”§Á³¥†¡‚‡ð´pXjéað‹' °Ôéû\K®¥–Ô’iÒÁ;Þþö3[ûFïûÛ¶ý­[¶õæ×šÑqìoÿbÏŽ˜ñjÞxcöO‘|w¤øãBñŠÅâ_ÚÞÕ|E£|H×>#ø›Æú^¦–¿àYìuÿ|[ø…¬\[œGÿˆ<ûµ}+Dm/ÄÃxïÀ8OìgC6ñŽ/‡qœ?˜äŽyWƒžYŽál¿…ò¬ƒ„u¸>«§ˆË²Þ ᬠ:¿\6[챬q˜ÿ­[Àâ;qÂ{ê¤giãW2«*³šv«´¥Z¤­v“•Õ­8~Å¿ûÆšˆðwìöŸ‰7ü=ñ:ŸíPm¼k¢üD½ñ~¥â­;Å'ây²×-î¯üã[½,j6× á‰üQ¬Éá†ÑÚöRÒüwà7‡È°¯;ñ³Ùp¾; ̸oý“ÂW!ÇðÎ$Âäø¬£þ©,F_V–†òϪդ³jyF9¿×•FÔkÞröx+ÔU#SÞÆZj¯?:’ö­;º“jéòó>NCô§á®‹âxÂ:ФÒfñ‹¡Xizœºÿ‰õM)ç±…mÕ¬õ?jzÏ‹u0ÇûïjÚŽ¯w7™=íäó;ÈßËUËsN#γ,ž8Èe¸üËÂC0Ãå8Ldiâ&ê5_ ‘a06\ò—.,ÁapTaËOB•8¨GÔ¥Fœ#>^hÅ'Êæã¦š:ÍéÖM·»os·¯Ð( € ( € ( € ( € ( € ( € ( € ÿÖþþ( € (Ê5¯ß ¼?ñKøM¨ø†åüªÁ Ý&…¥øsÅ:òi6¾+“ÄðøZïÅZÆ…¢ê:ƒ-’†ËMÔµYXèzjµ®•i{u³j²Þ_É Øiv†mOTº²Ó,ï/ ƒÃ~$ð÷Œt'Å>Öô¯xo^²ƒRÑ5íúÛSÒ5m:åwÛßiÚ…œ³ZÞZ·tSÁ,‘ºœ«·ZÛ 'Tø‹á Çþøa©jmã_ø{Æ~)ð®’l5"Õ4_‡÷^³ñmÈÔá´“J´—KŸÇÎúúÞòú=AåÓíîc²¿{p ý_\Ó´%ÓßQkÅ]SWÓô;?±éz¦¨N£ªMäY­ÂévwcfdÿRø[év)ûÛëËh¾u× € ( € ( € ( € ( € ( € ( € ( € ( € ( €?ÿ×þþ( € (àÏ‹?²ÏÅÿüEý¢|Yð—ã&‘ðæ×öžø9àï…~.Öï|?¯j^;øcyðÿßô}Å u=Äþµ†þê÷ân›©Iªbmïú•þ—quâHåÐ>~»ÿ‚küIÔ­|M4_´ÿŠ|âŸ|b²ƒMð‡ü%¢|<ñ¾¿¨xúo€š—ÃËKÆ#WÓ¼1ðNÃâ÷Ä´½Ñd–j-à+´»ð埀t-6Ü¡Ñ¿àžž-°ÕtŸ]|Oހ߳E߆Ljþ(êV¾¸øUûPøïã¿Åí/HKŸ[ÙÏ üOð?Œ,~éw:TpøsÃҴϲËá«-;ÃÚx;û!þÄ>#ýžþ1ø;DÔuë[_†ÿ> x7C³Ót}At âwÄÝ&ãâW„¼ñcLð€ñï‰uŸ Ãeð¿ÇÞ%ð—Ä]'_ÒôM ÅŸ ðÞ¿á‹kèük©8XÁ<þ8Oymâ]kö´ðµåôßõOxZïBˆ‹¦xêãSý˜RdÐ4ûˆmqrnÿg?ÝK£_Ük7QjßüEýÖ³}a®jÞ&ÚŽˆößW¡Z¿ÕèÏ_ØÒ_c‡¦âªW­ÈŸ³£8©Õ¡(¦×2RM¥k´®ì®ívú.íö3<[ÿîý§t›OxÆÛâýÄ_^\xëVøigám>ÿ±xâgŒ‡ìÈ|#ã5ÿ„»âV|:ð׎ÿg{?ˆ_<#þ³­øÏÃ(ñ_†!źÜó]x“žÓ{ÿïø§x÷Hñ‚~=\éžЛàóC¤kמ?ÕµmNãáô>,ÔS]²ñv™¬øTøî}3_—^ðþ‰ªÏá{ÛÏEâ 3Jðlj-üG©xÔé_Ù#à/‰fÏ ßxgÇ_´_I§øL³:Ô·~$‡\´´O|J×´ñâ†ÕTù)Å´¥9Z)É]«¥!´·v»¶½_oRzÌ ãWBñíÞ”ºo¡u2ï•Ü>` Áªq’Q“Œ”e~Y4Ò—/ÅÊövm^ÏKëk€ú!76ëq£O ÝK ·1[P\IoÃóÇ >kà —6ñË*©HÞâr­*µJ£§*ÊœÝN§UBNœjTIS§*–åŒêF•YB ©J4ê4š„œKôë½½7û®¾ÿ2j€ ( € ( € ( € ( € ( € ( €?ÿÐþþ( € ( € üŸøµû:üLøâ_ÚÇIÓ>éš§‹ø»ÆW÷ðÝïÂÿƒZ'ìÛ¬iºŒl45¾¿£xá?ÅýÓÂWVòYê^6·ñ$ÑZéÞ%“U¸óÿŒžw‚~6kž4×tÏ€>ñ_üÀ_¼ªøÓÄZ—ÂëÏøF|ð§á‘âýcÁ·zf©ë×¼_ñÀµýCc¢Ýk±_^x½o­“]Šþïúè׉̰¼eÄë*áœ×‹qXï8Ã(†O–dx^!§VYÆ—Q«›åXÌv ˆÉéâ1^1Uxˆó:Iá+©rÇÎÌ”]\Õ!IGF|ò›¦×#r|’ŠmNÉÛnº­¥ð—>$ëÞ ðO¾&ÛSÃ>4ø¡¦ü0ø³­[[ü>ý§>-I­k|Oû#|&ðV{á[øB/ ^ßh_>x“SÑ<>š}¦¬XxîËÄaÒ®4ûß?÷^EÂÙ~{Ÿðç ¿ól‹„q\[Á˜µx—Ân †ÂYOgŸc¨g\EW;žoC˜xsÅY^™K[‚Äpõ|±âq”ñ8|Î>,ë8FU>» •:®ÔñU¹¥VxJP‹Œ#㈧&“qMTNö$~•ð¯ÇûÝ;ÅVZ¶©ûuü9Õ¼Öê´/‰ Ö´ /x—ƺÏý&ÏÅ£á¥Ôú·Š|/¦ëZ‰­ø—ÇžñÆžú5•—‡4ßjÞMkÇ•çÐÄåðXO£×`óõˆá|ó á¦US˜â2¬«!Àñ62¾Lø®…<Q›b°Ž?•pîeÃø˜ã«×Äf˜œÏËÃÝĵ5'˜StíWÜx™óEJSt’š¤ï8)EJU)ÔN)(ÙÂòè,j?ÙÛ⣣Ïâß‹¾ÒâøùûBß|køÄuBÒÔxcàçÀS§Û~Ïß 5¥d¹kMWÅwþø_âxh™¡íŒÐÌŸ9¸óqøÃXlm<›‚¸ƒ?|4Ãð¬µoín8ñë5|Iã<N’­„ÉðÙ§å™nj½œãõn©H{+X¼5Fœ«S_Yĺõù¬¹haíõj2³•œÜiJQOKÖ¼YçÞøõãmÛTßíËð_Ƭžñbø2;ÿÚOâ†/tß]/—¥ëo(¼Óµ½E¾$ü+Ö4_ˆ…›áý¥–‘ Mð·Ã¿|sð.¤ðÆŸ®xçJ×!×n¯4Á¯éñ?òÚu³×Kè߯˜Œl»/‡ à*x”ÐÅeøeÂÜa‚ÇpÞa›®%«_˜Ã‹³>Ï©øƒ:2ͱ9ã0ËèÐż·¾³& žcEINNsöõoÚÒ”jFÎ1Pt£V› ß*”ã+¦¹‰<1ñ‹Pѵ¯…’ëßðRkú¬k¶¾:·±ø­«Y_k:„µŸ†úGÂjâMoÁZôzÞ£ã†þñ|Ÿô%]þ"|[×5_ êÒ6‡ xŸCœÛðØìÃ.ú,q&[˜fX,¾·TÄpv‡ÀæÎŠq¼a€§}—Ë/ÂäSÄ,x0o9ðÇåø,ç ˘f9N5ƽ¥IË4§(ÆMTýìÓqƒ§OZmIΜ%í£î/iUÊ-r©>8ðv‘ÃxÃöæÐ2qŽ×kYÔ”©Ã꜕5+sV§:p÷Tœe.kË¿øûQÞj_~iÞ.ý°¾Þø“Qñ.âŒO}ñçÆ?ük«xJßáÿˆ¾i>ÐoìüâMOáæ­ úÃ/Žž5KM@ˬ|EˆÞ {[=#QKÛß›âOèáxY/‚¯’.,ð·˜äs^'¤óLß ÂùŠ8J|cR¶2Íqc–P©K,»Ësuê84ó*\Þö«QsOÙâTf¹iG’¤ð×¢½ØªrjÜÎ3“â§íAáöøqñCEºý¦ô_x‡àÃ/Úïâ—À_è>?Õ|QâÏü[ø«yñGÿ³ ëòøfÛXÕ¼kðoáuö³¥êb];RM?[ñÏ‚Þ+­at·§„<$Ì×p–>„øü§,ãþ+ðW„|Dʳ.Áå6YÁœ!C„³?sÇ.ŽiWƒÈxã‹°ø^dž–+ÃÙê ÆB©Šƒ§R/<=<]\<ÕYÊS«UÕŽ*vRs£I´ôÒU)Ù»4n[|dÔ®ŸÄz ÿ‚†x'L‡ûR¸øoáÙþ>x¶ïû]gã_‰?Ë£Ÿc¸cW„Îò¥Ž¡_†‡f}!W—¼ÿ´ ½×ì¢ñ+•yÉÂoÙ{ïØIÂ5°Ÿ.ü‘Åxkã—Š.~!kOÛ·À^ÐíiZß„¼'â”ñ7‡ìto‰úÍ–¹ª]J𥮡o{ïf¾e4¸kãôyâ<×0­‘gÑÊ2Êœ9W€Ê³ø¼›™VÍrLà©pån/ÆeùÎs”<«3Äc¸KˆËðt£õ:Øj”¢‰:’ÿo„#í)óÏÚZSŠRåP›‹u(Ê0ŸÃq$óŠùŽÄÜ?V—Ʀ*9äòYVβ v”r¼ÊÝ} Þ>ÑS« Ê8©ÙÔr¢ãVö|ª2P¨EG8ÔM)G£‹ö‹ðÏŒRãÆW?µÂ}Çþ¹ø3ð[R¶â¯‹<?~ü=ðÆ¡ñ“Sð7Å­Å>>ðÔ¿¾7x¢ç[ÒüO}§ÿÂCãü&ðU¾±}g/ˆ./m|¹øašä’¥‘ÒðŒ³Ìéñ×áj˃ò|öžCÆÜKœÒÃp>ˆxFŽ;)áÜÖ/À9E,/)ÃâV[’güeŸTÁP­¶žuõ¨Nõ>µJ5`èPkÛNÒ(^»…^IÔµ¯7%&¹å 0Rk™©|ãáÏÚâÅ ¾-ZEûcêŸ µ«|C¹ð†µã_Ž!ð§…ï4‰¼-ûTh?¬ôûkO Þ­Þ¹¤xó\øâˆ)¡hø ÷Àþð½Ö›u­ëwž5ÐõŸÔ3O xg„¡Á•¥à~ŠpŒ«†igX‡€2Üç6£§›øC˜ñ¥|MZÙÕG/Çpö_â6SÃRÌ3ÄT3üã7£Š£—à(dY† žº•}²úì©5*œ’yÆ/ÜÅ*IZ:µQáåS•*n‹MÉÎ2úýhý]´?ÚtÏø(WÀÿë^0¾ñÍ÷Â/íê6ŸL]N׿áÑïõ™tM3Gð“á ZÿOÔüà;U´Hmm¥“á²x¹e¸œ»ûS†ÀCŠÆñ3;Ááñ?ÚXL÷ˆé`Ö>u«eÜ«/̲òŽ¿­JØ›fT"ææè©NS·2’Šæ²T”N.;ÚÊQr4¾iÔ¿k_Ä|QàÝ/ö¡×|!àHÂ1øS[?´G‹5èúbêß³ŸŒþ!ZêŸ/ü+i/ŠÁÒ´¯Œþø{¬[i§.¼Gâ¯éž+žÑü'¬h?ªá|Áe¾å9æ/ÂL¿:â*’Îåœ`†Y6=ÇbÞÄü†ka8k›×†Nþ¹Œà\ÿ‰pUq¸,†ŽU“åx¼ŸÛgxÜç˜r¼d¥^PX©Â¡É/¬ÎPŠæÃ΢•F£Ï¢¯N EÏšRŒÛ„c(ýõû |@ñ§Šþ.ZiºïíWà/Ž6:GÀæÒ5O 蟵ïkx‡B×|/ccã+ á iw–ºŽŽóÁã=gÅ–Z׋‰%°¿Ñ|Gý™âMsAÑ¿œ¾<7‘dü[—ø=Ä~â1¾ ,n7Ì8O/ÈðU2ÌÇ/ÍñòÓ>ÝèvÚ¾Ÿ§~ÙÚ‡|QâZkÇÅ ™¿fm{LÖu-"ý®<5¬[èž$Øó½ŸˆtwúO_¶Èýž>xâßá½ÕçÆoüPð¾ñCá«|×4}GÀ»ðŠ7Ž|5áŸÆ¦‰âX¼'ãô¸_üKñVµáøãÂvóé±kº ýöãYÀ8ÿhïÛñ5„°Íð;Ä/{∷:ÅÍ(|Ô!ð×Âï Eâ]ÂzÞŸ¡øÞ‰ÏŽcÐluKxkÆqxoKмe¥X\5ÅËZ^hQ_ÑÿhÛúÙCÇ,ñÁ{íGö‹µÖ~Ùx3EðÿÁýSO°’/~Ïß ü⃪øGVø‹s¨I¤x ãGˆ¼{ðŸU×ô½WTžÞ?ZÜÞhi ZŸˆ`à/?ißø)M¶•ãûöýžõ ›­KCñü;Ò´‚ºÓÜøOÄvÿÃËÁâ+ÍCâZhºý—‹¼Y í厗þ‘oà˜µ?ìÛ›Iu›Û ?|zý¹t¯‰—¾ :!¶×>,ë_>(Éàψ:»âýáá_‡Ÿ|_-î“á—ñíŠæø5ã/Oñ‡àÇ‚4í"Þ´¿‹Qéæ×U¹·{Û-m½~ý_ÞÝÿáÀÞо:ÿÁFãòõ½OàÆµ.·ªÉð7LÖ´uøâYtÙl%ñÏí=£|H»øu ïˆ4ýN¹ƒHÒ> xÆ CâE‡Ã íWÁzôZ/ŒäðW‹çÑ`Ð?hh € ( € ( € ( € ( € ( € ( € ( €?ÿÒþþ( € ( € (ã/Û{â7Å…¿¾ø§á¡™ª7íð«Eñ]Ö£¢jZç†WÀåþ£§xŸþ8´]Ä:æŸáXãžÖãRÕôkk+û aµtÕtø^ihÚ?gÿŠ÷>ø#ǺτµŸ‡Þ.Õü3ᛯ|<׬5«-OáÿŽ5? hšï‰<s6·£èw¬ž½ÕΑ6­m§Åiuqk2¨Šâ+›{pÌwö³ý°¼#ñYº°ð¶£ãl¾'|uðŽþø›áö± x;áo…-¿jïƒ_?eïi2ð‡øµûlü^ðÆ_ˆ¿ ôŸƒVóøoÃ~%øyáâ­æ—ñ\ð6mã_6£7‹~!ÜøGÃÚŽ§¤ÁgâØ€Ç…ít´‘ßÄ^ñ†›âwE¸ñ]§ƒÀ<7Ä¿ðRïÖƒâGü"¿³_öºxľ1ŽÆã[Ðþ0øy|.>#Ðü+®xÏû;àgˆ~.xCø…ñŸÃ‘êz$ö^0½ð s\ñž¥fþIü ®iº‡‹üugá³'ˆ@:þÕ¿>øsá…§Ãox·ö޶ñ/Ã/tÏø³Â#ð·ˆ>*jŸ µÍhÿ|7¥x+á¾›¥i?‹¨7ö­¶­¤é7Ú.¹£k†¯á-gI.]u Ü_´–O¨>‹¥}E@P@P@P@P@P@P@P@ÿÓþþ( € ( € ( € ã5ÿ‡ÞñG‰üã {L›Q×~Ýk7þ–MWY‹MÒu-{LmPÕ_@·Ô!Ð5MY4©.l4½WWÓ5 GB¶Ô5Xô;8jÚ—Ú€;:( € ( € ( € ( € ( € ( € ( € ( € ( € ÿÔþþ( € (㉿¶?…þüMñŸÃ¸ü4úÄ tëß¼K}âß øV×Ãÿð²4ˆú߃´O éZåÔz·Ä/]iÿ µ›ýGÃ~õxtíCI›Dµñóêfžåüçà6·ã_øj]/Ç:‡¼[yâï^øïYð‡‹cðî‹ãO_þϺn•¦G=—†ïmõO xšûö‡ðµŒþÙ§xgE¼µHõÙtûmcMº` ÁK¿f¯ëëÚ¦½à¿Zø“Uñ—tÏ øõÓះ´OxÿÇ–ž(×¼;ƒ.u»ï\Ø|,ø¹ªÙB¶þ _ ßê$6vó £üAý»?fï„Þ3ñÿ‚þ&x»XðTÿl¼ {¬x‹Uð‰çð†¨~ xWƾ9Ñì¼1â 'KÔí¼A©Yx7áߌ|Q­ØØ£Í¦èz©¨²Ím¦êOdÇxãþ 9û4øJM´½_ž7þ˵øênµ? xÆ—þ°Õ?g Ýx“âF™¬ø°h_ÙzréÙÏc>¥Ô,-nSÍ»– 9l®.€7õoø(Wì“áø|júïÅ .‡·º®›â‹+|Lûb_øWø… øŽ@¾ iñßFøiã+?xÓÄÞ ñ›ã߈Wºf¢4-7Xý §¯_øžÓB¶ÐtÛïP|i·ñ&‹âM'O:¥ÆŸzŽ©á}?Zð´¿Uÿÿã3Êèg1ð‚ÅG*t<5:˜êµ3¼û6á|¯ ªžhñؼÿ"Í2¨åÿSŽ:ž+ £[MVÃʾ__Áór}býþü¾ä#ROžÜœªŒ¹¹œZÙ»8Ÿ¢ þ-þÍžðž•á½ö‰ðŸŒ‚[jšŽ£â¯ü\ÒüS­ëwúTú–âkÚ­æ¨Ö:L·džüE%îŸaƒáÛ ý/^´Ð´m6ÏK¹²µùÌO…~%àÜã‹à0ÃÎL%.J¼;šÂ¤êãè`±8:ti¼7´ÄJ¾2ËkAP_ÝfµŒÃóè±Xgkb(»Ýÿ;E´þßG-{Kâ³që¼CûDx ÓüC¶¸·ñôŸ ¼mðËᮬtÝ2ÚtÕþ!üX“ÂëáxmçÔ-WSÖá‡Æþ½×Sge¤XøŠÊæ{ÖH5#a®Yá—æ”øf­*™fÊitø–ö÷N½µµó§·‘+Ôͼ ñ‡$Æbð—‡WF¾2y>*trªØÜ%Ò0¸ª˜˜`¾³€–"ŽƒÄW…5#Ë“ætêT¤°ÉÐo†\¶­ sÍS,âï&à·nÍ/iìÞ“¯Í¯O¿%ð4Ÿcø™à—øyÊY·ÄzaðÛÝÍ40[Zë}£ì—ÞËslš|PI+êjµk!:\ÀïâK€xÚÕõo´,¶šE•Ö¡©Ác ç‘ß_Ã<¥O‡hp¶y˜çt2\£?Åe™nS™â±¸<¿;Áàq˜bð«E*•eƒÃE{' ØÚôpØJ˜™Ö£íRÅPäUXFs§JQJR„œegv­î¹oð«¾[^4æý©?fû}BëI›ã§Â¤Õl|Uÿ5îš|qáãiãâðƒxfæÌ_›ˆu¸üY$—O’5¹‡ÄWVZ¨ší¥¼»ÃÂ?já¨ãaáïKˆÉÿÖ ¯õ2XzÙöd³¥›S¬ðîœðÉ¡S7†&/ÙTÊè×Ì!)a(V«I<^7ˆ¥Ì§È×´Ô¹¹yZÞê^ïøšZ6”¹‹¿ÚÓáÀø‰ª|,Ð4OxׯZ6¹­izžŸá ÏRŠ×Kð­ÇÃ7Æ^177:ÅŒRø[Áþ ø¡ xc[ž&²Úþ—ã -+EÔÓÁúýÅ—¯GÁž(ÿV0œ_™cøw!ÈñÙ~…ÄçY•|,êâóz\QŠÈòEJ–8gÞ[ÂYŽm—Ó¨£‚Yn/$Äc1ØYg™t*ÃÆSöŽ”cR¤ã'¡½#ì”çºn•XÂV´¹£4”¹$Î:oۻെ‰ðÃÆÖ•ñ#Ãÿ>4xÛÁ øYñ/Zð‡Ù|ã >$h¾0Öü âx5DÔæºÑ<â(ü!ö8u¯éúÓ®üUà‰5»M/Lñ=–¤ÞÝ?£ÏâqüY’`1|/™q7d9þ}ÅÜ+În É!ÂØü“Ä9UL$°´¨ãó¼²Yß·©Ê19Ö¨äùü0qX¬«†#ëôyiÎQ« ugR©8¨Â~ÑMÓ’oUrÚóK—šIAóÃÛ+áÄûßA¡'Ští3Á?|?ñ3Ç~!ñ›¦izG´Oü=ðÅMÏÅQ nã[Ó/oü ãKbËP:<ÞԦѼa£é^$¾Öü!â:ÃÌâxׄ¨eu3 eœV}Äù— pö[–b±x¼gcòž%ÎøC_(›ÀSÀbèa¸ƒ"Ä`«á¾¹O7ÂÃ’ã±™^希ERÆÑªä£Î•:Q«9IEF8UФåéÍI7Gi¨É¸Iv·'Â}KG¹ñ ·†>*ÿ`Yê>ð•Ö®þ ‹ìÐüWñÄŸ í|1ðRHWXkäø¨ê¿¼ µ‰´²×Û^Òo¼Omyá~;Côã.:–YW6àÿíø\ç:¥‚Žy7V§püx®¶mÇ‘¨ðþÃ`ø3;ÌcˆößÚµòÕ—cpÙMZ9¶Zñ±ôšmS­Êœ`åÈ­ígì¹h|WU[­ÚòŠ—2r÷&M©þÛß <=ñJøSâýâgƒ>$k~ð?‹´¿x—Â1Zê7úWŽ~3Ið2¬.í5‹íSÕ<=âÓc¬x‹JÒõ+Ëèü «i¾1Ñ¢Öôyn&·Ï àæ|7Œã —1áL÷…ð¿d¸¼ï*Χ[ ‡ÆpÿGÄ “ÄQ­Ãã°¸LË&úÆ ,Æbð˜|<øƒŠÉ1ÓÀãaWrÇÑ„ãJq«N¤£ (J+™©ÖöZVmJÒioNJpæI³×¾|tðíà /‰Þ²ñ^ Öd‚O êúå®›o‰ô«­/MÕ-õÍéš®¬ŸbÚ-¤ê6Œšˆ|?âM+]ðωtM]ѯôø>+ÄOs¿ x“Â|GˆËgžàcR9® /­Š«<§GŠÂTËñ˃ÁËëìˆÄac‰Ës,¯—æ¹^?—ã°ø‰í‡¯ M5Vš’ƒø\­ï¦“æ,¤­­šv”f¥ Æ2‹G³×›…P@P@P@P@P@P@ÿÖþþ( € ( € øÃÅ_±õµ–zçüC¦øãÆO‚´–~·Ótxwâ?ÁMᓦZ wY²ñ6•©øGP¼øðãÄoaýa©.£»§\êº6¢–±pÿ¿f/Gáÿêú^•§üXñÇÄoÚÇÃ?´•æ‘oãÃðWGðô¾øàŸ‡~ ±·×/<ñ^}f=3Bø_áuËYt}8ëšÞ§­_Z\hú}½¦–ÿ«xEÄÙO çÙÖ#9ÏgÃØÛ„ó¾­§ÂrãÔ£G…ÄᡖljxYáêTÂ:ò§˜hVXyÁSú_mÏK—JuiÁBѬ*[Úª:Âí>gJ­ÕíxÙ_~enY|]â؇ãðøgâŸ|?ø£xcSÔþøßᧆõ-cöÌmwDÒSÆ¿³…?fÝBóYÑãý–ln5‹ÿ ü>ø}â-nÂÞÿNžxZ;½û@¶Õu{+ÿë\³ÇßäüAÄž!c³l&‹ò*Í0¸_Æ<‡Å ãÅ,5:~/b)`±l׉x—,Àb*á±4éåYĨãèfpx,E)àqÎTá‡än•Jq”±ªi{L4pÍÉ}U9' täÕ×½ââ›G xgöXøùáŸÿÂdzýŸtØ~$]Ûx¥µßØþÙö6®½¬øÖ9¢ñ­ªËeû$ZBÚHšÅ4Ï ÞG'´‹ A׬|)ŠlN¹?Íf¾/xsšä¿ê½o±sáj5r…—dX±œ]È' åx<13×xj°’Ä<^qFqâ mÇ0˱ÅL£²è\p¸˜OÚ¬5ªµ>iÇäê_™·õMVÖƒ÷#Ë¡®ip~9ñÏÆßÙ¢ãàM÷Ç…_ ã’?‹þ1ß[iŸ>"xŽoŠ?~%kÖ^ ðþ³-¯ƒ¿e¿Þh¾ð^¡ñ’ßÁ> ÑuE•ßUÕ>ÙXêÏ{áËxn¼,ëŒ< ÆQâÚ9wˆÜu—,û…8CÃÜÿÄ*¡ˆ|7À¼0òú¸Ü¶ž$ÐXœÏˆñ™.UŒÍ³(,5*ÓÄq%„šÎæ¨i 8غ\Øz2ä«W?ö›{JõoË/àI¨ÒS”cIéMÝr.n›À_~.ë_ €ð'Á1uà/‰Ÿ¾ ižÕímÛË ¸þü=ñ¿¾/|4Ñtƺý“,u \Šž Ñõ+Å–ºœúï„ní´OA5ÜÝKìâü]ðï0ÍòÌ÷â/µÆåÙ¿ñ-O£ôeCžñ¿ pç gÙ¾*Œ¼aœhæ3Âð¶S™`kå«,³9§W€ö”0ðˆáq„éÇ ùe TÿßãxÂJ•!ÿ²»Æõe¦åÍf›\Ó©ð÷öiñ„žе_†Ÿ³Ÿ‚5_Ïiû;O¢ø¯Ãß·Kø‚ÓS‡ö_´ðæðþûOº_ÙŠÿFyµkoø:ÏÇ÷zU¤øÍüáåÔ˜M¤[²í™øÙÂ9Î'‹Ì¼_Í1+/å<;ðVñg›â¸šèx·OR–ŸgÕxn|Exdo;ÌÖ.8ʱ’X:±²Ž +}[UŽWÿeQT÷­Ô!í=ØóòFüÖLç¾|*¿ñ§Âƒ“ü$ý™|ue¯ ?ã'Á/Œú/í;¬i>2Ó´]ÅV¾;Ó"ðî¡ûÙxcÁ¾TñSM¢ü+Ô<+¡øYì5Uô‡¶Ô.¬0ÅøÍÂ9Ž{™æù‡ŒÜGŽÀgÙF/&Ï8Wà¦"· g1™-‡Í¨ËÆ?ílob08l#­ÄøŒÚ§â+`ðïšV§e&°ucÆ8()Bqœ*¬dUH8Ï(²rF ·û»F¶¡ªG}âoÙ3ãOŒ4ýCIñìçi}¦jZ߯=jâÄþÛÆ+qÿ /ÄuøÑ¦D±þÊHWOñþ—ñ;\Ðu) WNÒôÏIáíOGÕ´©Ï¾Sã/d˜œ67-ñ:¶…Àp>–!xÏSþ5¬8að..n^15,ObøO/Ìp±²Áâ±x¼Ò9–ƒÆ¼%,&"wæÂ¶œ«Jß_¿Ú=§¶_î¯JŠ«‹vMF1åqk˜ä>$~Ê_¶V½â„š×Ãƒß <Â~&Åeâ/Ú3Mñ¼:—‰>1|sð'ǽv ›}Sö]kkÏi~*ð}Çö„³¯ôkû¯øžÇÄñk> Ò¾Õîp·Œ^åÙgà8§ø¿>©ÅÜ3Á\':ùg…øœ‚x\«‚<>â/²ú”ªá<\U¨æ¸¼£;¥ý£˜sbpØì5Ï)Äe2Àg¸Å ©„ÆÊT¥N:~Ê¥j©K§RµzuÝÿÙ,à¥OÝ-âÜd¥x&køÁ_>|=ðŸÅ߈?t ë|¯é~,ø;ö´Õ ¿ñöñ#âw‡>(|Ohq~Ë,¼}Æ_,ψ®Æ‰ ¾» é𯻦X붺Mþ«ö¯ÍüFð“0©Å˜?øˆy¦+…süÛ*Ìò~Î|ŽcC„åÃ\5ஞO_ âÎ]9âòÆÓËa,\keøÚø?–ÕÄàðÒ¡¤0ø¸ªOêéU„eÕ†5EÖö•jª|ØiéR¬\´´¢¤Ò“MÆS鱇Äm6Á´+ÏÙ?Ã>$ð™ðŽðåÿº¹McöMý¢.l4 /öðÃG¡ü4ðÀX[Å?¶$þ!žÙûL¿øJÞ<øao©Áû2é>"Ô-¾%è¿ôý/V¹ñN½âMûž:×ü9¦éšŠuuº0>2xeK˜â1~$fÊY‡g^"ÔYG‚0Ë)ÏÄŒ^Œ—ñeL%Oñ¹f· ãøÓ‹ÁRÊrì²¶?“pö[™â±8\§éÂbšIa••8P÷ñªVçKÚRN8hË÷‘£gÏ)F.u%Þrrò¿‰¾7Ó4o|YÐ|[áø{߈óü^ñWƒ´ÏÛ7ÄV~ пh'Á_ŠRx»Âºü2§g¨übð¼^øcã–øieâ?æêzŒßo"ñVº³üÞ[âo†ùf!ÿñÙŽ/‡øcÀØ|ç1ð8ŒÓÀ˜ü»Š2¬wcëÓñ‡©“ã2Î0Íòú¸Œ> žGK-…,â—öVtµ–'9}[‘T©íœ#Ž´cYJ”•UþÊß:•(É')A7%ÉïI–¼3ðɵ]Gà‡…"ýštëÿêšÓ|aø2Þ&ýªü{á/iþ(ý›>4øëâ/‹5ôk¿Ùš§†uDñ¯íâÅ^ñ ¾›aâ?jðèÚ>…ý—¢ ‹j·¼'V¶u:^0æø:P«€Ìò$áà¬FYŠÂã|YÅÓœ0gpî7(Å·ý¥„Îpõs9âêÖÅV„¡`ê¥öHÉÓ9Á¼jRŒéÕ«YI5…Ž®Uê)^éÆÉF.1qû÷àÛé²ÂoŠþ<øíᛆ£]ñ‰>*x÷Äw‹µOŽW —à ´‡ñ7üIuà?ƒ?tÝ P ü6–ã[x<Þ'×l'×5-W\ñ¿‹§[ÿçÏ8Ã*âü߆ÞGÄ3ÌŸ‡¸f#ø:÷â6±ðžßUwñæ…àŸ üDÔ´VÓõ(Ò/ø·[ñ?‡t-Z-RKEÒn¾Õ¬x;ÄrÙ[_K¨Y(æ½´‚ÞöÊkƎø € ( € ( € ( € ( € ( € ( ÿ×þþ( € ( € ( €>ýŸ>|gøwñÓãgÅ]Kã?<}ð÷âÿˆ¿Ò¼'¦è~$ŠO  x·ãUåЮ[Æ:–gâ™-üsàßxæêòÏP–î/†imn4Ûitm€×ûJü,¿øËðÿAðN“â Ãz¿Æ/€? ½×­§¼†òÛà¿Ç‡Ÿµ ÒÚÖîÊå¯|Ceà t[yÒgO{ÕÔç¶¼ŠÍ­eøƒ\ÿ‚|ZÖ¼qâ¯ÚþÑÚ•ÓkŸ´L¬dÔõêLµñ¼Emð÷[ðü$àkþ=ÇW 4+Å·Óõ;oø[ÁšÖ“¬øG_ðމ€Aû'þÁþ4ý›¼}à bÓâg…¯ü ðß៊~'ƒ´='ÄqYkò]ø·]×¼7â‡Óõê–~ ñlVZì±xÖëÃSÅçìú†þÓáßë¶@[ìû@Ið·àÇÀ½oö…øk£Ù|&ø 'Á¯ Zx;Kø…á­cÄÚN›âÙÃ_Ôüg«µ·-¯no£Ÿá>«¦Fºl'†lüw­¾¥/Ÿ©T–ßðMßV‡û þÑZV«àËÅšU߇õ#ñj;«[]oÀ¿þhN•«Ù|HŠîßG𷆾#ü7Õ,_1kð‘ü-Ó.-5=?ÉÒnì=ƒÄ?±ÇÍWáì¹àK?^¶Ö¾xÞÓÅÞ;ñœš‹Ž¿ñ^÷DøÁàˆVúååèñ„¤kþ=ðQ üP‚Þ¤_ê¿5©¼-‡|g7Ãýpæ=Sþ Uñ®ëázü.›ö’Ð5]Pðþ¥ßx{Ŷ²‹Rø›i'…®¬þè·‹oáßhú$Òhÿl|9ñBÛÊÒáiu/ iBfkûho¢‡Â_°gÇÍ3ã.¡ñ'Æü5ãoë?á?Õ>¾‹ñCðg&ú+Oé°iŸÖâÓÇÞµ³ðÛhrÞϪiO7ˆF°/™t[›@ þ>ÿ‚wÉñGÄ>=¿ÿ„çáÇŽ¾ëßþ4ü{Ñü+â­Ä·rßxëâ×Â~x¿À^,ñWƒ|a¢êvþð­§ü%ZdžõŸ \èþ1ð÷ЇƒÚ_‡M/ˆ€4¾%~Âßþ*ø[öuð®³ûJoâgÀ/ |Gðþ»ñ'T>$o‰züOñ7õ¯xçEÔ¼?âÍSºñÃ7á´Zƒ­xàê ñîÖ_ø«ÍիЙkÿðMOÚ^ð—Ž|{ûHè:†•â ÅÞÑQÒ¾"\ð¾·ðoö·øK§¯‰,n¼y}gªjGþ áçˆ5”µ[M:æ_„:]¥´ 2èÚ––ÍKþ ÅñÅþ ø•ã/ö’ð¶¡wñRÓ'Ó|wk§x²ÿZ¼ÒôŒ?´'Ä¿ÁãD-¾ð¿´é?ì~Åáe¥è2øsáÆ‹y¡]x7ÄÐø_Zð ìܺ……½Ý–Ÿq}gþ¢·-§ÙMs Wwëd‘ÉxÖvÎë=ÒÚG,R\˜QÄ $m.Åe,r€!¸¸·³·žîîxmmma–âææâT‚ÞÞÞifžy¤eŽaZIe‘•#Egv P·¸‚în­fŠæÚæ(î-î-äI ¸‚dY!š£fŽX¥–Hä™YX©€%  Y¼IáÛ{½Nã^Ñ`ÓtûçÓ/õµK¬lµ(ïN“O»»’u·¶¾Pt°{I¤IÖñÖÕ£²¥mP@œu}%uEÐÛTÓ†´Ö_Ú+£›Ûaª6žexúéæ_µ›#9xŽëÁmñ\Ôm,î>(|yø§ñÃü-á‹¿GeáMwFðïŠ4Ox¿Â:~µ ‡‹µ]cSñeÖ¿$žÒ`ñ³þÔ_ ~(xÏÄ?³W޾xkÁ>+×þ|cñWÄËÆþ*»ðu–¡«û:|tøM¤[Yë6^ñ|ðºx¯âg‡uL­„NšªÍhóê1ØÚÎð>©û"ÁA.ìÌZ'ƶð@'Çóÿdxã‹ü; Ç{ã?ˆ_·Œ Ñ·¶øvëPK‹?²ÔM­Î««ùß ¼Fò\Muk¡âp¿ì}û|Zx£Å~>Ò>*èzgФöÖöÉá°aøIû,þÕZ?í7ào‰ß~#ÚüHðŸ>üKø}¡øºûâ&­/-t¿ˆŸ ?fm)l_ÁšO€|'áüAgñ#áįx“ÇúMÞ—ªø¥7øŠÞ#°ðçÁmgÀÚö’ö¾/ð¥•æ©­x¯ãS蟴ÿˆzž¶š÷†ü/|'‚Øé¨÷@]àÙ öÿðg‡,|$hXèžø9ªx?@›Ãß5­{W¹ñó_üWÓõkwÿ~x¦ïT'³ñOÃøuZöÊÿÀÚŸ€ÛÁ¶:½¦y¨jø>¡û~Þ£BñMÖñ;E‹âv½­ø«Nñœ?~-êg†|I¬þÀ÷³íŒÒ(‡ÀWþ'ñïíñãâÁ¯øCV›NÐô]rOø3ã•ö§ñûCÓìîáÐüGðKᤷ·vÞ$k‹€)Øûþ |mãß[ühÑ´?xêëáï‡ ø»Ä·Z¹}r/Œ×¶>ðÇ… ð,Q^ø¯XøãO†¿SâƒÎu_èžÖþ&¨hM#ë@ññkö?ý¯|sðëà—öÅ[{OŒ !ý>/í)¦x£À|á› Éáë;;ÿÙ²ëÄþñ•¨Áu“⸼>Ú~¥tÑ/ŒôÐÁ¿²¿í÷oá]+Á¿¾/ÿÂÆðÅׄ_OñF}ñçÆVÚÅßu/³Î‡¨x›Pñ/ü+Iï|Wðú?‹Þøÿ-ßÂ}I4ÿëzÆ 3U•m–4Öfß„¶Á€ÿ?gýE4_i ¬âøñ]øÅ¬jz_‡I­ü%×|IðWZÑþÞjZtÞ1²Ðuï iþ:ÑlFªš–±â@9»ýš¿oK­sWŽß㮡¦x*ë\ðCÚé‘ülñÿ‰WÀvß¿efûÂ6þ#›ÀÖ÷6'🀾~ÓÔþ #¾­ñbçâî‚úÿöq¶ûO„@>[ñ?ìƒûyü4ð׊>6YëÑøßãÜZnƒiwâ |@ñŒ¼ø…¯|ø§àÍOZÕm¼S§ø;ÃVVþ(ð¤>-‹Z°Õ@=âì©ûjkÿõèt/Š—Oð;EÕ>êž ðÞ¡ûF|`µñ¯ŠÃß³×ÄKéøo'…þ)ø†çÅ>!°øƒñzãDÖoüKâýQþëüg­ü%Ó5Ÿjš~›¨êZׇ~ê^ðæ­5äWSý¿I¸WÕuŒ NìÛè € ( € ( ÿÑþþ( € ( € ( €>Uø«~ÑÆ>´øÓá¿Ii¨ø÷â=¯†5yþ 'ÂÏxBñljæøY¨xWûY_‹z÷¾jž ƒÅ±øßN½—Jñׇ|D,­ôMîÙïÀ8oÛ{Áÿ´‰4¯ƒÚçìáa¬ÞxçÀ-øÁâ¯3K×¼7¤Z[ê?²Gíá?†M®i¾-ÖôŸø«J?|MðÛBÕ­u.¨­µýRÊ ?C¸¿µøãâ7„य़~|løYâûkv»ð§ãî…ðïZðµ×ìßáÏx»ÆŠx†?‡v_¯—\ч…tItWöÞÖþ Ä6>"е+¿]Y[-–¡ªnüP‹þ m⻋>ƒÂÜþÖ§ñ·ƒ­5­Rýœì>ýž5O x_Àkû2i~ ñ¿ÃÈ¿hßß|ZMwVÔtÛûHüy¦þÏ_O‰ôõø[ñv­ã='ÂÃ\Óg°²°ÊÔçÿ‚³i>ølº5¿ˆ ÄzÇ‹"ø“á?Ú×Áº¶³w Ýü ðÿˆ+ðšjÿ°æ›™âx4­båtû…ð¶L· ®=Ñu/ê?´'‡~-üÔ¬|ãü0ðO†5Ÿ\xOá-÷Äÿi^'·ÓF‡5ž¯ý¯ñÅbêkÔñßýRM'áV³¨¶³áËÝcYe瀿à§úœÿ uÏø‹_—Ä:?ö§Ä9~꿼? ÖàÚCöiÑ5ÇðÕˆåƒJ¹¸øáðÁ_~6Ýèzü°øfÏÆ ×[Ó/l“BÕ@:¯Ù·Â_·ÇÂÙÃ‼C x¯[ñ¤|Oƒvsø›àoü%z3k¾0Õíþ0hºw‰.æñ‡õ;À~]3ÄGü,}KUÖ Õö‡£k×S6›Šç^$_ø+¿‰ü¦ønûLñ‡uëø^ñ7‰¼«þͺMô^0Ó¾~Î÷¾3ð‡†ïoõ‹£½ñOÂß´\6×:{ø"ãIñ¿†¬¤×SD’Ëþ`¨|mÿÖ}ð|ðV]Á¾ÒLÚ†©£|<ð6›â;¯ˆ¿5msQû'ïƒöþ9Ôt½cÃ÷ÞF©ñäüR_Ž-á‰|BSàæ£àH¾ÝøšVñEΰó€/ÃßÿÁHü=ñrëÆº–|¶¾?ø™ðcþ+.«ðumµÿ…~»ñ‡ïî[×tïøÛAøuámSÇö~ø{s§xûÄÚWˆ¼9àíw‘Má {ñ^ûþ k«|kñÖ—ðÓIÖüðVOøRÃÂÞ$µ»ýšüGªC¡Xë’EâwÃöž'´‹T´²Öü1¨Gt4¿i^"ÕôýsFtûj÷VZ€?ƒ^ÿ‚‚ë_´/‰ß|)•¬xöhøÃàý5×~Åð~/øÓŸ±ÿ‰|m©i ñÿÄíd|Lð_Ç{j7ñê^Э µ·ð-ÒhšÝž¡ªrZÝ·üjúÓÁ×>Öþ ès]|>ð$ž6Óµ½ö4½¹Ó~%Þé­þ([騛û9|9£xŠËàÍ瀥k‹Ù.4]^_í¿í)íüCknæÿôoø+gÄ}KEÔt¿‡qèWž ×>xãÁi{ãOðišWŽô¯‡ß<;ñîÂmU‚öãAÖÇ‹|4xúÛÇúFâ¨-gÕŽ­áÍ/ZK°ÐÙ’oÛ ÷âÅkÏÚåÓ>$Ëmð¯Ã·ºÃ·ÿcBKëÞ,øã ûËŸ¿†$µ°ø¡¡j~²ðå·-ïî¾ëxDÙÅpöÅP@P@P@P@ÿÒþþ( € ( € ( €?3~ üUý¥5ÿÛ3âüYð?Å? |/ºð·ˆ>x3A±øsãx¾hÚïƒ~:ügÃ4ºñÕÖ¥ávûâÁmÀž/Ô-Ñ| 1¹Õt³k§€z×틨|U³»ø#oáuø¹ÁíCÅŸ!ø÷ª|Òõ_â톑oð{ÇWŸÃÖ¾ÓµoÁ§Þ|L·ðüW×¾°’TÖÃv:ì‘ø?Pñ pšm¿hÿÛÃTø§ü2Ð~ ^xsK_‰V¾¸øãÏ€¿õí*ÇÁ÷_h-Lñ¾¡w¤øçÃ:»0øIៀ.ñ£¦k~ƒeâxŠÒV¶ú'…3öÿ‚‘ÁcàÛ‰þx2çþ¯üdñ5Ô²üøÍ§\èW^ñ÷…ü1ðöÿHÒüEâû«/ø§Âziø›áÍ{ÅRø7Ã~5›Y°ðf‹%”¶§UÔ<—Æß?à¤^3ÐôÈ5øãÁí`ɨGð£à/Ä-PÖ6‹§Yx'ÄZ¦¯¨iÿ< u©ÙÍâ1¹Ò´ßøU~*Ò5;âΙ«ÛÂ8Òk~µœ+«Ü\w±ïÄßÛgPøÃýñ‹Añ¦§ðûâ~i«êšß~ xÿÀ’|<ñ¿‡¿eïÙkP¹}5}rMÃ^ñ7Å-cã&‰{à…Òíã“Æþñ§¤kÐÇq.•@àÿŽÿðSOÚÙøòo…þ3øÉâÍ{öuøAgã/‡^-ø3ãÿh–ÿt„¶O‹¼iyáFµñðׄR‰>ø#ð÷Åë¦i÷úGļsá]GÃwž“QÑP³~ øëö—Ô~þÍ2–èÿõÚ“á4?´/ƒ |töº·ÁI¾2I§x†_xSÆž»ñÿƒôSðŠ4× øû8x¯ágƒ¾+ÏñÁ_iÛ-{þ/·ø¯ñ‰~(xwCøqûCÇðoPø‘£Ýj>øƒ¥x[ãŽ4Ÿ…×^ÿ„åôÛï„Mâ¯[kx‡Dž[€ëZý¤¿nÍïE½›à“kx‡ö–×üÿ¶ƒð#â%ðð—Á_ ütð¿‚5ø“Çp|H¸ûmçˆþx²ÿâ‚üE§x ×ÂšÒø ]¹ŽU[›-På~~Òß·ç‹­<+á߉ÿ®| ž*²Ðîµïøwö~øÀÿðŽÞëß¾x±þŸ /f×4kïøLuoŠºøÁ&¸þðV§áMÇZðòêz¥‘Ô>ÿ‚~x¿öñÀëö›Ðõ«øFø9¡ÚxÄ^ñWƒ¼AãK]_örø3ã?j^%‡ÅZ®±>µâß üRñ?Ä/‡þ*ñ…Åž©­ø>êâMI¾k«zû¦€ ( € ( € ( € ( € ( ÿÓþþ( € ( € üÀøýûdüJøx¿´¥ß†5ÿ‚¸øIñ“Áß¾øk⥮¡ü-?ˆ^!ý<ñÂ+¿Iñ Á:?…tûÝCâ&—o­ø†õfÓ>ü6ð'Žü©ÅâéºXŽ?lŠÞ Ñ~#5¶à¯kÿ mÿ†ÿ³¬VödèV^9ðÄ¿‡_ ¾(ØIc{¬x’=;Bñn›£üYµÑZšþ÷G½¹ð̺ÒèPE¬®‘aú÷ƒ<’x‰Ÿq&Ožãñ¹V-à.,â\>g‚¥W°8ü‹ ^¶3‡Áãq8ì —5,F ê*±tñXw9rc1ÃÓ§8F3r¯J›Œ¹£7f¢ÛIKªo™+k±å)ÿ`·‘uoCðF9~éþø•ñ ÛS—âׄì²ðå߈~kþ3ѵ­Þ3¼ñ¯ƒu+‰­<qâ&Öµÿ Çs¢^Ë6”5kŸ øê×Âß™ý3¼¿$ž+ʱÙ{‡ b©SÁäÜKˆÍ(e¼_—dXìašdT2º¹æ”+g”òÊÀe¹´©ãðð§Œú•Û‡«æûG3ƒŸ³ö2Rýêw5jR¨œcQÏ‘ÝC›Þ”U¾.ZŠî±ûFxæöûÅvž Òü?:ëß´†ÿfß‚oÓu[—×µ D/ÿhoë^V«b·z/ÃÛM ⵎŸceýŸæê¿ o¡¸¾¸ÿ„‚Ímþwááðù=l÷™Óyw…Ù§Š|{õlV’˰¹¼ÞÃ>Àó`ñÇĵ³Äbqþ±Éƒã<éФòÚî®’ÄÔn¢¦£ïbc…¡xËÞpWÄÔ–ªñ§j©(òëI¦Ýîp> ÿ‚†xÅWÚ^¿ªÙèþøi¯|ñÿÇjþ%ñ§€ÓQÖ4oÞü4–:µÌ^1ŽÏÀ¾$’ÏÇsZê¾ ñ‹jZv©at/5{tæMKèóߣGäø|^]ƒ¯Žâ*˼Há¿ó<U‘ñ Âà±ÙÖŠlF ”²)×â ®5øvpyöY‰ú®' ˆ¥ì0X‰âTð¹Ã2„ß3Q…'‡©^U)óIAÒ²mTq§+T³§%&𸢑çöŸðU‡·%¶øMã[»XRµÕg´ñƒâÓZ´ñÿíðÒÒÊËF¼Ôì|A«i·^&ýõ¹ïµ¨4˜£Ð<=â]\×-,£³Ö-ì>’·Ðû‰h9B¯dTkTxJØ:u²ÌñS¯€¯Ã~ñUjõñÔ0uòì*–SâfžW)æYžUŽËòúµå[SŸö´,Ÿ±µ½§ ¦§^ r¾Y4åA·$½ÈÉ9%gÍ«¥ÁM¼­.i}ðgǰz×^k{]cÁ~%ƒ[O x/áÅ¿éúLJõ}JË\Ô|=ð'ãŸÄÍSO‚ey?á øá 6º×´ã¿âÇ}sÌ$q“¥Ç7Zž¦ž*UðîY,ÍóÞ6ଟ™RÌð8jØ &iâWá,."¬%ý½Ã™Õc—f3––iËûŠžò“V9_’«O—•Êî8zÊ«_Ü©y$£Èøþ ðgá‡Ão hþý™¼kðß᥇ŸüJøá Øx#OÒ/~ü3Ñu?üMÔü¡èºŒ62Cào Üx[UÕlç]&]O[ñæ“¥Øˉg¾—I}3Ùfœ¯ Çü!ŠÆà¸§%à¼Æ>Ï8¡K)â^)ÌpÙ/ åù­Z¸/öoõ‡9YÖ V„qpÃ`øÅû(òáÅý«U'BªŒ©Î¬_¹ïS§N¬£ªOÙÁE»¸ÝÍ%Íf{ïÃÛ·Ã~&ÇðÚjÒ,ü[wãïêþ8ðxCÂKá?ß|;itýEuµ—Æv:ï‹O‡´­PðìÃ=Ö½-زÕ4kÝ=¾CŠ>9§ p¤¸¦|I†Ì~»_&£Ã™ ‡øŽYÖróœƒÄÊœ3ÀÊ9#/É¿´ñ™†3œjS£—GE×Áã°øˆëK1Z¾ÏÙ¸ÙMÔ›©OÙÃ’£§£ÓÚ)IÁEÂé¹4õ‹‰çöðS_‡—–žÔãøsâwÒüsáïøÓ@žßÅ>½¼“Â|IáøæóJ³×¦¾¶ñ<^,ñM½ŸÄ$wßà O¾ñ¿çØ6ž·ÿG_è£ÄÔ+gxIq>S_æyöE™S«”q θS*Íóî ¥G[OS)žM”U¯Âùô¥ ã±8|³.t± ðùÿjÁ¨¿e+N0œmR“|•eSm'~~yZ¥4”©E9KGfü<ÿ‚šxÆÚ_‰umWá_Œ¼m ü ñwÅË?íx]“]ƒÂ¾ý¾%Gá]>ßÃ> Õ.‡ˆ5ß þÔ¿ ,ôxÞ&ãÅšï‡ÐÉ&§Ýë5ÄßE È1yVÅù{W0ãl—‚ëý[+âº9uL߈üMáYgš¹®[†¢òÜ»4ðŒë㦪Æt²Š~fÒ†+Céæœe)RœhΪ¼á.nJxzŠ Ïâ”q4Tt^û”ui)gëðQ{¯…ÚÅÇÃ_Š?µ]_⇆ux Ä÷>ñ/ƒ-|/©üT×ôOÙ—TÖ4í&Ï]ñ)Ö<9áKYi¿Ûé> ñD‘Z_Üø{VÓ~Ô×—zê½8£-ÁSâ®ãL „³l6}ÄYM<ÿ*ÏkfØNËqþ+á08œel»+úŽiœÕ§á>gW–å U°ô³,)ÓThcã‚SÌìêÑn¬\!/g(ò:Íaœ¢¹¤œ ž"<²—2|¼¼í»–nYCW*‰òK›–7ŽîéûÝÇÛwÇÿ |]eªxgÂñÃ?øçÃ_ ¼ie&»¤Zjúçn¿fŸŸ´oŽto xëUñ6àûtðw‡ü/ðš ë»;¸5íCÄ~'Ñ”[^ZÚËkåð€|7Å9-|kgoæ|?šñNC^9~6¶ /Èix«À>pþ;9áìWÎêK;̳n3©ˆÃѯF¦]†Ë2Œ{öôkV…Z¯©N\ЄeJ!J¢æåQákâjFŒ³ŒhÙµi9J>ë³9}wþ ‰kacmã /à?ˆ%øcöÏö·>(ñ'Äøc\º—à‡Â­sâÆ·§i–kû¤ñ ö‰¥ÚÛE¡xŽÿ÷P^^]!3&—w"úùwÑ"¶#W$Åø‰–Ë=‡V¥”å|7žæÙ}ñÿeü€Äãs˜CIå¸|~2µYæf2£R… RQ§,]óe¤Ö^ÊõÓœêBn…)UiCÞ|Î).Y[Võ÷[9ÿÁF¼oªø÷ÁÚW‚|áïøcEñO†4Ÿ‹VÞ0¸°ñ‰å“Pý®~þͺ¿‡ü-„|Skg²xÇòøÏEסþÞgÖNÐ.´& tóúYOу ÁðîwŒÏ³¼Ë<ͱù>kàʹ%ß|qÒ›Mñ‡€®þÏð¦ßÀ)ø€šþ¬ö:Åì:6¯§YøJóCñw†õI­.ü1â [ÖËu«Yê­{h©}s¯¬çXLgä¹}l‹‹èxŒX¬“ˆ¨û^1©Ä™G <»«à¨ÔÇ`±Uóš†Kš`éÖ£›e¸<Ò«¥‚¯‚XzéæÐ÷-Frç¤ëÆÓ¦ÿr©Ê§4­~Y%ÂN.kY&äzOÂø(ƒþ-|Ið?Âøþx§ÂzïŒu¯øv[ÍkZð¾££iÚ÷…|9¨xÎ ßRðÞ£¬Zßkº¿ƒì×Ä–úeÓèï6œºËhâðŸŠ×Eùn5ú7g|ÂÜAŲâ|£9ËòLG™Â†›a±Ø¬»7Í0ÙLƦ5Ã`kaòüw]åuqtaŒ1/±ñËcœäï¥ÆªÓ¥ì¥RU"Ûœ%(EÎÉÅêÜW5šŽ—åsåœcú_ÍǤP@P@P@P@P@ÿÔþþ( € ( € òKÏ€ÿ5?ø¿Åz¿Ãÿ뚯o|=ªø¶-~ÌkÚ.³®øWDO è^$—ÃzÃ^ø~ÛÄö~†ÓÃâK-2Û[½ÐtÝ'H¿¾¹°ÒtØ-À9}öuðÝφõÀ¾(ñG›Ï|H¸ø©âŸxkOøãoø“Å×z|z\÷º¤ß< ñcJ;l,ôK :{=*ÒÿBÒ|9 è:î— Ø -¾³ƒø¢ æXŒÂ¿eÒTí%.hFŒÕí¥jUb·½ÒRìõhð~Á©ñÁž'ø}âßÚwã­ï…*|&ð_íaûB'Š>ØhñLW ?aµ²Ã~&ñt*ÓGÔ¬?e›õ“Gºñ/ß%æ‡{ýŸ{ íÔï´T‡V°½¿òjøÙ—W©V¥_ør¯þÑ«~+ñêÓÇû8ÑXÙGþ#:O0…b]ëF„!F28Fµ‚klU}#Ëü<ÿ/û›v¾¶Úúêۉ埴ì÷ñSö^ð×Áü%øÝñ“ÆVž ñžð«D›Åþ'ý›|+/‚õ/Úcã/ÂÏ…k«iñ[þÅž>›Å:®½âO6½âßk-»i¥i¾ †ÎþöóÅ÷ñOëfŸHzyÌxŠƒ^W‡brlNc¼^ì{áê5¨d˜{PñR+ —å´«òa²Ì"¡—Áað-á›Ëð?UˆåêÏ—Š^ÉMSÿu|ª£No\#÷¦Ö³|òwoKÉ6Ÿñsᔉ¡øö‘ý¨tÿÛüF¶øOâit??±¶£ðöÛã±âoøWÇ~Ò¾,럱÷…|/¨3âßxJòû\›ÃZç¼EiáÙt?ëž/ð´Z§ükËÜcá¸ÆzQ‹âß9cK KØa)(ÿÄi²§„ Ý,PÃÑ“¥EBH¿©=þµ_vÿ…€ÞNòÿ˜DîÞ­ÛW«±Íüð¿ÂŸÚ;ÅVÇßkß|]øãû.êI§h3ð_ìWà›KŸƒ6ZÿÄ×MÑ5/ þÏŽŸ`º†¹âÇâü/Óu B³ñ6‡Ž.´©µ/é÷_O†úMã°ÙnQ”GŸ êà2>+|m£‹Íügƹq+†KMcñõqž.â+f´éDzc€Í*c2êÁóÑÂÒ|LëæòØ·9/ÆŠ£N¼¹ðøhSŽ £NZT!NÃ*p„!‹ÄÆ4ÒPJ?u%mÔïv·–®_i+{ß@éß¾i¾:×î¼3ûMþÛŸô‹[á'€ü)ÂÏÙVÓÂ^.ÖfñÞ·¤x¯Ã¿ tOøf»?Ù ïxOûOâŠ?²|%}âGÐïu‹íE4K{?¯ãæ“<‡àÇ…ØœLÖŽu‰©[3ñ’¦iŽÌp˜9`2ú¹Žw?çœf4²¬%lM,ŸÇâ0YW×1ÓËðøj˜ÜUJ©`\d§^%IEÂ6Ž–1“N\°XW¹4¹Üc;%&ÒN0ü2ý¥>뿾ø—ÄŸµ?í/à«¿ø#ᬚÔZgÁÏØºãÀÞ½ñ6£û=7|7‰¦ý“4¸ÓÂüsûKü(oj—º~—¥YˬÜx‹M‡P¸ðÿˆŸHó*xÍ•V”êVðwÃúÕ*×–*­JÜUãÅZ•qSÃýRxª“ŸŒ®U1SÂ7„ž"OÛK ÞSt_²)`ä´X¬B²²µ<×½­õ$­z×·7½«=á—ů„_¼Cð§CðGíYûX´¿µÍ~ßÀZΫðö*ð¶/Н<%á|CÒŽ£¯~Ë:T–¾=Óì¼_m¥|Cð…¬Sxøêz_‹âÕ4 Ý;Â~$ÔtÒ^3eSSSðwÃùª”pXj‘Ÿxó(ÔÃe­<»R/Æv§C.qOB\Ôðm'†T\S©¿ú ¯»ÃÀhåñ5þÇkËí4ï-šêx‹|iâßZX®“®~Ñþ3Ðu]Sã‹þÁàþÊ—^0týŠkσÿ¾"x“Ç~ð?ì+'І—á½fëÂÿô?x?ˆºßŠ<#ð×þéü3sâ›mHO/ñþ9]lN# á/‡¾×—æÙeybx‹Çjx<ï™å™”iÃã**øŒuœQúÝ5])f˜êØjô+bkÎs,2IâqR„—,0QÖŒ£w&©8Eò½*Oh >(ð÷Ã?‰:‰¼EûCüyÖ¼9ûW| ø?ûCøßãÃÍöTø¿á«øÇÄÿ þü;±7þ&ý´IWáî§{oð³FðN³g¢èA5Õ±×µŸèo]²Óô‚¥˜åœ3“b<ðÖge˜ÌŸ‡px<ëÆœ¾–]Ìs,ã7ÇÅ}CÅÜ4ñ5ñ˜î Î%ˆÆbªUÅUÃãj`eUàcK HX J¤Ö+ÍVQ•Fビ“Œcߛբ¡%Ê“\ÖRiø›ñSÂþ(‡~ ðwíûJxÏQ¹ñßÂo[Ýø«ÁŸ²§'þÚÔ¯ÿcH|1âkæÒ?dkäñ-ÿ†þ~Ý^ñ~…ŠïÛKñ“ý™odo´ùµ ›.ñß”áqØ<¿ÁÏ ha³ ›ÃÕèK;ñ«NžKšâ0øœÓ/ÁGâõe–Ñ̪aiG,º8J¸ª.­ ³õá7, ›NX¼Kqœj'˃^üSŒ%+`Ó›Š~ï3Ñê¢ìO‡ÿ2Ñüc'íñOÅ¥Ë9¸ÑµŸ‡¿²~e¬[\ÀÐMc¨ëýšüã8-%Ä2Ê4_i3Ìö¶ñÍ4–ÊðKù¯ø­ƒÏ²?f?þÇ?>.|M›áÏÂü<ý¡<ãÿŒ–ž*µ_¦•âRüiø³ð·^ø¢x‰4‹3ĺ'ˆü]uãRþMÿQ›ÃÚ—Ä FÏÄñiºçˆîSPúãLjþE¬üøañÀ ãý?ã_Æ?Âþ†ê *ëGð×~ø#Ç´/†¼[«ÛjWPJ°n> M{¡]ép^ê:‹#ðýä0B‘=õ ÇïÇø&•…ö­©üBÐ|áßë~6ñw5» ß…ž'×ßRñ?‚|kñ»Â—¾-Õ¿á𦳢K«ëÏÀ/‹úÔšmôŸÛ:•ï„õÛýcL“\‚á˜Ïþ?ÿÁ<>|Q×£ð÷„¼-ðïÄþƒÆsÛøãGøu?…á±Õ|}á? ê_ؾ%ðæ‘¨i:Fµñ Çü=¥è:¹²ñ‹›YÒ­4Û;Ë][E·»ÝðÇÅoØWâÄï ü#øcðãá¿Ä'â¿Á?Ú7YÖÜëŸü7¢øãþñgÂm_Þ"º_ÚÂýÓlõ¼AáÛXt¿jV<¿ ðü—Ñø‹VЬ¦ñÖm¨xjeÖn8ÿ |oÿ‚O\x;Ñ¢üð7†þ"| ¨x[ÇŸ .|%s}ðwAÑo­í´{Ãzï…âŽóæŸLÒ'ˆËâÏü*°»Ó ÕôïXK¦€u?´oüÿEñž"¸ð=‡Wá?Äoˆ®£ã]sà§Š¼¤øKźÇÁmKöÇñÿ´èõŸ é—æ»{áMsRñŸˆo46ÿÆV:k7–VñÉu©ÜušoŒ¿à>;ñ·…ô½áÖ©ã¿,¼²—M·ø_â?Ä·ôüIÖïàñŸð‰ÙÝxÄÇâìùñKÄ·#Ä’x_RÖ¼Uð»Ä¾&“íÚž‰=ýcxŸã×ü/I½ðgˆ»±_†¾üqâM#ÅZzOà2ïáwˆµ­+X†óÁ—·:h5ðwþáâ=]>iÿ¾xÇšÅÏxHø}ù¯emoÁÿüiðëAñF¨h~“COˆ®ÿaXµû áwxoOøAá O¾“sáïÆÀ¾—ñ[þ ƒà_üC±|øះoðÃÆ–¿WÁ_ÙÞ ñ‹.üKñëȃ¶öÞ…¥¤K¬Þøá÷‰üq§xrŸøI®¼¦^øtQ¤Y^]@«ãßÛëà€-þø—QÖoî¾üNÖþ4xsQø‡‰âHm¾ktÝvóǶþ=ð¬úñ‡‡áðõß…¼Q¦xªçTÑl"ð\šíÿŠ?³tˆn/í@;x¿lÿÙ¶kç±_ˆ7ŠÉñ2ƒŸo›À_mô>&[xÞo†“xJßÄ—‹Ã×7ËñðbÏo©Í§ÉâI-´˜ïd¼»´ŠpVÛöúý˜µÿMã|@oË>™}¨hÒ<+ã»}{[H<à/Ùß>•yáEÕ4? _ø{â·Ã Cþµ§ÙøÊËÇÞ»¼×cŠþ3@‡ð+ö¡øYñÿà´ü¨ßÅáÛ= NÕÃO@–>žc  Þý¸þ ë?ü_ñ/Å·zÏà x_ãGÄï‚Ö¿ð”xÄ«®x‡Vø]a­øƒYÕì<%o¡ZY/ƒ<7âj6º‡ínü=á­\Ö5‘m¤é—Z¸ý¾?d+Iü]osñ»ÃÐIà›¨ìµ¶“IñZÁqw/ˆ,¼.¶Þ¹>û7Ž&Þ¥¥ÚÉ‚¥ñE«¥ê2ìÓµ+»€ÏÄŸµ·ìëá84{½kâ~”¶ï‚<5ñNÕ4½3Ä^!Ñÿáñ´ÌÞñ ö±áíTÓ4‹??‡µ«G«]Ù]xçYӧм'³¬ì°`*ñü[öNð¦‰ãmN/ˆ—~$Õ<ð÷Ço¼- x?Ærk—Ö_ü+ñ#Åúÿ†ì›PÐ,4˜,ñ6›¥i7 ¥x;áÿˆ¥ñÀñ‰}gse¥G=•êÛ€z“ûnþ˺ß<7ðïOø©jÞ5ñ^ªš•áëÏ xçK½·×åÖõßA ø‰µ? YÛøC]¹×|9ªiVš7‹gÑ5+»ÏìÈí­eþÜÐΠõ]P@P@P@ÿÖþþ( € ( € ( €>CøiðgöR´øËã¿ü0Ö´íKã‚üO­ë?Ò¼?ñ“ĺþ¯àMSâ·ˆ|eãÍ{Dñƒ`ñ•ìðÿüaâ/øÚçÁÚ¦‘gáÍkĶ6ZÜ:CÞx?A›EÎý²àq°ø5iñŸÃßüC{¨üEñuŸÂÈ> _ø÷Oñ…¯Œ¿áB|c¹ñeÅ´ßüEáÍxù¿­¾,Ù,QÜ]Oqö§´Ñm$ñ-΋@?è¿à˜>%ð|ž#Ò¼{àWð­ŸÃß|MÕ.¯¿héè_~+ÿÂäñŸ…|_â»MgÇö:¿†to¯íiñWQÑï¼Mm¦½Ôí- ÀÓ|/o¥€o\~ÎßðMÇ´ñÛIâ¿AtÝ Äïáý¤|Ak'ôïë_ ¼gàOøÂþ‰Ÿ @¾%øCðÿÅßu­j[XtýcA“WðÅÄrjºÛ߀hé_ðíï„^ ‹ö Ò¾0ü+Ò®¥ø[ñ╟‹­ÿh{ïxkÄ ´ÏxGÃ>'èþ_k^ñ]œžø!àûOx×FÐõ;Ûù~Áuy¨M«Á©Ïp‡à/þ §ð3SðÄ |@øoáMÃ_ ¼ñ#À?|Sñòê÷álÔ|1âƒß|_§ø‹ÆŸ¯|){{Ãh%ïÐþèšN«ã _ xÆêÎ}@ðï‹,ô IWÂwv‘ZdüAøKÿÅøáÏø"òïFºÐ~)üMðÏÀ/xÀ¿$|aÖ¼Yá½C_»ñn£¢é64ø“ñÃV¿ñ¾§hn|'%ž™káÝcÁš,·¶ò€vÿà—¿ð‰ê÷Þ4×|ðÊÊ[xoâǽ_á·ˆ~ø+ãwÃÿŠ~Ÿà?èz¿ÄM2÷áv‰©xOãŸÅ³áß]diz5ïüC©xZÖÚõl¯mÀ+|ñ§ür?Œ©ñ×ÀµÇìᮿ†í?h_ ø/G—ã‚æÕ|7âo|Lñ'ÅÚƒ]¿× ýŸÿàš¾,ñÖ™ |;ñ—ÃÏüDÔltO‹>ðÏ‚ÿi}{VñF™á+fø‡âý+ÄŸ¼9£|J¸Ô|?ðÚóNý¨|s·Â6V> ¾ðßÅÄ·1M¥^øym@#ð4ðK¿‹K¦|Tøiñ3à~­.§ñ;âßícâÏ|qmQ»ñ¦›¦Ã |sñ+µ§Œì/£ðÌ:f€ñ#ÃÒÂáKy­(Í^3ð/üƒâ¯‡~&|øQûA|,мis ø“Hñм1ñ±¼mÂûwáüwsñoÄ:v«ñ- íöüiñKѾ'ÜË+è>Öï¼5o¯ØÚèFÃHú¿TðGü{â„þø óâwÁÿh~?ñ/Æ Ï…0i¿´jµÿƯ|aÔ|eáߎÖzf­¥|BMOãÿumcÇZŽtawâ4žþMkKû%­Æ—ö{ i×ÿaÿÙ³Äòø:}gÁZ½Ìžø…ã?Š~ò~ |B²Gñ×¾.è¿!|H¾Ó/áÖãøÕ »´¹ñd±É¢j?Žò]E…C/n$Œ#h~þÆì¥ý‰¿g{Mðî÷Âþ&Ô´Ÿˆ>*ø§q}©üNø™¨øºoøóÂ߀ i'ÃZ½÷‹<1ãfÔ|"šw‰í£ð­Í¦¿àíôã ­’iú]­×‡­TÕ4Û Cñßìð/âF¥}ªø³ÂÚ½åέà |4Ö¢±ñ×4K{žÖõO|=^Ó´oØXëZ×ÃÏkšßˆ< âJÞëľÖµkÝSGÕmoš9ÐÎuø'·ì¥ªZkvW¾Ö¤ƒÄ¶ší§ˆ|¿‰? ›[øOã?‚¼S©jwþ-Š{­oĺí ñ—û{[yµ5M[ÇZŽ¿svú妕§€y¯àš¿ ?Ôt_Ù>‘.›¢ÚÅÃûÏß\Ý_Êéº/üóö[Ð4¯i ñSÛxÏÃÇ„|Iq¨üYø±«jz–‘¯ë~ñ¬_WÔüku©Å¨ÞkžðÍûêÝG|¿`–Í&]:ÿP³ºÏ·ÿ‚qþÇÖÚð²|-½“­ ¤^¹ø‡ñ*óÃúŠYxgâ?‚¡:¦“wâùm59›Áÿ;øðjÇà¿ÅèOÅŸkš‡‰õ߈ßõÏÏàoYü`¸ð¯Åо<ñþ€¾*ñµ¿ˆ¥ñ¿á/xÿÅß4ßÝxzÎÂ=*ãû)Õ4ÝOTÕÀ5iÿXxßSø©¾ø)⟇ð_üMã×xŽ« ’øUoµ}2ãA¶Õ‘À>ðßüOáRøCÃ1|,øùâSà}#Nðv³ð“T‚ÚÏÄk¨i6Z§ì­â=øck ÃàçÔ´?éú%¶¡¤\_iðø³Æ^$ÖõkŸé—šnŸ¬h‘øFðÝÞ¿ÿóx³]ñ^¹¯€yv™ÿÃøSñ/CÔuÿ ü}]Wáïí~*^i7_ü5á‘¢iö¯ÿmx´›‡zέêZf‘àßi¿¶¿4cÖ°^ÙxªçÁÞ™æÐ!ºñ›ª{Ä_ػ¿´'Ž4Kßüfð‡Šµÿ„¾ýž~üMð”>Ðõ½2ó^ø=ñKøý¦xjëÅ÷³xe|ii¨éÁá½UµÓôFËY³½Ô’îp9Ð?à•àÀ—¿·4M&ëÀwËâ)¾èðŸËmáïهó'‰|?¦øÒOÝɧø/Å:„<1âí+Ã_Ù÷–ž×´Ô†âéÐiéÿ‚fè_'Óµ­ü?ðÇ„ô}àωŸ¼Oá3Â:Ž¡ã‰#ø{âOø—áf‹áÝCXŠóVÔüHÔ¾øóRÖ|d©ã ;Cö]_|4Òu«ï¼á›?hÃOñ[éÎÚPºOÿÄðØÕµ½h|DðÃÝÙh_¼=ð‚ï[øà]ü#i Oöƒ¹¹Ñäñ§eq}¦\ø‡Zøwiw¢iÞÔŸÂ÷–Sé×ú>»aü ÿ³ßü§áßì×ñËà߉äøã£ø‡â'†tJ_hÚ¯ƒ#Ó~9éü }ðÛÄ¿|tú>±¨ø~ËI“Ä?´rhš¾©ü=ø·á‹ Í[Mпhÿˆ¾ ñv¡û^¶öZv«áÛŸ‡Úå­ä“€\ñOüͼâ? ø›ö™”h~-·ñޱ®x«áÏ…¢ÔïüoñOöDñìA¨j×:§‰4*îoiþ.мMe¤M¦6«­øæÚkmOZÖî¼Q5Ä’~Ã>,ýž?i|x°ñ‡Á­?öyøsâ_üGñ-Ç‹à½øu¤ø xûöŸñˆ›I‡Hñ5¶‰áؼ ¤~Ðú¦‰àǸƒTðljF¹â+¯ØèRèÞ½pÚÚ(ÄÞ'ðç‚ô _Å~/×´ øc@±ŸS×|Eâ JÓGÑ4m6ÙwÜꮩ,Z}•º|óÝÝM /#ª‚hr€ ( € ( € ( € ( € ( €?ÿÐþþ( € ( € ( €?9þ þÊ_þ~Õ>øï¯|Cð?Ž4_[x¯ÂºÎ¬Þ;¸ñÔ¾Ô~/üUø±à»ÒóR¹ðÆ•}à-7Ç>øW¤Øé1C¢?„<ý¤Öé}ªZiº´~Ôÿ<[ñ¤|!Öü ­øgIñ?Â_øçÄv¶ž/·ÔäÐu›/ˆ?¾.| Ôíç¹Ñ„š•Ö‘mñSþ{3E©I¡6…;éÑêßÛh¯ÿàý¡´Ùì´O þÔž!Ò>éOð§EO éž+ñŸ‡õ½KÃ_þx¯á\“éž%Óáº>M>ïPðwÄ¿ x*ÃNñF§xÿÂ÷÷šwм?§ke—†=rïö ø­­ü0ø‘àÏüNÒ¼a¨ë¿µÂ¿Ú3Á âoǺ´zf…ðóâ‚þ"j>×üUÞ­\YjË¡kšg†äµÒ%¼ð†™¨hº.£«xÖß@´ÔÂüÿÒý¢¼ øgÂZgí/¨xÁšwŠ<-â/øSÁ5ø—áØu=F-âF›âhz½ÜšÝÇ…µK=CÄ~ñ‡´-ÊÏ@Ôoü-/öÒo—KÕí=·âïì_û@xÇã·‹>$xã…|á|wøAñkUÓ­¤ñÞ›âÉ´†šìõáÍWÃs^èš”忊ô…ü3¨[]iÒ¹Ò> Y˜õkk?xÅ`-à/ø&·í àÙø&Ú/S²Ñ|;ðÀ|¥øâ'Ä?é¾ð¦› kº’é×zWŒ-µ _G¦Âɼ[X°Ò|o©ê½ðÿм±ÜÑ´ø'§ÄkÙûãßÁÝGâƒo|IñŸãìãñjéÇâ“'Û>Íð Qñݤ–wÞ!ñ¥¡Üj:·ÂO\x'Qѵéï,Sĺ[êóµÎŽeœ†Ôÿà˜_5›ýWEºø—àø|â‰~3éúÞ³q‹ÛE»ím¿àž?t?„cÞø‘¤iŸ®~-üfø“¤|T“Ä?¼¿ƒüeñƒÄÕ¾è—6ö7QxfÃâ¥Úx«á‡Œa½øyãÍJ}v{¤ÓU{—ì¿iOØâ§Ç?Œº‡Ä ?‰zT~ŽšÎ›ðçÅZç.´K­àïÆ?…_ZKKm çL_Gâ/ÁÞ0ðþ¹6™qâ[ ^ë]ðÆ·‡t cB×µ/|ýÿÚý©|Kâùü_âÚG@]cþojþÕü9«üaÓ/~\øãJøC¦Üø¯À"_Mzú–ðš/Åà¿ëzŸ†µmWÄ[x‹SÕ¾Áq©k€÷û/~ÿ¾ üIÓøc_ñG‡ü/£]x‡WñUÆ­£ÿÂ.m³üA£jM®ZxÁu»ÝCNÖtŸ%Üv¶7V1i×–à'‚?àžŸ´/…¿³›ÄŸµˆ~$Åákà6£àí7ÄÚ¯­¬ô¤øGñÇáÞ¥®Íy$^%¿:ÇŒÿf߃| «[_ÛÞÚêuï‹ÿu7qñîÊ&×ÿà˜Ÿµ·ð§Ä_ /¿iÄšŠ|!y¡k¾ñ—о6ëþÔüU¬|'×< wñââïÄóëÚ:»ÿæµ¢xPÉ/„¯c:Î¥c«§iìZŸüëö‰ñx‘uÚ÷ÆÚ%Þ±ã‹kí¯ xƒÇðjwþ ñ­ûFiuvüKo§ø_â^¹ð—㿆|à˯Û7‡| ‿ |Tð_Ä/üsÿ…‡¿ÁýkÃ߬/õ?Í¥øÏâ׉õ}_Ä:ÏŒ<áCS¸²øm¤ÇªkÚ†œ–vz¶»¦ê³ðÆ—/…týkÂúo‰¨ç-wþ ›ñËSøm¥ø ?h­^ñ'ý’—à5¿ˆµjß/~üHð/Ž~'jÖ^ »ñ¥âï üS>8ðæ±â? ê:–Œ4 Oá—…u .FðÀú@KãØ7ö¸Õ4¯{ö«¹_ñ_ÆCâ^(×üKñI´ßYx»Çž3ð$~Ðô[½/Gð®»áø¼Y¢ü>×­"‹^ÓüKáx^âÇPðÁѬ´%ê>þÃ?´g‡>%|<ñ_‰?i_êÞ ð¿ÄÿøëTðMüoüÑjú×ÂèÒj~,¹³3xþ[sàoø÷G×´ n>øöMXñ‰õ¨—¥øM|;‡üq>‡áoø3ÃÚ÷‰|/4Þ?—Âú•lj¬;ªp$iæ1ËVy‚«ˆöXÛУ51’Æ`«Ò¡,/×b§:ÞÕÕê•èâ*R£Y}QVЧ.XqD§„–-åx˜SU0Ö©RU#‡X|M:µ&u¾­xÆ›¦©Õä¥RŒ'R—ûC„œãÉø)wÅ«-gÄç>èÞðÃïÚöÇøw—à}Fñ@øàÿÙ«ötø‘ñŠ]_UÕSí^Õü)¤I¿ ¥Í޹u©Áé–ZU­ë\t©¸J•<6.­lF+)áü[ž&•J?RÄg¾/æ§N±¯NÕê^V§J0w«:’‡.?ë-TœëP…:T1Ù½Z3…O¬Ò˰ñ*3œµ¥+½¦¹j9iÆ/›CÄ?ðX6ðφ¯?µ?eßÛüPÿ„“Ãú~‡ðÎ?ˆÚ&¯'ˆôü·ý <s¦ë¾ð߈§›Æ^*ðýÝŸ…tßZxröÖ/^Zi·Þ+¶°¸‡Tx¥áÿµ­L^Ê´ªc>§RŸ±«†Ìå•âTéV­E,= ±•iâ%Z2–2œh9G–US‹}7Í–ÔXžz|˜¬B|ôë`Ö6‹S§F£öÕi¸ÓÂiU’Œª¤ùãíß¶gí=ñïàSþÏ^8†ÃOøað/Tµ‡Sý¥ülžƒãn¿ð—WÕµ?i¾мEá[_|>Öm~_ßë&Ñ/ðÃ-'öhñ¯…¼}¨xkÇ8ø‘kã¯Eà[/|;ðŸÄ{?†6^=ðd^=ð¯†|CñJÏÄš­òkz•/†<w>o,WßdÕ§°Ó/xñ\#CCŒ©œáëaa[†Á¼5Šž+[ Þ)âTå%8ÁƒåV~ý‡¾ÿÁD¿i¯xƒÃ^,ñ6¯q£ü$ƒÁŸðMëv—Nð÷Ãký[Åš÷íqã»x¼Oâ_hƒLއs©hvzîk¦øWÄ+¦ø^ÏJ¹¼¶Óuk[Ò.4ߤÆð–K‡£Zjxé×â÷*ØÈÂ…<‹ /aF•OiÉR4êºUe:ôyëJ§+:t§ø¸lÿ2«RZ³pÂÆ eËO )UžgZ>Ò¤à©óBS§°Q¥>ZQùgRpqúÅ_ðUÙ|'û;øcöÔ~C†¾!i~$øð×Âr|gЯ¼}ã/ƒ>ð­ÇŒ5_Å០x?Å7º?ˆltˆMgìpøgÃ-skÿ ?Äm$3ìñhp*¯šÖÊaš·W :8\mu—U† ˜W¬¨C í«âhÆ­)Mþîµ;Ö­ÊýŽVJ^^(t°4±ÒÀ% ê¥\='Œ§*Õ°”麳­ìéR©(N1^ý9GÙÓºu1»QÌ¿ÿ‚‹|N_ø¦øÃÀ_ |ûfø àΕâO _é^2ñ~x“öaÕ~?ÞZø§Ã:Šã@ÔåÒWK×WXðÝÏÚ"7ö~µÓî¯toZÔ4‡àž±ÄÏŽÄpö/:5£<=62ŽqO+Œ¨Ö†•`ª9ÒöuT“ä–!ÍF¬)Ò™ñ%U¨êQ -,Ú†5)Ê5ªUÃTÀTƸԦÚp›‚…Nx5nuEFR„æ]Ò?ૺƱ‚tkoÙg_ˆ_›öuÖ>xBŒ¸°ñ7j|U×~x‹Ä¾-‡L};Á:Í«|)Õ`ñ„î­u[*×QµÔ4]OÄ«[ËàjPxŠ;¦°˜›Cˆy~%J†'%«‚¥£FƒŸ>&›úì] ñ”Tå B¤(ߘ¨ñ=I*0YdÝ|T°2ÂRXÊ.5(æ4ñ3ÃÔ©W—–Œ¯‡j¥)FN*JPö›Åû<ÁEôŸÚâ7ÁoÇð]øs¤ülø<Ÿü)âoø‰m“Ä^!°ƒ^“ÆþǧøvóÃÞ;Ô¾IáùÏ‹|[¡kÖºm퇈,ü#{áöºÔ­|üÛ„g•`óKÌ)c*eÙ‡ÔëÐÃQrthÍÒú¾+åV50±Å*«Ø¯aV‹œeJX•YBêÀqqøŒ%…bð¿X§VµK)Ô‚Ÿ¶£A*rwAÂÕ[©Fj2EFPrœ~a°ÿ‚£|LøeãÚþ ꟴ |qý±t…^ ðgŠ<¥j×Þý˜tíÇ^!ð=ç‚ ±mbáÆµ­éþ.ÔäžãÄúÖŸ‡äµµ]3VŸÚŸ`±˜|¦¶0† ¥|³‡êã¨â(b*B5³©UÃRÄÇê*v­:RÃÆ*4)ÉÖS’ŒéÇÍâpÕ±ô±8IbaO›SÂÔ¥VŒ$éeÑ…j”eIC™{,3EZ\Τ’§kÉN_Sx›ö²ñ‡ÆØßöƒý¤ÿf_Fð-‡Â›¿ŒÚ§Ãx·ÃQ|IðÏÆ_|ÑõIõMFÑí5ÿI¥h4ñ&‰­øwFÕdÔï®l­´wÖ…ê_Ak‰G"ÃåÜC”äùÄ*b¥Ž] f…gƒ­—b3:°Œ)T›§ˆö•pÔjR­RšŒTÝUOš<®Rõ*f•±™N?0Ëåâ¹µ 5uí7ÃúˆøŸ[ø mâO‡ÿ|y£ühý–ü/Å…¿5_ê³øOö…ø{ñ·ÅZ—ƒ.>ÂØû-ÏÅo j ¬/¬a²øgi«ø;ÄVZŒúVr\reü/ã¨ÓÌÝV S-Ϋ¼;3j¾UŒË¨CÉ`y–´q²ŒÜð²tëÒ”c)Æü»bó¼× 9`•ZŠñÆeÔ¾µ†Áº“öx꺲¤ðY”^*œ°ñäQ¯:R»Q’¹ö'í1ûI|tðF­û-üøy©XxsÇŸ¾|Nø…â¯x‡á,þ%ñeÌ¿<àíkSðÃ_‚/ãÿØÞ|YñΫ⿴Áá]_Ç—vþÐtO„}~îÖ ÓÀɲ|¯ ï0ÅÂUpÙv7„¡…¥˜*8x¬~&½8â±™’ÂÕ”p8jtxŠxX:õ'Iþê-Â^¶c˜ch<· BJ|^^­yá}¥Vð´iNTpø'^œeŠ«:—ö2®ýœ#$¹åÈÏÐ?à« aðîëÆ|5Ö~0xGÀÿ³ŸÂ¿^3øÅ¢á :æ§ñ›Æ^1ømðÃÃ:Â?k¾,Ö<=©xÇ“OñÍ׌µ-Á¶Ýk·Z¥Í¥µ½ß¡W¹±‹±ËñœÛ—á²úžÓéÃ/ÃáñxÚÒÇÑ¥BXÑÃW社¯N®"j4c)Jpä§Äî8gY᥋¥G‡ÅÖÅÁà Ï,Uj¸|=5…œëJ¥z\µ%í¥ Qr¨ÛŠQ—SwÿXÑü7Å]+Ç¿õ_ xóà§‚jÏ|@ðÝ·Ä ëšëß²÷‡>x¶çÃñ”Z]•·ˆWÇzÆŸ6Ÿ©>—¦]øS°Ôô­[B{„FnuÀóªðU0¹œ+ás ù<-g‚­J§±Îkcè*õ°î¤Ý/«TËêóCÚJ5¡8NRmG_õš0úÌ+`¥N¾že*ô–" ªeÐÂÔötê¨ATöÑÅBÒ´eNJQt’— |-ÿ‚ŒÚüIý£4²üÖü=áßüRø·ðWÃߤñç†5f½øðƒáÆ™ñc[²¼ð%¥´^ Òü;{àÍGu§‰.'t\Š-*[#o{iªKËŽá `²Š™’ÌiÖ«G€ÌjàÖ´9py†.xSŽ*MÒXâ!iQQ‹tïS™8ÊØ^ XœÂ/©Î:˜œ^ž#ÛÓ•ëàèG4è$ªF›¥+ªµÏhÚϘý.¯>Œ( € ( € ( € ÿÕþþ( € (ã/Ž?¶ßþøÓTðOо|x×n´¿x×âwöçƒü ¤ê^Ô|ðâÓÀ·^=Öt­GSñ^5õŸ„[âOƒí5ÛijK FïÍ»6Ú»q¥€zŸÿjÙïâ-€ï<'ñ‡áÞ§/Ä¿´ÃàÝ*/xzMcXÔ¬<ÔÕ4;}> Jid×4›˜.lu.!%̶—Vá]á} >ø“þ Eû;ø`x¾;˜¼u¨ßxoްøIÑôûX°oÙëão߀>8iôÑâ¨î­cÔ<}ñGÂÇÂ_¥šx‡@þÓÖ¡x!ÓåGÙÑÿà ?¼AñÂ_ t}#â%ߎ¼O­x£ÃwÚº&ƒ¦ßx?Ä^ø™ ü+ñ®‡âKM_Å6·Z—…õ¿é:ö¡ƒí¼X·^üw£Iªxf'Ô”×õïÚÏöað¾·«xoÄþhšöƒªÁ¡ëN¥ãßZ_iÚÝÌž&‚ßGº‚kõhõI®|ã+4ÓðnÍ÷„|Ocå ¿êðZhEûOþÎ3 Ú/Ž¿ ¤[Yõk‡Oxd¤2é7µÔ|ljUŽÒxae˜þçgˆ4‰•Ì:…»Ê'íuû=ËtbÐþ%ø[ÅÖ:^¿y xû_ðŸˆ4gÃÿͦ•ã;´Õþ,j‘j©‚4]G^ð6±ðûI»ÔM©|F{_ÚÚ>¦š’éà]âM/þ Ùà]__ø»âí#öWðγñÛÀºî«â¯øƒKøyasñ/áÍý¥µßŠu__ßÚ ×<+©ÚÁfþ&ÔuBú~¦`µX¸¸š(Q=Oí¼áÐÃaµ3«à§ ˜J+]C Rý”¨¥5ìåJòöN6ö|ÍS廑Ãý™—{ZÕþ£…öؘÎê:Ü«F¥½¤j>_}T²öœÊ\ö¼žˆåtïÿÁ3?fm6â_Ù£á¤ü{ý»woàÝÃGWðŸÄ]GW¹øúµÖá‹ ÝsNñjî§ðÖk¹ K6Æ]oJ•ít«Ym ^w›ãGŒÌñ¸ŸkAaª{lEZŠXxÖ…uE©M¯gí鳆Τ#6¥%p¡–eø^_«àðÔy*ºÑöt¡®¤ê'kóû9Êš~í¡'èÚ#Ô¬¿à–^ Ô|-âZßö/ð®¡ð£ÅZŧ„õKäøQ¢xº÷Sñ޵”Óf—ìðhºœ:ÝŸ‹ü];)´Í_Iñ^¶­g{¢k—6šKˆ3ÉCJY¾c*x¸Bž*2ÅÖj¼!J4c—šr^Æ1¤Ó·5(ªsrб+)ËèÍ`0Šxy9P’¡M:R”ÝFáîÚ?¼n¢µ­7Ì’m3èÍ3âGì½ñ7ÆÞ ×4|ñßÄ_øÖêšv±áøšÇÃ:•ýö‘ãÛmæÞk«ë7QÕ>jú_ˆ-chöûÀzÍ•ÌrOáJ/:œE:5pôëÕ… ó£RµNQ§V¥a9Á5J—´©ìÛÖ.rj×¼zåFŒêS­:P•ZQ© u%çÕåö±Œšm*ŠSI«¨¤ï¡ò„m?à“¾+øq¢Íá'öI?<~šOÆ]E½Ñ| Xëª?´4mÄkáv×L¾ŒÊ5WGÒô{"¹ŽóRÓ-t¹£šòݽ7Äyó«ï8Ì]hÑ–5~·[Ú*Sq”â§ÍÍyJ“ÔÜ£ ]8ÄâY6T©ºK.Áªr¨ªº~Ÿ#©Ò—//.‘”¢–‘å”—+M¢äŸÿà™·|}vÖß³µæ·y©xÊûâ׌ï´/išU­ôô+k~/ñ¹—¥i¬üø³§hš—ˆ´ó«é—žñEö•¬jB÷Ц+;Î#JæxåKp¡Mbj¨Ò,D1t£Msûª–&•:ôÒ·%XBQI¥Ë«Ër÷:• çYÉÕ“£ ÍΔèMËÜÕÎŒçNnïš’wMœGÆßÙ×þ ×û_ë? ü-mñ;À:‹×,tË?ü;‡Ã:ÿü"ÚÆˆúVª"õ2Ž/Î2kìªC®-G,Lý”–&XɺR¡ŠÃÔŒkâfêb©9ÊŽ)»W§RÞïaÃù~cìùã,;‚qæÃF„yâèÇ5Vh·JŒy(M(T µ¥R?kÕ/¼GÿÐñÔ?cñWe߉·ÿ ¯<9ð÷áF·ã¿xÇ~'ÑuË[KS¡èöçˆ/u=^÷_º>]Ký&ââò÷Vðþ¡«I¿RÑ5 ‹/2žw›Qxç†Çâp‘ÌjT©Œ¥„©,5ÒªæçzT\aj“‚Œ#©ÉÓMBð;§–à*¬2­…£ˆxHÂy×§Õ)¨(¨ûõ=æïɶÝ乚¼¼çá…?à–¿ ÛÅ>Ó5ï€-Öh ¾*ñ·‹ü\| âËÿø@xßKø¥ñC@ñ—íôx´I<)áËÏ‹¾ ¼Ñô/ßC5ÿ…¯ü¨Y®»oeoª§V7‰ó¼lð’ž;B8ᎵjT0õ0˜ZxJuèÓö­B´©Ó½IÇyΫ\±©(˜a²\· ê8jueŠuþ±R½:u*U…zÒ¯*3—³÷©Fr´"öŒ)ó9¸©GÕ Ðàšzt V?öQHþÙê^>øZì¿î.ê gÓ//G‰´_‡Vÿ þί†>6øç·öž1ð_¿éž1øÁ£Ç‡>&ÇáæáµÍEô»½[Oð¶¹>£áý'IÖµgKÓô!® ÛW~¥Ä¼@§‹:ÌÔáFž2úå~eF””©ÁKÚ_ܒ挾$öÞG;Ér—–àœ]IUqú½+9ÍZR·"Z­NÍv²;ýsÆŸ°¥ç‚¾0xáßÃŽ>7ø³âx-¾j<)àŸøÃÇÞ#øð×Å­þ‹­E{a¤\\|;øjºîŸ¦j׺ý©¶ÓõK è÷Þëº6“{Ëý±šý]a´qŸWQ¯Gë}š†*¬+âb£Ïeõ©Â­Xí*‘ç—4ã¿ö~Û{ªaýµéKÚû(s¹Pƒ§FMòüT©ÊP„œbìšI#Ê—âŸü÷à¼Wñ?Eý˜ÓÀß|ñ~ÃSÖ~*øOà&kàÛ‹^ø¡Àk^²F߯·þµñχ Ô"¾s›b¨TÃbsm|=jªµZ5qgN­UkN¤[jm8Å®fÒ”T•¤½×K.ÀP« ÔpxjUiÁÓ§RaB÷Œ^êwiòÙ´ì{ˆÒþÂ_þ;Z麗…>øãçÇÍ'âvâ/‰~Ð>éÞ2ðæ‹}ð÷Ç?|_âïˆÞ!Õ6_húOˆ4OøŠí5ÍbÇT³ÖµM2Ò×U‚m2'x/ûo5• 6®?_„«B­\Mia`ðÖTb©)®HÂ+–*<ŠMÂÒwöfT­^ž…,MxU…LM:4•wí®êIÍÓ•å&ï'5.m¢×»&ü!ø“û|!ø'iû)x[âïÂÛŸ…>øWºî•âÿh÷:%ï€|aaâ];k—–Ú„µëxÎçÆ°Z–w¾!—^Ó4kXæŽ(ÇfØìÃ4¯œÖ¬ã¯Šúã«EÊŸ²¬¦§MÑ÷œ©ª<°yÊ„W3jåa°l. ž_NØjt}‡%KKÚA«OÚiÉÕ¼M“”º1Ãâßì1ªø×Å~ñ/…¾øz_ø[Àžº×üc¢xËšŽð‡ãOů øÀ:¤ºÜ÷W þ#üñ׋4 ËcjÞ·Óÿá#‚Iìõ”Ò¢9¦cxã±Q~Û^ê½Eûüm/aŒ«ñG÷U¥«œ=Ù6›E< ׳¡I'N6TðÓö˜zkK(Q©ïÓ­ j“Ð¥yñ¿þ ÷û2ürñv“emð·á—Åxú?|hñv—¡ø{ÁÖ~ñ6¿ð¯Äÿ´.ŸsñCĺ‹è6ÐiÞ-ð¯‡5=oûWKmbÞïÄ·–¿ð[Ùîob19¦eŒ¡‡Ââ±Ø¬F ’ÃÑ­Zu!E(òEAJö䇹䇻G@£ÁáêÕ¯C FjîõªS§J£o™ó8¥~i{ÒÛš^ô¯'s´ñ¬ÿðOÿü;ñúø¶Ãö{O‡Ÿ³¿ÃŸøâ‰o¡xkÄ >xãU‚ßÅ~Ô<1¢Øê—Úg†|S¯xY,u} 0Úêšï†î,.-¦Ô´K¨-íg¬jÔ®³j­WCRªÄUU'ŠÃ)Lj”“R•j1©5Nn\ÐRi5{’òì § O ‡öp£S{(rF…WR”cÊÒ…G¹Çi8§+´˜Ï Oÿïø}¥ižðü2σôÏüBÐüi¥è‹áæŽt/Š:7‰-ô?Á¦X%½Ì~3AÓ|ai¶a}ZÇLÑ.Eá¨<'§â9>)ZèÏ£­–«¤ø–;/„¿gi?³tˉtm#Uk»Ëkmb;L°9Ž?,ªëåøÌN´¢á*˜jÓ£)Á´ù'ÈÒœn”¹euÌ“IµxÞ+…ÆÓT±xz8šj\ÑhFj2µ¹£Ì›Œ¬Úæ‹NÍ­™èú¯ì °üEø[áûoÙ™l4_„Z^…ñOÁZt?WGÓ>x:MdizwŒô¨”ivßü1?ˆ¼AäŪ*èšEÖ©«–û=Ä׆®y¶i:´ëÏ1ÆÊµ,MLe*ÒÄÖuiâ«*j®"G8Ö¨©RS¨š”•8&ä£c—àa ÒŽu(Ã:jŒ'BŸ3…)C•§9ÍÆ/Då&’m³Ên|5ÿ¯Ôü%à߇º†‡ûßø?ÂwšŽ¯à¿ j– ®4íTñæ·eàbëNÒo¢‘¢ÖU*TèK.ÁÊ•NTéËMƨ­RI5¬ª$¹Ûw“Œ[»Œyhü0Ð?àœþ!|HøÝ¢|Aø Ä¿ø£ÅŸõŸ‰>(ñOÖñO‡´ÿëžð6©á¯ øˆC§j:7ãñ%†‡ Yhïus$7ú”V^Ë¡k ^?ˆ³lÇ„ËëâªG„ÃaðÑÂÒ©V*ýYÔtëפêN51 Ô|Õ4M¤Ô"îå8L£ƒÄWÅÒ£‰¯Z­YVœ`êSöܼԩMFñ¥î+F÷Wjî/–?P^þÖÿ²ö›¤êºö¡ûAü³Ñ´Km"÷VÔ®~ xfM>Ë^Ó5ÍkI¼¹•õ i{¤x_Å:”w?êËÂþ&¹–H£ðö®m<3Ó!øûY|øwðëâ—ÄíCâ7‡uÿ|MÅ5{ ZÒòöÑôm`éà§íeû9Aig.»ñ›áŸ…µ;gNðµç‡u߈ MoHñ®£k¬\êéšþ§a/‰í¤ð׊ìg²Òµ RÞ[ï x® ËÁáíVKPOÅß¶gŸêÿl.4ˆzÞ‘ðÇÅšWÃ_xËÃ^Ç…-¾/øˆü:‹Â¿,îcÔcÕoüyâ«ï‹ÑôHí´vðÓëšéÑo¼Ke©éº½­€7ª~Þ_¼7ñMøEãO|Sð7ÄícÃ~ ñ^—à¿xBÖÛRÔ´|u¸ýŸ-Ηya®j:¯}¡øÁtÿkºn“ªß_‡Zîã kFšæKPgýžþ?ø/ö—øuañ[á݇ˆáð>·$x_Y×í4»h|U¤]é:f­o¯h¤ëÌfÄMômJÃR“Mñ‡ž½ž+ý2 ‹Ø´»gJÖ­õ&õ_þÄ¿¾üPÒ>1iöÖ½ãÍ*Ãâ@“VñuΓâÕ5üXý¤¼3à xwÅþ×<-¯hÖ3|w×,õûÝF߯ï«ÞÝ^é·—¶_`µÐô`5ø³ðóöHñìíðcâõ·Åi_ÿeÝüÕþ'ÂUâçñoÀûŸ†qh^>×~"xzÆÓFø÷ñÃÀ~)°¾øƒá+oiº~£©'†5?h7:ž‰£=¨°[ÿÁ6>¦‘ák)üOñPk^øKàï…Px³MñFŸ¥øSxÃß4ÿøVM çRñ—eø›á¨~"|y}âÏÙø³Xñ>«a Û\x£_}@¥ïüöl»ðοá(gñ晤x‡Uø½¨Ý¾“¨øJÇV[žø»à?h²kÉà·Öµ"×Løéñ7PðÊx–÷]¿ðö«âk-@iÖÖújnüýœÿg]öñ¿‹<âƄ¿%ñ¦—¨ÝE§iöSþÓ~$ñÇ]JËR½Ó¼#áé¼iá«ícâ·­xwÃ×Zÿˆ|+á=J {›m2ÇÅZ|úƒ€x_„¿a¿Ø{Tñwþi~1ñ6¯ãox[ÃÿüGá_§6GÖâõígþ ¡ð\³ÕtÛß|j“MÖ4MkE»µºñüÄÌÞ%ø9ðßàoˆõ©ux{Wñö½®ø+áO„fÔõWWÔLþ!‡RÖ–(§ÕoQÀ8Ÿ þÃz7ÀÚºÇö™¶øÝm¤x+TñV©þñÆ‰á »_Å¿¼_ñjñô+_iv×V%ñÅÏSÿÂ%â-÷K×bððƒáé:Ιâ CR”oàOücá×Û/ë_üWâOˆÿüiâÍ}Z˜t? jñ?t½7Áør+I/-ü; èß´wĹ-d}^oÏ®k’__x†öÊËJÓì9χ¿°_ì‡ñº¬^ ñ_ÅRϺ׎¾ x§W“ÄsišÅÞ¥ðÚ‚ †ua¨xSOK•ø_¨~Éÿ%ðŽµ¥Ø@uOÀVúΧ«x¶ÃÄÞ$ÿ„„Ðüû þÎ3Áñ÷À=øuoâ߈zO‰þ Üè~9Ðõ[{ßÚ/àÿÆë¯Š‰ñOPÝ ^Á§üSð×Å‹;„×´[eµð3 jÞh-~Π|ÿÙýž>ø“Á~%ðµçÄk ŸøßÃô øIôæò|QáÏ x3Â\ÿm¯‹ml·º´ó ~Ʋö¥ãøu¯ xÃÇþ"žÛÄ5[ ÛÄ6¾%ð…«iµ‚>5ükðÔº„ž¿´ŠëZý¢<-Ï‹¼)â_Ýk>£ãÝÃz>Œ5Ëm4OOÿ‚q|ðŸ†>ø_ᯋ>%øOø)¦øþ×àlk/‰¡øEªüGƒâ–¯øƒÂW(ÐuM|Ý&‰ño_Ñ­ô-Sć‚o­<=ðþ_xW_¼ð>‰qíGû~Ê|eâ>#ø“¤ÜþÐþ3Ò¾ÇáM\»Oø»â‰øñ[áÆ¬ÞYÛøoWŸGñ·Â½GÄÖ¶Z…έ¥øUµøvKË)õ6xup[â¯ì)û)jú¾‡ð;Å>>ø¿á[ÿÚ Áz¿…åðŸ‚u=+ºÄÛ?†ZÄÙ#üPø ñöIÓní­—Â ¼ðþ¥®ü0ø‰©xkûFæþÛÃVºÕ‡5‹ˆ­¯£¹}H_†?²ì«ã_‡ÿµ'„~ßxž÷ügñoá¯Å[´‚ÃBñ7†|e.ñ÷Š?hÂÿØÚfâŸø+ĺ'ü{­xgâ´? ôíjÖãßÚKNñdÒøoÆÑêš6µãmkBð§áí ÃÄþ°±ðßöý–>0|3ðo¼ãß‹úÿßxOÃñøæmrÓN6~ Ñì?i}'Ã:-¥žµà{-vÎÓDÓjŠše¼ZìrëI¿…ÿ´nn.´'šôÇgŸÙàÅ×ÄÚ×áøË¨üPø{ñcÁ¿þx³Â–_¯´94›/Æ á½KOðÿÆø<)§iËâ†Ww~ñLJ|1ãŪüH¾Ô¼iâ ÃÝœš@Zø§þ çð7Çš‡ŠõëŸ|eªøÛF× ñ£«x¶ÊÎæçÆž!øK§ü½ø·dt F‹Fø—mðÇHÒ<=£jZ,:‡´ô› GðÅ—ˆà]]€ ÔÿàœŸ³ÿˆ5ÚÙøŸE¼Öm> Erºmç‡g–ßPø{ðâ_ëzfµ­ø_XñF—{¥|(ðO†üWia¯[è>%Ñ´Éd¿Ñι{s­8Ç??aŸ‚¿µ?Ä_ø‡à'íâ_øY—W¾ ø£ãcÄÖšoÅO\x⟅hË¿…0ø:ïÄ^¼ð׈~Êß>#0ð¿Û9k¿Ä/øk]›ÂþÒÿiƒ^#øw£ÂÉÒìµo .¹Œ<âßþ Õ´Y#Õ¯þ_êúMψÃÚÀñ©u©Miÿáýb›PokZ§„¾$x3â÷…õëï[ÙëšÄ|eøÅñÂßÄúUþ£è†Ñõï|vø‰£ø“F‡/ü¨iþ¶Ñìm4›'ˆÚ¾þÌÞø ©x³VðŸŠü«ÞxûX¿ñOŽ×ĺ¦%‹üo¨èÞ ðí×u+ÃÞðî”ÎÂ_^]ëþ"ñ,ZÇŠuýS\¸ú6€ ( € (ÿ×þþ( € (ä?ÚöqñƈGŒ|)ñ!~ͦþÍ_µ/ÀËOémåÇŒü;âŸÚü—Ã|5}¥§Û[ß|9¼øO¡mi)K›ûËûI-µ-4éÛ§øCÅŸðK¿ˆ¾+ð¼þÖ¾7èói7cÐoü7â¶ñïü!qã[?‹qüVÐ$Ò¬üGâ‹[ïøjov‘wká;í6 G@¼´Ò.<;q{á_k:@ßàž´SØø‡Æ~øÓñ¾¦|Q¾ø}áÿxƒâ7„$I|[ñ[ö¥ø“càíY“ÇPé: —Âÿü)ð³K×u;kˆt ?XßBÖzjéö:@cðwö@ñäÿ³ïÂü~{[|5ý§ü{ñ‹âm¶£ñ]»´ø¥àx+â_‡­­$ºðÖ¹¢Úü?Ó_ÄtM[JðºÏˆ¼= Øx G·s5ÝìI¥pÁ2ÿh»ÿ iÚµûQXÞj¾Ó`²ðÆ¿dŸ4Ë›mSß>üðo‹¯ãO‰3Iuâü;Ó~-k*×§OâÍFèAnnmƯvôU§ìCñ o‡?ü ⋚Ô>>ý«>üyi“Æmsaà? |Dð¼gð¾ïÅPø†ÏÅ:݇Œìt_xfÅõ{«¹|?áÃá-OPñvƒ£YÀÀx×ö#ý®~kîÇüjð'ƒo~ë¿.uŠZ×Ã]íßü!ûø!õMsQñgˆµÛ»gñ$¿> øãU×tý7T½»Ð|Y㇚«ÏsñTÖ5 Kø$l¼cዟ¯§Ò¾ øûá6†Ú߆¼}«i¾¼ø¡û4ü(ø1ã_øn ¯I.•¨ê5øOgモBNqgâ}bÎT‹S´·Ô®>Ùýœ~|iøsñ'âGޝ,|1ñâ·ÄA¦øo∤ÖüQð×àÅܾ0ñö—¦xr x‡_ðÆ«¬ø§ö‡ñ÷‹¼Kg>£­Ã/‡þ'‚< ñÇÆ”ø oqã‹ß ø¾iµçøIc£øwÆž&ñôZ·Œõ‹­SÆ_´ "ãPÖo­®¥Ðôëײ\è%ÑlßMÕÀ<Á0~&é6º2êÿµ„m¾-/ÃøHø™s£øš{¿Ù»öNø?¬øÓG½ºñÔZ£ë’j³ 7~*™î¯–?üQ×m’úÛ\Ñ´Ý^ôÖWþ õ$ÒÏ6µñŸNÕ.®o¿e{MÓRñÏÄËѤè_ þ-]|Pø¿à‹;–ñÍ£]éŸ<5q£ü;Ñ‚X@úƒ4­/Kº²¾Ðm¬´h<Â×þ Ññf_ì‹OеÃoEàO~Îúkø{Ä:_‹_KÖõ¯ÙûâGìÓã+Äß#Ô¾ ^êwš†¢¿ > xquùïþÊŠæîÙ!–nÛÄ€¥ð¿öø•ðë]ø1ãö©“ÅÖþ ø›}ãxÄú÷‹5'âž‘}†Îê_ ëž(»ð~ã/Øxr+ëïøn{-GKÖZ{û-O_ðÞ¹âÏ kÀ÷Š?àš ê>ð•ÇŽôÍâ~ñ⎹ñ=â݇Œæ¶°¿øg¯\XxÄ>Ó¬¦ŸPVÕ5XÙ%ŠÞÔÕ÷üâ.“m¨Að¯ö•Ÿá?ˆŸâ'íñÛÄú•â«ÝoÆâ_|!ñÏáÕÏĘ®üy~"Õ¾|uð_†[Å:Œ^RüLøW?‹| ¬ÿg7u›¸€%ñ?ü+âŒóøÆÛ¿µŽ-|;©ü?_ 躯‰ †ÎûÄF¯çŽdø{ÿ ç\ÔõÏøNä½´Õ|‡*Ó.üÞ·ü‹âΗ5áðÆ/ø~ÆãÇ¿ü{®hÖš',´ÏŠÍñ“ö øSûFÞøcâ¤Z`7ºd:w„üoð¶ÿTÑ~ÍáÿZ_5¿Ù§ñ?‡µÀßöšý…>5üjñ‘qà/Žú?à hŸ5¯„Z~…§i¾>‹RKíwáoÅ?Ë¨Üø‚ÏÇ‹«^éšOˆ<]à/h(×jÖºÇÃëiu ýOYm#Ä:0ÿ󸧤|cøGãÛïŒú½àŸ„ÿu‰ðV·§xãU¹ðF‚~$þÔÞ"±ð‡€µKÿ\ZYGà?ÚÂ~ ×oµm2ùÌ_|#o`±h÷6å>#Á4~-xóÅ&ñJüyÓlogø‘ñâ7€n.-üus¯øYøƒcl¾ºÓ¼]gâ½7^¾·ð®³º®“¢êójiáëEµðΕ«Ïám?ÃzG†@ÿ‚vü\¼ñV£©|Lý©-!³ñ_ÄOø·B·ð”~6ðÆãü»ðO…uOiÒüA{;ÍoÃ^.Ðü5ñv-'S“VŽçZðäŸk›Qº¶myÀ.ø{þ ¹ñgLÖþjz×Ç];ÅZŸü,ñÞ±¢x¥~#xš 3Å?>*ßxãÄzÏÂÙu/ ? IñWAÔ"ÑüOe¬húµ¶‹uáÝ´g–Ý^Y@-êßðN/ŠÑ|Iø‹ñ#Á?´¿ ]x›ã‰þ)ÙhpØüC‹cñ‡Å½3dzi_ôÛÙYM?ƒ|,<[àŸ Þx^×L”7×nuèž[*ç´_ø'ŸÆùLJõ[oÚcÃ> ¼ð¶áï Þ\Éiã]V×ÅxgHý€|?ñÁ¾$½_>¥kቚ¿ì[ãø~!iÖ7˨H~3jQêK©Þézòø˜Ó?eoØËâìµã?‡h¿<­ZiŸ<+ð–OêW‰åƒYÐüyàÓ®xáþ“©ø¾MGÁWñhú=ݽîŸcâ _j:Þâ OB±ñ —ˆµŸ€_ñ'ìWñöOê? ¼ñ¯Àº„´¯_þ:x7Wºð·ŽÓÆ­×Ç/ˆŸïÇSD©á¿Œz¼_/'’ÎïGŸZ¸±R±—V¸]Y€1<ÿÖø½á«Ÿ„:ž±ûFê~(×~Ýøbÿ_Öu]oâ|ïâíkCø¹û3ø§Ä>&M5¼f4Í.óâ'ß‚_ü1â[}OLÿÇ/êòMªOÄ’x¤Í´ø&/Ňšg¿‡¾ñmŠhööŸ¾øÅ¿ `ºð^“¤|øUðïã7ËcŶÏ¥ñï‰þ6øâÔÃÁÏàí3\O‡¿´í/Æ,ú~™£YÝ(½ünÿ‚wøëâ_Æ/Ÿ<ñª/† ñ7Ã3Ùh׿ ×,o­¾/ÁíÃ^#_t­UðVâ»?|YûUž›gâ¨|CáMÂÃPµH_P 'Ä?ðNÚ+Åj÷óþÓ:O†5½KPø‡­é:ç†tKuàmwÆÖßðP«M7QðlZ¯Ž'“M“ÂÚí¥àNšÞúÏPÿ„à­ý€¾Ðφ>éý‘>k_³ŸÃox/]Ô¼'uâOŒþ)Å‚t½cIðî‰oñ?Å×¾0ÿ„rÂÛ^Õ5JH´+NçOŽòkÏôØ"†äZØ™ZΨã’9Qe‰ÒXÝC$‘°tu=]r¬¤t àöÍ>€ ( € ( ÿÐþþ( € (òwöÞðoíô¾;Ö~$~Ï~!ü5Ò|¥øvøSÆž6“Æ'Ô¾Q}©øÁW1|B‡Áë—Õ½ ž”€1ðóàü3ÆúoÂíc_ñ^©§øÃFø^ž"ðÆ?о*¿ø‰âgÀßgˆ:¿‰üS Ýxg_ðæ•©ÜèŸ ¾:XxSìoa¯Ïៈ~‡ÅòÙxu›Ow^ý—ÿà¢z<_´¯þÐzΛ§x»áv¹ã™u^4Õγ§Aà¯øã ‡Û¬<áŸ,WÆ‘®ø£áÕ—‰mü1»tÖþ.ð–«§ø£P¼ðÈ_Å?Øcöšñ×ìµû?|"ÄöÚ—Œ| û#|yý¾&Á®~Ðßnô/xóâ'€üáÏ |NÕu{ÿ êsüGÓ¬5ÏjšŒz'tAsáX|_mýŠ×'B’ÞìÞþ üý´|)ñÛDñÄ¿ŽZˆ>øvïâ0Ð|%Ä ÍsU—B¿ø“ûA]ø?Fø†5ß5Ï.Ÿá׎¾$:øñ›¯øg]øMq§G¬jšMæ§/€<;Á±çíÃà¿ZÙX|o×ΡðûÃ~—Á–~Ñÿ5-Ǿ5ÐÿiŸxçÅ“øÑuÏjw–šGÄO€Ú®à˜,ïGˆôï kIä &òÛKµÖeå|cûÿÁBüyàxWÅ¿´Âeð?Æ? õï k_|U«ø VŸÅ¿j]j–{ðÙc½¹ÿ……ã?Ù«[M~KHµˆ´¯xžxb‚îæóOñ8Ó¿ðÎÿµö©ð×àŸ‡õŽ·Ú7Žü/ñkâ—Æÿèÿ|e ŸÄ¿‚~<¾ñºñ?…mSF3ø3âNj|)©|6ð`–çÂ? .¶ü=¥øƒ[Ò`²¿»ó þË¿·½Æ³¥ÞüEý¤üY©Am«ükÕµÈüñ‚ëÂ6ž­u¦ÛOðcPðæœŸ /SCðüºÍ½¢øÁ!>-ð߆c²˜Xi~$ÒõL×À8«ÙCþ 3k¢krZ|pðÝ·‹5 ø_Ã÷¾!·ø•ãkOëz–ƒ¤~؇!x‡Â:–§á]xÆþÑ­4ß Me¢øÜü ðöëÐ-ÿi˜u?v·:ßį…ÿt¿„^$Öü[¬x«HðÅ­WâÏÆ­[áO‹4Ïêò<áÝᇋ>iZ¶¤ÜkpÛj’ÀØx‚-6ËSÔ€8 ö0ý¢5}oöŽñOÅxź—ÄÙKâoÀ>#ø‘âMðúOxëã.±¡øSÄZ¾­áh?·£°ð¿|+¤jZÊóÄ÷0ßxf[MOLÒmoõp‡þ ¥ñÚÊK5Õ4¯ƒŸm‡‰t FêßâOŠÚ >/ø'=·ì‘-¥ÿü#là6ø”¶4t²Ò†«sà½*×T„>&’;=ÃðLßiþøÍÄÉt/Ú÷‰µ¿öž}^ÿÀe÷Š4 ¿cï x—âW‰+üjýµ/ÙÛâ/…¾ëÿ¼7ðÓ@𗀬W:Ï<=£èÞðáqk&˜ÚTZì¾ÐÀ<ëÇ_²§í›§jtÿ‚´ß‡Þ¾»Ñ#ýž<á/ÿÂðóÁ¾ü6Ôn<-®øCAðöÎ…âo üC‡XÕþxóº߈¼+ñGP’×V³Ö4}Ë@æì?c¯ÛKÖ´±eñ"k;(þ!|TÔ|vŸHðÆ¡¯x>ïYð\~ÏÞø¡ð¢ëúF¹™6»u¢_Ãt‹|š¿†À1ÿg/~ÞúgÇÝSÁÿ5ŒZæŸá¿Ùâi8Ó¼gqÂSâ„ÿg›;¿ê–¯áH|=ª<ÿ4¿‰—~ñE—ƒ¼MãñŠüyuãï O é>±Ó@6Söfÿ‚‹KàKÃگǶø¡~išgü[¢|vø‡áMGþ4±ø£ñ ûĚ׬dð‡‰íÒ|1¨ZÚ]aê?³¿í¡áßÚZÇÁ¿¾!üAÒ~k,ñ?Åoˆ¼[©x~ÓÂÞñ·ìI¥Ùé?n%ð³/ĉ~/ð„?hÿéž×5{‡›Lñ<½ÇˆÓû"ÊçÃ`íðãáGí‹á/ÙKÁŸ`ŽßLñÏÂËÿ‚þ×>#ê´‹|M¬|oðN}¦_|]¸ðçÄ-[Â:§Ž~^ëºtèºEÞ©¦ßêú\š¦Ÿ Ï£½Ž‰âJùwà ¿à¢?eø¡.›ñ#â¯ÂMOŽüBñÏ…u?[A7í ­øSGhæð{j:&­¡éPþÊß¾%ø«D·Ö-|SæübñÆã_øš}6; @ñGì­ÿ Öué¼ðíšIuâ &Mã¨ü(—zÈú¿ì•ûrë>³Ô¾1ëþ"ðf›ªü%Ö5ïë´¯Ä?ëú”¾øÇÅoXèž0ð7Ãík 6[6±ð-Ì>%Ó¼Uâ <1á6ËFñ¢Úx“]³@øáû%þÜüY­ø«þf‹à+}7ÆpüHøY¡éß¼[©Ýü7ñ—Áÿ|'Óíü7©ÁðëIÑSÃzuç5¿ˆö·£ÃOŠõ}~ÎëÂ>/¾×ü+w¦ÜY}Eño¿µ·Äû¯‡^*ðmµ‡Ã»;/üd´×>Üüh×|6Ÿñ)üC᛿ž7ñ‹>ø?Äð™øXx{Ã~!Ósøoû:ÁDtü(ñ~7Åu£xCÆ6—~"Ð->1xËVÑõê?~&x§Yѵ'[ð]Ëø»RÒþx»ÃÒ®µíbâïûcÃl5úN‘â嵨ãöêðæ»ñ’O„l¼àï|eø•ãû¿ iµ¨›Å:/Ä_þ"ø™ׄ.n>ÝÃðKÅš7ƒµùôÏO£E¯Ûøó[cmª\¥Œúš€z_ÇÙ3ö ñ'ÅûŠŸ þ"Aý«cðàçÂ]W[¾ø‘¬ø3Å~'Ô¼)íqã]BÒûÃ~¹Ñüy©xÛâÁ^ø‹Ãz…׋4ÏøŸÀ7Z^áíe-/@9y?fßø(½ï‰`ÒüGñö-_Á©âO Ýë^&ð¿ÅÏøÄ>#Ñ'ø—û<ø«Ç0iÞÓ|äx0xkãï„t+=7Ä—`Cã} [½ÚIô O³í­¢üvøAñgã÷Ž|ñóá¿ÁoøkëñÅRC­øÛà§ìÓ j–þÿ„KÑKKñŸáÄïxƒÇñ]C¯ø‹Iø ùš\I£HÒý™ÿgÛ_Â4Š´Ä=?Ŷ6~øËá¸<7¢|rø«é>6Ò>êÞ#Hñ†ÿ³ümŸão |_¶·½ñOÚµ/ é>#ðíî‘çÛA†ôKIý”ÿà Íá› }[ö—¿MN_ü]Ò5П|}ý³yâý.ÆKÏÙÛÄ1jðh-¤éš¾§â]gVƒã•߇ôÂú†áß xCŠûPðÞê~ý?ké¾ø/á÷Œ>6x˜Ýiÿµ—‹¼SâãŠ-üo}û:Ýü9»³×ü$ž8·ð•†±{«ÿÂÉÔ®õ]7D‘líìôh4ÔÓüG§.›§é¶ 0x‹àWü¦ÃQø_à‹¯Ž?5ÿø×Røïs­üGðÏÄ SOøQàmcLðσá§Žõë]7ᥴÖ>½ñ½Î³kð?Z—TÐõ`×|1¥jöúF§ª[߀{Fû<ÁD Ö<-u®ü{²Õl¬>(|:×|[`>$xž×Eñv“¢øƒÆñGYû>“àýÄ^Ñ|oá]sÂGÁ_ ¼;âAá/x¯ÀÇ®ÚxÓÃ^/×-íÀ<‡Â?±oüÁ»Ñü+ñ«Hðþ¿¬xoÀ–÷wÖ_|~4m+Åžý•l> èúž“áÆðè:vƒà/¾²øÇ®h.—¦éßt}gûÄö0Ï¢K¦k€Ãgð/ö®°øáðÚÆóã7ÆK›?|PøûâÁãêŸ 4O€vÿdøð*ÃÀú”ÖºO‡ü#ñ14}Á_µÏÙ}²òçá§>%jnÖ"ðΛ©ÎúmðïOñ“à/i~+’æoéþÑ,¼A-çˆÿá0»“Y¶Ó­âÔ^çÅcÞ$®ÒS.¶<)á¿í7-yý‡¥ùßb€² € ( €?ÿÑþþ( € ( € ( € ùSöÍÓµMWàŒvz'‰bðv§ÆÙËX_?‰|#á9´-Âÿ´Ã?xÇU²Õ|s¨iÞ–òÇÀú'‰n¢Ñµ½O¬RhcGÖ´—wûx¬&§_•O<ÂK‚ᯠ'‰Ãã°þG“ã3nñ¾–k<Çã‡ç9j™’ÂáiÓ©Sªٯ䙦-QÄa±˜J˜>&• -jXüW“õŒTbêTÄ«§ ÉF¾ Å%ƒ©ÚúÛ¡)Á.YF\Ôâæ½ÞƒágíKûVx§Ã |]¨ünð.¥á_hø‹RŽo~È>ø‡m¦ø—àÃkK¾¾¶ŸÅIá·ÔôoŽ?ð±ô¿ ü?]+ÃͪøCYð¥÷~%ø~÷Ãz¥†µæq„^e·d¸nâ .q“æPÊð²§’øÙšpÕ\^Uâ?`1˜|=Zy;Í#„Çðá|^oÄ™ýS;Ág~áL†i„Ä`*–/8RŸÖ)¸Ê<Ò½Lj.zÚm9rÞ5ý¢…6¢Ü%iU8¸ž£âÏŽÞøŸ®xò5ø×ám&Žÿü1û5xzH~&økG>ýžþ ÂC®|wø‚^Ã\h¼?ªüM×­~*øþ&·6óêVÚ§Â=KKºšÌXÈ¿%“x{ð–_ÃÒ|›ã*xwÁ™·Š™”jpžiŽYlj\{ý™—øyÃibrõ,Ë Â™u^â,Ï*ªªÃ [ ƘLeWx„i&ÅËáãóÌ7ä¹–_F<9âÅ\6?Ž)¬ç!Îxs0̱òeW«›dž!C6Ãä¹%¿ Âø¾ £õìN?ëùF)Ésb¨F´£&êa.¨{“…XÅ9Y¥Ðår›”ªÆ¥’‹Qó«OŠ´G޾xÁ?¾,xF‹Ÿ²Ä;‰>ø·û"èwÞÓü'ðÄ¿tØì4?áëPé¾#‹âä~´¼ðω Öô6ëLÔW]ÓuÚj¿M[„<2áî1̳î àÜêŸ> ñ«†jp¶cÁ~4ãðüA‰Î0þ"å~bå‰Ì8~®a€©‹Ë'ÁrÍkPÍr¹à1˜ªX¼3˱X\ʾlMJQ…z°söØJªª­ƒ‹¦¡ì%ˆVHÆ\²öÜ—„î£gΜ9¼oâGŠ?jÿŒPx.ãÇ?ü%£ø‹Løa„õ{¿‡¿e_ hhÞ8ð?ì±?ă0f˜ö² ÿÅê|-ìæ¸rj9%>Í|5ÅឈêçQÎ'œÊ•<5(Už.²ƒ•XsFŸ$NE ]óu¿k¿¿|W{áÿ þÒ ðoƒ<ñZÓ%±ÔŸöiÐü)¡ü2ÑtVŸ m!¼ÔçÕ¼V©âïøKᦅâÿ›{ïŠ_|58Öu ‹|o¤ë:Wâ/‚ÜÂ9= Ë4ð¿<Ï3Ì÷†ð¸b0«ÅLÃ8Çñ^?1à:ÜYZ¥ -,&Nå“eÏf&{í0ü#Ŭ>£†¥^y3¬>3VN1ÅB8M¯{걄i(VöKÞ¼ýù”' jÓ¼íÏGÔ<-ûHþض·þ üNøC¨èúŽ­ðúÛÅQÅñCöN‡Zðô)â¯Ù÷⮣¬ù2´Ó®<76‡ÿ ‘¤x <'.±âìQà 5Ë(5Âã°¸.$«”J|%ã$ð9”哸ÕCƒð¸i‘VÅRÍa˜ÄÆñ³˜à²¯¾$Ž_‰©•¼V Ú¬bpç­E«ÓS^×Í{êÊVš\Ž?\>[Ï—Ù¹{ö‘ƒðöÆý£üyðZÃÅ:—ÅøüsÀÍoKñ&©ã_Ù[Â~5Ð4›_i?´e‡‡¼5ÿ >— ¥Æ·à©îµƒ‹ãÍkë_i^-ÆcI²›ÁVþˆ¾ø]üy‰ÉðÜÄYlx~~ åø¼¯ ø¿œd9Ž6¶IÄxaˆÌóW•c3SÀgÔèáxáðö>ž¶WŒÉ¥‘}sO>ÄPœ>7:<Ò­N\þÁ©º¸8TŠSK£ËÊt}¤~(Ôç²äŒ¼÷ãí‰ûWü-ødÞ+ñgí#ðçJñ^±à/iºO€õ_ÙoÅ:%Œ—_³±âxîÑõ û‹³«øo㟆ZÙ¼7¯ê6ÚW–òÿÀžµyø9ÅÜV²|›ÂÞ'ÆdØ,7g˜¬g`ü]Ê1øˆÒñk”pïVXl5*?SÍ<>Í•Uše¸Z˜ÌÐÃqVQÊs쯕ln2•.yâi)¿gRÂN+ý–S«SW-a^6q“´îáM>x8÷>&ø¯ã$kñÿà§Ç-Nñ¾‰ñ#ÄúGÂÔÔ¾#üð¶¡iàŸ„ÿ²ïíàmYñ/>#x‹Lðär|Xýª|v!×,/4i'o§‚5±•gáÛ-oKð8S…2n›ðß|?ÌqY?…²¬oK Âüs›á«gügâß…ÜA˜àr®!ál³šJ<áûL¿GK?–€¾*¾iˆËñzU­*ÿí41UI**UhAªtp¸šq”©UäŠu±u-+¯áºoEc†ñÞ«û@|Tø“­ø“Äÿü§A¬j_ü=¨XY|~ýœl>^øÁ?´—ÄŸéš7ö6Ÿã«Ï_xOPøMªx ¾$ÿÂAcã[\‹Å:G†˜é±é°]ûü=ƒðß„8[•å<+ÄXš˜7æxlN#Ãq<[Cˆ3ï 8[$Åã¾½‰áÚ68Ãqžˆ× ,·C$ÁåòÊ1¹³X©bªÐΣÄVªç:´Ò~Î-}g .ÄÕš*©)8{'KÚs~ñÉIEµd_ðWŽ¿j-V×ül¿,|7âMãÝw[Ò®~.~ƾ)Ð×â.»û=~Åþðö½­x*ßâF‘¡ÏàMâGÃÏÚËCÒü+âm/Ä–±jZ^·ªÛjßðêW|ù÷xGŽÁe¹ ¼>Äf¹nEËðº\ã–Q˜>ËüKñÓ6Ìòü}S…ñ™…>!̸_‰¼4¯˜b³Œ§•Öž€ÁÖÀÿfá©Ð¨TÅFòXˆÆuIÊõ°R^ÖX|$#)AVŒ=š« BŠ‹rK‘ëÍ>oRÕþ3|Bø¦ÚŠ­~8èž ñßÁQû1xÄÚ'…þ9|Ÿ‰u¯xïá§Å?Úîm3W×Ãß üai¥|9‡Â> Ñõx´MM¾Ôtÿ‰¾ÐÒÖmBëMŸäp< Ã< ³ž·‡ù†yÃÜxüYâ§›øâ+ÂeX³‡¸¯„|†/€yŸ䕱|QS:ϱØ9æŽ.†™–aíiá¨â#«¯R«Œý¼cR‚ÃS”cˆÃ§9Ntêã_»JnÕ8EÙAÊ5b¢ï(šÇÏÚ»FÕ>O®|uøuâí3Äþ$¶“â-“|BýŽ´ñð×CÓ?iY^Á Øëº5έcâ?Ùµí^Ò]*óÅúÜ>/B³Â?zlt‡åÌ|:ðw„âŠxxŸ%Åå9]XðÍxðÏØ¯õ§0Åø]™W¡R¤qm,#+ñZ9v´1”rLL’IÓþÑ ±È‘Äã#*nXŠSR’ö±ö¸%좱1¾Ò‹jx^f­Í.äi)xí—ÄÿÛëÄ_|iâï‹¿uÁ+iÄfÓãì•¡k«á/|;ý”¯~.xwÂÚ>™ãøuªëºOÄÿüo²ð…÷‹´ ÛX i×_²v±¥øCÅ_¿b½7VÕoÛö„¼Õ¿i8¼C¬ü<×ukàO„ºW‡nü3o¤x†ÆÛ_Šk‹ÿ ~±s¨ipyôx7€òêTèaü1ÄÏ6ÄÑñ“‹Î²~ñãƒÂa׆”0~O,Àq6^ùëqã3:9­Lf[ˆ«—Nñ ûK ‹ºÕ¤ß6)(Åá„ë`c)?¬9by¥NöTé(J)5νæÚ>~øUûK~Öÿ<ð“â·ü4§‡ÓLÖ¾_ê0[þȺN·ÿ ¿‹~é˵ã?‡W¾+ðn‘­|6ðçÅû'ðÆ/ˆü5ñ*)u}N%–Š,.tÒ8ÿøK>ãNÿˆW™<^‰ðØZ•VOãN7/þÀÉ|CÅ9àr.'¡“g˜ì月…,Û1ŽYšð¬ã‚ÂO-•l{ÄRÅóRÅcjFO¬ÂÎ ÿóΊIΓ”c*Q¬Ÿ"rVåïr«Dö+ÿÚâ÷tû}Jø©ðÏJø¿ð?Á|%ªè÷þjVš÷~+|Fð§ˆ>;jž»—Tð'Ãkß¿g}'Jµøq{¨ØéÞ‹Äÿ¼C£ßÝϫ跳?Äaü5ଇW-Æp‡âø'óþ(ÎpxÚ<ÇZÙwð ç9o‡˜<Ò„0œCŹ.]ÄÞ&ã1•¸£†¯‰Íg”ðÆ[ŽÃR§‚ÇaáÞ&­KKÛRjéÁÅÖ ùªV«^P|Ô¨ÔtðñЧt¢¥Rq~ôZ+ë¿jGĺ]…ÿíá‰ü¥xƒösñëž ø‰ûx'\ÖÆ­|7³ý£4+íQñ¯‰’êö)â/ü?ÒŽ»y4°¿Äÿ ø—WºŠßá¾³®‚< ÂåX¼Fà ڞyŒË|OËc€Ï¸cÆìÿ/À}{Åü0Ì0øì.E•:™ž òÌ£ˆñ‹-¡N<'šåX*2«Æ•0‰×ŹEðÿ‹4Y&†âMÄÚ6®éoqnÛ­ç}?T¶º´i bZZñ1Ê2’kÒʳœã!ÅÇ0Èó\Ë&ÇÆ)G•c±Yv.4ª«T§N­*Ê• §Ë5¤“ЙÂ#ËR©ß–qRÖÎÍI]z}ÿg·ìçû=‚øðhA|/ð@ ŽAhY„Jú‡â‡‰m4üD㦞>-ÏÚiôkëÚ˜ýS ÿ@ØüOÿ•ýœÿg¶%›àGÁ¦f$³†$“É$’Iä’y÷¤¼Pñ.)%⤴Iqn~’]’úû·õµ¬UÂÿÐ6ÿÓÿåbÿÃ:~χ9øðlä(?ñl<ÈQ…þ$\… ;J‰þ%+[Ä>9Òö·çê×½íþÞ÷{ë®·½Çõ\/ýP×ÜÓÿåzÿ†rýž¿èƒüÿÃ_àþQSÿˆ£âgýN:ÿÄ»?ÿæá}S ÿ@ØüOÿ•‡ü3—ìõÿDàÏþÿòŠøŠ>&ÑÄã¯üK³ÿþnªa?èÿ‚iÿò°ÿ†rýž¿èƒüÿÃ_àþQQÿGÄÏú8œuÿ‰vÿÍÁõL'ýaÿðM?þV9¿g_Ùõñ¿àWÁ·Ú0»¾ø%°; à@*KÄÿ£~_¸æ7wvâÜù]ùÛ«óÿ‚?ªá^øjø&›ÿÜ×Èoü3—ìõÿDàÏþÿòŠŸüE?èâq×þ%Ùÿÿ7¯ÏîÕ0Ÿô ‡ÿÁ4ÿùX­û:~όśàOÁ¦brY¾x ±>¤’Î’ñCĸ¤£â¤´Iqn~’^Ic´þ»Õp¿ô ‡ÿÁ4ÿùX©û:þϱÉð+àÚc)ðÇÁ*q×8Èü°)KÄ磻¼Bã‰%Ò\YŸËóÇþŸvƒú®m†¡ÿ‚i¯ýÇý|Ä?³ŸìöÇ-ð#àÑ< Ÿ†'` žsÀ㜠kÅÒ²ñŽR츷?K]^Øî¯_=Åõ\/ýaÿðM?þV'ü3—ìõÿDàÏþÿòŠŸüE?èâq×þ%Ùÿÿ7Õ0Ÿô ‡ÿÁ4ÿùXÃ9~Ï_ôAþ ÿá¯ðGÿ(¨ÿˆ£âgýN:ÿÄ»?ÿæàú¦þ°ÿø&Ÿÿ+þÎ³ÙÆ~|8ø_àƒ×þ$G'§òÎ(ÿˆ¡âZ½¼Dã­]ßüe¹þ¯»ÿozÿ—K$UÂÿÐ6ÿÓÿåbÃ9~Ï_ôAþ ÿá¯ðGÿ(¨ÿˆ£âgýN:ÿÄ»?ÿæàú¦þ°ÿø&Ÿÿ+øg/Ùëþˆ?ÁŸü5þÿåñ|Lÿ£‰Ç_ø—gÿüÞ¿?¸>©„ÿ l?þ §ÿÊÅ?³ŸìöI'àGÁ¢I$“ð¿Á’y$“¡d’z“ýi/«…ÿ l?þ §ÿÊÄÿ†rýž¿èƒüÿÃ_àþQSÿˆ£âgýN:ÿÄ»?ÿæàú¦þ°ÿø&Ÿÿ+øg/Ùëþˆ?ÁŸü5þÿåñ|Lÿ£‰Ç_ø—gÿüÜTÂÐ6ÿÓÿåaÿ åû=Ñø3ÿ†¿Áü¢£þ"‰Ÿôq8ëÿìÿÿ›ƒê˜OúÃÿàšü¬õ­;NÓô}>ÇIÒl,ô½/L´·°ÓtÝ:Ö -?O±´‰ ´²±³¶Híím-`D†ÞÞ㆑#*üf'‰ÆâqÌf"¾/‹­WŠÅbjÔ¯‰Äâ+MÔ­_^¬¥Vµjµ%*•jÔ”§Rrr”œ›rÝ%£’I$’²Ih’JÉ$´I/ºÅÊÀa@P@P@PÿÓþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÔþþ( € ( € ( € ( € ( €?;þ6|pøãª~Øì·ð‡Ç¿ ~ Øè¿³´¿´ŠÎ²Ž/.¬¨ã3lnY¤ðÒ÷“ö¸V£Rr„>Z”Ò“š‡>;ˆñJ5aN“Áâ(QÍ9éóañtÜðø6/QVàíé¸%%ÏîÎë”õûÏø+FŸ¥Øü|Öcý~(ø“Áô_‰±]|AÓÒòÃDñO>x‡Â~ñw†ooµ ZøGÂSø‹Yñ£'€vxÇ_¾Ö-|9©¶½¤xMæÓâºàNrÊéÿkà©b3J˜IG .YU£†Çѯ^…hÂ8o]R§J z4¡NU£ìêWåŸ/Sâ…ãgýŸ‰©GêUãu •°µ)R« IÓ*Ns©'E*Õ'%MóŸ4y½·ö€ý¢h 'Wý¾xkNð?ìóñWö­ñ74Ïø›Ç«Æ á>ê~<½ðΑo£k~Ñ2Êp”ãGŠÌêWU*V¶.U‡¢ë:QQ©FkU|±§ïòé-$Ògšø‹þ EâO‡Þ$Ô¼/ÁÉþ5MàÏi¿³Ö±ñ/À~)Ð|%mñö›»ýŸn~<é¾ðg½FçÅ> Ó<â.ÞßH·ñ}׉µDѵ­PB–æ¦ÝëUÙKƒèâéC³ìÕˆ¡<ÒžB­w…ÉãšG-©[Ž„hQ–*„äêK¨ÁÔ§ gJ¤ãž§UÃÎT^ë~ʬpRÄQ­ K˜<ÅÆ4½­EF¢\Š´§hÎZ*‘‹‘ÁêŸðYOêV¥ð‹àÄOŒVÞ/›Sÿ„ øZòîòãÅñx/à·Ã_‹ÿôíOðç„üW«?Š|wñ[Âß-´yôètSÆÐkðë&𞙢O/U?q•Xãó\.^ðê/í¡ªß1Åà0Sœëb0ôý†&8*Ø·QIÎwIÓ¥^uc qu)(<.¾)Voغr“u}–†+ÆÓö”^"•^ITöœÕiÆ›œ½Æ_ðS=SÖõ?ö{º|0ø¯kðWÃ÷ž-ø£aá­âGÄeøm§ü[×|5 øDð_¼qm©xÁ­Ýõ¿ö ùKȵQvÖ.…¬kÖ\˜n §ZY})æÑU±¸™U «ÑÂ`þ·< :Õ1SÄa°Ò…\E9F/ÚÂñäåR©V)o[ˆçN8ª‘ËÛ§‡ÄýR®*4êV®¨¬D鯄iT¬¥ -JV„¬ïv£ ηš»O üñιàà™ûC|FñE¯ˆlßZð'ƒuÙÎÏö]øvÏB¿Ñnm³5}áý¥íÿt9ïüª¥”Zjh˳wÓþ V/Þæ¸zxš¹¥L§EЗ³Åb!›K)÷jʵ:‰óS«‹”!‡«É…ƒ“—?<#—ú×RÔðçFcñEÍB”° ¬)A®Y‚”ªÓæ­+(¨%9}Ãû#~Ó:¿í?àø¯\ø=ã?ƒ·ºˆlôˆl5Ò<7¬Ã{k¤Íe¬Oªê_üeg¢\êZêM¢ºÍ¦EöÍ8Ý€t‹ñ7á»Í©['Ä=Æ‹u5ޱø¯Ai´›Ûhu«›‹=J!|d±º‚ÛÃ~"¸šÞéb–(t jW@š]óĕ⌟ <1á¯x»Uñï…ÿ°¾økÄž.ñ}ƬYë:/‡ü#ho$éßìõ¯xGFÐtØßüeÒ-4?‰~#ÑuÉ´›ñgâOiº~m¯j“Zݾ¯…œzœW‘@ˆº`8ƒ5Ëñ8LM,]Z¿T– Ó¡ˆ«VxiC/©*¸:5)©ÇšŽsœ©SN*Rp廿œVSÅQ­Ft!OÛ¬G5ZP„+Fx¸¨â*Bn2µJ±ŒUI8ÏE)&’‰{Dý?e¯øZhÿ³ï  [ÛxÞÐh–ÿü1Ÿ,?ôËâžÚ-5!˜øÛHÓ4Ý+ÄÅÐ[LÓìtë¡-••¬MN Îê×xŠ™®>UäðÍÔxª®WÁÎU0¶n¥ÒÃÔœêQKHNRšJNNNN[Nš£SJ²åT)Ùýb*Û´RýôcÔÑ©F1‹´R‰~ïöSýšoµßøšóà?‹{âV•.‡ñS›Àþ{ŸiSɦÍueâ2lY5Xï%Ñ´‰oší$–ùô½=®Þsgnbˆç¹Ì)a¨Ç3ÇF–¢«…‚ÄTK4¦£*>õáʪTQQqQSšJÒ‘O+Ë¥:Õ êb"á^^Æ«âÚžžõÜ åuvãù¬ŽÛâŸÁÏ„ÿ|0<ñáÇ‚þ'øQ5 ]ZÇ>ÒüI¦ÛjÖ"AgªÙ[j–× e©Û$ÓÅý§“w7¬¾TóFüØÃ–ÖúÆ_‹Ä`«òºn®¬èÎTånhIÁ®h6“p•âÜS²i3lN §ìqt)b)))¨V§ÅIm(ó'Ë$›\ѳ´š½›9Möaýœ¼1ã­ âw†þ|'Ð>!x_ÃÖðߌ´oxkMñƒáÍ+HÓ4#R³Ó¡¸Óí´ïáû²´RZh?ñ%‚DÒËZ6õ3¬Þ¶® ¶gŽ«„­VUêáêb«N•Z³©íg9ÂRjNU_µŸ5Ôªþõ¥;J9C-Ëé׆&ž ôà©Ó« 4ã8B0öqŒWŠ?Ý«;¨{ŠÑÐÇÔ?dÙcUð^‰ðêÿöyø;?<5â-gžð˜øá¨t-ľ#¸¹ºñ·¥iðiñÁa¨kó^\n{eµdžHoÅÌ-å®ÏóºxЏ¸fÙ‚Ä×¥N…jÿZ¬êÕ¥I%JœæçyF’KÙ_øoXr½eʲÉцX #¡Ns« ^ ©QÞrŒRI9Ýóµ~m¥Í¢:þÍŸ³÷Œ´]Sþ+ø/ðÏÄ:·ãh~$êÚN­àÝòÃQñü=§‡SÆ7vÓX´sxˆøzÂÓ@—Uuû\ú#HšWÓí›*9Æk‡© Ô3e*´ðßS§Rбœ0¼ò«õtÓOÙ*²uU?†5´¤”*eø Е:¸<<á:ßX”%F2¯Ê¡íZi^§$T9·p\ŽÑ÷Oš,àš?³F™ñêVv»iyiö´øomƒ-þÛØé¿“àu—†VÒßÁÑxÂ_‡°|ü=ð—Ão ]j2ê÷:'ƒ´K-NŸSšÞÚÑï%¶±Š4’agggg0Ä6v–¶¬vöñ"øìÙUUó ]|ehÁSLEIUš‚”¥Ê¥-mÍ9I÷”›wmÊ^¦…ÁSt°”)aé¹s¸RŠŒ\šJí$µ²IvI%d­J®3¤( € ( € ( € ( € ( €?ÿÖþþ( € (á¯Úö)ð6¥­àÏŸ—Z[j~&е{Ý>kC㎻}«ûch·†K[dÕ"Ô€[A§hZuç‚îuMKÇ··6f÷Åzx˜éŸ°Ÿì«à¿ühðïŒjox[ž²÷‚N•¬x/øSEð·Á?ÿ>-x›â…ö£áKm´-6_ør{é—wðÆ•ñáÞ¨môû¿øG,m>øø/û<~αßм]©Cñ[D³Ô"üLøFß¼%«xU~&|ñ0ðoÅR$kþñA³Ô‰¯Yýë[ß±ÎP(-½@;/x\øÁ>ðYñ‰ü^|!áoø\ø³ÆÚ¨×|gâƒáý&ÏIÿ„‹ÅÚØ‚Ôk'ÖþÉý¥¯ê¢ÚÜj­ÍÝØ‚7ËPÌŽ?±WÇψ> ý§t=ëàwˆþþÑþ%ø‘â?ÄQ¨Mâû'Ʋ„?fíáŠ:|=ñ¾Ñ4_xZûZÔjÞ!x<5ªÁ㟈_ <û2OàïB÷š¿Žîït/\ø‹M¿º×¬âôïÚ—öEø½ûDxöïøo¥k³ø?Fý¢¾|Ñ| âKOMSÀ~'ÿ„ÿü?«ü$ñÅݺ]kÐׯÞ6ðÏŒ5¿ìë7»Ö¼?«_Ûiö¾ ²_h”è?´ìëûiøÖ/‡iðOö†´ð§áßšÇ|Uªßø›Äº.ƒ«üCºð¶¹agã-+ÀþðÒÙÙë‘ëÓhñ[x‡_Õ|Y¢hþ½Õï´ß‡PøËÃ~×'ã¿áŽ¿j›Æ¸¿Ô¾¶oêýÆ«âm\Kà'ìÇûlxÆõ6¥ãÝ7ÂgYoN³ñÆ>%ðÿŠï.¼gáÏíŸøwOøqðêâ »ÿhðxÖÇEñ߈ügáOYø»Æz5އöËjš@•kß²OüÄ?ð›\ÉûFèþŸSñGŽx_áoŽ®´|9ðÂGðé5 |QñOˆ~ë§Æ–>¾øq§øzßÄ:QM?Hèçý•o5ëæý¤.îukŒº_Š4Ë1ñkÆZ_ÃÖø_aâ‰:•¿…î|á_†ZŠôW°ð‡Œ¼1à{­#Áÿ4»/j¿¼'ã»Ë¤–Û[ð¿‰À>Éý|âÏ|)ñ4^.ѯü7?‹?hÚwâo‡¼9ª¤Pjš/‚~)þП~ ø2 FÆgM*þûþ#Óõ«½œ\è÷œšeüVú…­Ý¼TP@P@P@P@P@P@P@P@ÿÐþþ( € ( "øù¢ügñÁ‰zìíão ü7øãªøGW²ø[ã¿xj_øGÂÞ1šºN¯¯øjíßV°¶›—ƒ7Æì—ØjpÃ&tÙxËÆwü§üCÖôøþÞ²ñψü?¤Ë h> ñ…®‘g‰µ½BšïP›EÒ5]i/¯ôÝ&[ûÙtë9á³’îåáiœòWãŸۋ[ø»ûX|Dø_ãߌð‡†üsðº|>Ñ鿬>[øƒÆ)àoêþ‹JøÑ«ø3TÒ4 Ç_¯ÔÛxŽÃK½oí@yý•->9¿Ç¿j¾2ðoÆ|ÿ…56‹à]âOį|BÓν¦þÕ?´ŸÙõùåñf³}«Ùx³Åÿ¥øQ⑦j¶Óê^ð^«áo‡ók7á9`€ôr€ ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÑþþ( € ( #øõ}ñ»Lø3ñ+Pý›t/‡¾&øógá-ZãáG‡þ+êšÖðãWñ¤pÒ,|a©øv7Ö­ti¦nO6óHÞ\&öÂ9öËÀ“xÒãÁ ¸ø‘cáÝ3â$þðôÞ=Ó|!y¨øOOñ¤ºE›ø¦ÇÂú†«okª_xvÓ\kø4KÍJÖÚþëMŽÚ{ËxnHÐó â?í!ûG|)ý¨>"Am£øçâ§ÂXüIà-*Î Ήσ¾ø;Ä÷ÀÏx¥<_¢X|*‹ÅÞ+ñ–—â¯|HðþüGñ¿ƒü]àˈžñw„¼'ð·LÖ\²ý™ÿkÿÚ/âçÅø_âGÀ”ð/‚éöz¯Äoˆ7ºtX<5á 6úîÆÞ÷Y¿|,æãÏ‘UÅ¥½åÙ‚ÎpËÀž$»ñŸ‚<ã CÂÞ!ð=ÿŠü+áï^ø+ÅÐZÚø¯Á÷zî‘gª\ø[Äö¶7wö6Þ!ðü×O¤ëPYß^ÚéZ\Çows ¤Îù#ûWÿÁF¾4üñïÆO xKáß|O¥ü0ñ·ôKF¼Ó¼O{¨Þh^ ýˆ¼3ûVÜê:ì¶>&Ó Òlß[Õõk~ ³³Ô‡†ü)ñ¿†|I©Ú¾“zwáçü£âO?i ~ÎW_ <#iu«~ÕŸþê~.±¼ñΈ߳¥§Ãÿ:×Â/hrÜ%¬W~;ñ×Ä?ßüa,ßÙVV³¤x‡K±ÖôSOÖ´mNÝ.ôÝ[I¼·Ô4ÛûY?ÕÜÙ^ÚÉ5µÌJM ¯U›ª€iP@P@P@P@P@P@P@P@P@P@ÿÓþþ( € ( KÇž>ð?ÂÏø—â/Ä¿xgáÿ€|¤ÝëÞ-ñ§Œµ½7Ã~ðÖ‰bžeæ«®kº½Í¦›¦X['2Ý^\Å’«»s(` ]ÑñÖÿôñÿÅ‹>ø½¤|5Ó¾!èÿ´ÆÏñC[ÿ„6×Ç^=ñ·ÀŸ‡Ú'ön‡ý¹¯izÄõO‚^*ð'‚-ð_Œ´M7Äžñ.‰|ž]æ•®hZ½µÞ›©Ø\§ÚÞ[K­·r©P BÑ|/¢hþðÖ‘¦xÞÒ´ý @ÐtK ]+FÑ4]&Ò+ +HÒ4Ë ²Ó´Í6ÆÞ + 8!µ³µ‚+{x£†4EüÕøÝû'~È_¾ |eñ??h ¯ø“Ä6Ót/ˆZ%¯Ä_„–ø'Ç_>|+øàÿ µŽ»á}KSðçˆüká/ø"ãÀš&µq6±â{^{­JÏYÓôØ€/ø“þ ¯û5ê^$Ö†¿ãÿl|Ið¯ÆiZ>±}ðªûP´Ñþ%xƒão5sðõµß‡7ºö—¬|;Õh‹‡†uíò]vßHñ guhš]¬@~x3UðŸØïüáßXë·_ $Ò|â˜þÆçUÐ5{o h:í–Ÿâh,Ä+¦ê÷ž×²Ñî­5KÍrÒit«[ Ë;»‹´‚êÙÜÑï/,ôë;½CP»¶°°°¶žòúúòx­lììíbyînîîgxá·¶·†7šyætŠ(‘ä‘Õš€9¿ ø÷Á;ƒPºðW‹¼9âË}+VÔ´Jk6¼V:ÎŽð&©¦\Écq:Å{`×V¿jðñ «vl¤ñ;€oj:¦™£ÁÖ­¨Øiv³_éš\7:å½”jzÖ£k£èÚtS\Ér_êú½õŽ—¦Z#‹ýFòÖÆÖ9n§†)@24xGÄ׈|7¡x›CÖ5ÿ ¦‡/‰´m7S³¼Ô´|M`Ú¯‡fÕlàšIì¡×4Ô{í&iãŽ+ûhå–Ù¥Hܨ'ÇŸñk÷^—ãÂØ|McâMÁ·ž—Çþ‹[µñ‰µKíÞŸK“V[ØüE¯ëšf§¢hÚ+@5-OXÓ¯´»+i¯í. ˆÖ¾ê³ÛÚéŸ~j77wþÒímì|}á[©î5?ÞëZg‚ôø!ƒU’Io¼]¨øoÄZ†-# >½{ kVšR]Ï¥ß%¸§†¾-ü+ñŸ‹|]àüJðŠüqà bƒÇ~ðß‹tsÄÞ žye‚hzf¡w©xvæi š(­õ‹k)¤’ •c&)€zgiúÆ“«6 šV©§jo¤j3èúªé÷Ö×­¦jÖÑA=Æ—¨-´²-FÞ«i§±¹òîbŠâ $‰RhËhÐ@ú¶¯¤è:mî³®êz~‹£é¶ò]ê:¶­{m§iº}¬C2ÜÞß^K­­¼c™&žhãAË0  ñW†¼e¥sÂzî•â=jšöˆÚž}o¨Y.±ámwQðljt§¸¶y#MG@ñªèZÅ›•¸Óµm6÷OºŽ«i¢P×¼Y០6ˆž%×ôø—^±ð¿‡Î±¨[iɬx“TYŽ— iò]Éw:ƦmåMÓ¢fº¿Eµ¤RÎè”ÐP@P@P@P@P@P@ÿÕþþ( € (ule’qš/΄M›œ¬Ðù‘ä´~j«4{‚ïUb¹¨Èþ:|ð?í1ðOâWÀïj~$ƒÀ¿ð߆üàÿ |3ðÆ£y}¦|5ð¿…üfšÏˆ.üMâ[}/AЬtݼK¬ê—WšÞ§¬Ýév–×Wz¶µq6¥¬M$š•ÔóÍró8æßÆø&ÝçÅÚSÄÿ´l?ì4‹kã_ìÇñI¼ú5Ådžü@¿³Wˆ~ j¾Ô¼Y"ÏÜþ2ðæáOŽþð•ÝŽÝ*+o–·ú½µÕÏ‚4ĺùÏáü›ö±¹øeámW^øíª|ñåçÃÝkÃú÷‚äñGŽüptÏàíWà â-G^ƒâ>§iq®x俇¬>! êV–VžðÆŠþ¾²ñI©DõÿÁØ—ÇÿhËïŽVÞ3ð¶“£x†/Áâoøfçâ=Αwaª|ýþøoEX¼Kâ­BÊþËÁþ-ø7âoéwú¡ÕJñ¢i6“ØEe$2€QÓeÚwÂ~ ý ,| ñSàþ‹ã/Þ7²ñíî¡wájpøZ²ðÇÁŸJ<â}OÄÚ‹tû'ð§|o'‚í5Iux¾]ë>Ñ< Ÿ ø¬õP{ãìYãïø_áϯ ÚøCÓþ ÷ñ÷ö2Ôo|ooà…"ñä?®<¬h¾×¼Xž2¾øy¯ÂcÃÞ]Ÿˆ5oÙü/öÙæKC[ÒÀ8›Ÿø'wí ÍÌ:/íeiáuü]{©xRúçâý¯„SYÿ†Ã·Ð|àEüj³MàÝNý©|;mpú嬚Œÿð¥ü,–1iÖ¡Úx8Ðÿg?ø'ï‰þ|i‹âß¼kàïͨø7âÇ‚¼F¶ú_Šôíq¬¼/ÃkËý+X—Ä~÷>ñ,"’öž{m_M¹Ó¯!¼¶¹y@8¯ÿÁ6þ1xfÓKƒÅ_µW‰>%6¬|½ðì~"ÿ„ÂÒÛFµøWñ[á­×Ž Œ/âOˆ?³÷À¿„¿'´»ó¬‡/>/üFÔEì¿um2 ²Çü‹Ç¿³ŸÄ߃ž9âO„NŸðÏÁ >ëš_„m¼{£EãOü9øñ3ቶԴ»ï^èr\ø›Æž)ðgÅèõ ME4½_¦ËO¸}º}å¸ÿÒøƒ®xKIø)ãÏŒ~ñ?ìÿáÏ _Fðí·†.toË=ׯO‹ßî~#Kã[idÕôߌ<¿ü1káírËP›E¶ño!ø›§ëz³XXt? à| ¯|'¾ñ?ÆÆñøfËöeÔ~%x¼s¡x‡Å¾6ý™1Åqâ+9ŒÿðŽò-_G®[ ܬÿe‰v^!ý§ï4ωVÞðwÇüAÐt‡ÞÖþ%Øi><ñψ|Y¬MñŽ}RûÅšŽ¯ð÷Ç­¦x‚ÓEÖá4º•ªj¶³xÑ,íu(ô/HùJ_ø&§ÇÛË ëMcö§Õµy.<àOéBÓPñǃ´ÍãÃÞ>ÓŸ è uÿü³â¬~6ºÔ¼;û@kš'Ë_|XÕ¼#ðëIñ‡Å?§…l|U§ü?‹Á2CâÅCÄ×zŽš¾Õ¼5âxãÕ,#ºðωï$Ò/-oW¶×=Ûö+øÁÃoÙËÀ—?¡ÔOÂ;ߊ+㸷ñ>œž >7ñ,^ ðÄŸ 랎ûâ·Áˆìa³Ñ5WH´ðwŠïußë^ðÜw¶:5 ˆÅÿÔøß>™à»]oö¹Õ¥ðÅÝ•äÖ±ëŸt»½²Ôÿc_í]VÂ{/VkßY~ÎuïÁ«]ÞZZx§öñYÓ„ñÇ®j^'ò«ø'íW®jß<#ª|g¿ð¶á¿†þð‡>+7Œ> êËãéÁÿ‰õ?Â/Äi®´ xoV×þx»SÔõë(¼U«xÇág…eÓ/.ló¬ià½âïø&ïÇ/ÍñFKÚJëA¶ñ¾ûAŸhú§ãß è¿¿k>ñïÃÃÄ~}æ›vž/øGá/im$–ú xL¬ñ×ìAñ7KÖ¾ Ûü?ñê~ø“ñKöH½ð·ƒîõíkX_„ZÀïß þ&x»ÅÄÞ6ñ$šå¶—/†¾Ëi¤øG-Y¼wyµ¡¯„, 5?‡úÂÿ‹¿ü/ã8&’{¶ºÒ¼¾•ymÍÅ€%¿ìkûV|/ñM®‰ðÇvžø?àÏxVóÀþÓ>"]x~ßXð¿…t¯ØÂv¶¾:ðå—nlµ¶¸ð—Á_Ú®ÎëL»¿¼‚Gø•áÈEÚÃuŸ €yφ?cÏø(Þƒâ?øÂÓâß…4OüBÓ<oâïØüUñ£/‰>'ø3Àá=âåõ×ÃX¡øw¢ø‚=_Ä©û=[ÀžÔôOØx~ãSOøEQn=noÙ‹þ š·Ä[i?jKû=¯ÄX¾C£xÊòßÇšLÖþ7ñ’ü$»ñ­­x&};Y’÷áßÅ]]¾$i÷÷¾$ø+ðŽËÂÚ¾ˆº–¯â}ïÙ×ü'àXtÏŒú”¯Œ–ÏÁQß^éþ6ÖO‰Røfˆ©á_/§ðTZ¤> ›Æ«¤ZKá(u·“Z‹Ã2k¢ýôµy$Õ#ÒšÕoÝ®ÄÌÀ•¿¾6þÜ_ ¾7~ÐOð·á¯‹~&x¾!.£á=?Äß ¾$xÃBOxGöiøâøGþꞼЭì[Ç?µ‰ÞŸX½>+†ßÅQ_-¾™;è¤Ýp,øïÿ¿ðoÅφíð×V›Q¿kGÓ>&hÿþ.x;ÆRëZˆhý ánƒðºëÂv¾&ð°ñn‹áß |ñg‚¼G­]Øèÿí>"˧xjòãÅ>Ôæ¸ôŸ?h‰>-ÞxGÂÚßÄ K]áWì®ø‡Ãžµ¼“Æ©ð×âŸÇ¿ŠšíkñÃþ³Óî5ÿøÇþð?‚tké4ý/Tñ'ÃÝPÖµ? é¶>(×-¦ºÇñíGûbø/x3áOÀ¯ŠŸ4?x[UÕ~xÛâÿÀ‹üW£Çà_ÙûWðqñýî‰/‡-î|e¨xÇÅ<7¯xy,t/ZXx@»Ö4Ý+P>)ì¼]ñçþ á]KÄ~™ð·á¿m,~;¿Áý+Ä)ð[ㇴ¹<=aðCLøiñfú×AñoÄÍ~÷À~7ø«¨Ëð’ cÃú¡¢xi×Z¶·¯ë3yñÚyoˆÿh_ø(oŠln4»Ï†ÚÇt‰üMâ;-GWð/ìíñrjÞý¹ü% höíwâST¶ñ~+øAû3x¾/ˆžŠÎ×ò|lðüú®Œ¾)>¨è³Ïíû^x‹á·Ç{_Â:'‰¼Iû8ü²—G»—Â)Ô=ð·u›+Ï?ÄxxÇÁŸü#—¡k÷ž+Õ<$toy÷–S€bÁûQÿÁDu(ãðü_³¥•¶½6±s¡Øø•>üKÒt?¾£ãi“_Áˆ¼[-ŸÃ»O‡ñV³ã©5êšÎ‡ñWSðm÷„<5&ƒ«µíµ¨Oª|mý´´ß‡²ˆtŸk¾%øƒãú|¿µþüLÓt_ üL×~5þÉ ×§ñÃÍ#XÓu-ÿÃ?üiñßÅveƱ§E,^Öuë6jóþ£ûzþßú%ü?¯ü ð~‘ñWÇún½{à¿ Þ| øáfþ:ñ&‡û=¿¾ºðß‚tÏéwþ!Ó }ï0ñO¤ÿ…÷ûQÇðÿÂ:,ÞÓ¬ôï³xoÂþø¦ø{Bñ± ê¾.øuãqâO êwãN²µœ§Ô?j¿ø(¶™.³¢ÛþÏ^×îÏ‹î4=ƲüøýáÏ ézM—Žÿkßéz¾» éš—üW­éþ2ƒà·ìñây/ü-ËàoþÐñk­¾«¢XiºÌ uÚ7þ sãxtË„£Ið®™ñÊÞÖ}CCøñ/Q—TøSiñ‹ö¦ø\4MFÿ[ñö÷²x£Ãþýž>!ÿÂÂðåž‹oá]âUÇŠ5 _—»°áãý¢ÿà ß?á@Xø·à¯ˆ~Ûkß?gø§Qøoð»ã|÷é¢_tÏŒŸ ¼{.½m¤[ü?Óüá=câ ψ¼Q¬ZøŸÁß¼g¡àÛè'Òµùm=ËÆŸ´_íÏÄx?Áÿt½;Aƒâž•àÅzß¿‰>,Ò|=áGãŸÂO‡úOïµ ÆÓ¾$i¾$øKã/ˆÿµ!á[ÏÚ|* ¿áñÕëϪý©*|nøáûx|3ø±ñ#DðÃí3â?„Þ6>¿¹ø/ñ2ûÁž!ð7Å9¾#øÒë_øswâø–Ê?Š^ð'„u_ØØ_x“Áñý.>ÓáýP¾Ô<ÓÅŸµüfÏ[Õõ}à+^éÞ Ô?h‹ Oè?>"ßxâüÓí¼i¯êšGŒ´}WXÓµ-_ñLþÐ|/wâ¤] ×þ'³ñ…¯X®­ñŸöÃñÿÄ…Ú/Å]Å~h×¾8Õ>ý˜¿g/|DydøãO€ÿ|Yã™'±LžOøáÿ‡µ<Úl0ÛŧÊúÕåëIc¼Ú96é KE÷Š( € ( € ( € ( € ( € ( ÿÐþþ( € ( € (  ’iö2ÞÛjRÙZI¨ÙÁuki%´/{kmzÖïyomtÈg‚ ·´´{¨buŽvµ·iUŒ1•·@COÒ´½%.£Ò´Û 2;ëûÝVõ4û;{4»Õ5)ÚçQÔ®–Þ8ÅÅýý˵Åíä¡î.§f–yÉf¿@gÜé:Uåö›©Þiš}Ö¥£5Ûé…Í´÷ÚSßÛ›KæÓnå§±kËRm®ÚÕâ7äÃ6èÉVР€ ( € ©acªYÜiú•¦£§ÝÆÐÝØßÛCwgu }è®-®Hf°7G":žàâ€-Ð@P@P@P@P@P@ÿÑþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÒþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÓþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÔþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÕþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÖþþ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( ÿÙ££PK!yxgzòçword/settings.xml¤XYoÛF~/Ðÿ`ð¹Žö&)T)xmë n‚*ù+j-³!¹Ä’²êüúIÑÊ16ŠôI˙뛃ýúÛ?M}õ`}_¹vÐW$¸²méöU{Ø?èë(¸êÓîMíZ» müöúçŸ~=­{; p­¿m¿nÊMp? ÝzµêË{Û˜þ•ël Ì;ç3À£?¬ã?»ëÒ5ª]UWÃ㊢‚³· ޾]ŸU\7Ué]ïî†QdíîîªÒž ÿ_ìÎ’¹+m‡ÉâÊÛ|pm_uý¢­ùQmâý¢äᥠšz¹w¢ä¥›çpOÎïŸ$þ‹{£@ç]iûÔÔs¸©Ú'5T|§è êWõj¶½U8%Óéây_'d{ÎâÛjçŸÓ 0zÑ”ë›Cë¼ÙÕPT'*‚×PQŸk®NëÊw¶t5ðÜY_BÒ6£Q°/Bpîn;˜Á»ïl]OõZÖÖ€òÓúàM•¶ fÊ$³·wæXÌn;¸n122«,ï7å`ý¶3%hË\;xW/÷öîO7dPµ@%zó`ß{ûPÙÓûªŽÞNvæÒ½<öVoÍ£;_p¶sÛ€âÖ4ü|ÿÜ ·noÇŽ¾úßgó3 L˜Œ/rÐæ¾Ú[@ ¶Ûá±¶bÜVŸmÒîßû¡‚æšâxð’¶-¿ƒ¡ðá±³Úš3h¼÷%cSÂt]u·•÷Îß´{(¡ÿkluZ_Ò 3sßy97,i „æ4V|voä^8„r©2œF„¢.²¥ò¿Ñ&ØBeÕ4A91-rÔ }ž1L†2Áj‡J…h¤TB¤çæúÚk0-m÷ çYÜQ·Ã¸¤µÃÑIŒÅÃBF)ʉI–âœDñD£2©Ì$Š5Ë¥æ(:,W Gå„ŹÂìpÎ^;œ+­QAT¨ÏSók¬@£¾‰eTbˆ0¤е$¡ ¨Œdaž¡HI‰D+^*NÓó@Æ‚¥hdÂ’ ŲÃb4?²“eh~Ž4dh/(ÅŸ©¦Ï#øm1!Š›JIþŒ©Ê©*DÄÐ)4¤‚&h~ÂDx]‡1M ´B˜q…b&ŠhNÃBÈçh™kˆp&P "ՋƉ° h")^;‘"Œ¢ñD¡ 9Z½QF4Ã=ÈD$P™x<èt‰…Œ4:«bÉ ŽVb™ ^Ç1RÑ„*ã˜þšŸ„‹÷:p4Ú§‰–Y†¢“Rx3¡9Má:SÎ"|†¤J‘—‰¨Àû')chÒTò¢ÀæNšS¡ùI õLRR‰VbƹÀ«*“< Ñ,dJèÍv3Y$˜×YÎ$.“Ã眊Õ–KÅ-—¡ˆÑÍ•ÈtVå¡Èð7`K¡9Í p·£E„Wb!e.PŠˆÁ+툤f(EAþ–)4‹#4ÛZ0‚w–üÆ<Њëç¤<“¨×:çRO^Ãwêø‚¯Óf=î¥ïýr?ù¯šy]ÈL³ó•¹º7WXšõÎJ«váï,lîöKÎö¸[˜××3£oL]kXÆ4\šõ¾ê»ÜÞMjë[ã½ç¥ÂšöæI׸öYÿ»wÇn¶vò¦›?åsTˆ³¾ªÞVÍBï»í"ÕÂöùëØîß=øQáêÏi=ÀŸÓJôÖ´‡å‹Ý¶×·ãŠbM?$}e6ÁßæúÍûQ–ÚoÇÿ:ì­é:XáÞî@7A]î:Š ð´‡ÿ<¦‡ÝylâÁÓÈ›L9 ·Ï‡ñÂ|„[çÃ…Æ¿Ð`£Ÿï‰ M.4y¡©…ÿ¹œÖ÷°ŠyXŸ?Á¾¹Gú«kw²û?â&øŽ4ƒ0mZÉqpËz|Þ†û ¢½-+(‘íc³»lÓ¯fɺꇭí`ñœ›ÓûËÄ£b½wå lNpšè"Q9|–ò'ö¼Ïß4æ`ó®º\äd*èåª×ÿÿÿPK!î·Ÿ-|˜ word/fontTable.xmlÜV»nÛ0Ý ôî±(Y‰ˆ¸n téЦèLË”MT$R¶êÕÙ;wh>¡èÐ]ò7²æzIIvjˀЦ.‚¤Cñˆ÷Ü{.u~ñ‘Ç΂*ͤè!¯‘CE('LL{èÝÕè¤1!±´‡–T£‹þógçY7’"Õ̺ËÚ¥iÒu]Î('º!*`0’Š“ÕÔåD}˜''¡ä IÙ˜Å,]º>Æg¨ QuXd±¾”áœS‘Úù®¢10J¡g,Ñ%[V‡-“j’(R­!fç|œ0±¡ñ‚="ÎB%µŒÒãæ+r L÷°½ã1rxØ}5R‘q Úe^€ú…pNÖ„øvÉÇ2¶xB„ÔÔƒ¡‰{WÈ5áŒ(MÓÍ‹~G„³xY¢džÊOXÎJxA3Ëɇ4›ÂÀ\ñö{(G<(‡bâï½Óü -OûÁ,@€§ Ä|ÓÍ gO‡+Æ©v^ÓÌy#9•‚øØÇg¸‰Oq§wAÆ® 8‡ÿRKX·?¶‚ iµoONT bÃ÷ržú‚ å\1ªŒ$ÄhÁ·bÿIŒæ1ÄxÞ4=IWJqZØöZ]OÁ(CÂÇ`áJ!|kŒÜ Æ(ð\-Äãû ˜ ¤fǰió:Öhõ rûõþö»s÷ùÓÝ—+ÇN.¥ EUšÞô³6nt·ò½9Ô`¯ËgÕrHbù>¾iÁÒmöƒ½t†é®Ñÿ0ÝëÕõêçúúz½úöd“>ƒWÿøølíú&íGpxåøoº~ñs û¿ÿÿPK!äçG°q®word/styles.xmlì=ÛrÛ8²ï§êüƒJïÙè.;µž-]OR•™ÍŽ3»Ï”DÛœH¢—¤ÆI¾þ HBhÔÍFòˆ—n°ïÝ@ÿÇ÷ͺñ—ÅA¸½k¶ÿÖj6üí2\ÛÇ»æ_çïnš8ñ¶+oný»æ?nþã—ÿýŸ¿¿|ˆ“k?nÛøÃfy×|J’çïßÇË'ãÅ Ÿý-¹ùF/!?£Ç÷/ú¶{~· 7Ï^,‚uüxßiµM&Â@ ‚¥? —»¿Màý÷‘¿&Ãmü<Ç)´ ´—0Z=GáÒcòÑ›5ƒ·ñ‚­Óîåm‚eÆáCò7ò1ïÙˆÞSPäõv þ·Y7›å‡OÛ0òkB¼—v¯ù ¡Ü*\Nýo·Nbú3úñŸüü3·IÜxùàÅË øJHJlëãhMrÇ÷âdž|sƯÑûOôAù¦xs'Àq° šï)Òø'yí/o}×ìôÒ+:åÚÚÛ>¦×üí»?îåÁÜ5Å¥{×ô¢w÷# ì=|iú¯ôÅÏâûÙSòÆ6ß3i#Äó>‡Ëoþê>!7îšDbá⟾DA‰ºkÞÞò‹÷þ&ø¬V>îôÁíS°òÿóäoÿˆýÕþú¿æ ©â2ÜmB‡áX¶ŽW³ïKÿ™ÊÁ·õ(;~£/.ÂIx`@»`?v!ƒ.þ7EÙfÔ.Äòä{T0þƒˆà«w•uèÉp­ÆÚ­¢WD¿:b™ªÒbX1ÂUGÁdC’J‰Âí£‘"¦¥mòlóüäÅ i ¤ïT$ýW¢4þ/ VFT}&|¹o‚¢Ð…}Y{Kÿ)\¯ü¨ñÕÿÎ8jñþoaãþÙ[/h\E¶~Ÿ’Æý¸\#²†èzJ0øŸƒhpP™šO1Gñp ‘K=ð_ýU°Û¤¤AD#fÏ-ØœACÊÚoʈD$€ø¢zŒ7Q=ƨã@TÝx›‘Ôg¼¸¬mƒ°©²ñF ‚GlR}H6ÞDÖ¶Y;^3Jý@9œÜÖ`¼X¬”7Þ,ÖÜÑo.xÄF2¸„©CàªÇx#Õc¼ˆê1ÞDõo¢zŒ7QuãmFRŸñFಶ Â¦ÊÆÈÚ<D²ñF ‚GllC¡ñ­?ºñF`±fPÞx#°Xs'cPEŠÀeÍ  .a¼¸àaà¸@¸m>ªãø¢zŒ7Q=ƨã@TÝx›‘Ôg¼¸¬mƒ°©²ñF ²6‘l¼ˆ¬mC¡ñe<ºñF`±fPÞx#°Xs'cP…Cà²fP—0Þ\ /•7ãÀem„M•7‘µyˆdã@dmè:[²^½<µ­ì:ƒtUaGÃ$,Bþ¿û~D:¢|óêŠÓ/´À¨ì'ŽÃð[·°»«4ª`±BXÒýVéHÝáN‚¯ÿœ4>²˜Ü{ RêÊÒc$· AOm"ãL~<“–çte9…FZ‰ho‚~¶O¤!ˆ·õЗiŸyÚŸøe˜·åXÉÿ FxÑ€JçÓ†®"ü¾Í0,<ÒœôOÚk”C¾%+¨‹®¯ƒí·ôzŠfòäEŒ¼ûæôÞÁ±ÿÒ “u¥e«5éw'd #Œ‡4iÑOüæûÏ¿üpþølý~Ål…6y}ᓦ?BìÞM‹½üç2Jú|Dá.!Cö?ÿµNïÂã„¢iŒ£8£ÂV8ïÏ­pô¦¶Nysß G/ï[ጠömKºô3e·×ÝŒ¨AØ\Òç‹ÁÀe:Hh0î3ì[ëºôʾµŽ]“:ä42µ$ìô–”‚»F|y…X×-YaÖtZÀGç%…ËÀ>.gÏ)ë~É%½.$´»àÀ˜¡ûà Þ5àF¹üIà É4B²ŚIùϧ-vÒ% 3±Ì@¬¾{ ¹?ñ×ë_=Á$|Ö?ºö¨B@íDUP‹0IÂþýš´YåÁ°Ÿô#ôôÞî6 ?âý9ù-¤ÑH3+¤×®kDKiýØ„,›¬¥Kn0p‡u¥Àx2VnËv9/¤YÞT-[{Ú¾%ý pÇF"Ƥ×4KSš1‰ãL‡ywÔObõ¨œScH´ Œ1»$d¹¼”zWÈR©·SI+õr@Ú‰WþGòu^ÿw¹×™ÐËä¿fõÌ«Tø’œ(•&BöŠ@z• ŠÀÝ­âëZð'ëëä=Ýœ" Œâpd½º§AØïá˘ì$pü1w,äQx‚¸Rý&k- Xë)ë\ ›‡>¨vHíJ½F‘O¬úEf~î!ˆâ„0ä–‡nù`L¡÷@bniìG7€ôÇï;ºIBj& yÔ0pÁYFÊàN²äŽ}yTI÷6XsuL=|2§k*c…3×…yåשíé¿xä꜈†²l]“­$W!n{E\e%v”•[ê"Í¢¢Â­òA © Ô‚8†ö¿ýˆÅ£à:ôJ]¨‚õk ‰âžD6¼\û$“&6Ü#7SäçC°&Û¥LZô¯p“s¸¨zIzík@÷馎’Y, ¥<Ãè'°í-“‡P+¦Á Áá? ªÞ±6‘|ÝE ®ÒÕ»<.9U”Õôç·û€ŠèTH¼¤®¢ŠÏÆY½ùM{<z’ùÐÒ‘–,Ó19.¸üôA6ÀBÈ_U¬ed©æ²Ò 8`ê” Æ¸ê÷ Tì *ÅØø×o!¨ý†8ëb.°ì,s9œ¡XÄ\Óît>› _Âb®¬Ï|ËQW­ªwuµÒ¸‹Oœ*îºíu¬«??““«ÊLÎÇ]“V¿ÕÓÄ])ÍK”0Œ`]Üu‰5.#ÛjŒ»¸\ÜE§“j©^"¨][Ü…Àufκ¸ëq×lN‹½w”ã.õê[­vÕJ ŠqWwñ©ðSÅ]ÃÁm§;¡»R‚•f¯%îºÇl»Ì|€™Ò¼DÜeëâ®KŒ»Œl«1îBà:³w~Mõ.µk‹»¸ÎÌYw%îÌfSèw_"Ç]{Ÿù–ë]³: T1îb}Èë» çù)§Š»úóÞíP³r–-¾–¸ë¦5èöÙˆ`¦4/wÁº¸ëã.#ÛjŒ»¸Îì_SÜ… vmq×™9ëâ®cÄ]ÓùôfÆÚ:è¡Yrܵ÷™o9@ÖqWaß ¶àˆD‰‹O‹áúF`íì5¯o—­¤ÚÎRru;é,`×á+¶¦fVT× U¬v¨ª /íÂ˳wކɫ4ÁÕ3ÓgÔ”kt»´8J‹•ƒ™%Hµ)åE·X\¥¬ÂoŽIO%ÛÂ"ßSyiZà”ºc©ŸB¯{-ÊZ.Fd™Çå­QÐö+šbÄšlšP“ “ÜQs1ã‡Eä_¢Wìx.Hå@ìE“•Xõ?i[ÏKÓâÄÁBéqÖ+¨<³X~|Q-_N"êlÑ<~”xarÖÁ¶:9».9Óù rÝ®‹’–Ò -”ô‘tùþÉWUv³lƒÂ¥£ eJo°%¼/j©ò®eΗjÔb-‚<øuéûDÁ y#²H»Ž¿¿Ã+΄Œ²¢N+ŸD»µe8Ä`O¢ÞÕJqƯPÃyû+TˆÓÌ‹_¥>àŠqFæœAt™&b¬o\\YnCv£ÚÔ»“(1HGšB´}‘ôŠBÍ ¾á¸å9™ïä}Ì,Ê'µ6ÁÆ V{3YPœl (Pª`g„«Ú‹‹“¹ã팔qܡSÈœ.!×K—ït;qÈå»tKuzÄn˃WU¾Ct¸ÛûeÐ21l‰„µTù ײ|g„K5Ê•ïð›î^e¹Wi3ÊJ/‡zH»µå;Ü“¨wµòñ+ÔKçþ ÃpW¾S3$)ÓÀ•ïŒÌ9ƒ>èÊwˆ±¾qup廫*ß!ú­‡š|ÃqËwŽwF ¨¼³(¥Ôº—RaÜpÜò‘2Ω–,¥){á2w¼ò‘2NæN#sºü…\/]¾Ómè&—ïÒÅÞxù±Q’}L…z(Á×%4°%ÔRå;4\Ëò.Õ(W¾så;r:ŠQVÊx9ÐCÚ­-ß!àžD½«•ïŒ_¡†\:÷W†»ò]Åò‘9gЇK÷v—«®|wUå;§|F Tð Ç-ßGî §Ê;›ò][rÆ Ç-ß9Ù@P ÔJ(#Ü —¹ã•qö¨dùÎHYUæàWÁiÉäzéòn_`¹|—nPûÆËwˆý6íËw ‡|]Bƒ["¿G@-U¾Cõ,ßáRrå;W¾#å;£¬”ñr ‡´[[¾CÀ=‰zW«W¿çþ ÃpW¾«X¾32ç úpéÞîrÕÁ•ﮪ|ç”ÏH ¾á¸å;ãÈáTygQ¾«ug÷¸á¸å;' ”*ßá^¸Ì¯|g¤Œ³G%ËwFʪ2¿j.ßõ5Ç©Êå»~Ó9AüÞx4™À¾Ýù£O9‰ìËw ‡|]Bƒ["¿G@-U¾Cõ,ßáRrå;W¾»Pí֖Mve Ÿ²7¢Åö®¨õ®V¯0âù¿Â0Ü•ï*–ïŒÌ)õ!€^³·»\up廫*ß!ôä­‡š|ÃqËwŽwF ¨¼³)ßuf£y»I·|Ξ\©ž#þ5Ø&wÍîœf®€­ m.ŒŽ[¾3RÆ9Õ’¥#e/\æŽW¾3RÆÉÜidNg‡ÈõÒ«ïˆòÝ ÞòÝ`Üš¶ùŠ>R<¡†uoI/øÄØùðvÐÓ”ï8‰ìc*Ð2 l‰ü5“ßãöCõ,ßáRrå;W¾#å;£¬”ñr ‡´[[¾CÀ=‰zW«W¿B ¹tîoï<¾Dâ,W¾«X¾32ç ú ›¬BŒõ«ƒ+ß]Uù!Ðo=Ô¬àŽ[¾s¼3R@åEùn>õ¦­ÂòÝ>1›ëõ…–qNµd)ÅHÙ —¹ã•q2w™Óå/ä:º|÷«¿ v›û'olóçV°Û ~¿QþÐ ^ž‹br€-_Òj]záN›.{»$ä5Ì0IÂMúIjuÊø:e «á«E ¶êsÿËpÒüÖÍápäz﮹ð–ߣp·]ÁiɄކ3²Tµ}¢œQª(³—2%Ù@3¥ÑÌuQÚä×ÁZH‡êÆOB—kß‹(퀤wM@L~>Àç®Ù‚?‚´4ºk&þ÷$¥i²ÄÎež¦ˆ¢FJÄ2¼ÇmêŸbx…¬Ïhc}^©ðPT68‡V ]‘³^qÑiëgr0'ÕVbHaBÛÍ“ñª/¯Å ZÕ .Óú7ãd«@\‡X CCG"Käùº¾ ؉ƻõé!õ -0 A 3„KÉõJçÆXFŒ×âc ØÀFÛA8nfžqBÄ"¹ÐŽG½…¡ŽöäzÉ´ðÝh¹ô·$Þ£ +¶ÞÆO£îlzØ`6 2|ù°°ß^Éå‰Ù8œ›M—'º<‘ŠFüì-‰?…š5˜Iž®·9k€”9Ò–% ·¶ÎßeŠÖ‘ÁY™ŸqÒ.S¼k"jEgeYíúêrÅ´dV+i]¶H#ÚÅú>ù±öÕŽÒú,S›„Ë/·¼¥ËXd¶ÓšT¥\¶˜f_‚¡U&t´¯œ-š'ÓlÑÍ*²’Æ~"¡RšYK¹Ü´XÓ˯kŒŸ‰½ð‚éÔê»GËs¢ºDî¶[¬Â:'î‹iÞO 641öSkÒa²€ôo@Ùá™=FÓ2SM¾`á?„Qš y‰Oæû +Z[rÙe‹—-fNP”³E°T6ܼ¢¢•0Ñ-Œ¾PÅ‚ý4.=õpÙ"™B¿®¿v}uÙbš-ÖJZ—-²¨Âe‹ö¦pªùâüŒUdà²ÅëÈóg.ëæËŸ¼ìæÝÜ"dˆ.[¼¶è3s¬”œ-‚=°ò nnñºR—-^]¶X»¾ºl1Ík%­Ë]¶X¸#/¢‚è²E·õp“‘.*#×-W¢~âD;¡HoVhMä[mé[ù¢ähn“˜¤Ó^¼ ‚¯t»Ç»æÆû3Œ>޶q@s+ŸtLŒâÀ“oÎø5zÿ‰>(ßo.cX1ÏŽƒUÀJÿ°Ä/Má3XÄ'Ò•Ðr+–ÜÞv%» >JÌILsè¶o1‚Çx»Id†¸J¹§®BÙÚ“ÈÌä$r?zU†U.à’Ht¶snÔ–DŽÓé Ú¿rI¤*9çO"GýiVœD Õ%‘ôÈ&¶†›Oå»EtùTù¦—O‰3W3Ûº(®ƒoygŸOeº= )×`¬«•"À*ñ£÷T€êò© ΧæÙ|®VÓ¤Z™|uùBw}pùÔ1Îæ>O>Õ›tǃâHD•úòáöÛͧ2ÄÍø/ÒЉP…²µçS™1ÈùT] vù:Ÿ:7j˧&“IkZ\`T%çüùÔx>nO³»5ᱡº|Ê>ŸÊïp­Ë§Jïp=tù”ȧ9Š}>…ôÊÌO!À*ñ#.ŸB@uùÔ%çSýùÍlV8?ÕU®¾º| ¡»Š>¸|êõäSýÙ°ß-ŽDT©W¢~«é‹·›Oeˆ«äS{ê*”­=ŸÊŒAΧöCpóSל1qµ-r<7j˧¦ƒYw‹Õ夵d;2gtSÌ,'°}îZ&÷@€Ub-\1p8¸¨‹œËª6 4ÞBƒÕÍl:›šZµÖýêr„ä*úqÌnmܯ;“NñVdªÔ+²Ë=ÈÜ|‰þÏ»&”¶ zã2ÄÍ8ÅÓÌådÆ çu1ØÍå çrNÀÚrY|3.ÞíF•œóçÓùhHúQRÒ 9êáÜÂÞ¡K!Â6°¯¶Á »6®ÛIY—Oñ™º6¬x›½Fˆ˜Ì>ŸêÍoÚã}ˆ«ø£”k%ÖÆ!À*ñ#.7A@uùÔÏå^£Î¼xiµº±Ë§Þ‰š‘çLžU[4SQ`ÞÒmXñí1 wÛBHpÊìgЙô&Cu©KZ°U¥ÞåSò8—!nƥџBÙ\aŒ+Õ%3ØåSè|*#rà_—ºÕ–Oo&“Æ4œ?Ÿ Çóiñ: •¬.Ÿâ»RˆDqùDö¥X&~D³Ñå.N ä’wM œØÂâ£ï­H©=!ÏçR+~³ÑnÀmØ€"“OMýo·Þï‚AOêdûY¬ƒí7‚6^M±èvº€í’ÈÞPd·Öô•VkÒïNÄÜÛžá,.ØwÃ1+|¢)d·×ÝŒDÂØŒùîûã»|JJ>~‘]#~zœÉ¿À*º·ü‡`f•€âI¾ ©fw"aW‹Ø'o@²%;„¤&_— öÂß³¤ÍwÑïYÒíh³ Œ†ïYò<^EṫfÑäÃñÀz-ÙŒŸ1?#$LáÓÚ(vò‘ÞQ»f·…Ø EìYvéƒÏLÙÒvý\æL·vÙ—Â9—í1L¤F|3h"—Áo~´Mvn3örÙ/KvÍ,—K¤áÙKR¡´Vµ8’Èë…Tµ7²`ò ÇéÞK„åxä?‡q„Ñw?ñÞÁ¦DÄ[dù¯{®È~éÝÊÛ½/Ñ[Tå;ö’Ô]#jsãü(îØ,/l»À—»íÉFþóäoÿˆý@Õ}†0JŠ} lÍçÜ˦ú͓Β—‚óp½_üÕþ‹³<Ë?QMb| V+ $jµ»ýÁ„‘€k±B¢B¢›ý*Ç ó"¹/dØ04L%*þåÿÿÿPK!³Š®=VÓ±word/stylesWithEffects.xmlì=ÛrÛ8²ï§êüƒJï™H–%Ù©õnY·ÍTÍÌfÇ™ÝgZ¢cn$QKRñ$_¿$!4Hêf#yHÄK7Ð÷n Á¿üíÏÕ²õÍâ \ßµ»?uÚ-=ÁúË]ûϳw7íVœxë…· ×þ]û»·ÿö×ÿÿ¿¿¼|ˆ“ïK?n€uüáe3¿k?'ÉæÃû÷ñüÙ_yñO«`…qø”ü4Wïç§`î¿ £Åû«N·ƒÿÛDáÜcÀ6öÖß¼¸-À­B´•7O_u:7ïW^°–0Š# 7þÆûF+/‰ £/ðFôu»y#ÜxIð,ƒä;Œ¯3`¾Ýµ·Ñúƒ˜Õ;9+öÎÀ‡o«eú0 [ÿ,§ÀþOúFT˜hÉ ù+“p¾]ùë‡÷>ò—0àp?›ݪBz<§CÚ;áÌd_6Ýë>I Ó'‘÷¼O¿l àJˆ±à/­–œL vb”‡Øí8Â@È1P† âLG’¾—j¤ÙIÒ˰ŽBý= ·9«MPÚÏ믳#ë PÕ³S‹­lÅó·ñÛ­ÕüÃÏ_Öaä=.aD@ñ“Èö_Á6-ÂùÄò¶Ë$f?£O‘ø)~á?³pÄ­—^<‚Ï`³Ê*€ï×qІ;¾'÷qàeoNÅ5vÿ™=˜½)ßœÇIà(Xí÷ iü^ûæ-ïÚW×é•1„rmé­¿¤×üõ»?²ƒ¹kËK÷®íEïî°÷8ÓôßÌŒ7rþü©yÀ€Yyàöˆç?ýοú‹‡nܵÁ'àÅ?~þaò®}{+.>ø«àc°XøÌ}¤®Ÿƒ…ÿïgýGì/v×ÿ9CÃ+ ÎÃí:: Ȳe¼˜þ9÷7̦¾µÇØñ{¬+.ƒ´ v£árXñâS”]NíR,ϾÇ^ Ç¿Îz[Ñ›Qv×j¬½ú ®ëƒè×޶.-†õA@˜Sw\62RIgjιðee¢w»GdÙ)2¾Qã1¾Q ã 0¾Q`¸ñoع÷¹‡†+/E=¤I±?ÉœšÁÒukš:áZŸ¼Èûy›çó‚ùaï3–ÛÇ„6T4§ÕåC…,64P䊫Ae›<]mž½8€Ú„¨&é?³8¥õ÷(€XÓ€ªÏ…¯0' !J]ا¥7÷ŸÃåÂZŸý?9G-Þÿ-l=l¼9ã†ÁÕdë/Á—ç¤!s¹FJ 4D×S‚Ãÿ%ˆ‘{½ù@3p¹ÔÿÕ_ÛUJB42àöÜ‚Í98Äý$ºf,**±qŒ”)pwa?„O?w.öð)ã箨"|Âø¹ãªåc?­-Í &-’z ­uw.Ãèi»LuÀh†Ö,QЦ`­Ä>ÉH ­5X1Ÿ­ûù27ŠœZóbgG-°X³ƒcAe£ÏÅš)9³×µ˜‘5ƒr¸®,pÕ³µˆ¬îïþ·€•ˆmZikÕ¹§¡¸ R ýÏm˜˜cè+Í£bùy å’ØoѰõ4šGÅ&ä‰û; ×s|ˆêy@ Dõ\¡"|ècééHê;G \ÖfYz1;²eZ[f‰ÈÎ4ä7 ñ—F{õ²Pô›,Ö *úMkîä|™ô›\ùM.×Ðó(kSm&eí7³ˆd$@˜Q3Æ›€¨ãM@ÔŒñ& ªo¼ÍHš3Þ\Ö¶AÚÔ¬ñ& ÂGlR}‰(k¼ ˆ¬m·v¢f”ú=„²?¹mÀx°X3¨h¼ X¬¹£3Þ\øˆ$äpISGÀÕŒñ& jÆx5c¼ ˆš1ÞDÍo¢úÆÛŒ¤9ãMÀem¤MÍo"kó e7>bcJ7jýÁ7‹5ƒŠÆ›€Åš;9ƒ*ƒT.kåpIãMÀ…؃À…Âm3©fŒ7aFÍo¢fŒ7Q3Æ›€¨¾ñ6#iÎxpYÛiS³Æ›€ÈÚRj‘ ›š1Þ„5c¼ ˆêo3’æŒ7—µm65k¼ ˆ¬ÍƒD”5ÞDÖ¶í³…ý¢äí©]P÷¤»È¯4L¢"üÝò#è9ôÍ»Cj"LghQ#Ô)ŽÂðk‹¶±»§2ªàq„¸¥û;îÒÉ4"ô†{: >ÿcÜúÈ` ï¡H©;o Ç(Û.„=M¬qÆ™|ß@ËÎ&ÝYΠA+kÂ-@Ø1ú34‰¶ö2ëó±ýI\Æu[þñE* \L¦‹]EYð»6ÄðèAsÒ?X¯QùvP—]_ë¯éõÍøÙ‹8ywÍé3¢ƒc7hЊa_©@ÙéŒû½1ìaÄñ@“›âWßßüøñûñK°öcüóÚðú£=¬@ìë›ù?ó(Ûè‹…Û†ìÿòm™ÞÅÇ¢4Æ1œQi+œ÷Ÿ=­p즶Nys× Ç.ïZá9Æ|ns¶õ3eïºsÏ»èÐæBŸnvD#€—Ùz Ð`Ôç$صÖõ®Ò+»Ö:~-Ó!§‘©9°Ó›3 vøŠ& ¹¯ [(ò¬é´ÀI%EÈÀ..çÏ)û~á’^Ö]°gÌØ}°WïZø§\q€Ðð‡C2Xö¸äRÿùyÍ„ýEtüq±øÓã àþØ_.õP“p£té?1…@ÝFU9Pa’„+ýû6hY³ƒá?Ù$ôô^oW~$Z4rò[È¢‘v^2 ×¯kDJiýؤ,H›ˆ¬eKa0x‡w¥àxrVogírQ2 YßT-[wÒ½…þ¼c##èņã͸D qf'ˆî¨`õ˜œ3cÚKüh<À@l“còRé])K•ÞN%­ÒË´/ü0»¯ÿ«Úë\è³ä¿dõ,ªVÄ’‚(•.BöнJEîVñuü“÷u DEO7c€QNV¯Xö{ø2‚³:‚2¦ŽÅ'À•êŸ0Yë¬p µ.‘R´Î%º¹ošHµ}jWè%Š4z"dÕ§™û¹§ Š`.Ê­ÝŠÁ šBï baYìÇÀìÇï[vRBj&dÒ`óÐ= 3?Ÿ‚%—2î°¿ÒMÎð¢ê%ÙµÏ;S¤—:Jn±(”Fò| £ȶ·L VÌ‚ ‚ã¤ÚT½ãm"ź‹\¥»wE\r¬(«7èÏnwèT^RWQHÅçã¬ëÙMw4‘z’›håHË–ëX6.8ÿô!k€¥¿ªXËÈ6¨æòÒ :`êT Æ ¸š÷ Lì0*¥Øø×o¨ý†8ëb.´ìš•»v>ó-Ç]È:î*íáÁÞB‘¨`‰e1Zßî½äýíY+©¶³TÜÝ]€,ã>|ÅÂ64ÐÜŽêF¡ÊÝ@uá¥]xyòÎQ`Xv—&Ú¢fVúŒšrdîV¶GPi¹s0·©1¥<ë‹‹Ô‚E¸-Ã1ôTò#,Š=•ç¦N °;–ù)ò¾×²¬ålD–{\Ñ…m¿²)FîÉf 5T˜²5g3~ÜDþ)zÅŽçŒTÅ^6X)Uÿ“¶õ¼2-Ž,Tgó±‚Ê3‹íÇgÕòå$¢ÉÍÃG‰g&gWÔÖB'g—%g:×íº(Y)ÍÐBÉI÷ñWïŸ|Ue7Ë6(Z:JZ¥ôF[Áû V*¿‘áZàŒp™F=.e‡¿Îýœ(¤ÈadÖ‚i×áÏwxÅ™QVÔeå£h·¶ GìQÔ»^)Î8 5œ×¹¿R…8κøEê­gdÎ ôA—iÆúÆÕÁ•åVpÕªÙ“DÁ h=ˆ ÐöEÐ 5kø†Ã–çdv¼ËžcfQ>i´ ¾4n°:›Éº€âdƒ@J;#\Õ^œÌ®hg¤Œ ä^>Cætù \¯\¾ÓÄ‘-ߥGB¨gÐN[¼ªò¡ÃÝÞ/€V‰©`+$4¨•Êwd¸–å;#\¦Q®|G?t÷"Ë´J›QVªx9Ð}Ú­-ßàE½ë•PC.û+ Ã]ùNÍ2™­|gdÎ ôAW¾#Œõ«ƒ+ß]TùŽ Ðo=Ô¬á[¾s¼3R@åE)¥Ñ³”Jã†Ã–qNµb)ÅHÙ3—¹Ã•q2w™Óå/p½rùNw [¶|—ž,öÆËw„ƒ’ìc*Ð} ¾.¡!€­Ð V*ß‘áZ–ïŒp™F¹ò+ßÁ×QŒ²RÅË€îÓnmùŽ÷(ê]¯|gœ…réÜ_iîÊw5ËwFæœ@ÎÝÛ¯:¸òÝE•ïœò)PÃ7¶|g¹3œ*ïlÊwMÉY7¶|çdƒ@J;¡ŒpÏ\æW¾3RÆÙ£Šå;#eU™Ã_%_K†ë•Ëwºs³å»ô€Ú7^¾#œ·i_¾#Ý—àëØ ù=j¥ò®eùΗi”+ß¹ò”RÅË€îÓnmùŽ÷(ê]¯^aœÍý•†á®|W³|gdÎ ôáܽÝùªƒ+ß]TùÎ)Ÿ‘5|ÃaËwÆ‘;éò΢|×èÉî¥qÃaËwN6¨T¾3Â=s™;\ùÎHg*–Ue5\¾ëk>§š-ßõÛî“à_îÇc<·»øéSA"ûòè¾_—ÐÀVÈï P+•ïÈp-ËwF¸L£\ùΕïÎT»µå;£`éLÁ—çÎF´8Þ•5§ÞõêF|4÷W†»ò]Íò‘9U¢>ÐKövç«®|wQå;‚ž¼õP³†o8lùÎñÎH•w6廫éý¬ÛfG>ç¿\©~Güs°NîÚ½Ë\[IÚ\7¶|g¤ŒsªK)FÊž¹Ì®|g¤Œ“¹ãÈœÎÁõÊ»ï„òÝ ÙòÝ`Ô™tÅŽ>(ž0ú³¤güÅØÙðvp­)ß ÙÇT UØ ù=j.¿§;F†kY¾3ÂeåÊw®|å;£¬Tñr û´[[¾#À=Šz׫Wg¡†\:÷·sŸ"ù-W¾«Y¾32çú [¬"Œõ«ƒ+ß]TùŽ Ðo=Ô¬á[¾s¼3R@åEùn6™^O:¥å»]b6 –Ë3-ß)ãœjÅRŠ‘²g.s‡+ß)ãdî82§Ë_à:¹|÷«¿¶«‡go¬¿¿[Áo·ÄýVõVˆò\ÃlÅNçÜ wÚtÙÛ&¡¨a†I®Ò)©Õ)ã댮ZD¯=ò]Ÿãÿ‡Ëå縟h†¤#³{wíGoþõKn× üZ2лæ§áŒ,UmŸ,gT*Êì¤LI6%Ð\i4w]–6Åu´™êÆÏRçKß‹í¤wmD ?Ÿ ð¹kwð$-‹†îÚ‰ÿg’Ò4™S×2SDQ#%bÞÓõO1¼BÖç´Š³¾¨Tt(+œB«¥®d³^yÑië÷ |˜“i+R\Ðvóh¼*åËk1ƒVõ‚ó£Ää†ýÍ9„¬U×!wðÐd žozã Ùi¼kŸ}¤µW¡1Há¦è1ϸÞÌwc,#ÆKñ1lP£‚õ‹$œ03ŠÏ9!°H.´Qoih§£=\¯˜¾»ŸÏý5Ä{lcÅÚ[ùiÔO[üÁF†/íWryb>fÓå‰.Od¢o¼9øS¬Y£™éz›“H¹OÚòdÁ–ÃÖù»LÑ:28)ósNÚeŠwmB­è¤,k\_]®˜–Ì%­ËYDû¸|H¾/}usof–©MÂe‹ç[ÞÒe,Y¶³šV¥\¶˜f_’¡ut´¯-šÓlÑ­*ò’Æn!¡Vš[Ël¹éqÉ ,¿z¼1"Ü€½ˆ‚ëÔâO•çdu îv;¼Â‡:'ïËiÞO >49þSkÒq±ú7°ì°á±ôVªaþS¥™÷”ø°Þ‡YÑ2XÃe—-žw¶˜û‚b6[D{Àdí+*Z‰ ÝÒèKU,9OãÜS—-Âúe%øë«ËÓl±QÒºl‘G.[´70¥KÍgçg¬"—-^F¶Xüæ²nm±ú——ÝÚ¢[[Ä Ñe‹—}æ>+•ÍÑXù·¶xY©‡Ë/.[l\_]¶˜f‹’Öe‹.[,=‘—PAtÙ¢Û‰º¿ÉH•Áu˨¿q¢]Pd7k´&Š£¶ô­‰bSr4 ×I é´σà3;îñ®½òþFï×qÀr+:&îãÀËÞœŠkìþ3{0{S¾9qǼ8 /ýã¿4…ÏubOd;¡³­XÙö¶ 9Í0)¹&Y²Ì¡;¾År_M«2Ðtí³¹rßôÚVr…ŒÆ?R±¾…™øÇ˜©Ò_d%—¨MrÌÚ?N@_²ÁÖ(O ëåêlË€qPû3O²ùqÕN–ÊZDàš$ðë"»ÒI§»¤FeʩՀʜ»dqOÓËšdoˆ’ª{’ ~]â~á©ç¸Ãþ2‡¯HòP,{íèçIiÑÑ‘´ôÐäɬëuöt®3Þµ2‡¥ë,ÃlI{ø«¤ƒ®“s§‰}eÉ‘èß».ôï±Z˜>‰Æ=‰Ù7î ;<_1fQJB“ ]DB“m%æ}CÙ ðˆiܨJ~¦»&q‹œE°˜ûÀ_v!y/Ŧ,·Ü3ƒ†û@•™‚)•?â¡,ðv–UŽ×µ5*’Xå>H%íæ‘ d.§Èú.óÕv?Ò­Ž«Ô¥eåàóØtïÍzÝ~ù;0ý“Þ\\0´ÿbÇ™òuYz$EèÏ®o‡÷¹@Š·–2ddÏìA&t‘’™•ífµF£4Ð??¬BÿÌa¥‘ß21?†ÑŒîjŠ÷"f@ºø‰âB ]ù Å.Ææ¤£·ÙÒ¹eiä½ ¤?¸@š¯˜HÓ}$º_uú7ƒaiܦ~ùÎÒ°è»ð?BK[9Fí_B·Hí{Ý›ëÛ!.¾x~¼@úÂÄ|t³Ä´ ¤±Âû´]ŠÅEaºøÍÀô9yò¸¨O‹½:êÓâH:»út.¶õé Ùp£ÝÎ ]ŬxÉEä-ú’‡ná«j‚®VRj€Uª%AÍEQD¸Xy–.XP6·žaø8€–Ø,ë¸À“m“¯Ùtv=K:g“¯²Ï¶toÙâÔ%edutWч\°yð 4·ôÂ9“SÉ.­û;u³›‘JVœÄ™õilC_®€€Öz•JÕ²’bTôÊJ0yµz4èÄ©,ùo«R/2®[Uì)ÔV–.‘æl›éÁ ,5ëzäEÕuÈË$QWY§3¯9â*NqG]…²C.Æ…ò-ò-2¸ÜôfM¢+Ù)Pº‚›] y%ü•ÒÀ]vcùô¸aÊßȦa6š\P´åú%œ ‹g¯î„—Éß4À8ÚJpLÙ‘ÅPÇ÷÷Wdß]aý5s{™ˆƒzйÌìBj ÖìðÙx‘÷%ò6ÏŒzøÌÏ‹»6Û¿óIÞÉÑ»{v·ùf õ\îßÂhå-ùþmð) Â(H¾§¿'öýwÆK€šE §×ý‘ȯÄ1]Áš}\†™ò»öðJì šCÿ|6fë-ø)^<(ÃWô“N¼Ç¥¯Lms!‰,.ʤÏå“Èêk3¥Iäí°Ó¿‰i )@s­ž…vß®×¢„|/ëÉiN˜™ª‘@c`•H¢1¨.‰ÇŽq€ m9̳ÛRG¤.`pŸùŠ’H‚î*ú‹°\É—0öô-ª]9My5ÜËK'ªÔWÏ1Þn™#®’DP¶ñ$27†l¹»ª Ã*pI$9Û97K"GƒÉdŠí_…$R•œÓ'‘÷ýIZžD– Õ%‘ì“M|?5Ÿ*v‹èò©êM#.Ÿ’ß\Í뢸qä}>•ëöP€¦\Ûóc]­”V‰Õ¸§T—Oq>5»šÎfjµ1­Aª•ÉW—OtWÑ—OâÛܧɧ®Ç½Ñ <Q¥¾z¸ývó©qsþ‹…4l!T¡lãùTn Ù|ª)»|ŠœOåSãñ¸3)/0ª’sú|j4u'ùÓ ÊšðøP]>eŸOO¸ÖåS•O¸º|JæS„Å>Ÿ"zUÖ§`•ø‘–O º|êœó©þìf:-]Ÿê)W_]>EÐ]E\>õzò©þtØï•G"ªÔ+Q¿ÕòÅÛͧrÄUò©uÊ6žOåÆÍ§vCpëS9ל3qmr<7˧&ƒio4V\_Z`T%çôùÔx2™ÜÓ‡º?Ÿª¿7®xt².÷¨ü-V—{@9jÎOdÎ}ÐM1³‚Àö¹h•܃V‰µh¹jÎÀÑà’, .«AØ,Ðx V7ÓÉtRjjÕZ÷«Ë=’«èCÎ1»½q¼7n8¼_•E¦J½!»Ü>È-¶èÿ¸kci»¤7.GÜœS<ÎZNn ÙÜ£)»µòZθÑXî1ínFå§Ý¨’súÜc2»B?JªQz!çCÝŸ{`¸#:tD<öÕ6XQ÷Æu ')ëò)±"ÓÔo³×ˆ“ÙçS׳›îhâ*þ(åZ…½q°JüHËMP]>uÆk9Ðkt5+ßZ­žEìò©@t¢æä9—g5VÍU¸·tV|ý…Ûõ !&8UÎ3¸_‡êV—´`«J½Ë§²Ò\Bޏ9ÿ•F e …1¡TçÌ`—O‘ó©œDdÿ¦Ô­±|jt3O)¦áôùÔýp4›”ïÃPÉêò)q*…LçÏp.Å<ñ#–ηq®0—¼k#åä}oE¤îž/¤Vâf«ÛÂÛxE.ŸšøOÞv¹;ƒ}©“Ÿg± Ö_7¼šbÑtÇ%ÁÙPpZkúJ§3î÷Ærm‹Ïp’>òyãgVÄBS:ÈÞuÿþæ^&üû=ÁHœ~±ûübO,Ie?¿È¯_ÀgøYÅÎÁÿf^ (?‘äs@=0 ¿Zƾì$k8!$Xöz–‘i' Å3KºâÄý™%½Þ€5«àhÄ™%›Ñ"bcÞ·Š–ý8Z¯9_ñ3æg@Â>«‚°Ã$½'P»v¯C8 EžYvéÃi¦lé{ƒ~!sfG»ìJaÏÞ>ËÏ©‘sFM2øÕÖ)ЫÎŒ\öKä’_3Ëåœhxv’T*­u-NFäõBªÚ›¬`ŠÇÙÙKDåxäoÂ8HÂèû»•ŸxïðP"ðyþëž+³_z÷£òvçKôU™ÇÎABÝ5b&°0ÎòŽÝÈŠòÈ |ù°]?C6òïgýGì/ªnÒ()ö°5› /›ê·Hjœ%/% fár¾ø‹ÝŒó<+>ÑMb|  $êt{ýÁ˜“@h±B¢ ÑÍn—ã˜{‘§Â 96 S‰Šÿú?ÿÿPK!<Â,ÝdocProps/app.xml ¢( œ’AOã0…ï+ñ¢Ü©“R!@S#Ô q€Rœ-{’X8¶e»ˆþûohÄœfÞØÏÏ_ ·Ÿƒ)>0Dí캬UY •NiÛ­Ë—æþüª,bV ã,®ËÆò–Ÿýçà<†¤1daãºìSò7ŒEÙã â‚Æ–&­ ƒHÔ†Ž¹¶Õ·Nî´‰-«ê’ágB«Pûɰo>ÒoM•“9_|mžshpðF$äs³P. À&—„iô€¼"yjàYtùØXÀ› *ò‹U l,aÓ‹ d"‚¼¾^]› pç½ÑR$‚ËŸ´ .º6OBj›\ì‹ìl¾ ˆÎå>ètÈYæ-ÕŠÒL@€ÉÁu’Í öù½Ìö‘P’¢!É[{ya,Þ Æ^°³ý7»µåöØ%"U*œQ6ò%µô}©y.yésbFðî“/Žü;Ž1ÖŒÈu˜¨C½¹Q‘£$^ðF(‹T†KDÈg"IÖù¢v¦yó¤È‡|O@ýFðÞOµòí÷q{ñ¾¦¼h*h ™¨Ç¡žU-hÄ ”+¾ìL ך¼l=LÌ•ÅÔ#…GHOæ*‰i…Ÿ÷î ÷×Ëz*ˆñ/°×ðì`:SAÖæ¢º4 aH‰Ý½ÚŸÐ9¯G%{vDZ×Ðg}Æö†®ï$;f#e6SžuöÄ9Ð6|Ðo„_Cߌ$ªâXE)–’+ r‰ÑAf]ºéâjï8(L9¾¢oé£ßÿK×·.Úœ¶ûªíQ5éòTɱ$;ÓÛÆ9^ÑEÊbMN› £!Kì…™eƒç|9º+ I.šìžÀn¹ÛÆk´1Á2'f1` ºS ²–J–PâHkÍð¯`ÜÔ.’ª¶3Ì ï‰Èà3Š2Ö)®63‘\2‘v}ýøþoS#Éx u¦ÞóøÅP¥Rʯ53ó˜|4çðª>Ô"ºdÃhg ë…—Zò.„¤™v†)K>ÅÕfÞÂ)ë=Ý/Ui™œó¡ÄL”_kf @¾¥bÕ…ðÒ t¶Ê?× ¯QÉ4]/mÔ21éáGÆ‚÷t#¼tµer·R›ð$”Á£µð” 6ïÎÅ*ý…]ÓK%Ïi¤ð4"övw¾.k…& èH™ƒ*qœ¯RÑ-[ªTåw*OŸÊ~¾"W·Døê”P8Y»O­ÓiÍUW73ø*•PÓÍœNçiTítª^È9]çÜÄéF<}*NSÛ¤…6¹ÓUÒ¥BZ( ÆøNWÂ7sº1O£j§ÓBj8ãt Z“攫þc]™/XŽnÛœ’Š1-N\Î4§úê·¨b˜•×&âÕ¿f&ʉnWÿâóLLäGÖ­þuóFþêvõ¯™òUêvõ/Îõ.rºîVÿš)ÿ uºú×ÍÏø*u»ú§]gœTkRýÙ¹;{öן4]Ñ ù}Õ®I¢¦ÊOé9Ž#ýÍ©|*µÄ.Ìžû›Sìa剩¿95ª Ôßœ‚Î)çÂfsê‚ðêoNÕ„WsŠ&8áU‡üNs~ø(\ˆîoN½õÌÏé7§ íØ~Ò‹üì¦TÀ¾Ð«îñ~õÔÕ‡ôÝçÈØ‹K– xd¬õÅ%‹¯î–æ‘•þ!áMÈ5Ÿ!ÓâF÷Û”¬nŒœý/ÖãÿÿÿPK-!¸+Ìã™G[Content_Types].xmlPK-!ÇÂ'¼ ß Ò_rels/.relsPK-!yø— Ý|word/_rels/document.xml.relsPK-!—e¹P$ aD. word/document.xmlPK-!!Z¢„!Û*word/theme/theme1.xmlPK- !9YÖ<¨¤¨¤Õ1docProps/thumbnail.jpegPK-!yxgzòç²Öword/settings.xmlPK-!î·Ÿ-|˜ ÓÜword/fontTable.xmlPK-!äçG°q®ßword/styles.xmlPK-!³Š®=VÓ±\ýword/stylesWithEffects.xmlPK-!<Â,ÝêdocProps/app.xmlPK-!Ü]y¬,­docProps/core.xmlPK-!åʳC¯s!word/webSettings.xmlPK-!NRKNµÒ5ª"word/numbering.xmlPKŽ(CGNS-4.5.0/release_docs/CGNS_TestingSpecs.pdf000066400000000000000000002676511474000356600206500ustar00rootroot00000000000000%PDF-1.3 %Äåòåë§ó ÐÄÆ 4 0 obj << /Length 5 0 R /Filter /FlateDecode >> stream x­\ےܶ}çWp<»³œµ–C€àÍ#Ù±µ–%Y±e{'ñæIW*%¥Êñ7å?sºÞ7Ú²KÞ¾žn€û[úCú[ª4þÏñoÕ6yÛ¦M͇ÿü#ý9ýwzzþ»JßýžyѪ«‹?µRMmü*q(ª.ùý(á†I ú~4¸[6m—6Úäxí݇ô«;Ü* ݤwïRE¤ðŸ;Þ}HOww:Qéݯé/i¶ûä˜Þti¶Ç¡M³ 9»”³ƒ®äâ}&§÷G9^SfŸzñÉ1­ÓìFîØ×sy.–ivâÇ텛Ȫ:\«S¡¼ ƒFœ;K{bó~¢Z$—U’6i?^v~â¨ïò©/9s©© v©ä½ŠsIN”æ9ùŒ€ã2­>-ùÌèɹñ¾t¹Ï0Á¼"ÁºÙø$çñIÔO öa¨ãR·¹.›j³B²¯zˆ!Hk 4iWLqFYÛ¡hדžM²%GwH²ÑÇ¥²F¨(}H™hRqdâS  W"Ïú‡ùt1nÙg« ¥¯WVÓbÖÁøæò•Ò º ÈNÍx ‡*ReMÞG„l¤àµªæ>ëî³+½;èî¼ëÎÝS qÏð˜°vÓe•ÊÀìPTºMñsƸɈg‘¿Ec“53mVBwV¨y@BmuW¢ èNqØKuQX©†”VЯžŸŸ^ï H„HV~ì€Cq¾Ó8Þò¿ˆón¬1›ÚtÕÌÃB¨Ë{Tw{xW• †÷XÄM:WOHL#£8=!øW>í>9æ'±H"N²ýÁ¥ä+A³e®2°Î²C”c&¬EÊŽ1ÙúµÙ¶Ðp$qñ¹Ù hnL¶á){sôǵÏ (ZV“¹šV‚ñ,$u¿?ZÌù A ™·KÕvyÃ!à!šU¤ñd)»¨®Ì›¢†Ç´æ’Ë@ôúJ’¾1UÝð?}äšÍ4ºƒÑxÞæ^#6Ä2BIUgÓ)2Ÿb>Šp³O4ît9Ñp 7-À”´+!GT»œi=iÊ4¢;¥¯ +_…MLiÎQ"# ÖÝ×½ov/¢È7H4ªS¢%ayÅ#£ tu>}cÊ«¢¢Ñð-I ¸Ô¶è E£EŠ-C |3Τ²ÔÒ¬ôÐÓ6ë9?ƒ.‰ïMø[¾ãa{ }›„jnp¸‘Eæ]»¼ëTk&šB$%ÜÞYF:+l ¼<Ä;[R³_#¢°BNÍ&¤;Åáv+\£Ô—°¶Û—c¿§VéäíuÄá‘ßvP~â–õÐì" ºfn$Ý=˜÷d]ÿˆWþ51EéÑ™™ãÎ7¬bü›Žæ…{½±Tos¾Dñ¦ëp6ìZt/™JÏHÂ…r\i9ÖÀë‚¡6©TšˆÀ³©D–²ÖfÊ^!܃ú¤.;À`ãH[ËÒ@Éåylv~u•Ÿ|"t äê’™Ÿ”A……y ‰8ÁûjêÖ†HdŒæã ”é¥jؼªtj²‘ïYZÛ}/ Ä)j,á˜=ÄÌ×gýô+íá'dMßòÁµØûâxÐ>ƒåœïÞ2>Ùu'ôã— I‰N¢AA7;O§›7¿š¯%ʲÌM…<±‘Ö/¡Ó;ïsGï–‡ûÞ­í©{ŸwÎØ§˜ÏØÑ1X¬ p±1¦–< ëŒÂ·äƒæ‘ëÛmtÚÛE³¬òN5°Ëpd˜VaÛ 3¤$,néRþ…AÞï{Š‚ô›[ƒ‰ïþ‘>üe2a‡›öÎy /np=Œ£QCWF»¹[_ßT³©!4ƒ›EÐMMf¡LÅ¥ØI—â’nZà˜Ôœ ÄTáú_¨?Z!}÷ý·oíO[úùh{Ö˜S °L+kê>s‡*ž2– åpIk0UçDó‘ÎÁKk2ã`û¶´“}þÖVmDyjÂÞá‹•‘'sãe•dèqPÿË£‹õ…@ÅòY=± U†èÆ5b]XõÆs£¸'Йµ°ÇS÷/¹g¾„ßF­`G¤Ÿ§íÈK”žJÿGO¯lqà£>’c¥ ±+¸ÎcAÿ.Dï³el‰åÂÎh„öÐè¦Lc¼iHkÐÂb5LŸÚÄž¿·çBQÎU²þtK% [«\{è1+ÙîÔ¬'bäRɆ”¶9-ÂYTÉþhÃþùöò Œ A9Òáp\ \QJå‘§b²Ã(ëX‘²]Kh:$6#èQP~ÞìŠÜ?……®2ÞbÃz’v° ™‚' ìT¨Ø”ù¨û;‹ÿ•/1‰ìÛ­#àoÊÌú ùbKI -y”“щ]5rÕ‡T(ÏrMë"ÄG&‰¨Éã˜<ÚTŒô!Þ3àB¬K.ÓVbi~èšøw\Ÿ–«Šýn ,OË…h')@Ó3<ñ¦7i:=Üì¿‘îY|Bá2Áÿ¥Ï,¶4;tÉ™Eòr¨cì½^^ŠäSƒídÅÂ…Båü}Ž=Øëøçå<å•‹‡Ö‹Øjš6`X>ѢƦŠQŠ5’+ŠD©ø¤Ô;©È»àøˆÛ;y…Ðí©ÿ¤x„ç-D,“– ˆÏaM@Õþ_5¶¬÷ÛÂàÿH$ãΞӡ4/\ãÎ&/kF´÷ýóÒ|TÑäEE“G¶.Ư…èì₺sΫè³3ZPŽ(GÆ8pÞ…H@ß²Õm1`s‰X † E‘«€¸üGÒSÄ`ÿ’þ;?Ol'Es°BóvÚ–þ.¯uG”Ä V•QÕ?ÍóHßÏMY­ó¸â+]Ë7›3l.}‡øùùÏ»}†ftߺkX°œoPjR¨Zt/¢‘#Åž4ÃFõao >™Ê-–ÖÈú‚?®üz#X!6´ Z²Y^„Ä`‰3_U³‘&Ù_ª× &Ó¢u—†„gD7ìþfëûÔ| cŠ>…x€­Qk,±à›¹!kVx!%fcá ‚OsÂâÇ|,B5*$Mx@nSøÁŠ*>ž’б‘åMü9‚ÞòÖ¨ Mo‚˜•^Hi[*xÝþu÷· ,ñ7µhyqÎPï¹²wⱸFm»CJxFÇ dÞi‹i×âÏ[ð~‘ù9?H€´‡ñÑ p…Øvñ„Xzc{²Ê_/Û€ç°$Èí~áõC”S‘[U€­ôU±¢Q*» r¥–keð-HHk.Ç™Š#wZPë»ÞCPñM¥ ,~êóPS*ŒéûL8IÉäµB§t#-ðJM ZØñkõ\²ð6~ÈžëV)QìâO«ð÷7$€Sâ]÷oévõû7ÐÛའ@—ü&Õ¡L:æ î†{п);jÄóƒ%êj0 .Ü«ÔórÅxLÜ !È5”øë/@"wß=Rø:Ëï8˜±ø^”¡‚ÅàGKŽ|"íi…îwÄýxkmË%Dw©4 !öqŽã#:¶ú×€æj܃’âz›ÃÒ€ÖL\ïõÄ]¥×[ãú€z4°}¢« (};9Š<Ö[Üßr¡22ö x °8*içy´S„½¸w|ïY¨¼c÷‹[†[ù½ç:ÿì=ÖÓsc–‡Áí6-wë–Æ¦"ßMÁECüžsyľ<¼Ó¶ƆQP¢Ê2´i»ð}XûáÂué~ endstream endobj 5 0 obj 4722 endobj 2 0 obj << /Type /Page /Parent 3 0 R /Resources 6 0 R /Contents 4 0 R /MediaBox [0 0 612 792] >> endobj 6 0 obj << /ProcSet [ /PDF /Text ] /ColorSpace << /Cs1 7 0 R >> /Font << /TT7 14 0 R /TT6 13 0 R /TT4 11 0 R /TT12 19 0 R /TT2 9 0 R /TT11 18 0 R /TT9 16 0 R >> >> endobj 20 0 obj << /Length 21 0 R /N 3 /Alternate /DeviceRGB /Filter /FlateDecode >> stream x–wTSهϽ7½Ð" %ôz Ò;HQ‰I€P†„&vDF)VdTÀG‡"cE ƒ‚b× òPÆÁQDEåÝŒk ï­5óÞšýÇYßÙç·×Ùgï}׺Pü‚ÂtX€4¡XîëÁ\ËÄ÷XÀáffGøDÔü½=™™¨HƳöî.€d»Û,¿P&sÖÿ‘"7C$ EÕ6<~&å”S³Å2ÿÊô•)2†12¡ ¢¬"ãįlö§æ+»É˜—&ä¡Yμ4žŒ»PÞš%ᣌ¡\˜%àg£|e½TIšå÷(ÓÓøœL0™_Ìç&¡l‰2Eî‰ò”Ä9¼r‹ù9hžx¦g䊉Ib¦טiåèÈfúñ³Sùb1+”ÃMáˆxLÏô´ Ž0€¯o–E%Ym™h‘í­ííYÖæhù¿Ùß~Sý=ÈzûUñ&ìÏžAŒžYßlì¬/½ö$Z›³¾•U´m@åá¬Oï ò´Þœó†l^’Äâ ' ‹ììlsŸk.+è7ûŸ‚oÊ¿†9÷™ËîûV;¦?#I3eE妧¦KDÌÌ —Ïdý÷ÿãÀ9iÍÉÃ,œŸÀñ…èUQè” „‰h»…Ø A1ØvƒjpÔzÐN‚6p\WÀ p €G@ †ÁK0Þi‚ð¢Aª¤™BÖZyCAP8ÅC‰’@ùÐ&¨*ƒª¡CP=ô#tº]ƒú Ð 4ý}„˜Óa ض€Ù°;GÂËàDxœÀÛáJ¸>·Âáð,…_“@ÈÑFXñDBX$!k‘"¤©Eš¤¹H‘q䇡a˜Æã‡YŒábVaÖbJ0Õ˜c˜VLæ6f3ù‚¥bÕ±¦X'¬?v 6›-ÄV``[°—±Øaì;ÇÀâp~¸\2n5®·׌»€ëà á&ñx¼*Þï‚Ásðb|!¾ ߯¿' Zk‚!– $l$Tçý„Â4Q¨Ot"†yÄ\b)±ŽØA¼I&N“I†$R$)™´TIj"]&=&½!“É:dGrY@^O®$Ÿ _%’?P”(&OJEBÙN9J¹@y@yC¥R ¨nÔXª˜ºZO½D}J}/G“3—ó—ãÉ­“«‘k•ë—{%O”×—w—_.Ÿ'_!Jþ¦ü¸QÁ@ÁS£°V¡Fá´Â=…IEš¢•bˆbšb‰bƒâ5ÅQ%¼’’·O©@é°Ò%¥!BÓ¥yÒ¸´M´:ÚeÚ0G7¤ûÓ“éÅôè½ô e%e[å(ååå³ÊRÂ0`ø3R¥Œ“Œ»Œó4æ¹ÏãÏÛ6¯i^ÿ¼)•ù*n*|•"•f••ªLUoÕÕªmªOÔ0j&jajÙjûÕ.«Ï§ÏwžÏ_4ÿäü‡ê°º‰z¸újõÃê=ꓚ¾U—4Æ5šnšÉšåšç4Ç´hZ µZåZçµ^0•™îÌTf%³‹9¡­®í§-Ñ>¤Ý«=­c¨³Xg£N³Î]’.[7A·\·SwBOK/X/_¯Qï¡>QŸ­Ÿ¤¿G¿[ÊÀÐ Ú`‹A›Á¨¡Š¡¿aža£ác#ª‘«Ñ*£Z£;Æ8c¶qŠñ>ã[&°‰I’IÉMSØÔÞT`ºÏ´Ï kæh&4«5»Ç¢°ÜYY¬FÖ 9Ã<È|£y›ù+ =‹X‹Ý_,í,S-ë,Y)YXm´ê°úÃÚÄšk]c}džjãc³Î¦Ýæµ­©-ßv¿í};š]°Ý»N»Ïöö"û&û1=‡x‡½÷Øtv(»„}Õëèá¸ÎñŒã'{'±ÓI§ßYÎ)ΠΣ ðÔ-rÑqá¸r‘.d.Œ_xp¡ÔUÛ•ãZëúÌM×çvÄmÄÝØ=Ùý¸û+K‘G‹Ç”§“çÏ ^ˆ—¯W‘W¯·’÷bïjï§>:>‰>>¾v¾«}/øaýývúÝó×ðçú×ûO8¬ è ¤FV> 2 uÃÁÁ»‚/Ò_$\ÔBüCv…< 5 ]ús.,4¬&ìy¸Ux~xw-bEDCÄ»HÈÒÈG‹KwFÉGÅEÕGME{E—EK—X,Y³äFŒZŒ ¦={$vr©÷ÒÝK‡ãìâ ãî.3\–³ìÚrµå©ËÏ®_ÁYq*ßÿ‰©åL®ô_¹wåד»‡û’çÆ+çñ]øeü‘—„²„ÑD—Ä]‰cI®IIãOAµàu²_òä©””£)3©Ñ©Íi„´ø´ÓB%aа+]3='½/Ã4£0CºÊiÕîU¢@Ñ‘L(sYf»˜ŽþLõHŒ$›%ƒY ³j²ÞgGeŸÊQÌæôäšänËÉóÉû~5f5wug¾vþ†üÁ5îk­…Ö®\Û¹Nw]Áºáõ¾ëm mHÙðËFËeßnŠÞÔQ Q°¾`h³ïæÆB¹BQá½-Î[lÅllíÝf³­jÛ—"^ÑõbËâŠâO%Ü’ëßY}WùÝÌö„í½¥ö¥ûwàvwÜÝéºóX™bY^ÙЮà]­åÌò¢ò·»Wì¾Va[q`id´2¨²½J¯jGÕ§ê¤êšæ½ê{·íÚÇÛ׿ßmÓÅ>¼È÷Pk­AmÅaÜá¬ÃÏë¢êº¿g_DíHñ‘ÏG…G¥ÇÂuÕ;Ô×7¨7”6’ƱãqÇoýàõC{«éP3£¹ø8!9ñâÇøïž <ÙyŠ}ªé'ýŸö¶ÐZŠZ¡ÖÜÖ‰¶¤6i{L{ßé€ÓÎ-?›ÿ|ôŒö™š³ÊgKϑΜ›9Ÿw~òBÆ…ñ‹‰‡:Wt>º´äÒ®°®ÞË—¯^ñ¹r©Û½ûüU—«g®9];}}½í†ýÖ»ž–_ì~iéµïm½ép³ý–ã­Ž¾}çú]û/Þöº}åŽÿ‹úî.¾{ÿ^Ü=é}ÞýÑ©^?Ìz8ýhýcìã¢' O*žª?­ýÕø×f©½ôì ×`ϳˆg†¸C/ÿ•ù¯OÃÏ©Ï+F´FêG­GÏŒùŒÝz±ôÅðËŒ—Óã…¿)þ¶÷•Ñ«Ÿ~wû½gbÉÄðkÑë™?JÞ¨¾9úÖömçdèäÓwi獵ŠÞ«¾?öý¡ûcôÇ‘éìOøO•Ÿ?w| üòx&mfæß÷„óû endstream endobj 21 0 obj 2612 endobj 7 0 obj [ /ICCBased 20 0 R ] endobj 23 0 obj << /Length 24 0 R /Filter /FlateDecode >> stream xÅ}ë®$Çqæÿ~ЦIŠçÃfwUõmÉ5 ‰âB¦weÃëÇŽÖ ŒÇ€­gò{î—/"²ªërÎphHàLÔDEFFDÆ-³²ÿ}ÿûߟ:üÿ€ÿžo×Ãí¶¿^ôÿø—ýöÿ¶ÿæ79íÿô—ýQÿ÷—?á…ã¡ –¿œŽÇ^ꯇs·ûÓûý¯ßîφì¼}¿ÿæíÛËþ´ûçýÓ'Ïû·ÿoÿÛ·tŽý½;]ð·þÜÝðp<œ‡Óéz9ï ÕuÃá~;Ý÷—û£ím´ãáx<_öoÿ´¿€þçظ÷ýi‡qÿ7F>=ƒ‡§¯ô¿ß<ï»ýÓ—ÏûaÿôFŸÜõ¿7}~Ô¿¿{.H|yŸ?ïûýÓA‘ìùwú÷/êÛFõ‹çý÷oÿÖ&<]½n§+çãÒ›™…J#Sz'Læ´‡”NÃEÔv¹ŸÝþý¾ëO‡þ²3ð'!“^TüS`þ×ýŸÍ œŠ=¿ ‡á¶ïn‡ãíxìv#[È¡Ï0œKÝ·ÁA íàõz82´bï.„eèy³äó²îÔucY;Óð 686­ ‡6&¤3âÉà]ŠÇgTųÇËùp½˜=$iveÊÝA—Ë>¬Ì J¸„idísêÐß¡âU;ëúËáBÃÂØçë¡+ƒ;H»2ìvÖÁîï·ûuÝÎx°"c0ÌlÌ’Ã*¬Jïš5³®¿®}«h3²~·bdOo¾N1v?Ýy€¿Ÿò‚ó~´ÄMhWCGJ©Ø ´x×.MÈAŠÄ Œ ª– ºwÇã),h?空‹ø²´ÞÛý0Р Â›ð¢§ê®·Ãå )ª£Zâ¢5#B8ÊQÚ09LéØ|¯pˆp?Ó„œE7¡5?õôŽAgbB·óá~B¨0/´0ùŸË„ªÑ¼ß÷½&tC)3±ôîaD­ ÇÃn(ýЬõÈuºÁc«Œ®©PŽn ­Æ°aÿuÔûCw=ŸÖ͈’DA-"‘AR£‘ŽØäYâ~‘šö‘Ñc\c™°"©f4tý±ë ëÏäÅZ„«çÚm¾ÿr‚ÏÊÙÝ åü?ÜÐh9`Yn'Åܤ^®²Gr‚Êv¶$ÅæPj «rr€r!&aú©ö¹ô²¤Ýñ%•©õxéo¬x'ÂÜ”784›„«Ê&5^‡*c¸Jc+—Æ¢s¢Ê-³ìêfZÔhmÓÙN¶l[ÍhˆÛ–jHz€*(*i¯9f”.´æ9²ß^»G‹+mnÑG1kܨ_"7ptb’»Eµõ'Ì †™J›sý²­ñºžîTИdñg"N´³mqHÅ mfYbjŽISÓO ö|› -U­ž½@ÔõÁêÕÔî¥!GgiH¸ zâÒús¸]†f}̉Z·¸>¸´±»;Iƒm]mÍVÅÏêÓD9z¤þ±]! †˜„EP²>Úç­Ú^êÖX©Ú¢ú#biÆÑ‰I¸ªmâÖz,áËE¼uŠúµn Õ²‡s³Úi}·&µTÏÕ6 J_èÖ¨`àÖˆY%jkŸ·jeÍádçÜ S«U›˜änQmÅp0ÍTÛãÕ† Vql\m¢6Œ`ÿw+­«M7¼ר“îO=Êž3dÖKöwXö]­ôCË9€tdX ¬Ñ ž‹Àì~n¯§$*”Aœ¨ ‚]4ÄÒIUÇZDeâJâ(Í•=­×,=²Ê­Pʨ¡1§ˆBî§ü3ßKT6Ö&â…mñÆRYˆc/üx™m@# W:®“_Ë“·˜¹g€FôKFXæ1Ãzkœ¸2«œ±d~4Xáå§ ã“« ’ " ¿SÌ­ôCi€Í1Í€ÍÀ³Û™r ´KÙQ£º€åí@vퟰÊõðB;¨0Á¼Ü°’)µU£ ‘¿­Ñ‘q!Gç2ä8æZFÈE`ƒÌ›’åï•e™öÄĈ\% ø‘$PÇÝÌx N^XÖw'_¦Ã5#¤) ‚¨j“4n•Wi®‰A+Ϙ¦ĘfÀÊ$e@Í ÿj¹½ B¼3(Ú,–·ÙßNƒ$÷¢ÏæM¢ìkÌI4ðМô ˜GÈѹ 9޹æ6‹Çr„ñ–ä;Yäp«.,HÆà’µ¾bN”]™‚’+SˆáJ)ÅumÊrœË/ ª„¨ÍRy²yPiLk½§ibhh‚¯„U Dvƒµ †o£¹–¡ ovR^î˜1†9å $SÉñ¦!¹ª‹ rt®L»äÒäøx'yç+@êf´ìŠ9% Ѳø—ãƒ)ˆ«Í$(Þ(SPò6…à BöbNÁi°â$ Â>íÀO1€©e'ݾ#»Œ¬j]´«APF4'ü«UVnè{†·¹¬‘}~iN1É3™ˆÞar(LìpTnmiÇ!Gç2ä(p.ÃÀO9b9VIÀOËÆön$!S€¦§ µ>ÉÇœ|La<\+A5'e)4‹_z§€iN£)£c1´N:§išÓLXÅ@¦M ;Ökæ¥VÇ¯âÆ ‰ìB s²A¨O!ÓFŸ„•LéÌè¢]Ú1×EpåºØåø»é¯™S²èrì”XDŠAa÷©‰ì’X4'q~ñ§@rœÂx¸‘ENÆ|"i°BÓd‘Îàø.–ÇæÔ»œ¦‹cP´‹&ƒéCÔ½8=ë¦ÄM^ÑfÁ9jC¼NòŒ~Ë+P:`^H-§!J¢P7F)vÃü"¡0ê(û¸X+HüÝÃÛ,bÎbB*e(Ì;üY€ÄÛ^–y–tPòOæ£ b“°Œ±yÿ›Qo 61 ëÛ¤µM'ˆ(Œv”y8bÓi–·såáí°yíÙ¸A+¶«wëÛÏGæ#Žú‘ùyµ®H7’£f skÛ´;v-pT1¢G¹-ý0ƒ!}‡‘¸è)r?¨î  ¡[ õqÙ5ž¶-×v°}×8Øá^±O°ã0ÙqôÂNØòx-wŽÑ£C™™ß/èÖ1ÿ¡[ÇcºHÅV÷Ž?Å+÷[±íŠo 8WøéÒôÓ­?\qªÒoÓ™ŸÄnq+ù†íH| Ò“½äëu2‡vSûߟÙײ•Œ-c0|ÜaÿÅA{›ž XvÇáÞàãdd‡s—-÷sª;0º1€à–¯iÐ!À÷.§–Ç=¶”ïz¶›­³°Aº+]"âάâF'+ ¦˜ nv•§í¦òtM,rƒè[Å\¡ˆ'²÷¦ìÁ«ð<~°cè…ŸÙzyü¾šî¼ Uy/o-ŽÎ­¬ÌЃEÜ[1C‡9CG/3T‰×Ç>w„kÞ6:׸±ÃÝÁo  yû¾ppcè…›yyó°úì’m×Ök7}‚X]Ì;ªT„D·oœ ãÝÄÀ=F+泸™;‘¸°Æõ†Cê<æH•\a‰á;CD7P;¶³ç†î¬À›“¯üJsû“v~žÐ¢"‹ À=ÿàü½ÌOì›™Œ>~±ÀÅÕ©Àë¦n2d§’iâÜç%C¾ì æâ´…Ô8Êö~(y›ÀÓ¡¼p/v"ð˜Ÿ8ðHÛÜÂ#ñræü<Ë+óS×Ç­À_êÃc“5²¼*pÍ &C~<¶04oáX‡¶%«"ßp¤las/÷d·Ûº»÷¢€À,šö™­ˆ¯T}.¢q‰þšÇ­þ<&ìâûÚé ®…ªÏŽÊ&C–ÎNÖ’!G/ Íê/÷fUäþãR ^Ð_nÎ’˜œc\"¶Uû?ìÊçÈ[7N­±ªBvg½4Ñ Ka_m2ê[±É—kQÉ,Ó¢ï l'-ÞŠ(Ú &t 3¡C5믽Rh^Vß²Ö XÞ¦ˆßШ§5Aƒ0ÙÐ1’- q8ÀÒ ­4& â;_¤‘ïH¸µÃ\¤p¡Qi‚†ÖØš„: N•†4Õ(Ò1MáÃÞaÁ*o9ë4<,V•¦Ò Žð¡ÑiÁ.Ý A|Ÿi(ŽÏÅ¢ù*e»¿ÓF3VFã=û «ƒ·î ùüÂýUÐðÆåa^0í!ð ÍícŒ…:»QÁ(™(ƒD‰Ý¬5Ù7œ.EÈÞ½ ‘‹SlWIYU2˜®"[1¤Ð^¢»XCÊž­©j«òïÒu'_…‡Ö2m5T+£eÛ+aø•BcSfÇc›Ø_aö' æ(³h­¡X šv D/<„Þ‘xzìAÉôZôÎ!¼™Ä!Tí!7ar­•`ð)¶¯Í¤•¤°hÖ!p§K!Ì–A$n3ØóÒMšFíݤàˆÝ#å)¼K޼T9 cgºÙOÂ÷œ¼â÷O£î¶O”nö©>ø[0W»-ù-B™À2ÛñÅä@ç)>F¨Ä´ƒ¤—1Ìç ;tÞ|ÿ;íý}Ó‚É5üâSµîÚ!¨C4„žòÙvŸ ­É!é结 ›¢S¢M9LRô41¹S1¬¶ATvny;Œ ¢àÈDÃÊNެC¤°{ Ùô4[D³Bg íg·g”õ‚›ÉÎ'Ä_$°¹CßBGN©;stü:Gñ-ÌÓ o¦KôXè°FgÈÜxÛ‡ y—(„îp2dø„Õ£¢„Öï¶Æ®%.5X•y½|žWº± :¶«Ñ5vºÿ†?g¤ä sJkÓ¿»©ëÖŽÄdÃ{XˆåEG;Hž´²÷Vm=ZCn„É{E„]ì3½‹Ò =”¾UîZŠ™ÜÇ:ìÑËôTúVbŸ<ïxÓÃϧÄH_ÜN#û À2‘ #âã{»‰Si2.p@ú …RŸƒ&eÊBé 11÷"¬s¨¯IÈCÍ@¤‚$vå86 &%N!@ŠA±Q× “¤P((èo¶Áºý$Ïâ•ld‘‚‡XŽØ•Åñz;[…Bú9ñhç'IQ$IŸ¯¯¼Ç)7;qæä,<T cr Ÿ }€N!°Ë,Ç)Ðà (Mr9Û”²ìB!úHûûÊU¶18Mv1È$9(CDAß,Öì^Q$¾bèêˆMX­·Y²e=ä iñ|‡kˆp³”Ųv›Ïì9×@¥ÑÚ¤eêc›•cÈ|‡ø„i?Ò}µétÑѾôðE¬4Z›È>EJóÃO¾„íàcÇRCuˆAÜÛ n^Š|sÜàLW´ÂÞ•Âæ¥—…U†Ë¤²—EX©½,{^zYÓÄ5ŽØ›"GÞËRÅN&Úž* Gaúãb%{Y'¬Õ[öœìZå¦ÐÒ¢ ½VcL÷:¥ÃúcM§ˆM - 7žªÄf:[m ­wïþàgº¾ÐQrIH9s¯-®îˆ{¥úÎaUyÍ3žûç°¶Å¢ñEû¯t}45¶´Ìøq}ƒ€¢©9:AÚ~óøa‹kóþ+[\±±¦eûÉ`¿Â»XŽÄ¯,-´¸x½FQðâ—Èš§>¾U8îרJëÅí²mg˜,1 yyâòR¸ÈË“½*/1'0{>ß.C³nñDyû‹&Åö˜™Tܪ‰7süÊмy¬ªÈ¼uYí²ü¸Çª(ó²>Eœ·¦Dzñ„Öž¯Õw±‹*&'«’';IE;`»Œ<°]¦0Ô <ÍŠéy»lVîô²ëŸ•g»l+±/kë®Ì3ù˜gÚ!0‡C`Ž_& G”-˜á} ½]–è1ÈGÀN#ðñ¨½#$ûð.h:XÌMæ­ ¬ÇÅfUbŸúå s´Øte*r®L×—=™­ÌÌð…ßvé•uE£*€øÕÆš #{µ¬6Ã"ñÉ—È>ìÙiŒm0ß!>a™Kk[Ù®ª¶'¶ÈwØ®",4»€˜ÚéœïŸ°ÐÀß?ÿ4ÆÄÐÆ:7˜Diˆ »Áo>z…ëëp}„Ù†¶§f»jw9êIÏlW–™Hìeh°ç¥]5:“ƒŸ% %oWGlO‘#‡u$L“íªÊQ˜þ|» ý|çS?å“{Å—&ÛŽ^)ÝÒû…ÚUu:ó“ØØ®ªÄôXÚô V[£]õü(>=įNÈõ¯~ ,®ó—‡øÁ¦…ÖîqÄù4eªìæ'ñêÖÕü¡•r:+ÌŽ­*3»h]ÑÌÜkä:h¯µ®Ö²ÓVÁ|¼´® ÎÖY`늰:-Â|m“7Ãepëj+­—›îe¢+ó¤*ä¥pº2&‡U^âÊÚç‹­«²E†¼u 9¬ À“±uUš­!â¤W‘yë¾Ú%úÚúÛ¦·ýøH£qÚh\wÖ„9% ò©ƒX6NÇðÖêï±ØÁ]9ñ­({´ª‚'ke‘'â+̸9·n²u5+÷×´®¶{ñÂy|"q$0¶œ(0ÏÖi§Ì€B`Ž_¦M”ú|µþ+Y@9%É“[aX~²+y²ÖUðä­+ÂîüŸ’䧆«Rÿ˜‡$YŸp†‘#º™挈OØ—N|²hÏ_ºtRêzH’­(·„hUOÖÊ"l]ŽóðÏøÁÿR¹3W¹{½FËbÍ9Ÿ0åÞ>ÿ0¹³Û”¡–Eb¨Ð#õƒùùrÈ•–„®Œ1i!¥ikf©Gûœ„ ‰BQ)EÎè©,k+Mv#É‚á$F}lxÆ4.3ÑTÄÑó FCN‘( IR †¸(âí;y2¥ÒÐ}y|þˆFî¥dë*hŒ°äKäÁàgïd» ÒÐvøÎidK![W¤AWOyÐÕ8–E>è~’†·œ1MáÃÞI3¥« cWè×>/&×ir8¹µ*õ¶Eâm 2Zõô+ê÷v­åÊôwuÙ¥[$¶ºE'Õ®Yš¾FHÂaºRâÙG+Jß)k‚4Ü~ùñ « À¶:œa3Y{vb¿b«|‡öLXiT{…Û a¾C[$l6 ½³à#lÂù ]ñÚa¡ñÀðÌ¿”Іåc늆D˜D‰OØñFÌkñ7‹ðS\·Ò¹R~ÊÎ]¡œ“aãj° QWþ|¾q… NWàìAãŠü°O%ìc|o[ÖÓ aö³m«3r¨¶kµrÉÒÓ¦®Õ˜ìƒ¦U[M¢á³|ÿÔB¿'îŸÒQ7\;±tLŒ×OUZ3-+ÖežÔ÷;üz3?›™¿T~íð뽕îGhIMÎÀÌòÝ›¸G|¸‚iІL{ÒÚÍÀ:¸`º 6¤ø ¬ykHÑÀ½E~ ´‘$Q°Û§†æ»ü¡¢j‰¼[û[ú¤ÚJê•5µËJ¤6½ , eùËÕ”•! J©K:'VÔÞã«©¶œN‰Ö’›;Oî› ,ìè™+ÂË%±5+îfÝ}¤‹’˜•º¸#xÚüä|˜ÃÖùéZZëúóµ’n~±HŒ®’IœM(7ɱÖ8{SOm¹ÿ(ÇÊdž[iéjyù£+ÂbòãÂò<‡Â20„ã©RÀ\-íóV}ÓSÓóIIÈþ ÊÛOJ±a`pàØ‡ú„Ô8¶Ä/©È7Ä¿…C£ñ F[imuv/:õy§©/RFbåÂqì€C}P3ª$ÞªOw›{„VÔç,WûXnP¦»õ6VÃÑl¨Š_2*+æµ'qkÖVZ[Õ¿ƒ¸åÌo¤ü®>/È(,M8°}Çn„%γ}þ@}ÍGû®¾™èý-rdí°àHÁàÀ°S‹«/Î^‘·û&ˆW3?~­õÂÆ/ä·/ÚѳÂVZP¬€¢”Õ5_•¸d†Q,j!U ÉšDZY¤ã€.+dÍ}d)­±œ6NZrˆ½À=¬°“€UÜÎ{Ð7zFÁ1lQo…QöÄ’½P e`‘Ü&%É(aŸÑ[ Òç²1­>—ÝVò`9f™=)x–ÑPWô ë+q–¥¨ÔXR`ÔYIر¯÷ü•@A×e`¸Â3 Ò‰"…– èÂÞHm†3w ÛÄc€”C`q`Š’lÜøkH9†Ï¢iˆ y(oS ‹ ÊF¢LÓ»TÁ$a›×hÄëÏ-ÃVrJØ–K¸*_«çúqpù¤¡™±Ç¾|V ÕœA¡1vÞ¢oxw*`Õºv§‚‡jYè]8ho@þcm´ª)ekªZÆvZrë²CÈ3UN¡ /a6äÁj”io2ûR©õ˜f´¡¨déL&S®tá?…1éaˆÚ² ÍÏw\²­ÇGÙ‡Xú@ãîòùßÙAÑ…F§¢KSj𯮱c§©Œé’± ¥ì‡ÉŽ£v"ÎŒóØøôï|;ËQÙz–jÒ•jŠÀýƮԘTKwµ-µ›?†”m)ögúôÏdSΙ]7œ¥úÞî=÷Ïÿ¾±›Ýq°jžùg¨†~ÖºÑEÓ@i%µù8Ȩ˜ßµ—õEo§¶.®LS 7>ü² Ãn]Ž]lM‹pkXéÓù~Õ¦Aì@‘v¨¸Þqí±aUø™-âøTÕïk«€hXÃ[¤õÊ*`Ew 4”–*O£ >ð i9z‘–j¯>†&Ý¥^Ϥ x|°ÈÎN¥ßb‹Šºs؇·þV0'nt^wˆTú ÛUw‹%ÀBÞñ'¶ç‰:—/VÞ&qYÈqE„vq¦¸½—*Ï©(ÖZ7¶&hrz«0¤‡®ÂšØs†¼[æÆµÜpŒ#Xó"O_§¿¶½ ¿øzpØÇ¼¥.2,_|žÇ§¸,»ââ#ºI/ú—Íã—êiÌôüUê/”ÃÔŸ¿"±þž²×^O_á›é^ô>¶Ïœ"OMÅü<ù æü É_dšæÕ=n>ÍÔâW€…!=je°Ô<'ƒÉ5¸*C³/;V5¡ZJ– ¿4ýmh_nux/Ê4¢ð¹ºÀY"R>Dé¯yÜêozeì²þ¼e•ú³#[iP ‡Ë%zahVÙ²úÈ ÂZ-ÁÒF÷‘Þ!¾£—õ‘Á¨ŸÜGø™«€eÕD5ѾlÄ¢ùke’”bN*°Rò,Þ(ɦoø3Ù´BÌ)‚ÙJù)'Ä(Hh_*Þ1’É•rѼ6˜6‘a΄øÃP•qȇÇaü¡g¼ O>ˆŸsUùÑ¿ å0àüÇ4…Ãal4P´64öqÇ4I#Þñ3*ø¶#ix$#ŒY„•q\Þ“jhh7|?åá},Žg®Œ†úSm;…LéÊ+ ¦‡hIæ>Ò¿ðA4j;ý€‰ã²fVð%òØØÍ*“Õî)ƒè™« Ú &déÊÔYøÊÌIú²sÇÅ…YüXó(vÁǺ¾u8^áÝq!„7Ͷ '%KÁ˜הê x½¥°‹ ‡øËû))úJj´¶¹}Ϲ—‘\諚¥ËQ¬y¤ è ™å…Ûæ•÷ì­30Ò]q~](ä|«ßÉÖýr·wÂäÎÑ\Õ­$‹Á´Çr„BQ n9BáÖ˜ð@›~Ð)ÐeU •b³Âº~ǾŠð˜¶µöfæ«oœ– ~l¾(Š3%·móÕÄ¿yůâoÉ“»ÆJ¡RôùÚ9è¶ê0Zc?[²`¢ûPÍ|1ˇ67ïä…[ÀõiØé.dyL¤_w tÁ1_b‰…=Ù|~ñïnÏôÝcÚªßgÛÝ0uäAQíæüȹ—ù6L€‚ÇR èó l— R`Èq3žF‹ I_@šA…‡Ñ ú˜]dÏÌÎ_FÁ:ïswž_н?çý5i|Ó{¶tÚÿxû~ÿÍÛ·—¨(ã¾ìqS;‰AhØãȦö±—¦öC²Ö@óù7Ÿ½{úB³òsýï·8b8ß´=akãŽÓÔûsk÷p„`|þÄ"¾Ç8_{HÄäœä(äãFŒß¿û»û—`¿¶ù‰ýñ™õ ;™Îî ?²€²©Ù?|oÈ­t÷o?9ÚóOº7úèþí¡AüîþN~–Tä×>ñÇßè¿Zî³;œ‡ùç´ÇœÍ7ׯšÅš3öçA˜fCBrÚ¿ýóþé?çˆÞn‡þt?_ש]Ø~žØ wÓÃe¯ñEó]<Ò{¼¡®¸¨}v°d^°ƒï¿ø•|¹ õäïÉ U.Øñp–0–ÕxK ‘l6äT°K'zå÷…úëÄlÐÊÌ 4cÝáÛ_ÉM‰ÂôçŸãWdå/¾ Ÿ€;ݯÈEÏ#‰-q_¾hYMöܤ0¯Ì±(~—÷O©ÁÊpÖ¬¥–Êl——s+¯Ufe»n$ÿ%q,(Sv6ðKÀœÀËXèýLƒóõvG˜×f×Aî§ 3§Mß¼íÜüjdˆŒê ²ÐÇà AWQ`ÄUØm¢«æ9®=!¨{¨kt_ d"ÿCeÚŸáË\?¥¯ÅÁ½ÎÊÑ ›ð¢ºHZ¥ØD¼Ùœ3úæëù¼¢¿Â˜Ïw¬¶J¹Q¾G£ WVˆöÜiǦYŸ2* A™ ))|¢‹ˆ ERõUõSÕˆÓ)wÄT à«i^=øHÒ êŽu`ü=G5<ÂËŠ¢¹Ž^ªÙ˜ûÀh8béÜï°§_H5”¾*òÁnG:‡(â*\TÓ<ß÷H¨oëŠNÀK½àè˜4ühÆÈ†LpQ9N¸Êo.`­üͰ ¹cí$=¡Jùç_4¾'D¹VO’yPA˜¿DdWC)ôc0$9Wæ‘É!\ Lú”q ™‹…ÿñ/rJ¼Ü¤½¶ý£È†¡”A0¤0 2dá­p~bÉ3^µG¡ñ -$Í—¯åBö1œ-Í¿à\6uý£þ"àÿ)wOÿdÐÍP~ð4ÌcOÿÊp~k8ä/:í¯žwÃþÉ©økþÇÿìê|ÈìqP«Ç ä<2S÷(s–íù¸ükhj<ÒTc]ÂéâÚ·4.‡]ybk‚^tÉP±l`VâªÓÀš(±Î“‡LÀÛ,õ…:¤Ç:¸b3x;±WÕUqAERhR…âœåP.ýaŠËÑ‹¸T…õ1¢-Ïk=tË;à½GàdH®;Ç2¶x.G,¬ÌkîÞá§;%…)ž¡=¬ÕV#K_†öøzúÒÃD7Ûª¹øÞfËa-ÑL]|}áâSV»| =ü*];©(b1² Icsñ=ä !ÆÏÛµçµL}íÉ1¦C}“%<—Ådžþ_w ¥ÈÐõ‡›p6/ó¦#òêD¯È)0 Ù,=õhèœ1Aèú~ÁnÒ÷¦r³:OW‹vâá|õèm{Ò N?ÿŸ ×ræˆ^5x“_šçlwÙ6ÀE«C¢\iUmˆ› ”"ünÈ+B‘(ÛH™³ç«#؆¬h,n¼‰[?¥<ýŽà/äürÌ"þ*¨ñá Ñ2CÊçÃsú­z°aë·MÂJ>—D™„Ž!°¦`1'áëZ@™„L;Þ¨q–bÐ8[D߬bÈ…‹¿Õƒ–A”÷~W¹²¤ôs?Åðä$*H|n }±uÖªà v2 +‡3RIYI¤"éØbXªJŒ:!»!Ñàw$êdX[WXfHyà¬BÆs0&‘aø'ß\Xœ„¾T&¡DË$®èBqEV ¹a‘ §ÀhÏÊ)`]Ó0‹àz^ #ê¯X1Ï ]ú.† Ì‚Jg ˆMø7NÊÀ\‘;(„a•áD'W¦c`KÊy R‹KtCˆD¥ƒ@v]'›— t×–ªøÄ†k x,¡ï 2]°§“ØfQ.Ý.'¡.ˆfA¢euLÍDÂÎdÁ)09!Â.`v¶&å±¾1Œ&¨‘2ø)K"Íývìï˜üÃS Mâ2Ä4å_I×!·ø!U&_ 9ÙQœX€ƒÃ.'¢§¹¨q7±Ò“¯ÙTó„=ÝP¬›Ù—„:ERH‡a&Eo(sÆøÈ&Gå‹Wˆ^xXTJ#1gò‘D-N“:l†ðÌÿñ•P–¶á$‚–„IÒàh™àº9Aâ=“]€b¼Ù4ñǵk2n>>hဳ¦…=cÈ[&ÁÁÁ5ù÷ÃË Gág›&j$DlòcÃmÜ4i‹¤MM“ýlÓd‡ ¾ÿ—õL~oüø÷ØÈÿ°ÎH‡S8}‡â̦óñ:#+7Gd«ÃT–kå$¿ªiKÍUòÅ*¤µÏÛæìhÔYã)ZÆSvBŒ'ƒƒßOX½òìÆtéïÿõrO¥s,FçèpÌɳ´€CîFÇŸ—ŽÆ´ß¹"ôìR8CÅ“H;ÆP“Ð-…†•…†¶ÏhE5«¶i¶kõ[f/¹aÃý;]eñ¶˜-ü½Å«˜“Ń©¯´ç\mbê.'‡»Ìëμ,eÏÁX28YB^)b4gn‰÷œ‘Ø©¼vÃeAêÙ…XûflÀ/r‘áo öaߌMòãè¢;×÷JZP²•^î((-ˆ,—”¢­®‰¢>Prog±;ÛÉÊZøÌ†‚`J ÃÙ¤;HÍšÌlcJQVÁaSäÑø“…BÁ9¸m뤼ä©\ì˜E}E(xÖçr0P;yúFÁ ‹i”¦Ï…¦”)GY“ƒ6DbÇôkùRaÃÌ R.9ëpÔø(9—*.ç8öÓ£èoh´’l¾|Å;Ž°Æ·m5k’‚ä‚èØÚ ›–¤Ð@×1P‡M€â7®wÙç¦Aua%5¬& (‰<•œ»$”ÆP&œ€ÁÃÉ&¬äˆ ¨ŸO@¡SœdYL@é^ã¬ìú®Ý|ºGŠßG¾=ïdÃïou¿Ï·í~†<àîçó~ÐY}¼()¾Cé$§¾0>'¤‡3F’›ƒ¸$I”ø ÃëÛ “$7“J©@|ÍᜇÍ$×`&¹»7ø ÍI.A¢$¹öxS’‹©Ît}#i5†2©œI.9°¤8ŽÂiÌ'¹W-´“ܶsó3tYøñº–ÐΟ5ù™¾AÁ¦¬oÈdqtmîÀj‡»'†;¾¾ØLì•Õ¤GãËQY­¦k÷•j|š¶˜¦®‰O˜Ö×>_K‹×x²´8D¦ÁGÝBw˜<0-&¬‹n>-f{v«?ŽÜÓé܋wÒ9æœè ‡ÜŽ=_ÌdW„níYÉÝœ!««uÅk&«C”L¶²²Éúy33s¯i—2Ù…œ*Λm&¶Uw£³].*8ÈG¿EP"‹‰ÊÃ¥‰.c6dø­¬i±á­¥Åõ w8—5ÜmX›·¡½LƒMK–;¸5-®»QákÒâUb¿DZ y¡q”i±Á™ºR¥Mˆ¶C)áÚ'¢JKÒdÒ*øºÔe)Ó}Ú;–IZ4ª[–ìÝ ÒH‹+ I‹+ ‡Õ&JR¥°ò¡î„œ%UR.ÝÇ¥[",4 ¾üÊĬҨò(øÁ‡-ŽkyŽ/$ã%ç•jåãAr‡ÐWU)‰¨Hò&ip0š°-¢ÄF'i±qÐX"Sc\´´œ•ñL/i'i¸ ˆjÐ`ž99ÅÑ&³í/$¿ËÁ% M æÜD•ŸDværµ(šjr12c«xJÖ²_‘ÓÍŽf¼$¯c¢‹ ÙxÕ…”عÈ ÖfŠ·ƒ”035´œi±i3'·Ù)ÙÌ4y±™rJT›òšÈ>Ó›Ë,…Ïr&ÞRºÐëz…þ`½Èz ^Ÿp¥aÏHƒKÀb©ÑË ;óo·#â ’Ï>†·Ùk†x”à9®QpêÅnÀðâeCÎRÒŒyZ¸í G²ÞypĤÞyt>Àÿdù~‰=î—@ôüî—€5ËýBì%÷K u®Í§^í ë^üXpq¿Ä€¯‘áèLpˆa»iûý«Ô6ß/±J)î—˜¯åÊ’ë ‰4Äì³;ù²Ûkj¦þGsí ÊáßÃðäB†á|¹Úßþ(ßRáÉ?bGþüá÷ä?îž~+_Tá¡ÿñƒ¿ó•¿3úWýþ Ø?þ¸øÖˆž: ª&/ŠØ^Ò¹\Pr;ãüÍÄ.KèqtðÖãü­ÄD ÏҚѯä¡ì…áÃFtN÷Oø$NaTôˆ>»'Ž«íŸðÉ›¾!_À 쵉T ŒQø¶ØðÊî)Þ ªö/øöŽÃ k¡´‚¨(KŸÄ_~xFïÿì¨ñ‹Ð øe¾#vuZ lô7¿fÁ=Nvpk`%>`8ãnU|Ðõȳv'ÜF‚›Nt%óvk‘/zÆîJøŸÿaæŽpä’hç¿ÿµ~FoÿýRÈÉå7ñ—úá‰Wà@/øÐêûV‘>×ÿâëa<7œÿéá5|ëGFÉP¿À“|ˆ—í5\LûW#jòÈ­(ó½¢^®ð]b3Ñ…éÉhìÍVÓ˜äÒ®[•Þ}rB1k2—ÞŸ‹°0/á\þ0莩}9ÕÀx [›ø‰ÏõŸô¶@óó…8 ‘ºèubäl¦FÔ+kBæ©°'€«—ê,—hýßÝ8Šœp!Áí%´–øÂõù·;Ù•/µÝÛºô¯o>÷À%:0¨ïMÞ÷ïñ—…[INW8±ãÉÇ,Ù¨ŽÏ¤B㣠k>Uûþxo†w0&þ§ýáWa9@Û@ØÁŒ‚ý;BЬÕþÅ/¥r[ÂÅ@xÇgö­OÔå#ß1uÁ¬Ôýû`{t7!UzX™ ò­sÞT6MŸ¥#2S7lx·cÜ€=¶—þ {é{¬[YaR¿v]E4{@+Wëå"Ÿeê÷à@q’•ãrÒê61¾vAâ&Ü…6œö½¾¡Yñè€ÆRÉ™œÏrkŠÍdiIn"†«‘péEÄþáÿ¸Îôv endstream endobj 24 0 obj 13351 endobj 22 0 obj << /Type /Page /Parent 3 0 R /Resources 25 0 R /Contents 23 0 R /MediaBox [0 0 612 792] >> endobj 25 0 obj << /ProcSet [ /PDF /Text ] /ColorSpace << /Cs1 7 0 R >> /Font << /TT12 19 0 R /TT6 13 0 R /TT14 27 0 R /TT9 16 0 R /TT7 14 0 R >> >> endobj 3 0 obj << /Type /Pages /MediaBox [0 0 612 792] /Count 2 /Kids [ 2 0 R 22 0 R ] >> endobj 28 0 obj << /Type /Catalog /Pages 3 0 R >> endobj 13 0 obj << /Type /Font /Subtype /TrueType /BaseFont /PNUUNS+Cambria /FontDescriptor 29 0 R /ToUnicode 30 0 R /FirstChar 33 /LastChar 96 /Widths [ 220 621 488 556 531 430 278 338 414 504 264 552 490 494 552 547 205 441 832 563 611 681 496 611 488 524 558 271 504 382 554 382 266 332 653 555 593 537 483 205 303 324 537 774 554 687 662 554 554 921 648 221 264 623 554 568 815 571 554 554 371 575 554 500 ] >> endobj 30 0 obj << /Length 31 0 R /Filter /FlateDecode >> stream x]”ËnÛ0E÷ú .ÓE`Z"í )xÑêöô \µ,ÈòÂßsÇNÚfq\Íp8w(qñ¼û´úÙ-¾M§fŸf×õC;¥óé25ÉÕéÐÙ2wmßÌweïšc5f ï¯ç9wCwre™9·øÎ’ó<]ÝÃÇöT§z÷ujÓÔ÷ðóyooö—qüŽi˜Ï¶[צŽrŸ«ñKuLnaKw-ñ~¾>²êoÆë˜±byk©9µéæ[ö+àý*J$x¿¦L™G$í$WH ZH®‘@t#ù„¢Arƒ¤mT!iÉ5¼/*%7H Ô“d‹|Ù¾ D׊vH ”z.˜­ ª &(X›$ñ*ˆªç¯ÙJâUx,Š×ÂümTàUµRx-Ìo´d¼æ—# ¯‚ÊKI¼ d-‰W´Rx-n~Eñ*p´’Ä«À‚¦QàU0+UxD5É€WAeM=kts‚¨%`Npú&1nÕ¦ Úоs‚,йp3¨&æY˜ f‚D1'(¥IÌ ,XeÌ1R­5‰9º•TWs‚doÄœ@jÎ|¶T™£0–ŒW¬•ütÅïöúáscØ5ñªKÒ Êê€"cô !SÛ j-1†h£ 1¢ŒA¬¯(2A²ƒ`­¾“ÈR“‰ŒA¬ŠŒAPÊúg ¼W²*¯ƒÀ¥þ±£‹DÞÛÕ\¦‰»ÉnE»¶tõCz»8ÇӨơx[§ endstream endobj 31 0 obj 649 endobj 29 0 obj << /Type /FontDescriptor /FontName /PNUUNS+Cambria /Flags 4 /FontBBox [-1475 -2463 2867 3117] /ItalicAngle 0 /Ascent 950 /Descent -222 /CapHeight 667 /StemV 0 /XHeight 467 /AvgWidth 615 /MaxWidth 2919 /FontFile2 32 0 R >> endobj 32 0 obj << /Length 33 0 R /Length1 24396 /Filter /FlateDecode >> stream xí¼y`[ÅÙ7:sŽVKÖjm–ɲ$Û²-ÉòÙ>¶eÇŽãÄIœÄv6;VV²’…Hb &Á a B I›¶JoC0¼”J(ÊÛÒÂÒR xÛ±|s$9 …{ï÷~}²Ÿ™9sæÌ™ggžiãÕ›–"< ®XGÄOËïܼё¸6l!DñàÒuËV'®íVBÔÝËVm]š¸.ÜKHÅ¡åK¢‰kryårT$®i9òüå«7¢öñ®"„JV­LÞ/T rçê-É÷“?ãÚ±f`õÖšEÅHë®^’¼O{Ñçnܲd#‡6­]Ê)»Ž®¤DƒW࢑Œ’r‘ŽèˆŸ`ÄÊyú\àKÅûÒ/gKÅiÃÿ"v6 BžüÛ½u,?]—µëŸåw˜?³~ŠK%zH|Яü`¼†Kß?ËÇ›?{JÞ³Æ'‰ƒÆWZéÇ)úUªp!Uø2Uø"UøŸTá|ªðiªðIªp.Uø8Uø(Uø[ªð~ªð^ªðnªðNªp6Ux;Ux-Uø]ªðjªðÛTáåTáLªðRªp(U¸-UØ—*Œ¤ »S…]©Âͩ¼T¡/UèMzR…îT¡+U˜š*t¤ SR…ÊT!*øS…’T¡8UP¦ òTA*Œ‹œû§˜~.¦Ÿ‰éy1ýTLωéÇbú¡˜¾/¦ï‰é»bzVLÿ*¦oŠéÄô51=#¦/‰é‹bú‚˜žÓçÅô91}VLGÅôi1ý¥˜žÓãbú˜˜>*¦‡Åô˜îÓ[Åt¯˜îÓ1½EL‡Åt§˜Þ„T¨Ÿâ¯vˆév1Ý&¦‹Åt†˜v‰i›˜6‰©†¥ÚÆAI#Éø €é€E€µ€€Û< ø- ,â?„* ñÿ$·b€QÀ+€·ç ôB¯!ôB¯!ôB¯!ôB¯!ôB¯!’†1”£u9Z—£u9Z—£u9Z—9Þê"o>ðD‹4ÐXxHâ\ÒóïÐØØè7:öÊØÛcçÇ$‰Œeüíñóã’ui7†=ŠôÀÛ€ó· –¼ýÔù§81Ñ6ê%NtìdVˆëAk-Ò·^›Æ®%ŠÇ©ÖCµv‰\¼–!ÝÁYĶ\îâ4¦dä-¤Ÿƹ„Yü[o›-Y¯ÿÉu×›í×]o{õw(o¾ÉêuHV­ErÕ³ýª5;®Îܸ)Ôµl%’¥+,Yža_²|x}¦mƒùÚf›s+ÀÖäî ÷8’…´˜•¸û¸ƒÜýDÍÝÊíãnC>Âíáö5±s÷‘= „ô!ÀÏH¸GÑæ(Iç³#Ï>HÒÇ?àöÈpÕ<‰ÂAVhÌänä¶Å>îîz"E¾»–HoKæ×rsÅúk¸eb¾Œ›{BêsœâÖ°;j~É]û¬ýÔKXýÜ“ÁP²±‘[Ol€c¸J´Y«7QúÀs;¹­ ¨BΞߜãºd¾•›#Þß±YÏÇmFÎîoJæ’ùÒd»ÈY» É|-7ç„ÜWØØ…kJnf)·€[È- gp3¹YȧqÓ¹.RÅMÌ iÜ2 å^”76áú~\?üÈÓ¸xâ*t=-AÞž#_AÂÜ  °00 áÂ"Õš9=åã„äu=®ÖuœTkm4¡ž’V¤Ï8nîËq¿9£RU²½íåŒÊ¡FsM£™ó'o”&óäŒÅÉk_2/ƒRßäÆ&\S"Eú(€º!Òˆâj#@Â5q:ñÕÈYO ÈÙÐk“õÕɼ2™W$sG2/GΞ &ó@²¾0™p: 0Ҹהd"}’+ÊÎÊÙÀ§æÒ‘+8%—&2Gæ¨@| F«sT`Ž Ì±€9 0Çæ(pß…'Ü`F6zÊEž‰ž²»Àˆl@&ÀP$LgÑN†–ÌçÐùŒ)tv2Ÿ‹œÝ“¾Ûæ£HæïÓ·†ôl2›~$^Šœµÿ˜~Z §)Ó l£Tr"L 4§ÆGÿu®£-øÅÅ5?£<óŽNäæ¹ždÅ“£99®Tevvª2+k¢ÒnOUfd&KC*c²$(ÓPâ(=)tíA‰¢GVjLC%!ÓI.«b9FFNtÍGFNº\lDä§Ù95Âv»8Ì¿ç»k朢 ÁHÿò©oÒopBL•^ǫ́Ô<„ª‡ŒÆá æƒÔwÿA©ïà~‰ï‡÷I|÷ÝÁû„_kîØÏûvï¿w?§´þzw ¦kÑùùÇ'çºk~sЦ YôÞÔWõ ½ûç³Þã)ª±ÜCu„š? ¿ •´ó…Nœ‘øNQÿ‰—XVrâ ¬˜Uþ‚N¥SÄ6SNìúž¤óh7ôJÛh£Ý@·›pôfº[dÎ.äŒÉ·$óÝô6ñÁ}ÈYým'‡¥¾†F5=D(}™¾$Þür¨!}•¾tBÆ8+?QVVòÇ0†ñÑ“ÍÙ*èÿlͬyáEÞ÷âi‰O8íÌcTÐzï]\¼[TTsæ%HÐKM±ýK^/Ëú’%³æÙ)°VžxS|±úÐí®yëC*.+¯>ÆÛX7‡fÌLä-“yuXìNuŒë=„'Y»» ÿȅׇ@ŸvPßvŒj^qð‡tǰ;w÷0õíìÄ[n× ·óK‡ië0­¦žaj¯2Y+M¦ “¡Ü¤ ™Ôe&eÐ$ ˜x¿‰”š.|¥u\\à<^MW[äÓû´y.M¾K›“«qäj‰T'åÂuUxcø¾0¯ÕéÕÊ4•Z&W¨y‰T B-㣹늨¶ˆª´ZXŠI$ÂoäDþ¤•©ˆŠWi'‘IÊ^~žr3?¹_yŸöDý$UQµP¤µÓìt«<3ݤ³¤$éþ k/ü ð>à=À»€wgo^üð*à·€—g/nìŒvvnÌôz=€n@`* 0P ü€@1@ ¤ÂŠè?£ŸG?‹ž~=ý8úaôýè{Ñw£g£¾ýCôµè™èKÑ£/DOGŸ>}6:}:úËèÉèñècÑG£‡£‡¢û¢·F÷F÷DG¢·D‡£;£7E‡¢;¢Û£Û¢‹£3¢]ѶhSTý&cþÿ¹†êýïøé­p`ˆt6b2>1bB$”“þ‰2–Wß#dü|ª>>óRO'é|Ig½p¦ñóÜÛD7~èò©ç.å<Ú$®X¬‡„]6‘m,Ãg0‘!OÄš˜ÿÝŸg¿ûÖwÞy™¼@~Nnïÿ‚œ$?N¶ü1y‚ “gÉ/H"JÖ ‡h'9„´5}¤Ì& É ´^O“G“O-&ý$ˆ?BêAÑ‘dí‹äòô"ÚÝŸ¬¹”݉·\MNáM÷“)诞ì¶w‘‘‡H¹W—>oˆÅ·¹²’l GI ÏFÉr±¶“Ü@ÚÈ|Œ­•ÌÁ˜Öàí}ä1ò8YBŽ“ûPÿ 2“<({Š(¸ŒSãÿÍÕŽÿ7Ùƒ§ïæ6b}·"ÉõäAòW‚%?¹-þìÿ=÷. ì;K·“{ÅN²<íãëø.¾‚·ßùPòÆOA¯g@›-àÊðåAr;u“ƒdÙFÕä{ä´ì êü?õ÷m÷Jö¢ï+?ÿIžÝ÷bÀ—`ô]W6B8³€¦AnV’>ª!_‘Eß¼ÿÿÉõ:ÈÂHÜxÏÕÀ¼Ó Ù„|9`SêpëÉnpýÅ÷PßD¶“5ÔIäy²›Zɵhÿ=ÔÞE~Fh»ÿ‡ÿ)ÀÉ/¾+}‹k—j¥tü#É1¹$>þ x'Òëð·ìÛÄñHÿDú³x“T/ͯ_¹ì¿ÈÉoɯȻä5ò{ò"ù;àÅŸå?—ôKdÒ3Òï“'$¥är÷7{•¬‘,—Ì–ôIJ¥^hPé„]‹¹ªŸ,&WÁ®éíò äéi”ÿœÿJz/úX»w3lÓ°dDè[]´pÁüy}½=³»gvNí˜ÒÞ6¹5ÒÜÔ(4Ô×…'ÕÖTWUV”‡Ê‚iI±¯¨°Àëqç»òœŽÜœì,{¦Íj1›2Œ½N«IW«Ò” ¹L*áð(¦Ö˜µ¹§eeÌÖÜß9âÒ9bêiç;ý1b°;]zGÈß[’l“úbÄØËèê9N„êÞ˜Ì÷Í&Ób¼[÷¹wÚ-1‰ÿ®)ÑXÁ̧K÷†}â~/ºe6÷8öçÆ;náÊ€#Óu¡7ÄšöéêapjüjT’jg/Ò™=±œÔe/ë-Êeƒ|¶iôÜFGtÇÕ¶æHŒd'êwbÄÄš¯†?Ž`YèÖ¡$öFü1šñyŒcÔÔ ”®|{ìíêo¡AKt¥«%ºö_¢éùEŽÇÈÌ}ÈîtŠƒÆÊeFÏqUZ³«yI°ÀÒäxš 5*V¶¬;NÕõT,pê–ÚãQ¤ƒ|6Ü+cž~\Ð wŒ—î ²°÷ò[%4KT|gLÖ“'áXbdãxñèÈÞS:²¸ß§Žº¢ó{büuœðî–åݱ¬Ž®>Ta€þåÆîˆ˜0æ9Z–;FpÍÚö#uEðè•õÑåKú™˜Ð~W÷”Í=»œ£v,Ç{vµÄô¾X:O¿ö=;?Òb]á`—##»±C3z.¿ëdm Ö’bÇH‹ oCg-+›Çül¥±=*2GØ3àˆ -^ šá`oJþ#º˜úœàøƒ'™v03ˆö¯d¨¬Ä“dŽ‘=KDT÷ЍA^-+# ؃~2O÷õ´,wµ€žÉ‚ xžwóY§3fó±GFZØ¢=£ þmXc‰ è„ÝG1žæ˜Ð-f¤[äÞ( Dz“Uɸ#bB¤·—!•`@LîÞ%-u9FX§rw,çs>‡{£%Å3{Z"L:Ñ’kî©;gµŸC¹£k¢šZÑfÄŽ‰Ý™åꘑ‚åŒ>,éïN(0¨–ä<š&Û‹½ž±ÚÏ$Þ0¿§ÕÕÚ?2Òêr´Žô œZìrè\#ÇÕê‘u-ýQý)ê¶ÇkÝÛÓõ/§µ"‡ØëïnÅêß8ccU«cùjðßàrVÛú‰6°"ß~;©s~èÓ¹ÝÇÀ^ ëdw´2Sƒˆlµ=¦«f*‹ÍîN â-Q1® 0ÄÙ™Öð½î–³’IJ;ñJQx˜ œ‘¬E'N'Ó§=§²±¡=‰kYl?A¿|ìgwFSwL³Ù¡Ô‰Çû]à›•¦Dùø.ù†mŸí½Ëà¨a†£Ã{46Ú ¿¬Ž)@1‘õÆæÞα&(qvž•Ò|˜Â1‹O|ÑsDçr¼âŠé|1isϨ=ÜëÐéa,)Ú´¡!“TÝ+®(³£$C£á5³z» êÁî[ªqsB-#ýI¼-4e­£Ë'T)1xè.à Øë\P]{‚ zƒ‹aøøÔÄànez–ˆ„šÒÓ°ù.¦ùXL0^{s–š;C,8Z˳cŽþˆhzíì~ªúÔøÛýf{ ƒhbOŠ8=AÚ+E±¤øÿ­ AÐoØÛ»¼cŠ€£¯eDoîîIª›È'Q ð®v†Ê•÷'¨˜jÃuvÆ™/X!¨™VQ«º;ÑLè6 ¸üeâ½”x°‘ÄZ1ÿ'l€8²ØdñZÄÝnûÆíöÔm˜mökÑYÓqÝ=ã¸@wÏêëy /Çîîžåšû›zçã^Ï“8Ab-âvýM¬’5q° ÒAÑÛ lˆ±öö'B†Ä»±B¼D W¬K4B%ƒˆúŠuºT;u’D Öa>Á[¬ËaÞz\`z4&tõ\ß»|¤¿—›˜ÉvÕ“çª?N9™:–æZÒS¹šX}«oHÔËX½ÜÕñ‡r8NAÕGú]Pàb§½L„™”snÇ©ñqXÐ3°¼Î˜Ì=«ôõ:bR÷´›Ì Õ“cCƒlLLñ¬ÜÝ>ØSLtˆ&í1%zP&{@‹VñLÏì¡Aë€K,¢Ê1Ôëõ±—ö¬`#r8൹jc2ObR{‘¿wÄà*§™;–æÞ…'ðŽ)¢!kì¸ÄËØ|„¹#t¡Õ`¿ÁYF‰‡ý§1¾¡f fu‰“* Š,ÞĹ ¦øªô´˜²⟕U¥èÿò^…!/^íJ6À»u1F乌”É@ÜjgcÁÿ. ž5}†u3ã™éÚ£"EÅWÉq;–în€³x^…ü¾ÄÃèKáfU¬çµr†¹Zth»OumeJ’ú”»b¤»‡ &Á>HïÈ7+bó`8߬M«GFéßþ@‚^Šô‰œõâhYY%Ì) £ÌÓ>°§ÚP^"§([Ñ_$2É{d«dˆ\#í [$Qëíd+woâZv3Ù$½PK®‘ìAÝ—d+ÿ%Y'yŠ4Iý¤O¾ˆ˜%wÿé’ ¿‹¬¬#+ø¿“åÜ*2ÿ'Nœ¬$WCfqN"•”áôH1iý€Ì’\h@û ¤ŸNfñëÈBî â–\EÚ% b”•‘lþ¯Ä‚r=L¬Ø¶nCy5÷²ŠþŠLæ?&õˆŠôñò8ÀÇ}ÜÖ€·:wn¬\$ÎÝá!60Y¼Ò vP¢#™ÄMò‰—äâ!%$@²I9É"…Ä‚”•äAZ8$¤Ç¨™8ˆ O‘JRCªH.)#b#œe,&¥ÄŽõ#N+œÚ“’:RK2ˆñ?áH˜hñn6ÒêI5Æ Œ‚Íøû”n¤g¹zîy¾QÒ.–üAºHú[Y–l›\!ß/ÿXÑ©xI¹0-+í¶´1ÕvÕ§êhúŒô?hJ5ÃÚíÝÝûú*ý¯ å†ÓF‡ñ.ãXÆ÷Lù¦M/𕿠s§ù*óAó)óï,Ù–e–k-ÏYˬOزmgš2¿Ÿù ð{ ¼YÚ ÿrÒ!¸Mþò‚ÂbRœ­ ––«JKUÅå’ŠJRè „ F£Æj- ò¤áL™ÿ yãL™Þ@-5~|tgtgô!Ý™2Ý_žhEy=WUÏW”{\yN¬ •åp¦ \hx“ÉbrUP½SÏ€«’™‹ò-»¶±ÞÈ·)û÷4·ÖgióÃÅIn¸^“ñ«éßÍfwQ…׿Õ¸:ffä—åܘSšj-ôÔ×µ–8‹½Y²5?Orð륒/¾ú1dÀõÒ%à]Ù&DJgžT•æÈÓäÙ¬yg/ÕH3ssó5£B•—áHãÓö ZÇt§ç«fäðzƒþH„˜52»Ôg•†ßòé‰%¤7ÔXýXÁgžóé ¤¦&€EI(d¨A¢7Xjô¡n×èè(ƒ ³¢žU¼^§\&3e˜-&'hSEC4‡³˜¨“ç³Ê‚VÖ/ÍËÔÕ5ÄgWÏòÒ‡¤ÝVwyÉÅ“ôûOÓ¬¾ü¼éÁO™š®VƒÊuË%³¾~tÚÌRUËâ†!µ[ñJÄ8³E¹½J˜d6UUò•û…"uvÑþ‚@v _²?[ȦG"Ùµ‡÷ìW jÕ‘ˆš×ow:ƒæ"Ûö`°ºÈ·Cê?[dÎêkXJ|$Óª;ç#ÖT E ÷` Ä0Ô——rÞ g™q ™LnJä.¾ qŒRΕ'“ëõæPY%.=—kk}QzšÅƒ;=³°yÕìÝ{·¾yþ½—L_Õà¹>·½ï¦ý“ïºñþ ÎÛ6…hip™Òƒ‘ás‡ºó•…?Ú¼ûÇÜgwîm™Wi‘pc_­‘7Ý00°½žY€kÆÏK གྷ¬t:©-CkXdXkà W  BÒ…óL¯p%ÏåX4¼f¿`1æÈxÙþI•ɸ4j<Ì yiÛ3ýgoÏBøkðODZ€Äª{bPãÓ=‡Z w‰¸Bì "²U!½LæÊ#úrC~¨Ì,1 Z§,nYöðü©w­š¹|²cpá¯6ÇãwQÙÌ;(­Ž4wYñ-ñsÿù\ü£[ýKãïØl´‡Î~ƒbûR½Éëà±Ö§FpØsøœývÁ†Ú õ‘ˆ¦/ܯáÛÜî’¬2qØàß9ìþNðNä?Á/¦¢œ\Ùty1äzIE9–o)-0§C~ú¿üìÈÌÎ)‚ÎÖLëÞ¹jN¥mÓïïŠÔÕæ<¡…hmÈwf}ÿ³£?ŒÏ,È[ É _µçØ’ßPéXq*JgF^Jv=I´8Ñ¡T·iÓrs-VŽSâE¼A@Á²_H+ÍKƒ´æ¹ŽDò¬¼u¿WZr$Rªä•ûKyýa­Á`¥‡9ÎêtÎÍ ¤Ywx“â*ʬȨ$ÊLFêþ̱ç}¢¦ZýàŸ_÷|’W—SÏdlbŒséeõ|Uˆu6!ÑÇb­#¯°Úîâ2§váBMžßÿ­ ÖçY2'EY:;þ»à”²ÕØ?ma!>®Ë{Z_Ø49ø 1NÑC z‘]Â,¢ÑišCš˜Fªä5JŽS(•f^«ÏÕûõéŸÖK•zó~(©‰Wå(÷+Y¹9¹G"9E…G"E ^±¿ˆ×Ök4.F˜b¥e‡+I’+¨ÓbÔ`†kìù… ’Ñ=Š„ìòߤG³Q—SC¹Ø\XÆÿôr‚Ú<éËGeA¯ÌåÊ;qñdGqzz­¶hG6(sRK;³ý>Ñ^‡˜©RzKÈÚ˜¨Dá?iwc>KqÒ©ÿ&[Eô01§påL’Ûeš ·7¾ ªX?öºÒTXŸ—d0}´ØkQqÅú‚Iô‘êbÝWµµ.³!-ÔäµÎ¢Ä4×ç[ÕWr;¨2;›ZâÒÅs…<šºZg&°çr}&É R…\q$"7Œ†##ÐT‹s²ú“¼úÖqÓcâðúRÃ;†÷Õw"¥}:¼7‡L¼D©Srj^©´l¨ sé~Ae3[ÌG">MyX¡pº„`ÁËec§¿¤þˆÚã†å\i9D¢ÒR™¯¶Ð™cÏX’qq[jŒ»­êùi&wxÞ¼øš+#¨6:š0=Q¶*cç*ÉRaR¹MPÚl¶[¥ñòùîü#‘t7 †‚G";âmÖr+„¡¼¾qCüvØ+±îζKè"z#)Í¥àâCIÞhò[gÐ÷Њš‹NþÓºøèãw| Û.†ø3Œã_IyP£œ4 ù k!±xtéeåeG"YšrÞ4ÄK,¼BQiÏ*çCŗІçÆ0 ãçË¢DÍfKÈÃA½Ed˜zë]ªÎ5ý›œñä3Ó¥ …É]J——¸-êmc¯•õr¨)tcÕ.;ÜW]G¯ºãw-›ƒê ‡ÐþõCü‘¹]ÞÎøêÓ/} ŠÌce^ËÂêà·ø Éà3`óÊ,>k¿R’¾ÍjÍÓo“úÿþã’ Hó<À£ÜwCÏàdTgÀœfHÌãŽÛ·åW·vî;z⿯Û;O?ùãÕ÷Ní=¸´ï†Ù^Ýô£TòÄ[T8ú½øoÿôaü©CÜoâgâ£{¨úä›4÷ÆîûÿŒ‘1ϲZÔ‰î,ïØ/deÁÒ%4VÔWæyyËöüü’\QuËô¢ï(ú¢þŠN3,°hŒ®œVà6²…‚+Ï[‘p™%§?L·—ãí)1:ÿáûm;\[·qýÓJg¬k,›ÔZhQ]ikNþtù‘•¥’Y“nY?gCk¶$‰Á—ÀÀõÙ¡"ËN‚AÂA_2Iž¯„÷s$âôÈ3ŒG"“øIû3ø¢Ü\»Ç]üíUUõî Ý‘ŽÕÏPÒý‡(N-̼&E+…¸`³é¿ÉÃQtŒ-qV…°yKyD\!Àë¢ÇTfOi|”}úá÷ÜS7·¢Ï[]ˆä‰8{ B¾`pÍú¹«æW5î\×Ç͈ÿ¸­ÑÉírOùØÉ[F+¶‹·M-P+®m8:µ-[Åý`ìÙZ·Í[´½ µnü< ÂÖÏüd‰õD%1³I7Œ³>®Õa²J4¼Õš¥ÊÏ—d•HxÉ~¡Ähd²i”XO·P‹¥ÀqN« œ“ËËÈá@Â\BXA0ÿÑ …Ê&`,˜Å9ØPƒkÜG s8p_œpK!ÑliNÍÇlådÝ’b¢=#²jö¦må›·nÚݼâ77MÝ¿zÐÒº°£qY8´jåЭӛ6=2ð½3´ªgiðÚMKûµkoì\÷hŸ.+þyÏbo` yòâîraÍ­ WìŸWXA Ìâ6AÒ¯‡œ8Èl¡DkÐc"ÒóÚ\šÎçæê•6bãmž;ÌkÒr­M¹‡gÚh¦“aÁÌëYÕ}~6‰é„«JN`F'Ü ~fJ8$úÄr¹IR»Øì TUíe¾ k\£j»¿®Üg„cyxN´Ü|‘$¥]®³äׇ%ÄP³¢ £îƒåx£’¥µSa4•ðf¦0Ÿ‰òxB™;4‰ÂÂ2ATFšïŸéhž\Ä™4œhðEÁ¼Ü)X’aô¸–ßÝú“õeiÆü =Œù¿pÊÒ©­+'gê½uô¶ZŸŽþaõôŽÚòö¢ÊëŽÞÀÝ1­Êat²,<°³ÝŒÞq·>áhó#Ì0_÷7Ùþ$6a_@l:Õ`©AL±n{E¨QÒNTÒNÔÑN·ÁÄsA %c–DC¬yr%ïÎ7™rpÞ`PdqÖ%Ç«€ËÏôVT\¶zG19 2:X0÷%&RLw¥<ó÷ku#–éF&’ PN]üOâ£ßÿÅ€ï,8éëƒÝ ´éTú±/4‰Žää;½™ñ»n“ÌùúI}dNзWð¹úë.~(Yóõ~îë=“ê*á,¥Ù|}S¿~I R· Ø×“eBmA©ÂJ«ªüõ9Î _ê/=qTøò3¥~ª3òuõuÈIºYZÏ+¬U|AA®±ÎXÈÍ~ˆŸŽ/¬<ÀKè]´æXÒÃ:%ѳT‰–GDŽ“óÆ„(®Ñ½<ŸŠV`Id©BÏŠ<®ý·9éùEtƒ{Rsý;ñJ¡ßo/-ÎÎyâé@~Qüfw ¸rÒÇñ¿º² ÒÙA¹Ç™Õ]ûß/¯/2çú HiÏ¢ø÷ã {'ó! —++RFK㿞rá¾*70e>]G_jóµ2?äHlU ~€±¸¿á0÷øku8J{jü!•¸Rš-)ÀŽQjÛ T*/ï½[X§RÅT£* QéT]ªÛU‡TR5¯RÙ´TRÊ—>(HÌîü£·Éa cFI gd§÷½Þâ6‰1W¶tS¶©«/Þ¤³éxݽ61#C‘3LU¾Œ½T ׫¬¬¼hX+æ”+à”ƒ!¾„×u†ÍØð@à+"d°Þ·`=B) s·$i ×'–'>Ñ¡ôùÜâÂÄã©(Ïw‹AÄP\õ°‘ˆ­À‚0žÅT 5TphçÞ7gêÆz”sÌi›¶ÈzSÿÐPÓà–0—–á-Ž¢þÍ‹¥­ÈÚúÛ$½S&]ÕzÇCéË·TÏœyc™ßÞpãMñÃSêÊsÍê =Í-_QÓdkZН*‘hAz¢¥¥d¡à.¦…RÌö÷RüB³.Ý•îâ]„ts¦íh$“dQåMF¿tÆ' +-Í6Š+RFÌÈc.°64ˆÓèÁ´$ñC É•çñʽ0IÐG,Ðpbv`ÓDHZ Nºê¾YƒÏìœrS[k Ÿnñ†>Ÿ¤q6L l¹~ýÕ5]ÓÝ|.mor­~óÁGÎn°çÕé$ ýS+r Êò´¯_íœ.3>÷Üó¿vMi+…®–3!aNrqàX!Çr‡Œ“Ä 38 ¼2×@µjC¨ÂSØfÐZ±\»G°šs4: äêtº4ƒÃhtá»H®´›ìâÌwgÚZý„¡™`:æÔ7›¯ÆJÜvÁµ3 Ö3­LD wâLX…¨ˆœ ù);ôeMÁÖU ÖÚþÉ-×5¡i½sC¿<½îÅ3÷ð¾ÚØ‘Ówjxö­ÑêÊHSu]¡ñësw½= Çp“øÀÁ<¬%– ¥úc:öhDg eø­~ÞÏÈ+ÌÍWrÙшœ(hÚ°!#w1V2ñv¹ª‹VI©þ& k uï›KŒƒ³'wUyÙ$“ÂÆÂøŠ¨ ¦u1èÄK’ü“eø*?«µ V„ŸØø«ëšVÕhœÕÍþ¡›×¬+®­®µk.ãâµÓš lªò´Ã’ææ‚ ~É?>m¡Pœqftô´ÖY¨íÇrp÷.p×þnšFsŽSÏëïœN•™Lv¼eûÔÆ›Îæ°·!À`3K̼ù˜‚lîX ÄiÐÝ”™é2씋tøÌPó†¾üM±5ÁbÝà-¾ëzööò@©û2 Àt2Ÿ2]Å3wW&燄«†:_þÝUÏß°dßl??6R±u`æMWÉŠº#Ë®Skžêûâ³ï]/¬ýánÃæ‡çÕµÐÙ«niô>6‹L£ÿ.}±ýU‚#  G# “Î6›é'>-qèǨã‡4ÇÚ¨`Ís·9ÎçóïΆ×Ç9uø¸a+.£'u´S‹µâge¯3~‹ë &¦Lh΅ʘ'R—œaŸ$Ø•!Ü0o–U¦7øiº­°$¾¬ØcJÛê±Yôéeݦá¾éUƒÆP©³ÄcOÿ”Ÿ;öHsÄeÂÔ(F¹!¸%™¡ÒÕ»û½ª'& aÑÔ8ªJâü;àei$³Èyan“s¦×›¦ð+*yÅÑJª­Ì­ôWòÊÊJ¿v&)5Áiu¹:¿îSݸNêâu:E<ùD(ÓÚÚø¶‚-ËßÀ7ðë¼i꼩ùŒH… D~~޳©ij‹Cg¤S[rrº9eAPR4i§TµJM!BfOe³€J‹SM¦Ù¡E¢€œñz6`_ ÆÆÇüpãL¢ —LBÒ Š2Ãä¶á c?Š ¯™ÅžÙäí•‹Áu¬–D¯8$N¢ÁÝæ*6eTŠ)3¦'uŒmB€#2£8eL,³\yü;O*só_xrVxjvsäüÊ›kV½´{ÉÑk»;ý•ÂŒ¶Žš%#]m“éâ±)KûCm%¦²9Õ‹¢¶Pè¶;ûnˆh¼mµfðsåªÜ«ê9nª­v{tMk§,¼s¦µfAkÃ2¯qJYÍ¢º¢ÛçÏÙ1«PeÛno¤7س¹jûÅsžÙ•}³}ᬊ"dë1IìT-Y)„yF]® e a‰Îèã ŽF …&ƒ„lª®:©&5T=lµ†‰k8á@22vù”ÃÂI8áõ%æœúÀƒE;Yt\”Þ„}rÐí“gú♜‹æì³0f é ŽÌŠÎ«fÆwÍmp!ö¥68š#T6|kkVÛT_ü†H­×†%l"–Þ’š `µgA­ÿ}]VkŽPd‘Ø$G#6SÊzk¹Áu<Õòoñœ–_„ŒçéMœq˜KKº ÈEENóû|ÏÕ%þëœKØç”öbWŽñea6ËŠ$ ;N-õ:-ék°äuº’P|‹4òì³_ÃØ›ZéãÂ4¿EQ¡«˜ÓìJí«4ÞB7‰cµ ’T)ˆ×ß+(²LG#æc& Vøæh¥Rk¥;9Ëðe6çìëg™ÂˆF• 8ó\Ãû—|%q–¬0²-&ïe㦛~z¢ö¶¡¼úÆ"³,£¨êÃ:q¼¿ÝûƒM¦¿ƒûû´ˆ×ªªP2[Ù9 CÎrË“Ä0þsØàò‰y[úÖ¡¢¨´Îa±KMù|¡Àaó—Sc'CkËÝò£»ß¤ÕhµõuG#õD ½É–/%EÕIºW2é³@ÇEw‡áXx%ݽÌ3–Ö!@V”C*«ÂNûO®7€£œÅ©Ä C¦½ˆ`“B\ §Ä4)’«N“-\UêW*ÜEô±ÒåU£Ž²øP¦M•WrM^¶Ã^Íø¸¡Ì«—'e“+‘+}!_؆åRž ›ŠBù›ñÝM 0Á¼>C›]V¨$K}^äq0=ËÛ\É_ÏéŸAE3 & V‘G#0HÆ£‘ b‰2œž$DzÂéK^0‹]¦j)¾9¾¯¾óÍÐ Ù"þ%œ¸>+ÌQ)À¬4ûT:HØ%ÏŽ]R––(B2«=4}¦´²¢òh¤+³Â´èØÂ… ŽFj©²À×*m–5óÍ÷¤ËtÊ’á0“Ø~– Ì…Ã=Æa­“6¿ïš)n"ÿ6çâ~Ò6Œw£'õ´¹(Jì!kׄ(° ¬Ï».ºP¨ÀJœ­ ØTtšaJHER$Ä5)ÌæS³è#þ1:`FªT":ÃßQ—ø‹íDå¦k5áζgt»µcÁ@uó@snšÑS¿†0¥ÑžWê)h™‘©.ÍäÌ+Í.lëðÈÒ3ÜîøÓªf6áÃ:>O®sëæ/šÚæõθvY|×ÔZ‡Qÿ¤u›½¶É“¥sLí,ßyåÞu‘"³ÊÝ:µ8~KM8Ïdd3þf…i(8,ñƒÃa²Y¨+e (aö¿˜%>–زÂ8îÎaÁAM…Ç ¼G#Úbƒ6Àœò€®rX¡¨/.ÊÎCà€©7òÑÇuz:5S¢ °·5$± +–vâ)õ`á}@ð˜+3C¹!>t––cpi0Qhón &g/äXBB{‚ÁZbÍä«ÅIBP¢FËäî©/±±œQÀª#µœ4¦¼T÷DH_TqE þ1Åb¸b]Â'Ö\ºÄòrÒâ Ä—ç—XµÅ[òQ]º¶¾­srÁ£Ç£O¥ÌZ7+²õÚ÷«gt9s^kÜVÓ1¶Öò}mu™e…òICG÷Å'ž]o£‹ú—7:^xŽîvMk/JJ8_zITÈ1Û¬X;[M,á9æÖj©š(t .ƒWH‡ÔlF2èÌm]¨¥:¥BQ襆ᜤdç°i†EÛd8ƒ¯y3?þ#¦–ÄÄ™ôÓEiM¹åÌŽü›@Ã>T-\ÝRë_o­ôçOn²™C¡øêËtÞÌ7wÉþV,êj Ä¿?¯ÅÁ¢[—ényÃl!ÖZiÀ,HîÌþ̆Ìé™üÓ™øñ]¦šéɦŒ·ms›Kl*õ¨7«oVsnu…šã‰Z‡c)]ê~µT)Ug—š°|@0™K±ûs T—ù¨ÍVTFñ U…n8//¤NxÚ,Ì,:¢V'Öc,Ô J,Zb°I—íx#ؼàjx‰¥öQeùBlA–ˆÆc®MÅ ¹ñ~sxjU×"O×’¥k*ïêê~°c±}å‚ü–JGA÷Êykz°¾éºÜÙpKVGci¸ÜWty\žã°Ÿ¾@t “+bô—ÓgAúœøW{Î[r! {j ÕêïQzë›1¡¤’.€Ø:mñ·vq鸿µMÊfþ‡×ËHÈñ²‹_ÑxZrŠp®.(×f× cÐÏ‚°Ã¯A¿*}’É üÐË—B{ÑH\ƒÉÍç¹ò ÿ.yZïø€ h‰Æ^$Á~E@é6jÜAz„&6b&öá-l)@}«€ËÖÆä€Uy/"ÄyKcŠLx8Ŧ̼|:Ù3½æ·ï§yãkfiŒûêî‚ø gEUÉ+¿/./6ÓÝÓMf®ñQ{ÈnÉ‘ƒ*ar<~¦©U‹ ¬Üä±½xÚì¶Ø]%¿¦ ?¢”®ÌÂò@]f)ÍbÒ”Ÿ"êG)ô£^eÕ›ÛÞWýKÅÉ”ˆ\'wÈ(—«Lÿª ’,Ñ™MÞ"všNšE«xT.7c›ÛQhN°fìÜ1à‹Q4´—`¼} `Ȥ,p6a«Dµ`*òï:Ã)ª–o›SÕÒ«ÎÏËñ‡Z|ñìN—Þã÷Ò5'NëþÚ„ͼþà´ôç –ê½Ügíµ9˜ËT&g¦½ÖWÑ· š³})]ÎÖøÇ´¿{N\‚Avb4]P¦·¥ËäéÜq•J«aóÊÙçŸ/#~_æÇXÞ$AzÙL⥚ÀŠù•¡Ò ù­‘ÖZê8É9…yríèw#ÎV³“Çõ‚G‡¯ué×é‡ô1ýy½T?ñ"ÝcÚ&.ù6|ë3ù6Ýy¬éñB?Éßx©‘·]:ñ⟟¾òÕÜC~ˆ·;¯ÆÛyœg ¹\Œð:ÞÁwñ·óR-ÏËc‚ŒrÒÇd ¥ì±H¦îl¨L<úÉÎᕈXWˆoºúôéÓü®?øàPk5ú­µxbÒøØGã8©D7Á©< –¯êÅÐíWÑg¸07í‚£<÷¸@(N»Q‰”’‚ZøvÉÓ¶x¥³ÂÉ…ãú }æ~öìdþ‡t>V¡âtr<§Ñ¨ä¾è´â߸€?ƒÄà £Íêô‚¹½uÁR™Zzsš£iéŠiáI[çæDZÐ{}|&ÿôΓlAÍSÎN¨ƒOáʬ;z44 Wkþ'c¥ßã^—ÞóåÏåìÙ>ú„ë³V!aõ”pB‰ÍW`ùø8?•¾´“aóx¼“{Wz?N& –4(ÐÝB%AßMìªÓN©Ô‘˃¬MÄñzvD¯3`ÏÜ”‡•¸ø‡C¨œb²˜CÜ»ÇþkKeÅ–?k­¬ór\zCŽ+«Èš´0Þ¹ôUü$\Í¢3^_9S­)(ž>ÿÞ‡ÇÏÆíöš¬lT>Œªï£²'FEsTÒ&SbT箕;UøŠ2‡ÙºÁÄÎ¥x=ìÏåûÎAIï_újüDüø{ñÇ®”âÕãZî‹ñ›@]íäSê×=Gü-¦Oî‹Ï6nÄÈOÀr¿Œ3™Ð®ƒçÐ2¥ByNÕá7a4f³R†Sü#M–=¡UØ(±ˆ-i¸th%Ä¢®©tláaáz/ ÉLÜOÓõ ;Dz×.*³dÙ›çÓ׫dTZ;ÉmRqííR}^}+ï+p7ÕvRKÿ1ŒéŒéŒ©€,BŽlƒAiµšÙf>Ó|¿-QJ±MZ (à RØl¥T.sì5ŠlJ¥uŸÍ6ägÓ¥ÿ³7ÊΰX³åÏó>f9qÀ‰íª±]`F€§Ç‰çÒX`©*áÚâlMâ|>;uÃCX¸§‚á|“n¶þâ ¾;nÞª®²;~Þ¸uëkÝ?{ÊT2uþú§z©³Jüñ?VüùÀPSÛŠþŽ M¯ŒÖ„¹¿¢wntÙ–în·Ã÷¸Èv!’®v{¹ÌKN"lzu±ÍT–ƒ—m|qáúc}‘ë×­ï©XòÊ9¿žµÅµaðÆáر¾]Oöm^¿ps–¤ö©ªÊÖ›æÍ¾¡¿T©ªèÞÔ±ññå^ÇëËîÛsÇÁEÏÈœµ[–®€]íDôÂ)DóÈ¢Äyg?;ï¬U¤É¥iYRœ›¹¥ŠL+Ú‰dÂ^i±{xK–éH¥ùv¹+ìÜVö{8ø‰ó#à'Ž%öÙà,±+Ìn Qᬠˆ%Š'™åŠç‹`)± ࢜¨Æ^çÚo3Õ–95SÕçÅ#k+ãŸÐ]2IZ|«xrèp¿áâ#z_ðåÉjtüÂÂL»“éÿÝàêïa=äÀO)UK3uÙ,b+xôYmZu6–¥Ú쇲ÃZÏÎÖKÝX¬ÜF=NÌ<„ÃDØmþf=o¶XœÚÌ=:uîU( ¸}t‚±gÙïtÄÒgöõĮ̈î·KHÃ˾ÔIB®Ái@w} £‚?¨J,ÜWª‰ƒÜ÷Ü©O%ùwoÍÙÚ?¼»íÚ‘ÅÕ]œ7/Ç ž¦{¦üÚºkNE×½¾ÿ'U¯/í?ôÐÊ=õzƒŸ»Ceq|o7›Nn¾y4 ¾ÞˆP¤Û†3Ës„â©L¦W*±¦}@P*m~ÎR°Iôøj¼.©Ë†Y!ýVŸÏïÚ›‘@žøš²Üg’ªš”Z¸¿°3¦<'·\>lߨ̯¢yã/¹gÊD—¿íà'ßs¤u?²hýC]ÑWïûÓ[ë^¦º»ããÁy]µ,M6tcÇÒûµÒÒàÎq“„«On¹ñ×WS~R‘Vþ}X1v•¹È¡R«›ž>]>ﺶ»°°æÉZð{xfϲH¨$T§—Lr¹p8î à²(\Pfb7…Ñâã}-û­^o•:çV£Q-Ù[UÕXºçw™Þ~ËÂü’ª2—ZjŠ(Œ¸=\åMí3¾Áð²ca)Þ&ã4ÉK Ç[¹õ×ý~ßð kÃS¸ÿZÿêŽÛŸ\5˪l›µ¾ªñê)Û‡U9KÛgnªkÚ2}Ê’;÷jzñ¯Ùtb ÷GçÍÊK_ðβïÏŸqßUk¢²I˧–4n›Ù·-|ËÅÏ×Ï 4ïìëßÓ^: {¹ž–ã7=‚FrR.äЧPÉSBLJµÒ\)—ÆKy9‘(”9ü=ÓÊ„ó¡ý+s™Œ˜œ(àz~óÅ~3÷Úž=ñ=ìg«Ð‘À>2x3¤kÚìÙÓfùšV/¾zÅÀÿnÕ[¾ endstream endobj 33 0 obj 16250 endobj 9 0 obj << /Type /Font /Subtype /TrueType /BaseFont /GMYRRS+Calibri /FontDescriptor 34 0 R /ToUnicode 35 0 R /FirstChar 33 /LastChar 54 /Widths [ 533 631 646 459 226 391 527 305 335 715 479 349 498 525 452 229 525 799 525 229 525 423 ] >> endobj 35 0 obj << /Length 36 0 R /Filter /FlateDecode >> stream x]’ËNÃ0E÷ù /aâ&}P)Š„Šºà! Ø“‰:‘›.ú÷œ1$×ÒñÜ{ÆÎ7Ûûmè'“¿ÄÁíd2]|”ãpŠNL+û>d³ÂøÞMJ{îÐŒYNòî|œä° Ý`ª*3&%å8ų¹ºóC+׺÷½Ä>ìÍÕûf—vv§qü”ƒ„ÉØ¬®—ŽrÍøÔÄä)õfë‰÷Óù†¬?ÇÛyÃȘ}_É ^Žcã$6a/Yem]=<Ô™ÿ/tIh;÷ÑĬ*5f»6,ž¥°,M™[©á¶»/fu¥²v^Ö”(@®K¢8‘µ‹d^‚ÈÚUˆ¬]vj¾¸T\ƒó\±˜jA„y¦Q"¢…¢Ñ…¢€L¥:aÖƒJÆ¥"êiNE”IT%Í•©£¥W¤æµ"TaÖƒJšS¥Aæÿ36} ý2¿OìN1òºé_¥‡×íƒü~½qµ@ÒŒµ» endstream endobj 36 0 obj 373 endobj 34 0 obj << /Type /FontDescriptor /FontName /GMYRRS+Calibri /Flags 4 /FontBBox [-503 -307 1240 964] /ItalicAngle 0 /Ascent 952 /Descent -269 /CapHeight 632 /StemV 0 /XHeight 464 /AvgWidth 521 /MaxWidth 1328 /FontFile2 37 0 R >> endobj 37 0 obj << /Length 38 0 R /Length1 20284 /Filter /FlateDecode >> stream xÕ|y\T×ýö¹÷ξ0; 0 8l²‰0¬²ˆ€0 *ÊêwÅ}‹šÄÄl¦f5iv³ £‰˜Õ¤¦i’fiš¥m–&mÚ¬¦¦MšÄDyŸsÏÅ´ý½ïçóþÓßÀ3Ïóýžeîùžõ^F×®$z²ƒH$·YïJ"¿òÕô¯[ëavê"B”ñ V.\Æì » ÑÆ-\ºq³ P.îþEƒ½Ì&´|á"8˜-€S-[»ÙùÀs—®è¤`ç.ëÝù|ò.lÏòÞeƒ`¼ZâñæY¹z0’.t¢:óÚ ƒkE$¬Z±Œ³@íeý‰"„1‚‡˜É/ˆšˆà‚-{…DTš®¼utÏ·/Yæ›Ê¾!±8yüó-¿¦üü%÷^þéӗk¿P? S‹Ø åÔ·žþ!º?œ:u@û…\S$Q¦˜°VòŒŠ»kB#Ä..vrq!;¸ØÎÅ6.¶r±…‹Í\lâb#¸XÏÅ:.†¸XËÅ.Vq±’‹\,çbK¹¸€‹%\,æb ¹XÀÅ \ôsÑÇE/=\ÌçbÝ\Ìåb³¹è⢓‹Y\Ìä"ÈEí\ÌࢋV.Z¸˜ÎE3Ó¸h⢑‹.깘ÊEµ\ÔpQÍE•\¸¨à¢œ‹)\”q1™‹R.J¸(梈‹B.&qQÀE>y\Lä"—‹.²¹Èâ"“ ?¸Èà" i\¤r‘Â…—‹d.’¸ðpáæ"‘‹.â¹pqÇE,N.b¸ˆæÂÁ… V.,\˜¹0qÅ…‘ z.t\h¹Ðp¡æBÅ…’ "$"„1.Îpqš‹¹ø‹S\|ÏÅw\|ËÅ?¹ø†‹¯¹øçâ+.Nrñ7.¾äâ_pñ9Ÿqñ)Ÿpñ1åâ/\|ÄÅŸ¹ørñäâ}.Þãâ].Þáâ\üž‹ßqñ6oqñ&opñ[.^çâ7\¼ÆÅ«\¼ÂÅË\üš‹—¸x‘‹¸øÏsñK.žãâ8¿àâY.žáâOsñOrñsñG¹åârñ‡¹8ÄE˜‹.B\<ÌÅC\<ÈÅ\äâ~.îãâ^.îáân.îââN.~ÎÅ\ÜÎÅ.nãâV.náâf.nââF.ösñ3.nàb×sq×rq Ws±—‹«¸¸’‹=\\ÁÅå\ sq—rq sq»¹ØÅÅN..äbÛ¹ØÆÅV.¶p±™‹M\läbë¹XÇÅk¹XÃÅj.Vq±’‹\,çbK¹¸€‹%\,æb ¹XÀÅ \ôsÑÇE/=\ÌçbÝ\Ìåb³¹è⢓‹Y\Ìä"ÈEí\Ì࢕‹.¦s1‹&.¹h࢞‹©\ÔqQËE Õ‡èi§æpb¹gæp¢´“Y†Kaí`ÖvFÛ‰8·2k £ÍŒ61ÚN¨D– á„jÐzFë ±´µÌZÃh5s® 'T¡ÀJF+-gY–1ZÊè‚p|-r.a´˜Ñ"F -Ç× Ë ³õ3êcÔ˨‡Ñ|FóX¹nfÍe4‡ÑlF]Œ:Íb4“QQ£vF3µ1jeÔÂh:£fFÓ51j »ІFõaW#¬©Œê®&Xµa×4P £jFU,­’• 0ª`åÊMaTÆrNfTÊŠ—0*fTĨÑ$VY£|VK£‰ŒrYe9Œ²Y¹,F™ŒüŒ&0Ê`”ÎÈǪNc”ÊêLaäe”̪NbäaåÜŒ%0ŠgäbŽ›Ž`Å2r†ãZ`Å0ŠfN#;sÚYYX𙑉9£Xšž‘Ž‘–¥i©©Â±­øte8¶ ¤`$1§È,‘IctFÎ"œfÖŒ~`tŠ¥}Ϭï}Ë蟌¾ ;;Ü£Â×ag;èÌú;£¯dicÖ—ŒN0ú‚¥}Îè3æü”Ñ'Œ>fôW–å/ÌúˆYfÖŸ}Èè–öGFï3ç{ŒÞeô£?°,¿gÖn™…¦¼Ž™ z“ÑÌù[F¯3ú £×X–W½Âœ/3ú5£—½È²¼ÀèWÌù<£_2zŽÑqF¿`9ŸeÖ3ŒŽ1zš¥=ÅèIæ|‚ÑãŒct”Ñ(Ëy„Y2z„ÑaF‡ÂÑht8=4Â(ÄèaF1zÑŒ2º?U_¸Õr/£{XÚÝŒîbt'£Ÿ3ºƒÑíŒ0ºUv+«åF7³´›ÝÈh?£Ÿ±70k£ë]ÇÒ®eµ\Ãèj–¶—ÑUŒ®d´‡Ñ,çåÌft£K]Âèâ°£m¿(ìèíf´+ìXk'£ ÃŽ ¬a6a{ØQÚÆh++¾…•ÛÌhSØ1€,Yñ ŒÖ3ZÇhˆÑZFkXÕ«YñUŒV†ý¨e«l9˹ŒÑRF0ZÂh1+·ˆÑBve XñAF,g?£>F½ŒzÍg45º›]Ù\FsX£g³ª»Øu2šÅ.w&û  «¥ƒQ;£ŒÚÂöÖ¶Ó°¶„ítÂNÛwšÃö,Ð4–¥‰QcØŽƒ„ÐÀ¬zFS™³.l߆´Ú°ýPMؾT¶ïU…­u JFFŒÊÃVœ „)Ì* [º`MfT¶ÐyT¨8l™ «(lé†-³A“XZ£ü°%Î<–sbØB–¶Ð)‡Q6+žÅ>!“‘ŸU6Q«,‘Q£Ô°…F)…‘—Õ™ÌêLb•yX-nF‰¬\£xF.FqŒbÃænÔé ›çbÂæù hFFvF6FVVÀ ˜™ÓÄ(Š‘‘‘åÔ³œ:æÔ2Ò0R3R±œJ–SÁœ#‘‘ÀˆÆL}nŠ3¦~÷iÓ€ûGè€SÀ÷ð}ß·À?o€¯áÿðw¤}û$ð7àKàü_Ÿ#í3ØŸŸZèþKÔ"÷GÀŸ?Â÷øÀûÀ{°ß¿üø=ð;ãî·Ýoß4.u¿aLsÿxú7F¿û5àUि ߯ËÜ/A¿ýô¯ŒKÜÏ»i\ä~θÐ}eúžžcÇðþ4ðð¤a•û Ãj÷ã†5îÇ kÝGQàü í0ÒÁF€ð°~£û!ý&÷ƒú-îô[ÝõÛÜ÷÷÷÷wwé³Üw‚Ü2·ƒè/pß}+ô-ÀÍÐ7¡®Q×~Ôõ3ønö×××× ÜÕ¨o¯nºû*]‹ûJÝB÷Ý]î+t÷¸/’RÝ»¥b÷.¡Ø½3¸#xáÁÁíÁ­Ám·õ[ýV×Ö¦­›·ÜúÎÖ€U¥ÛÜÜ|pSpcp}pÃÁõÁÇÄ‹Éñ¢@YpÝÁ¡ bÈ>´vHúzH88$Ô ¹C‚H†ÌCž!ɰ6¸:¸æàê YݺzÇêÐjÅäÐêV‹dµ ;vhµ+±زÚh®[\\ypEpù‚eÁ%¸ÀÅÅ ƒ‹. .(ö÷{‹{‚󋻃óvçÏÎ98;ØUÜœ…ü3‹;‚ÁƒÁöâ¶àŒƒmÁ–âéÁéð77§l 6×Ö§×kÑxoŽ÷ÄKfzÓãq%Ä%T庮\'] â ¹Ž¹$«)Î'f˜b…ê–XaEìöØ«b%“óU§pfdÖ™b^ùcÌßb¶@LFv‰6G{¢%m[tsmÛ¡èŠÆ'ÉmmŽö¦Õ™‚Éávˆµn‡@,XNZ$ÇÓæWÍ¢É$˜Lc&1`BvS”;J¤ocQR jbQÉè6ŠômÌ(EŒðЋ÷Z;êLz·^ Vè[ôb@_Q]ÐgåÖIðøË$ièÕwݨ@E JaTØ;ÒÑî÷7jÈŒ¦¦uNH¸4”ÚNßm³CªKC$8{Nçˆ \Ù5"ˆÕ!{SÛlf_´g©Jh %´w†$t5…v@¨ƒ #ѤªË?oÍпí<¼Í[³Ö/ÿ†¨…ð»f-lú‚MhÊ~±lÈ7 ^r5¬öÿ\äAŠð¿àÿË/q„`ˆvVމ»É€¸ Ø \ì¶Û€­À`3° ØlÖë€!`-°X¬VËeÀRà` °X,ƒÀÐô½@0˜ts9Àl  èf3 д3€6 h¦ÍÀ4  h€z`*PÔ5@5PT (¦eÀd (Š" ˜ù@0Èr€l ÈüÀ H|@ ¤^ H<€H€xÀı€ˆ¢`l€°fÀDFÀè 4€PJ@Q9†w  d@€O8œ~~Nßßßÿ¾¾þüø 8 ü ø8|||| || üø ððgàOÀ‡ÀÀ÷÷€ww€?¿~¼ ¼¼ ¼üxø ðð*ð ð2ðkà%àEààWÀóÀ/ç€ãÀ/€gg€cÀÓÀSÀ“ÀÀãÀcÀQ`8< <a`ûû€{{€»»€;Ÿw·€Û€[[€››€ýÀÏ€€}ÀõÀuÀµÀ5ÀÕÀ^à*àJ`pp90 \\ \\ \D*w»¡v; Àv`°Øl6 Àz`0¬Ö«UÀJ`°X,.–‹EÀB`0 ý@Ð ôóy@70˜Ìº€N`0@;0hZ€éÀ4  h€z`*PÔ5@5ø/_¦ÿÛ/¯ë¿ýÿ˯Ï9ýÆ!g®ÿ%!ÒJ–5d~.&{ȵäiòé#» ö“änr ‘gÈ äíóJýg6*—ƒt„¨ˆ±Sc'ÎÜ Œ*£Æy®…eSxÎyÆÌc_þÄ÷å™kÇÌgFUV¢“ËÅ×QÛ?„Óc§°¿ªˆq¬Úâ%Ð&ù“¾Rßzæá3÷œ×€VÒFf“9d.é&=¤í ‹ÈbDæ²”,#Ëek9ÒB/€5¹°–Èú\®d%YAV“µdˆ¬ÃÏJè5‹¦­’í!²?ÈF²‰l&[ÈÖÈûzÙ³)›dï¤l#ÛÑ3’²âÌ<»Ènrzír)¹ =öŸ­ËÎæ&—“+ÐÏW’«ÈÒ{ÎKÙKö’«É5בëÉ>ò3Œ‹›ÈÍ?ñÞ ûo$·’Û0fh‰ëá¹MVûÈ ä òKòyˆD”{.DFH˜"‡Ñ“’#dTöÿOicíøi™C‘ºÂgk9J#c„R-×RU‡Ôr]žÅ!\3¹Ü3’yløŠQ3éëñ¼½s;CR/ KµÃׄ,þP†·&”±é#'8ÊôÖÔ†ü^\XÓŒ³ „”©f¯gø‚‹÷žøW=ÎÓñ¨RÍßšH›x6L!¡—k‚kâ}IIôZ. >¡mÌö>W˜rü]!±‡¦ã)Ž MÙÁSÎïñ"²µÞÚžÈïºEÎÐŽ>OV&zVþM )R‘î Ii=}ý‹(÷{kÐBÄ’tà¡M D 7ÌÚ‘ÜäïíA#Ó0´u†r¼+Cvo‹6¨$µvq{§\„ykCöêéé” åÔ¢,†Hí0íz´.o[çQ’?öÁHÇu(Ÿ.z¡èjtJZípçÀ‚»Ç5€ñ¹ÀÓéJ º¾.oç`í%¯9”ñ>/t \ mûInžÍ©S5žNÑ%uÑÞ‚ÃS‡7oUÌ!3iV•y:áÙð)‘TW )µº…Á(Z]ïJÂà–_ÿÃ%¹Xp!ÍÙkRà"”箉}μ4–›^P†§v°fÜžW) ù#µýûëi,"ÁÀ%hhwÖÓ6deŠÐ$kB"Ú)»h/:=!Òêéôz»¼CÖNÚ94Örÿ6µ{éƒA¹·#£¤ã<‹¥³´Ijêèä}fªóËýJ»U¶§ÊöY³þ'É <Ù3¬ñ6µÓ÷F*$Ì tŽ*­¡÷òbk&kJo]¯×cöÔ ÷ŽŽíè †WÖö,*Å4ö6 {Û;ËЗò¼ßêÚD?ÚJš„¦Žª¬L¬=U#^áÒ¶‘€piûìΣfB<—vt†E<í©êIAZçQ!Ù+R/uÒ,jКfÀÐÈù]G„ìS²C¶ûñ\Vö±Lð ¤Td>3Ï'§`¾€ìë 3̹]€u¸Ö3@»gK×¢áž.:¹H4º¿BHð–“è-Ç£\•!¤óV…ôÞ*ꯠþ æWQ¿Ú[¢gkÒpë†\'‘wat˜éèS=£ccI/»Nt%aJÌfw†´~ìÊÔFä›JÑ÷ÔÐŽþ^z$ˆ©NgfCæ¯YBZÔ Ô€ur:Q¨}ƒ”Ëï€ÚÑêòÓí\L¯Èã1‡H½·ÝÎêT¦ÑÊé¶zóèÀFÖ.õJZ\ÁCjÙらÂK[¤6àÊû½Hêïñ ¤¿C­¥:Úoð bIT¤ Êй"‰„6KJÕu!m6*Ä/ÕúlTˆ_u‚B/[—D2à³Í!=®(m\(#$5ÐkÁï%¸xšõZMÛ(™áÝ€¥‘^´üQj$‡Œ© ½XüYy=<Þb^uiR©‹ÖqœyÕ´åÄ]Jí»Ç»‘®ü••饛˜Äu›t ÿÔšãÏÊÔüÔk”ÝÃÃã¿/Àâ¥1žeZ‹§{ ! úÏX^×^¥ÌQN H’©Ò›d®ÔGf+ HôéW‘TWÇ_ÝrûÏux&¸¢lqV{¼MëËñÕ^üÌ–ÍOn¯LËISYÑò9c_*6(=¤‚ÜHˆ79h·ÓŒF;Íh±S‡æ:Íh«sT´ŒäiŸàñ|=>ÉgŠD ,G ,G ,GINGIÓ¨˜w8§@(pŽ ºÃÉÉ%9å :Œ[.i· ™#9ˆ•) tÝ,^otwg n ½‰Ta‘%)9mdF–ÃbRŒj Å…Æ 6ÏÛ5û‚û×UÔnºo°ló¤3oX, ­A+ܤ¶ê¬¥sû&îûâç3»ï;±·qç`mœN1Ï–`Ó¤e§M~jÅ–c»k„É)6—E£1Ç[ÏØâÒ’†îN^wã©Poœ7#.Ñ|`ì”b›ÒB¦‹ùL&{$B2#¤2#ªà“tÉ6"d§±MLÔegçÑðç9‘7ωŒyfäÊs"KÍb&‰Å3tÙ&Ÿ"6¹-6¨ê Ö˜’ !ç ¦Ënœò®¡YAr°^Ъû]2ºWÍëæ«ìqÿ¼î’6 òJ&æÎëNµ«°âbŒO¢ŒíŠõüIÙ˜ g·& 5[…£óó ‹¤ s¼+Î5ùê¶©kÚ²Ê×Þ»xKôÄé%Sz&4ÀjWÕ̽—v¤Ý¹§f ÊÝÕZ¹bŠÓ`P© †Ùu©u *§­lL­+häJð&ẖ¦Ø„8o‚-3¸­ãxLVEF]{U fÀlD×#½€ã²‘xytbì‚? ‘r‘">:$€å,/´²ÀŸÑ¾QQ0æD Q±»:c½;eTÛ¥Ï'b Öë'fŽ ªm3Ý¡ütáõ#z‘E÷8FmÞ¿Û¦äØy“1:Ùˆ•÷v¨TÇ–5uæôîœT¹j—¿­f’S«­F“¯,Xº~{R »¬df…ß Ö©¥;,±clj‚5°ùÐÐEOošlŽKvFÙœVŸ;)=éÈC³vuúSü^-`Ôõ .7ãézvæËîŠÉ‚ÞUBÇZ Ý—Jè /¡£«„½’Çñ·VBrXÔr"ÁËÁ’…d?r猊º€Î–T§/ñ¹Qdʰ³Wq(ªY9 ++_òÚÊf-_a1¢0 "Ãfü€Ê‹Ž9»†Jiiã·ó"éfµ%ÞNS÷Ïé¿bVz^ßÕó[vÔv·3ÖcÕÞ]½µ¦¢³(ÖQ0³2iJ Î‹mK¡P4ë›g6ïé[ûøî©µÕ¢ž¯©§kÛg•õm ÔìœbP¥M$݈Ö~ÌQ?žz<˜SXQ¸¢P²y/›Q²Ù’2éz˜I£•IØ)ÏVŒ…ï©ñßééçäô("ƒ,1ÙF10›® ¿¤¤Ìçw(ö*Äc á5… PÄç¼›Öèü¬'je”¥ý,^`Ý‘™ºj5Ÿ¢yïùÙ`ÃÔõûPçȤqà g¢s3•ÎK_¡Pµ´ß{:œX·²-0ÐcPëU’(©õ…3WVܳº´lÕþ%×÷dÝ-m\?eny2¶._RÓ†™ÙŽ8‡:*Öj´™ úX§­|Ó覵G/¬­YsS§mçuÙÓ‹èN”Š¿´\¬Ü@ÊÈ@8ÚL' <ñ\t !\”åµ âŸtË›‘  çNH{-`5c#IÕ(œ—v"·Þ3Í\O·éyh½ÿxþWtW8îÏÇIð¼óŒC^ï¹=‹_«°bå%*Ä‹JJíHÌp¥x¢^ÐèµJ«éÍãtzlšíf3ݶ{ë—5z«R Ii²ÅD)µz­3¿­´Om‰³¥x~üçG=DJOŠ-΢îžwÉÌ £É`sÑqtÑØ)¡M™ƒ{“$rÅ‘ o‹w…WЦME ÀrÓeÛ&ÛÐE ¶<Ïd?Jô㸃Š'9|]M.–f‘tŒ ß=ªs0èð5Õòñæyò½uÂ94Gæ%g§ÝÙyf£÷ˆQa~^´P®±zbµáÀ¬ÒØ2'—ú)bÏ6x7¦šnP ¹¥2JÚïûÑârå*´8p¤"¦%fEŒ„Ηû,_9]…陟úå1@på‡uæ:ùr#×úo¯ñ_¯ëìå(‹Ñ[ôrðÿ$ÈW¡| ó·•|pYé¡ÛFgjš™<|Nú¾r†Pg‹\X¾"ðIÚ2ÓiÙl¸@œ*£Ñi‰‰y:ºbêè¤×ÑJuòÌ×aÜi¥§§ÖrìrCÇí&rµ°ùn#Ä÷8¾Î’GÌ‚*ÜÔˆE0V6–×e7dM‹&G‡Ò’º~òûž’7Ø97‘‘]Eå/áëSº«ÔçF¿¼?Ÿç'èp¢¿qte·—åkèxt¸McϬÉ.YSK§CL’MY]²¶† •5>&:Á¬žvUCqWM®9«­ijʬu î³ý!zKæÕ¤tO_ÎÌ¿z¤Ý˜t’¤ÕkÖ[âr*Ó'ÖL°MYpÙ4ÖƒÒô`¹.`b=H»±¢@˜ðozI'ürØÁ‘ÞD¯¹õtoÓÓîÒÓ NO{OO;N^=B0I¢™F_—Õ8!6¥‡ÞŠÀ 8„²M+r3‰öÿëóCë°˜Z5Îì†Üò-ÿÄšgož–t.t¦æŸ„î¼@!@=tm¡'÷!ñ‘{ñBºUȰiF!Í ¤i„4µ0A2D!‘AËã,‡ÀòŽ$§# ‰t#JÌÑ :;½y²ÓpÙéžg·"Hv3ûcø.ÎþGL¤y%º)vT¦F/NE#JlQòH펄Œƒ0@ù‹¯Óü¸®ŽœùAHz¿t̓«Wܵ¼°dÍkÀE¹Ê—´4,®IrU,i©_Rãþ²üèÅMUÛ¯7‚·4ìì+)˜¿³¹qgoIÁ¼ˆÍþ3×Io"6pÿ¸ã‘Š !©_a–G X%Ô–Wy¸`ˆqøiƒý´Á~ùÈO›í§‘ч®pR’B™‹Σi®sK d¤áؘpÈá÷çÍØ‘ÙÇ7n>ò1Âæ‚Úãr¹(½™ßͼôšÊ@ʸgw¸¬êŒiÍmY}óÒräÏ xÊqÀ©ÙT]ÞU'|ºî‰]SÍÉÞ3å|-T|ŠÉ%I˜f'”g8¦í~x¨öÂ2[FõÄ37âúÀ–Èj)Þƒhå“þÃ+' i¦HˆÀrdÀ,TTÐËDCe%lZ„.y„ÆŒÄ!‚©­¿1Íäð48èÁO^¼„z–g=<ôT7~‰:/$*ñQ¥ÕhbR±¹“J½ãâ ¯<©•¥% Ƥ”ƒB¤¾èD‹V«Õس§ñçÜ´ÙUXã3IN…}Y mc'ÄWÐâòJÀÓTÑÔÒ´½éá&å¸[eyÈ6føØ!´V¶15dƸ¨Þ ¸Ùý2]a\tq‰Ü.#ÙEgë1|YS& ƒA ø ô&8 õU6ˆ†ì÷ŠtŸ[Z-=–•‰Ý¿C?asêì qäv¸Ûïl~$åD‰±ÓŸ<ÖþŸo‡ÅWòç휞;«67Z§ ·»þŠ™Åjò\¾@k°-à˘±yFJ}i†C-I‹i“ r&2éÁö€Oˆª]Šþމµ§¸mqfµËã²z SÓ ÒÝÉþò™e“z2 V‡Ù`Š6[bÍêèØh›77Þ7)Ý“<¡¬ƒöEÒØßÄeŠI)™{8ƒX¼Yt!T2#¦`¹/Àò*&3‚˜E¡!ƘuÂ[Ÿ`<S?w#j¶½L—î|¶rç½|œÝ„±çY–Ÿ± Ž;0ÊÚâ2Ù“‘S7HØf²*5FÍV~ú˜Þ³ZMMI‰·k”Z¥bNB²9J«JmZ3]ŒbgÁ·ø£™·ØiñŒ®{¾V§UF9i»¯£wdÒØá®ÁýX ÷Ñä£#ȧAû|ò¹ÂGw=²™æŽLA°ðwò2F=UÑ Üq’9„ïZ[VƒO¯ŒmÀ1Cyî¶ŒÎO~²8;¤þímÙÙs¢E¾·ÀÓBþ 7dÖGL‚EÕ¼OÞÈÔvv„ŽÉ©Ï-ß\‹3%­Ú³ûÛúàô²…—õ‰É|÷?ýuËüêÔΠ8Ä=4>Éc§¤ÍˆO&ùóQâÃÚLmn }Ou ‰L$ òq §aÚ^þ(¬‘U OžNŠ¡{¤Eð™…t¥œÇ”d!%YH¢²"IHI<²×#¤xŸIX—$$ÑÛ­ÅQŸäÁ¬…õI@‹e ‰Þ R‹ÞÁ€O ¨#)½!I× g âKoSüÄß-ïƒþînú+ÐQNðÃöû骨¢$öˆ1ò`…žÌl1E¶ÈÃÿÍ‚(‰g^VãÒÓc£g^Q(écدM«8£~qîŠI´¨¥ÛZAýã}ú( žrGé¤Y«VÂq]Ä›ötœÁ þU‹ÛQ£§Ñž4vJ¹Ñ®%ïÅcÄc)hÎÔBsF±PD95[HKÒ,ã2Ý>Xg¾W*pVމO¶j¤ß‹âó¢ÖŠaç¼âۢ𖨵%Å9ñ§é6µÝt®SÄ=Zíé5çºÈdWkõè!µ=¤Õ¢‡ŒXxq£uÚÉ-Qƒ}Ñ¿á{ÃK…¿œ©Í]3f´û«{—.î[½øÿ÷ܾ“ endstream endobj 38 0 obj 10601 endobj 18 0 obj << /Type /Font /Subtype /TrueType /BaseFont /YZSCZP+Cambria-Italic /FontDescriptor 39 0 R /ToUnicode 40 0 R /FirstChar 33 /LastChar 40 /Widths [ 433 522 535 382 345 457 199 530 ] >> endobj 40 0 obj << /Length 41 0 R /Filter /FlateDecode >> stream x]‘=nÃ0 …w‚c:–g)xH[Ôíl‰6Ô’ ˃o_JIS Ã>>>‹¤‹sóÒX¡xNµa0VœÝB£±¬¬@ï”kjê<+(Ü®sÄ©±ƒ!@ñA‘9†6ÏÚõø”joAc0v„Í׹͕vñþ'´8“4ô¹kç_» ¡ÈÑm£É7qÝRê¯ãsõ4%ÊÛHÊiœ}§0tvD&8—âr‘ ­þgÕ·@?Ü;«RŠ$Î;ÉDU’ë„;B!&ÜÖ¹ùHH"÷ÜšÄy•›O„$rOy’ß7ÓPéxeÕí™/œOV3?Á;ŸVÉúZ¥‚æ endstream endobj 41 0 obj 270 endobj 39 0 obj << /Type /FontDescriptor /FontName /YZSCZP+Cambria-Italic /Flags 68 /FontBBox [-1105 -279 1222 1047] /ItalicAngle -6 /Ascent 950 /Descent -222 /CapHeight 667 /StemV 0 /XHeight 467 /AvgWidth 542 /MaxWidth 1224 /FontFile2 42 0 R >> endobj 42 0 obj << /Length 43 0 R /Length1 7804 /Filter /FlateDecode >> stream xµY tWyþïÌ>µ«ÝÙÕ¾´£Ç¬F+Ëš•VÒJ–Ö^Icí®,Y~H²\v%%Ùµ$[~%ŽIœ—EfmLñ’BB1Ú«¤‡#s ˆ$àà”¶À -ÒÚœ·&­(ŽÔÿήäGSZXÍ{ÿÇ}}ÿãÎŒ<2 ˜Ç÷g€ös…°ª¿ç°”§õ>î©víÏÓÆyëæ]ûŽîÌÓ®)óÛS“Ù‰< ×°^3…Œ &ø,€+æ.X7ƒ¥L®¿úòñ¶â;챫`a˸øOç;XýêìgN½»ú½¯™_5e±·Kþ‡ýŒ[Œâàßzwõµ³æWá0”.+HYeVü†Ç[öÝïáí=â–þõß`ûž{ñ¶ÿÞöÝ…·½wzĽw;è?|Äå.Ûµo;wãmrÊ%NNÍÜí/=ä¹?^8Še~éÊ OT¢X«ž'%9*}ßj‹¾þ"‘¨¥8ª~-Ô„¢…^()ÑTª®ˆåÑ_æ”Ä/Nœ>ñóó§Ïÿ\?ÿsb÷¿:ÎKãÅv¦ö†ʠ¦¾ú|U0Úöqrö §øÎ­®‹zÏáL—ýÁrùmNQßvy£ê7\.6‰*Ïá,˜Ñ+ÓÇ8å‘cDyø˜^¹vœS›á•בc3ÁÊõ~²™l‚f¨$I’Ðê6²F«ã¤[«;HL«»H§V·ˆºŽ('fˆ2‹åQœà8ÓŒ¹ âj“YˆŠmnß·»ÕílqÛ#nk³ÛÜä64ºù°Üëb$&°=1€ðD‡mB8t†.B°ðXô bÍ$zt#X$lKX7¢¤ÛØV±ü{‘bu_¼3P³ÊV»Ên¯k¬åê[H±WɶjÙ^Qi“*í ôœ]pXÍE«Áh²ò:½g5ð•P[i±÷Û9 ¬ƒ˜þÞn°€…·Ø×Á:sš5ßÃ?O˜?jÿX/±«N»HÊ‹}F±[ð;u®bXo&6céÂò8âU Åêbµ±šXu¬*&Å*bbÌsÇœ1{Ì3ÄøÄ"Ä:û¡¸›–¬·uÓˆÒ?ÏKC´Yé§æÑÔ!œF.åN̦ºóVÎøÈhjž”2ñŒxÚŸ™ù`ZQÊéDÿ¶.OÓfÖøPyúió ånåüiœC‡$yZ9Dë’4”ÌÒÚd†ÖÈ ”:|Kgr}ƒ+H1ÆáB§ü¨ÔG»p7uCbÎÌ6;0ÔM¹øX?ꧣꗻûé7Z30J­r7°þƒPŠ~;æ E?†±:/kçcœÿR¾½teéO–®0>ÞaqˆµõgA­_åu Àw,]áÞaé©¥ÿ‡&‰±ûâCËZùzñÈ2Ír+:Æè†OÃi`º·ÁØŠõv,,KÿößK¿]ü¤_†‹@5Ù<àãZûóðüå =Ò…öV†û`žÂ5í„ r½ ¤¡ ÿKÑ ÷Ex s2·É?¬ð®7f±9‡³}6Á$têßÑ¿Á•|úá8âpý÷šÖ|ËÂ.­õðu‘ÖÚ›±îÅ1¼ÅURøŽ9 Gà,Ò³pQý,À>øx×ÿø$<†' _Ьöïú9(æÖ¢5Mh…{ {ñõÅ—˜­ÿ¿F@ ¨hÃ4Œ!n_„Cú_€ÙXƒÙ½Jçó:ô¡"ÃàÐ .ýRné—Ì¿˜wñÝKÿ¢Xú/5=yÇí·Ž¤SÛ‡‡6oêߨ׻¡'ï^¯vuvÄÖ­¶·­im‰475†êCJÝêÚU5Áj¹* UV”—‰þRŸ×ãv•8‚ÝVlµ™MFƒ^ÇsBÄG}ñTr-g0² Që–+›Ãœb@vH‘pº¾ Eõ …’~êHÍÚž¦åV•-” ï°ófQJR]/ycv‚Ö¥²ð}qEžÆa©?ž DÊñêC^³ÒÓGa ÅÊüÒ›íÈ„ö@ïC)Z±L¦Ùhù­Ü°È‹äÂ-ËÜBrœµ4ž àšë›ÜLíJ;:KŒÖbF ØÒFƒ0%®w()¡Ä½·tó¬Ûí¿ƒäÄ99±È\ÇôJÑ€”“rC)GD ´Ec2LÍYŠâr|²wY0WdAŽ…1Ð,戵“h Κ\;Ç©ás²å&YÙCÕ“lÈ Ä %%×%x„ŸºQØ-¯¨¦µˆ6'5Ä©1¿i7U³NJs¡…Ü©yvdë„<‘KQ>‹‹š>˜œ¦eý#ÈÂE`ÉLIÌÜ íÆŒ'%§¤ÒL7ƒw9]oæOLMf˜›Œœ@™9žš ,ˆx¥f“Ô¡Ðbì^|ÿOD>—ôí–™ËÍJô©ÁÔÒÓA'ðÕ‡¤\RÆÙp°äžnf±ðŠÙ4oì›ÐŒ£žÌJtzÇÄ ¯ì©eÿäjýÏZíƒ=Yt0€Y™Èìa[Ùƒ=uXI¹““ÚVOi[C•’{¬°Žèý°{¤’Srñ,Lˆ€`>xkß@€–*¬c.—dKÌNàê2x•*Ú2òÆ„¨\OœªÃZÚ pF5›HX”èÐTÍ$Òi¶©¼¨18«o¥Þ¤.E¼‚²…úPÿP*™`Þ‰š\<ÕqÙ'^ÆvÿÀ ›øP'¾Ì@b’mrÿ`Þ ¦>ì–Î0¢V°<ªôµQ/ùÄKùÆR=rO&—ë‘¥ž\&—_šÞ!K‚œ›³Zs’I ‚ü/žiÏ©42Sd­f!6=nŽöà^28ÊLÕ#Me‘ƒW—hŽÌ"¿^\ˆ9ô~Œs9ág¸{+f'Qêa©ŸžÛE*´³ÅmOaLŒãÉ í†±‚ÏDœÈ¢†O“»·À8¥æ<,¸8H Àâéä¼ ; Óƒ©<-ÁñyPà Ú1Ã$ Ë÷v&™^–¬tÏÈh7{&Óüã7ù7æößÎ9d§e‰W‡Wß]Æ=þ¢š1Íô%ñ/rL[œÈ³V‘‚ÇCŒz­#Ã3fN¥ïÈTP¨>žZciIp`²$¨Ó‹ŠÌS…ïÈß$,‚K $F‰‡ñó*¢‡yßÛŽÂG’’¹LÁoܪ2퉩•PÊ/c—í w/Ⱥb‡Sf;ü6søåƒ!ØÃâ M¢µ1Mmì¼£¶Ÿi7\¯OI˜‰0rµ†””¦˜±©”Ih)!-2ù2{~éL‚¥Àú ªˆGGÏC{³+Ö‡þ·Ž>ŽþÈ©ôÔZ\“Z‡;ZqZz|8U7ÍNZà\}l+7ËWP\ÖÁĆá þoúÐQý>-ªó±»¢ŒFÆÝ¬àÆÉ4Ù²{°•Ð<ÿó9@[Ý ÑÚÞ™¸÷qß²ÓÇCâý¨‡Y÷œLN ΩäĶ‘ÔE?œN=Ï.žéNÏU£,uQP5.ǸŒÉT$F@?ÁÑžçLš¾xQ˜Ö¤:¡ÑãøŽ£ñòJÈ#0Ž/<OXÖã§ËóT‡ç .1é›Âô–’ÑèTH=˜žÊeÒ lðä=[îÊÉs„3Xi‘<ÙM-r7ãw1~Wžo`|£ÜîÁ!Íc¨ç22†?&àˆ$Í\˜y9”æ—–0ƒ^ÂÌ †àL°f%-Q}p#êm`%ƒì tz<ËÖÁÜûƒ}ãijZUú¨G0F@­ϬÓ8:kVÖšÈÆà˜NÓ´Â&Míf+’$|ê•×RCM~‘ú6Q8sÊÍÚqbÒ¢à,öÀ96j‰PãˆHâdì<ÂËhŕ˨5ž‘Ð:߆Ψ«aW³r&ñT×Õࡊ¥YÛ´Qsˆk[p@¼Œi…m^£f 8·@-¸¢š ,t@tPÔÇÖ‚×,.ž©~• 38Cò}”hˆjSQL‹ƒ}Y|XÈ÷· GÆç¾|gËd,6Æ+y®‘íܪ=ÐÏ/=#eA²ü«É†SÌ1_±ñí »•AG1qšnåkì\ÎTüë;äñ2¯Ôlð4A 5}Ù“íΖzœVŸ€ù{á}üg`H×°ô¸®6ëz‘¶--q/ÃÃä¼ö"šÿf†ÿÀ~ìÀ·"‚ßõH³/l&M àâ#/ró"ÿYÝ î ÝU俈ï²é‡¡ß[¡²j‰Ëe«2lR”F›Ïר¢†1U±"B„‹”[jê”W³K±ð‘úú5‘ð%g4ìôF/…ñ/Ên¾í’ÿG~ƿ䈆ôš#êˆ ÑÔHZ[:¹¶N¾µ¥F®²qF¹uÍšHsçv!aãÝn¯[n%Ž€ƒ®Íà©«öÖˆöõRcu©9û@¼g¼³Ì^ I5n£óCäÚ{>{­ü³Ç¬k]UŽDåþ!WusÅû+Ê#=«k:;zê¡Uµe†;Ÿ~zñ'ºýj§îÝÿúnqzßÒ¿ñGùoƒ_ÇðoO©ëŽJ\¤ÊJÓ£*x‰•÷JeÓe:^wF-jU°×!Ù…»„cÂã‚ÎŽ·%/á—«˜/>§º<àëò_VÀ'|ßñ{á%%Ïðû„K$ŒLÿåH8¾ì`ˆjÃïqø4iàä*âYÁEš×´y ¹ª¦µÅÉ`öxÜ9wX™|z§=ØÙØqûWî<}vàc¯¸·¡‰ûö¦DÕÓ‹?8Q·qMercÇTæsŸÚKौÓú&~¤ö¶û~þ”AüU¯Î2c¦º:äyT5»Êùò³ªÝUéâÊyô%m¿êŒj@•‚½sÙ•2Ηét¥|é9Uw3X+X9œõå‘RñåÀ¡ºŒ®A¼šþ“¤ƒ6®cþ‰H¹]º€Áíò0 ƒzÍ] ¾aã‰C[öWo~òï8ztñ«‹_·Ý6vvh±nìäD÷*{´½gv׫ƒ·×FÒôî½úòÞSÏ>ëÙ}ÇÀ¶k¤$ÐÐÖèHN>ÜÒã‹ëù7Ë0~ÃøiË åÕÕeøîßZQÝÊ[,‰ÝL(¤WKj$³Ð[SQR8,ÔU” eÑÒ(=£– ÅÖF¡‘o<§ ž:#o<£Ö•-{ óCD"šÿaÃ×a>‡0cU¶à‡ÞÈì‚0»Àò2[ÚkC·DD1¬*¸e'ϼ²ÍËŒFþ¡ ¤Ö„¼y9Eè°ËοeßþñGÇ’Õ¶ì§3û®:þá­]¢cê”Åê—U5(÷<±{ñ±D?Ù™<¤Öwo®Û´eÃZ)öGÞúºòþdÏéï=ÏÏÜÿ©ów½þç‡Ú+ª»…E¥¹ëøÏÒ»’]Û~Ø>9Þs>÷ö»v~ø™­S»07àw*þ"~õ Á ö©××Vñ„4ØEk±Ío³ ~Þ¡gvp[ES¥‰7S+Ÿ÷™„ü­Ð…iàº"äÞ¢¼°àp’hØËüÙÿ» ï‡%kðCR>ò2éD§­YÕÖá½Z”»]FÞÀœ×ãå/,~ýa›»1ºzüÎõ%£Ÿ'ÄbÖEº­ï­ýœõögSÙ ×p‘É­„ɵ¶»z;'¥·êîm®¯±×Uq-æ÷úuÜ»[Y|Ri)©¬rèYÎD\^Æœ‚Ó\jõ7áR‚¸† qûŸõixØoèFLXžüi×o@Fü]¹›ú=N&5èk½¸´à]Õñ°ôˆ¾W³ŠåMæ{xÀ|Ä2¸=¼)T±AÍnyrGꣽá-ÆÑ÷¥'*Ôu][”¡s“nàþvdPŽ×;º•õ÷Ü~\õ»^M÷)‰ÎZeÓhÛ¶ûU?$xñ´é^€ øRÏN½è¹«"þÇÏSRbr;=`2›ÞdwàiípªfË3 ³û_ñ6ÀŽk*x|îÏ©üu0¿[8lÞ{Ežãq–åÀ‰„1QÂmw75Šªüÿ·1,ä»¶~Ú"Æ€1 y!;_¸?zjdÏ”óÁ3–uÉpmE®tx_ÊÔ¶F&cóã“ûvumáŒc°cÇíïN.>øÉŽ® ½ˆûGÄUünÏƒã ø/5:Mœ€‚.ij3ÊmW#/FÞzë-ÔbX:±°ŸÜé‘mñ‘%žÝ¿ãàîl}ßáì¾Ýãðßc[Û endstream endobj 43 0 obj 4964 endobj 16 0 obj << /Type /Font /Subtype /TrueType /BaseFont /XEIRGF+Calibri-Bold /FontDescriptor 44 0 R /ToUnicode 45 0 R /FirstChar 33 /LastChar 62 /Widths [ 529 637 659 473 226 495 503 399 347 246 537 474 537 418 316 494 538 537 474 537 631 630 459 355 537 813 246 473 606 537 ] >> endobj 45 0 obj << /Length 46 0 R /Filter /FlateDecode >> stream x]’ÍŠÛ0…÷~ -§‹ÁŠåü1”²˜¶4íØ’œÙ(Î"oßïÞ¤Sèâ>]Ý#û–/‡×CS~Ë“?ÆÅ c 9^¦köÑôñ4¦bU™0úåAºçÏÝ\”4o—%ži˜LÓÆ”ßi¹,ùfž>‡©Ÿdïk1édž~¾uçxçßñÓblѶ&Ä»÷nþÒ£)µõù¨Ëí™®'~Üæhx«û“üâeî|Ì]:Å¢±¶mÞÞÚ"¦ð_éÑÐþW—‹¦Z·¶{ÃX*ËÒYí|œ©v÷;úáa^­ÚFdmíZ,*[A"0 Ö ²v­‡7 k©nAdíf-¸÷‚[=܈ê^ª=ˆ@uö õÞ"zy~SEQU«Dà†ªãûˆÀ• iDà HX ’F„³<ÑFDu'È‘W‘pNÖÐNDUï% CX©3YÝ=¯ÄwdáÉ*½ YEôªYæ­5YÝ=/÷òßÿþ.ÕÑòל™*g8¤1Å‘Ÿ§Y TÃKÕ« endstream endobj 46 0 obj 421 endobj 44 0 obj << /Type /FontDescriptor /FontName /XEIRGF+Calibri-Bold /Flags 4 /FontBBox [-519 -306 1240 971] /ItalicAngle 0 /Ascent 952 /Descent -269 /CapHeight 632 /StemV 0 /XHeight 469 /AvgWidth 536 /MaxWidth 1328 /FontFile2 47 0 R >> endobj 47 0 obj << /Length 48 0 R /Length1 19240 /Filter /FlateDecode >> stream xåœy`TÕõøï}o–Ì>“ÉìÉ,™Ìd™d&™ì’GHBB’Ñ$„U¡Á@dQÛ*E¬ûRŪ­ZT&â ¨T©Ö*ÚZj][lmë–J]jE“üÎ}g&íöm¿Ë¿!g>ï®ï¾sϽ÷ÜûF7 ¯ *²ð¤p`]ÿz"~üWºÎßèÆ°ùBd)+ׯZ‡áô/ QW­Ý²ÃÙÏ{bõŠþå&NÊVC†i 0kõº›1ì×/\;8H÷Ÿ€°°®sâþä »¿Ñ¿n>-ì+gýЊD:í&ÄôÝ›Wlä aÃðàº$) /_7@‰–pQ7ѓLjœpÀé#D=@g ¤²téñð'ç*—êª>%¶ˆ äÐû>ÏøÌŽû®üâµñŠä?†¼ ¨?PN~Çøk„(ïüâµS—)>kJ$Šp*ø8÷yÌ™áŠs9€ÏbÎ|À_Ÿ">Á´1ôâψ“ˆœcˆ0ò}Ä{ˆwï þˆøâ÷ˆ·cN4âwú-â­XF*DžˆeØ¿‰e„¿F¼‰xñ:fy C¯"^Aü ñ2â—ˆãˆ_ ^Büñ3Ä‹ˆ°ÇÏ#žCüoû,æü âÄÓˆ#Ž"žB<‰øââ ¬óqÄcyqñ(â "Žxqñ0b?b"†¥‡AƒQÄÞXz1„B<ˆx±ñÃXzd¹q–»ñÄ÷÷ îFÜ…Å¿‡¸±qâvÄw±êÛ·bñ[7#nB܈¸Ë]¸q-â;ˆk»WcÕ;±øUˆ+#ˆ+—cˆË—"¾øâ›1G èåÄvÄň‹Û".@lElAlFlBœFlDl@ !ÎC¬G Æì¥Ðˆo Ö!Ö"ÎEœƒXƒXX…X‰XXŽ@,Cô#úKK½ˆÅˆEˆ…ˆž˜­ZÖ8q"‚èBt" :íˆ6Ä|D+b¢ÑŒhB4"æ"õˆ:ÄD-b6B@Ô ª³Uˆ™ˆˆÊ˜µž¯QŽ(C”"Jň0¢Q(‚§1kj adQ€ÈGyˆ\D"áGøb–™PY³°ž³Ìx0Òp!œˆ D:°#l+‚0#Lx‡4¼ƒ#S„¡Ch„¡B( ¬3!ÇHBŠ x‡ "‚N"&ãˆ/_ N!>Güñ™x[úñ‰è§ù âcÄGˆ?#N">Dü 1†øñ>â=Ä»ˆwÄûý!föºâô÷ˆ·cf9ôwˆßÆÌz q"fž¡ßÄÌu€_#ÞD¼3×Cäë1sà5Ä«ˆW°ê_!^ÆÊ~‰•GüñVös,÷3Ä‹ˆÇÏ#žÃr?ŪŸEüÿ âi¼ßcæZhÙQ,ðÞèIlõ°²#ˆ'#CFB<ŠUĪãXõ#XõÄÈýx£}ˆboEìE<„U?ˆx±ñCÄý1Ìúô¾˜i6à^Äb¦V}?fš¸'fjÜ3-Ü3 €ïa–;1ËnÌrf¹Ó¾‹9oÃЭ˜óÄÍXà&Ä1S;Ôy¿qâZlÒw0ç5˜sâ꘩ÊíÄœW!®DŒÄÒº!íŠXZàòXÚbÀŽXZ/à²XZ3àÒXÚ"À·1í[˜ó›˜åa/d=©«w}¨mtPÏw= ò## O¨ÎrÅ@FA¢ {Ayä= ?¹ä>{A~ò}{@î¹ ä{ w‚ì¹C¹Úu+È- 7ƒÜr#È ×ƒ\r-Èw@®Q¬ví¹d'ÈU ³Ü—Ü)rqq_Wƒ7~qÌS&½(–ÊàFĆ˜Yíâ<ÄzÄ âˆuˆµˆsç ª3czVÙ D%¢QŽ(C”"Jňp §EˆBD*€Ð#t-BƒN‰S5B…P"ˆ„<¦a]-ÿ2òÈû ï¼ Ýù_ƒ¼ òÈë ¯¼ Ýò ȯ@y ä0È!GAn‡®ø.HœnGMoØàØ‚Êٌ؄81Œ˜ƒ¨E=ÌFˆD5b>² ‘†02äyž‹ ®{ç9²ä(ÏlˈNìõزD;¢ 1ÑŠ˜‡hA4#šˆ¹ˆD=¢‘‰ð`ã݉È@¤#;†°âcZfá6xÜq/A¾9ò9ØÀ_A>ù ȧ Ÿ€| ½úÈŸAþò߃¼ ò;ß‚¼½{ äyç@~ ò,ÈO@žyäÇ GAž‰ƒ<=~äaý û@nc½Ï£Ž·!.D¬‰À¢««P-++ˈeˆ~Db)b ¢±±±уèFœ8 At!Bˆ ªº‘ ò¹ˆD6Âðaßd!¼)B‚à‚âˆ$Â]ÐI“  ï€b_ù%Èq_€¼òsŸ¼ò(ú È¥¼Ïõm>èú º¾Ù¸=rÉží‘‹·E.Ú³-¢Ú6s[Ë6^µÍ¸`Ûžm¯o“]ظ5rÁž­ÉÖ´­œrKã¦Èæ=›"ªMT}~ãp¤køíáO†ù´á®áåǯ>ò{†÷æã“G„Ôኙ Û‡¯æÒ #ÃTÇ¢=Ã*mÃÆÆ¡È†=CÉPÉ7ó“!zbˆr…C´}¨oˆƒ\û†²rXîÒ!³½A?T8$ ñç5FÖ ^<¸{ð‰AéŃ»¹½pÅ ƒ MÃ7×E~³Ž’ÃÜ$уá&c¼rð7§rÂ$=p(bMpUdõžU‘•Áå‘{–G‚Ë"ýÁ¾ÈÒ`odÉžÞÈâàÂÈ¢= #=ÁîÈÙÿ¬`W$²§+Òìˆ,ØÓi Î̇øÖ`KdÞž–Hs°1Ò´§1ÒÞHç"õ|™ Vâ„¿õÎíΓN‰ª/c}·>ãDÆÉ ~}úÉtîbÕÙ/¶ï²ó:øâðËæ²í²í¶íµIuâ¯^Ÿº=•[oØnà ‚ág† 1Üiàt»t»u{u|›n©îCݤN²WG÷jŸÐ¾¨åÛ´KµƒZ^§ea^/hƒE :K#Ì iøª¦FÓ¦áwi¨  †MVvCºM½TÍïVSAíÏmøP9©ä%$|¨˜Tp“ Jxê¦p¥ð)¬¨ÉÕ§dŸ™Jiœ^3ÚÕ´Äå“ Z¢)í‹¢ôò¨¯“}  £²Ë£$²pQ÷(¥W÷ŒRnNW4­¥c!†/ݹ“Ôf´D3:»£wfô´D·Ã…À.&á‚dŒšImO`Ɇá 66à dɈÙ8 "(|Ãõ0|±+YçÃr@"ä3m^: u@fˆfµÃ °,§ŠÿÝhÖ¶ÿ³ý?»óÿ÷7¶.]ÂNo ™¸nÚí%äò]²‡Ãp2'GÈò‰“ƒÐ›‡Èa8ýúñôì“b‹I†ÿ~NÌÿ9J~Lž&ÏŸgÁ2ž#Ï“cäò"ùwR~¥ù‚LÂë½ÅºEìGÖ{·B¿Ý#ê™õÇ^³B­³¾ytþ ô/ëv}k¢7‚¼£ ×¤¦™–¿®›}…ú> y˜.˜>Q›? cŸ±zŸÒøs¢žbb>9Õ§{ééïW$©7¦éð÷ä¢f˜v_u÷Æ4í1-¿ d½Àê8S·¿…²Ø;¬,Ó9Ói² K{ ÂïÂìðhšñ}±'Þ'œºþc"}Œü‰|H>¿O’?Ã|ò1ù˜“ú¾ÏŒýjÌgä3òWò99=ø%Ÿš~ÍRÆÉô1¡”r”'§¯NDz*CsZ UP%US ÕR¸"ò¯¤¨¦R _K9]êtšB¬'•iÌ—j¥vê€y3ƒ:©‹zh&=f›JqCŠ—fQ_¢œY,i›* ïñ kaysi!Ýߤ!¸.¢%´”–ÓJˆ)€pÂ3 ­Pd-i'ËÈZrJú÷<´+ f•Q¡aé’ÞÅ‹ötGº:t´·Ío×ÒÜÔ8·¡¾nNíl¡¦zVÕÌ•åe¥¡`A~Žß—åÍtYÓ zF¥T¤ÈeR ÏQ’_ïmèsGý}Q‰ßÛØXÀÂÞ~ˆèŸÑuCTÙy¢nV®’ÎÈ)@Ε_É)`Na*'Õ»«HUA¾»Þ뎫óºãtaG7\ï¬óö¸£câu«x-ñ‹ <(á®·®®sGiŸ»>Úpþê‘ú¾º‚|:ªRÎñÎY¡,È'£J\ªà*šã]?Jsª©xÁåÔÏåHІÝ6Êûêû—GÛ;ºëëOGæˆuEes¢r±.÷š(´™\éÍ?2rU\O–õÔ˽ËûwGù~(4Â׌ìˆÑ\o]4wëÛVPàŠh¾·®>ðBÃZLÝ€F¥>½×=ò)Æ{Ç>€VO‹éOÄÈ|úO Kd8¥¦(íO^h´žÏãam¹2.eˆnïèÆ°›,sĈ ôD¹>–r$™bа”íÉ”©â}^Ðl½·¾/ñwþjktû2wA>ô¬øç‹J|îŽòþ¾e«ûWŒxëà A—¤ ¼ó:¸úʬ- Aþþ>xˆ5L ÝÑw}4Í[‹Ú†¨ÄW¿¦³[,‚±õÑ´9QÒ7( ÕCY0‘úÖ1¬¬.oG÷ARš{nè@±<ÛWr'3ÃcGå¾w7çà{XoA„»¾¼µU Ê0Èz´¶ÊÝM$™ î’ÈÁ®Î¨¼oN#BÑ9·øùMrà@3¢)Sm’@#¤§Û„÷ù»MÃܬA¹îúuÓxF¥˜¨ío·“cºH(šÂº³‘=CA>×nHN‰rðœbëE«;JÚÝÝÞÞ/ØÐÞÍ:‡éZìß–N/Ûн°’®3B˜^iQâiéêN`ÿØmˆýʺU ÏÃSÁƯ$7%“Ý#)Þ–Îvso¢Bâ†#ó7õ_Y‘Zƒµ&JoC¿×­w7ŒôÇ'·/„‘õõ}«gÀ0ñ6-ñvvWA_Šã~›c+»u*i¡-]µù0÷ÔŽzé壽¼sa÷AðeÝ—wuÇ8ØýöÕöŒfAZ÷A7ü˜DŒåX,‹dYÜ,ÀjZ1¿ã @Èv1U"FˆáØ€‹q˜ â(ˆs§Oæã N‚q‚×aÖÕÐ0×»—³î¹°gõH_\Ä ] 4J½Õ$Êy«aÏ.SG•ÞµQ•·–Å×°øŒ—±x¹·6JÍ”‡9i¤Ï ó˜\7qа=³~ÎçŽONvu{Ž9Æz<0$ƒ,ìŽ*°H}Ío.“>ˆžÝ>ÐÏÚA"0ÔÙÈl豬²4EPƒ"QähË0s„BÐ7Ðbùíˆnï‰öØM»×°¹Ýú(iô΀nÇ:¥~v£PÏHª7Ì ²F•¾ hÓ1ÆA¸L¸ì‰äjhù€’úÜÐ2Ð ¦Žs©’õĬ€)Qâ_!ŠÒ‘H$ì±xŸJ£Œ*‚P!ü±kU*„?y(…=¼Ú‘È÷ÖGUÐ"ÿ4U& €v ©‰µþv@ãYÖ±j:âdw3L¬Ñâ­äÕøšúaòÇò*ˆñV$ C])>Åê8бröäjÐ;ïëŠOÞëÝÂf€ä§ ßËf˜Äq ›ôŒ|5"º(PŸòÕX=2’¢ùÛP_)š)B-DÂ~6õ"!’WaÏYEÚ¤*²“€ì”ÚH“T ¬‡ðOH ÿ¢æ?&s%-ä"¾‡4[$rÒÌ]NlüsÄÁâégä\‹dß$±°¤UÌw÷ ”)"MÜÓp²…–˜ùŸ3«t%Õ:,vP¤A«Ìkì¿Åî³(•Ÿ=ÝÇêòÏX&OIž’¦‘Lâ'o±#ÊøY“ïìWéèѨÜç®Ìš âÌçèh«ÜªÖÐyr½ .¥gãäÉpm4ÚdñÉû ¢–ΓÅé¢ýBf‡MK0xH5#ÍÞŸ™Yª>DC°(¦¢ ŠÊÎ4ÑTÒâtiLáXSa#‰ME¨@QcHÎÿÌm’ú„Eãô0++7ÀTZÃMÔ2(X2mÁ€R…fFߥÝKn^;cæ97,Ì?Ë÷ijšÆ}Xo3*M³ûV­)½íÓ.ì‹~~K×Ȫ:‡ZRŸ‘gSfåeÍÞtïŠÁû‡f¤¥Ñü‚²t¿E¥2»ÒÆÇöô4eÏýߺ{|t‰ÅãO/F›•\ kAˆ¼ˆ½p„Ð} ƒÌJP• 2AܽãUǹëb–,ÖKÞ‚,QÿY‡è8FjXNÒØÜ¦S»ÔœÖ‹3Vqi0뮡¡ãca=³j|âÿv]8ãáB KøiÆIÎq¬˜•K.Ö8Ãþìâ ÍDºÚ‰v¬qû³ÃN5}[“Qœí;5YJ½R&ƒ/N5þiòZòtòjÂG_O^'´—¦’YäaÔêl2¨Ó¥Å¹’˜3ì'Ί¹ñÉ“BªÎÏÍËÍ fªõìJ­’éâtÛ#ÙJüA¸Ž ²ÄŒkje嘡²2¦\yZg!Xf‹Á˜cÿ u&uÇŒ2›úýÙ^³Ù4M…Ìùqr£“·ûÙšTd\ïð×{‹9¶‰ÇÓgX8‰DåfyƒveyÎNIn–ñKs ÇŸJy^ÌÊ Ú”‹-`-Z_M˜ë-Û6³q×¼ñEJœ*”’+C!³4{";ÐÙÙžÓps=·T©WK¥j½t\3ù.•ÔGšÈ¡¤åÎænz8+œV;âÜwcD40gC÷L»J¢Ð)µÅíƒM…óJÓ [—­^ÖZX?¼»'¸¸½:M.åx¹F¥*lX\¦PÛòÕËçÒo¯¼uU‰Ù•i/ ºòì*OŽÇ’Wíϯ) ΊlìèÝÙÔZiZ‹×ž‘cW§{&_IFÓ7€Þհʽ«\&‰ ÞG‰ V¹}Vƒ,5©ÞTqíÊèPO­]a::~ ´7ús%52mÈz˜Ëœ-áÎJbâ0 lÁ™8¬Ô*¥03*ùk@°ðdäÚÔ_Œ%ǢĨ¶åf8ól*¶è€ß1¬æ|þW¤˜4ÛSXJâÜ¢ý$;›Ìˆsõ‚ÞÀ[èÇj‰«Kè—%´„ý>CÁî’’àì¼8µ Ž™”ß–¹3“2Û3û2y]¦+“SK23%0/ Z5Y†UO[3N›g^f½-¨[%Ä÷Nô^Ø’¾qoïÒ^qq ôž7Ö{ø4G+Áð• 0A÷Üq>`.4 öÒĈõGq)sš¦6@Õq:•ãJg.—•óç§ò r å;Ïš»éìÂY[öo:Û=»°f`^±^ePÉ”é Kg®¹¡/ÿ³¾Yg•ÙæÖ”ö]Z½\®×ÎYëkZÛ8CKVY^M^ZzfºÖî·¸²2¼Ncnä²Å¯¥f{*„2øÏ˜8rÑä»°Ñ\Oò`ν1ѯJOÙ!®6žîÛ‚‚˜”e¥‰´0i¤àl·³£A?¯Rœ*ã´&Ö¤wYþ%ìaØèOtÆ·Ž¤a³95ézŸž: ¸½PP¨Ü`ý+JJ–íZT0n}˜¯Ó•kSª3 }¾Â uf]]cÎÀÈÙ9_òæÛ ‹Ëœ¥ý¥EuiôƒM_ÖhðÏÈíW锉R§’z““ê„1³Ð¥m»lßpå9 Š´™e9¯ÔÍ ·¯„‘Ý8ùïá_&¥äö„ÓIöãÜFqç?ò™ÚœeÅ©+fl–k?v48ôÿn¨%ô¦Ù°Ù2µ^ó~ñø"©³rþy¥5×éα©êoZ¼rgONñ²k—¶l­R‰&—®>U6PV47`JÍ­+±—¹3“æ5м,j€™Ý¬™ôwI[/©k,Z°¢´âœÎ°.³<‡ÓfÐÛ˜¤„JQoûŒFO~œ› ”HâLs>ߘÏ9òŸ’°‰×ž?‘è%ܼvIŸ„»S•€c‘­2¯QpCžÐÛþfë_ˆV¯å ¼Va…‚ Ÿ éIs ‡Év F5›w{Ï[Ò[Ò ú¿™Ø ŠÿÝ{‹Ó‚Ìë™f·0;$vê¢us¦ì2±Ÿäüܬñ·3{g×.o*Ô)Ô)<'IÑÌX¸±vÓ¾Í3«Ï¿ÿœõ»W~Â/ZZ87dãè©`~eïìL£Å(OõØÌ.³Nkµª¶>ºmÓ—6Ôß¹Ä}Ζ¬Y!û6øMÊÍÒͤŠlHôŠYOÀZº¯0Ï«Œ}esíþ¤%ÃÑ…ë€PØèž§odÖ+šo¸ü¤£ÅãG‹ÙaÅAp»þµBÓ¦Fqí0‰ëŒiïi§3¹c‚5GÔŠ„»Y’¢”É ¶L‹#Û®¾›-þiÆ»Õéᬬ¢ Õz£Q QƒY­›:²r´ ‰ä£ ¯Q'ŒßÌÀ¥%'£<4TB1ð(”ÜK¡òŒ‹²eÑ‹‚pŒfˆ“EÇÄuü]ü/H5œ..¥êEhÓÊù osqóSͼ«™6¿õ¬š‚µ©Ÿí¤ÎNjí¤>¯ØM”˜ô&Ng2õUðŸW5æ¹ók×»Z{¬¢Y·ˆêùEÏ î6\lÀ.kÆz{S+kD?€¹ì}YÌ ÌˆL¿³ª™þ󛟾wUí󵜤–êþáýá¶ÉœÑ€^±pl›q;åÏ–Á|k¶XœüÔ‚S^†²oÖSf‹'l¦xP ¹Ùªf,ñggk¡âï2ëט%ýWtæ›ÔÆâà«ó6uflÜ;<ô½U!ƒ§Ð•¼yåË._×ꡃiâ±ö&_…/µ}®¿ÂgœÙX³Ïî2ÊV,®œ_˜Æ÷­³<ó·tLZM–9ÃÇ¥À;¿%UµÃg…³„žROUyØbi ÍìÏö.kšA¤@©ÈŸø¼±Ý¨tÕµYóÊÇÏ*(ä¤F¯Û©—Xü!v~x½/&ëз4΃-]ß>p0õɱ¡ÓVA!4g5ØæáäŽã#‰±°xXû×òOŸÅ ¢³ÿõ½¬x Ç™ø—ÔéEY¾¢tµ1«Ò_¸¬4é+$9{GÓ¢m­™™I£§ã³›K3æŒïMÆL÷„šªÕW°9ûÜÉSt§t>8RROÿ1sO°C}ð¯”ðóß lú&|Ú—a-×0qøzÚ™O•˜äŒl g–&C·&[œ¤±º+2sV¤«jªíüVpkàDI§¤…ófT4Í›Y‰½D·B/™{]çÚ‚Nc¢àž¨”TC¨JB ·”úl* A[‹ E¼×±/ý7[øõVM5æ´Ú° 2¬píd¶a´N—îs:ÃJ`¬½:›y¥aøùž¸3ƒ‰µ4Ã9 †Á»j´Âìæê†‚Ц‚y§­¶ IG\ çYpœÅ¦†ƒÿYeg>/sêϰ³¯E$úÌ„†gAçÕ$S¨Ó }þ •Á[ê+X\½—Å|UCfYVpñ”9*í¹.wžEÙ|]{yw}ØÓÚҒݳµÅ=¥OÎPðÃüz aÒhWµ·[U¾@u¶±jÕHëÔh…>“K}gdJwŠƒ–8a°žÜN«8hÙVM´*´y¶¬¦)…Ã\Èü28oe€¤¢ÿ+%ÿ‰fÏTäßÁS*»¥óŸŒà3Ôêè‡ñÛ{# hÃ'ÓSgíiÜ0xªNøVÂâ–g‹S» Ð5{EÕ§éÓwCÓÏÚÿÕðüâY{r~yr““ô;%’ª­ñ 6E7VÌÚúÈ›£*&ÆMáÎšŠ®2‡¹¨«º²«ÌNß:|ysíEñó‡ÛÑ<û¢ø%µƒ ‚¹mƒs¹óÙpâ §œ¾ô”)“;ÀKÿѰIßöïÿYÓT‘ýõIÜô÷v€à„/Éž=«Êœ •¶\—v‚Ù-ó;CËØð”!wNع³´¯¤¨>ßDÇ6=qY£ÎtM,N:ã’_'ÇËšœY¹i­—Å6U®YP¤c;À׿4…;ØV9îè°˜ÀïËØü9ê×ÁŒ)¨‰]§t)CJ^ÃÃùï;lì€SØ)(…@³_gr7™Ä]Lr‚‚ \ÁĈãù–šn˜ ø79ÔŒ;¯2%ÍæL5åÀR—Ø'ˆ·º¢"]ãt[áÇ·dÁÑ#sù²ªòÇ'Ÿÿô Ïöëx¹B©6á‰w¹àé›È»øôÉl.8u¢X'dµ$Hƒo—Ãr¢ü£¡\`SH¹»œãÅÓE]…Æ“‚ƒwW½ÍN›Ízvn/QõóGSG  Ÿ€x’èÏ—öôc½ðwÆA£àþ¾ÛiµÿËçÜG•«¯î /j,4«%)j…* DÊ2K³Ó|³Z;ZgùÂKvtåµ ùÆ ÏËÕ) eKafØ­÷W·u´Uû©sÞÆùÙ:‹ÕTŸá5ÉmN»ÖžcwÜé™ùÂÂáÜyyêT“NgrY™ir“Õ¤µ{Ó\yîtO¾Ð6j™ü€»Z2Jfë°—143s‰·€­®MAr-€MÊ>oc†&¡aÇ–Æ¢8ä‰SØ _#‡†Ù "q=-HL‰ÿ¥J@ŸðžßæL½äInY8Óôèû²wµ*Õ*OoùFcæ¹FxÉ£Sž£Ê@?îIf²iƧ‚3ÓÜ6ƒ\¦’I·æ‡ŒàøøÛ6/ ÏâžåâðN¯|w5½MMr…\nÊmmaçüÓ°ž›Ñ*p?Ø!…‹[*èŒMÙ*©­)ñÊ<¯I°-:sâDû¯dG-œyö0uè`wºð ÷qàµ>Ï&4O®UÙ|Ë‚ÅÛZ=âÃ×ê'¶¿;ŸÔ3;<²‡ÇÃßr#¼¢þ’„÷g,6Š=sšœûÖZE{kN¡•“oÒ˜¤Ç4VxcN×Ê_âÈŒùåJGÊÄQ›Y®·h@fÓò%^Ÿ)…WÛ,ã{¸~»!%Åì³q¦‚° üÒ]ß´`nC`NÿÚ5ˆÖÔ®eÿS«ÿ/.Á¥ endstream endobj 48 0 obj 10440 endobj 11 0 obj << /Type /Font /Subtype /TrueType /BaseFont /SELGHO+Calibri /FontDescriptor 49 0 R /ToUnicode 50 0 R /FirstChar 33 /LastChar 33 /Widths [ 226 ] >> endobj 50 0 obj << /Length 51 0 R /Filter /FlateDecode >> stream x]ÏjÄ Æï>Å·‡E“[!eËBýCÓ>€ÑIVhT&æ·ïhÃzð¿™ßø9òÒ?÷Ágïí€&á7²#Î>ˆ¦çm>nÕ³‹IB2<ìkÆ¥S„®òƒ‘5Ó§'G|(Þ9$f8}]†ê [J߸`È „Öàpâq/&½šAVôÜ;®û¼Ÿ™úëøÜ'b¢ùd£Ã5‹dÂŒ¢SJw׫ܿҌ“½]ÛhnVÀâXZÅbT%ž2£üõžÍnD«.¤&.I|ÀûÎRLååz~Õîqe endstream endobj 51 0 obj 233 endobj 49 0 obj << /Type /FontDescriptor /FontName /SELGHO+Calibri /Flags 4 /FontBBox [-503 -307 1240 964] /ItalicAngle 0 /Ascent 952 /Descent -269 /CapHeight 632 /StemV 0 /XHeight 464 /AvgWidth 521 /MaxWidth 1328 /FontFile2 52 0 R >> endobj 52 0 obj << /Length 53 0 R /Length1 13616 /Filter /FlateDecode >> stream xÕ›w@SgÛÆŸ“°C 1Á#T ˆŽJ‚ ¢ (– ¢Èp£¸ªÅÚÚÚÚ­vi[:G­Ø¥µv[»·v/»×«E¾ëœ›ÛªßÛ÷ûãû§oà—ë÷ÜÏÈ9ÏI¦´±¾©R˜D‹0ŠÁåµÞ:¡ßRîFô._Ôh§v\µ¾}ªêf×RûâuBöž=oiµS^BJ¯®ôVP[ü‰^µ¥¡ÈþÕµK¨²0oAywÊ´ýj½Kº_¼¶}¾·¶‰Û0 îìuõ•Ýý’ËY—T6ÐÑд –SÒÚµå’Á!¡aìÂ"žþ€LX1l‹´Fø Wë÷ÝÞ±ù÷Âf…ŽùUô @AˆG¾Yóâ™ wo:}ªsSà·þ¡ˆè†yþÛ;ß"hçéS§v~«¯ÔÝ©‡A 4Ú; ëöFK kYÖ°¬fiaYŲ’¥™eËr–e,KY–°,fYÄÒÄÒÈÒÀ²¥ŽeË|–Z–y,sYæ°Ô°T³Ìf©b©d©`)g)cñ²”²Ìb)a™É2ƒ¥˜¥ˆÅÃâf™Î2ÅÅRÈRÀ2•%Ÿ%e Ëd–I,YrY&°ä°d³ŒgÉbq²d²d°¤³Œcq°¤±Œe¹”e Ëh–Q,#YRYF° gÆ2”%…å–!,ƒY’Y±$±$²$°\Ì2eËE,ñ,q,ýYd–~,±,vK_––>,V–Þ,½X¢Yz²D±D²D°ô` g c±°„²„°˜Y‚YL,A,,,þ,~,¾,>,F‹Ä"ºEêb9ÃÒÉò'Ëi–S,ÿbùƒåw–ßX~eù…åg–ŸX~dùå{–ïXN²|Ëò Ë×,_±|ÉòËç,Ÿ±|Êò ËÇ,'X޳|Äò!Ë,ï³¼Çò.Ë;,o³¼Åò&Ë,¯³¼ÆrŒåU–WX޲¼ÌòË‹,/°<Ïò˳,ϰ<ÍòË–'Y³<Árˆå Ëã,±<ÊòËÃ,X:Xö³<IJe/Ë•¥Eayå–ûYîcic¹—å–»Yv³ìb¹‹åN–;Xng¹e'Ë–í,·²ÜÂr3ËM,7²ÜÀr=Ë6–ëX®eÙÊr ËÕ,[X®b¹’e3Ë,›XZY.gÙȲå2–õ,ëXÖ²¬aYÍÒ²Še%K3Ë –å,ËX–²,aY̲ˆ¥‰¥‘¥¥že!KË–ù,µ,óXæ²Ìa©a©f™ÍRÅRÉRÁRÎRÆâe)e™ÅRÂ2“eK1K‹‡ÅÍ2e‹‹¥¥€e*KË–É,YrY&°ä°d³ŒgÉbq²d²dìÑ~[ÆoÍjß±6üάöD¬¡Öjµï(´Z¨µŠb¥Ú7Åfj­ XN±Œb©3C–¨1ˆÅ‹(š¨¯‘Z õT\¨Æ¤cBÅŠù4¤–bÅ\µ#çPÔPTȘ¨RûdbH%µ*(Ê)Ê(¼¥³(JhÞLjÍ (¦(¢ðP¸)¦SL£pQRPL¥È§È£˜B1™bÅDŠ\Š ª5çC‘­Z' 5ž"Kµæ¢åT­™éÔ7Žæ9(ÒhÞXŠK)ÆÐÈÑ£húHŠTŠÃ)†ÑbC)Rh•K(†P ¦Å’)Ѽ$ŠDŠŠ‹)R  ¸ˆ–ާˆ£5ûSÈýhéX ;ͳQô¥ˆ¡èCa¥è­öžŒÍêE­öž‚VOŠ(*FRDP±E8EõY(B©Ba¦¦>EE õPøSø©½òðè¾j¯|„…‘ŠjIB©‹âŒ>Dê¤ÖŸ§)NQß¿¨õÅï¿QüªFÚ:¤_ÔèÄÏÔú‰âGЍï{j}Gq’â[êû†âk*~Eñ%ÅŸÓϨõ)µ>¡ÖÇ'(ŽSßGRñŠ÷)Þ£x—†¼C­·)ÞR{NÇ©¼©öœ†xƒâu*¾FqŒâUŠWhÈQŠ—©øÅ‹/P§±‘©F¬Bd¨-ˆt5< 1ŽÂA‘F1V ÇïÒ¥Ô£†yÐM1J Ó^G#)RÕ°ñhPÃ܈ájXbõ ¥HQÃQ¼„FQô¬†ioHɃhz=B"E-v1Å@ZlÅEñqj˜¶Ký)dZ³­K‹ÙiE_šCчÂJÑ›¢—j™‰5£UK ¢§j™…ˆ¢ˆ¤ˆ èANÂh‚…Š¡!fŠ`i¢‘AT ¤ ð§ð£‘¾4Ò‡ŠF …D!]¡e63¡å¶ÎÐ ÛŸðÓàøj ö;ø ü ~Aýgðú~Dûð=øœDý[ð ú¾Fû+ð%ø|2ÛöYHµíSð øœ@í8ò#ð!øí÷‘ïwÁ;àmó\Û[æ!¶7‘o˜çÙ^7ÇÛ^Ç௚l¯€£àeô¿„Ú‹æZÛ ðçáÏÁŸ5ϱ=c®±=m®¶=ežm;‚¹Ob½Ãà àè:„ûƒàqðXðBÛ£Áõ¶G‚l7Ú€°õ‡À>ôíEßÔTÐð i©íÓ2Ûý¦¶ûLͶ6ÓJÛ½àp7Ø v»LI¶;‘w€Û1ç6äNÓ\Ûøvø­àøÍXë&¬u#ÖºµëÁ6p¸l×`ÞÕXoKÐdÛUASlWͶmºËvEÐnÛzcœm1Õ¶VJµ­qµ¸V·µ¸V¹š]+Ûš]¦fÉÔlmÎm^ÞÜÖü^³#Ü/h…k™kyÛ2×R×b×’¶Å®‡ —‰*ÃzÇ×¢¶&—OSDSc“ñ—&©­IÊl’7IÑdi²7ƒ]õ®†¶z—¨Ï«o©Wê}F+õÇë ¢^ êè:´§ÞÚ7 éXQo¶d-t-pÕµ-pͯªuÍÁÖ¤ÎvU·ÍvU¥V¸*Û*\å©e.oj©kVêLWIÛL׌Ô"Wq[‘Ë“êvMÇøi©….W[¡« 5ß5µ-ß5%u²k2ê“Rs]Ûr]R³]9mÙ®ñ©Y.'N^ô±ô±÷1Z´˜ÜG"¬Rú`«ÃzÜúƒÕGXë!«1<´·­·a`h/)cJ/iA¯U½®êe >mpDLÌ íy´çG=¿ïéÓÃÑsà ,e‰²G#µs‹šT¨Ûž¨´LÊ!Ãôs%Çg…FJ¡‘¶HƒÓ)‰°ãa?„#ZŽZ ¡¡RhhW¨ÁŠá¡!¶ƒv×bt„ ‘j¶™ Ú]—Ùå0£¢üEÁy…Y¡&›ÉàJ3M1¦´Œ,‡)ip–0Jv ÿåÇ‚0hG#EÚ²:$±'Jò•:¤-í… ¹bj®W¬H•¸íÞ‘_¤ømT„«¨ØÝ.IWzÚ%CF¡‘›_Díõ›7‹ô˜\%¦À­ìŒñä*-‡&]Ó%Ò= % M %¸+ihLпђš´nèÀwC#ÚÚm¡õüý†aܬÜôehõ¿Ÿò_Ð#ýã?üÛž¢îq]†u¢Â°¬«A XV‚f°,ËÀR°,‹@h `!¨ À|P æ¹`¨Õ`6¨• ”ƒ2à¥`(3Á P Š€¸Át0 ¸@!(SA>ÈSÀd0 L¹`ÈÙ`<ÈN 2@: Œ—‚1`4F‚T0 ÃÀP.CÀ` $ÀÅ` .ñ ô2èbØ@_ú+è zhÐDHz€p, „3&Að~ÀøŒë½€„¨P“΀Nð'8 N?Àïà7ð+øü ~?‚À÷à;p| ¾_ƒ¯À—à ð9ø | >ƒà8ø|>ïƒ÷À»àð6x ¼ Þ¯ƒ×À1ð*x/ƒ—À‹àð»[+±Úy·vŸ÷ìßšsf,êÞGm÷Öb¤¶;­Ý×A[¥¹»Â;±gFþ×yj{¤ÃUç'Ïø¿ªÚkût ö‹wFÛ³m¨Ýô¿ªçŽ8×·‰[ñ ¼ ÷Ú®jv;œl‡îçÖ·Ÿ»Sï»CÜ)îµØ-4ã¤Ê.Ôv‹»ñÚ¾W´‰ûðõ—ŸkÔû€¸_¿rŠhªØ#öâJ>$ö‹½þŸúÄ{Ç…söt¯¥ž]å€xX<‚gÈãâÞiã‹+¡v°»zDEíÃø[Ê#ú(­÷0ž[Ïàêyñ‚xQO¡õ²~ÿ,Z¯ˆcâ5ñ–d†½*¾Â}§xÅ÷Süiæ8üáåø·ˆQâ_1«dæŒâ"ÛUX05?oÊäIs'ädÏrff¤s¤½tÌèQ#SG –<()q@|\¹Ÿ-:"Ìj6øûùúñ›m¢SÎ*µ+ñ¥ŠO¼œ¤µe/ Þs ¥Š¥¬óÇ(vmž]çt`dÕ#4Òqv¤d±c’íNÙ®¼”)Û;¤¢|7|s¦ì±+'uŸ¤»O¼Þ0£‹vgtu¦]‘JíN%kQu«³43)Qj7eÈ•AI‰¢=È5Á”r]»4`¬¤‹a€sT»A˜µ‡UŒqNo…’—ïvfZcc=zMdèk)~Š¿¾–½FÁ1‹MööÄC­WtXDYiBp…\ááVŒ^Lj5:[[7(a Ê@9S¸ìÓhl`¥’(g:•–;õìHŠoœE¶·þ*pðòÉoqÔçT¼Ý¿8˯BëÔNñì6)’—]àØp„8¿ØXíX6u8DJK¾›ÚvQfU…#9Á£JµžCÜéÒzZ¸çìôR;딥Ýß‹ª£•–2{R"®¬þ§øÄ¡ß®ãKËÊ«µôV¶Ê™8Cì¥(ć6™‡·{3탓1Þ[Š“¨Ñ¶!ß­$ËuJ„œN»‰sÖ¸õ)Tu*Š(-$;1Og«va´ÔÖ’óÝDJ×ñö¡vëž1Tx´ãP¢2pQâ­îŠ*ÅVj­Àó³Êî¶Æ*¶Ï#»+=ÚU’-ÊÀãx8ÜpõY8· Fó`œ¶â`w¬FvµP°gáNNƒ‹âGM튦±»%«àax”îš·ƸŒlLFbjF¶5OnýöÉJ'€ÃPΓÂ÷¯c¢ÇùÛC£ÑÚ ´;+3Ï9ÀóEC?ÀîÕþýq´½èÞ B€v9³µsHJ4ÀíèP 8O½¤]Åh»"òìn¹RöÈx9òÜÚÅÑöZ¿¾¹²öÁ ~µ»Ÿ%…絨?•ú›[èæ†ö™’• _Wí²êíñzûl3û‚îî¶·ȹ­ÚƒËÝ ;^A¸8~ñ9ÞM©áCñbÍÂ¥œå•í{V«·£«¥¬µÝáh­s–VÂË UΩh• Ücp-õ×}³u™öÐá"WÊ-LOJÄ{Oz»,mÌowH ŠÜðúö…nÕ€EKÓ=íýÑç>`¡W ZU+jCìZC[i*úxë‡-z¯^ÐÛåø\V¯Ñ Ô$QÞa š…ÇPó¡šC¯ypÃ+,º—ïÃN{…vyVxª[K=Ú‹KDáRâ[R$y¬P òX|”ë¬É•éŠIN×êiZ=ê~ZÝ_NW¤( ›Ó÷¤ÖRïSxʹñ¹Ï‹öì7ÄÙ;ºº ݱ/YOzbñ’˜ŠÜJ`~øÆMÀ¸ñ¥(WZʽÚq^êÚ+3§Üƒ×/ˆ!9J Vì^#²ô9ÚÓ“Êqmpõù-h(-Å“ =¨»F;"»Ý¢ˆly.;­é¯=P²§5\¾D{bc¨·A‹@›À‡ÔzÅŠ& o¸ÚùãÈËet•—Úq|Dyžêô^¤]7T*ñ–è_©díîÚiãLæ %pÄ·æ¦AXßþlŠvòzkC÷<¶E1áˆâÏÙÊî ØtåhÇ‚ï 8xmèÚ2ùbª¼oÚAëånÅ—ãÅ›?Í7¡"§òd¬§•´5ŽPÕ_;ó`ì»1®°£k·¼T{à[R¢¬ýpО˜ÂzOlái½° '$%\X5ëåÖÖó¿Ÿ@û`>›Ú*v'~Öá£ýo,Gñ|i·`ü{*{¶"ðûém¨øâ_˜ Æcø×˜ÿ¿ËH1ILÅ 3>6‰£¤}û"33’üÇG"aLJ*B’2¡>óþÞ½ÓäýÃü6Ãr:¤¤½iþ›ñqaZç‡/'w~x2|dòI)ùƒž°üørØÈ䔯Ÿ2X ‹ Ó‰1øûGøÉý†]?<%å’±†aCãå~!½6tøˆ±Æ”KúŒI•±­-ýYdœÒégX)§MKñíÛ;4Âìçkèž4&ÎRP7fPŒ¿ÑßÏèà?`Dz¿ÜyÎ~ïú‡ÅDFÅ„„ÇDEÆ„ùw¾çrê'ßÓ>óN_kô=#­¿ñ† ƒŸ_Gßè^ŽÍ™ÚÃâcêa ‹ ð 9£ó²È>Ú}"#i­ÎIÚöbWûwÚOûŸˆ œÇgOIÈðΫ)«¯ùd]xÈ endstream endobj 53 0 obj 5932 endobj 14 0 obj << /Type /Font /Subtype /TrueType /BaseFont /BBRAOR+ArialMT /FontDescriptor 54 0 R /Encoding /MacRomanEncoding /FirstChar 32 /LastChar 32 /Widths [ 278 ] >> endobj 54 0 obj << /Type /FontDescriptor /FontName /BBRAOR+ArialMT /Flags 32 /FontBBox [-665 -325 2000 1006] /ItalicAngle 0 /Ascent 905 /Descent -212 /CapHeight 716 /StemV 95 /Leading 33 /XHeight 519 /StemH 84 /AvgWidth 441 /MaxWidth 2000 /FontFile2 55 0 R >> endobj 55 0 obj << /Length 56 0 R /Length1 6780 /Filter /FlateDecode >> stream x…Y xTÕµ^{ï3¼È$@ž“̆ ’IŒh€`2yLÀFBÐdB &@T„¡ŠÀð²ÔRÁ>ª¢V9™ –(j+Šp•j}‚h¯Ú¯ú}j}åÜŸ™ X¿Þ³ó¯µöZk¿ÖYgŸ}&K/m£d ‘ oË¢æN2®ìÀrZ–-Qcõ”,"sã5óÅꃢ~ݼ…7^«çXÁ ÛÛš[cuúüíPÄêl øðöEK–ÇêÙï‚[v´Äí9Rm^Ô¼<>>I»z]ó¢6iÀTš@ÔÎŽ®%F•rdu.n‹û3?QÒŸ»–v,b0tµ.ja4ˆHV8}Aé^²@²Q ]I¤üQÉ#êÒnJmúí¾GÇÍIø¥5W.ƒèÁGJþÂÝs¯úv÷óldMF5Áð—´³Tô_A56úv÷·7Ùb#IËÀÅ{©Q\ÔãÎr; FÒI€‹‘Ož£WŒy‘r‡7*\=éCKS«Š…ŠK ª‚v»ƒ€BsD>¬6ÐU@Ø Žf"PiU`'p0‹tÜÙsivŸTîDDÈy'ö„ƒ Gݨyᤋ9gçK>¬§°2V¿xBiGÕd~ á6¢€‚titBw© •À 8è€ÞðŽ-M-*9À*à `6¦sSáÔ*§¸Û˜X h%0UÖø!”a(NîôæÙì6m²Øbg©ùlj¾žÏË(#ûrzš5-ÊRö~òï¯S(¡*oæ[(7âŽ8ßù&ÏewEÜûUCÙï)_AÖ±ñäfàã¨Ë¨%»UêÇ?^±_‰f©w‘c$[íu|cÿÈñ©=Ê!~bßïxS*,âø4Oìu·¯w¼TµBsÀe`ûTõ×>ÎñäaÃu5 ;"Ž•’íuÜbŸä¸ÖnÚb†«»Pó¦:ܳ“Ñ_­}®ÃÛ…>÷:*íW;&ƼÆÊ6{—` ž˜XˆÉŽ´ƒºòg–EY»·È²Íâ·LµüÂRj)²8-Kž%×2ÄšnµYY“­‰V«ÕlU¬ÜJÖ!Qý¤×#ßzCÌÆËÏŒ„f¤² ; “Û (qfåôKÒ‹z^?£šÕk}-T?WÕ¾šáвÄé³4“«šiéõTßX­óÔG-zƒVæ©×,Ó~åïflsZ¯‹2jôG™.Ukrµô/1–¶fS®ä­ÙPVƲʬÊôŠ´ñuµ?C‚†2XëùñÊúQôdyò´mõ3üÚãy­T z^ ^ûí µÉß˾`g}µ½ìsÉþ^QÁ¾ð5H½¨¨ ê£ìJÃTö9ü1`ð³âÅ,ýHµæÇüvÄü Ð~Ã%ƒ_B~ †ŸÂ¤_w×p_m÷pødªÔeøteªçû.€O|2BtØð9œ’>Z…ÑÝ—|¸°².v–c¸3ï6\Jâ.ëϹ¬7F±Ù>’ ›”“>)'ás^ ÿ»ØVíñ°žò@K“¯Íå º|m@PÛ°¬=K ÍUÕî–€4¨špç¶´KÞܦ\mµZ‹«Ví.7ÚýÄÜ$Íå®Únjò5ú»›¼mµ‘ro¹ÏÕ\è™4mLÙc­?7Ö˜i?3Ö4ÙÙ9Ö$£ÝOÆ*“æIr¬29V™k’w’19>Íßm¥ê@ îŸä=<)ùÌuª3lFò–;³VæîÃie%yZ²«ZKd^WWIž)iujÜ”µ²Ü™»íŠ›lP§¹ªÉ³di×RÊòͯýuá‚jÉRy+bÔ#u?{Áŧy›kåÙº^+œQ¯UNŸåï¶X  Ö ›0 KJòEõ¾˜òb('HG!Î9JÝD©KHˆ;þg.s‚ÑéÅAcóæ³%ÔZ~}#ÇVÐ8 ahšå߇³”|It°À.æa]½Éu2Å4„ew `ÉҸŒ87\»<äéÉ@w,ƒ±ZâÁÖfÚGÙ@ŽéQÊVÜ„ïýcàÉûçëŸH»äüŸØè¢qí¢'Ù|z’Òsì,Zí¦^ÚCòTK÷Ð º“Öâµ6 šõÔ€b‚þN–­ïÁ—Éxa>@Gà{­¤}”Á²ôOi­¯£ÕJ¡aTEÓ¨ƒ6±Ëõ¥ÔD'”[©Œ.§ë¨“…t¿¾Yߪÿ¦^ñWýJ¢jA9¢fú»þ.£Åïh;`[ž&/F Áó^ZL;Äl…éóôo1'Ý€9(4…ް>îAïmô1Ëb+D zyH×ôçáe§ÙÔN;hË&q§©IŸ¢¡ Œ±½n§íE‰Ò3ô6K6Õÿ Ÿ¥l*¢Ë°ž=ô*ëý?¬î¯DÜLˆÒHKý™þBǘ‹=Ë;LɦR“×t“~œ†Ð(š‰Ù>Š–ÿ˾æ+QV‰•:½ykè72Úô}ÀrX ›Ê®ä#y¿O,&+F…ÒJóï»ÐûûH£½<™)O(ß™óúOêƒpGÜt7ÝKϲ¬Te]ì×ì ö!¯ásøÝü”¸SyLyÍÒŒU_M‹h=A_³t6ŽMg¿bíl[Ë~ö³#ìû„WñF~-?#ÚÅõâ¥e†Ò¥ÜjºÝ´ÁüI¿¿ÿùþÿéÿZ/Õo§éȇ՘ýïè>¬¬—ŽÒ[('è3±$6EeN6“ÝŒ²’mb²]ì1¶£c§Ø§x%}ɾãxÓr3ÏÅáG\|1N˜wò{øQ”cü_ü‘)† +&Š€èÀ¬ÖŠ;Pž(9ÊQEGœKMÛL;M»LO˜ž35'[~wü+ß?ôCáï÷Sÿºþmý‘þ=ú4÷o|‚MÄì›Qà~oCÆí¦×Y2b—à Y»‘™Ã°ëÙrDò6¶ƒ=lÌý)vQz“ÁœS¸Ý˜óÅ|,¯æSQ®æmüzƶò=ü þ­°ˆ$‘*†ŠB1IÌmb‰¸QlšxE¼'N‰¯Ä÷(º’¨8”aŠ[ñ(“”9ÊRå>åcåcS“éeÓ?̉æEæÛÍQóç8ÕTX¦Y¦[f[¶XöZŽ[ƒÈÎCô4ý xîb'ÅjáOÓf>ZÉÆ'Ì«Èç9Ô*¦pd*ßÅÖñ[Ø>Ü´Ü\ÎËÙtVq#Ö/òü+^.¦°z6ƒðQ±ÍC”Ç!MTÑiåÖö*z^nNf+ùs2EpF3Ò âÅ#^¦·Å fQ w”D–ÉNóGÅ4dÁ3J…ÉONq=%®g·ÐÓÜG”øu#òø ö8ö…FVÊþ-tƒ¯@•‰éVº–ÿNã9^G¿g­Ê<ÚL£Ù ú˜ÁS1Òt¹Ð<”½Äç+a>˜í!®<†ÕgÙ0 ¡ÛØl±Ã|†¿EK騒Hï‹?böGùSbŠrÖÔÀÚñÜB·ÓõújºÑäW^cóH°+©@9‰Ým…(Uœà«°«4aOÛ‹§{ö*1š,dÎåÈ‹™Ø!v Ü…}BAÍÇ3~v±Wi¹‘Gižiîƒ_j^îo Yú#´]ŸG×é[©ûÁZ}zÜEÿ -´‹­é¿™:ñ)ùžíËMuü¨©N/æaþŸÁ·]xí–EÿDy w¦Â´ŸÂÊ›4ƒ*õúßÝa‡ÝNsq`ý«ü #L}4ºÿ ޭ׉N¬÷M×Õ,‘Úõ…4•ÐÃ5[<¸Ç{ ë½™Úxƒ¾D´õÏG¶ ^Dk)öŸõÞš™UÞÊŠK'–O?®lì˜Ñ¥£.)¹¸¸ÈS8ò¢î‚á®aNÕ‘ŸgÏÍÉÎÊÌ:dpzš-uPJrRb‚Õb6)‚3*ò¹ê‚ªæjŠÛ5yr±¬»š¡h>OÔT¨ê.ôÑTÙ®¦ <½ð¼æ'žÞ˜§÷œ'³©ibq‘ês©Ú‘Z—e³¦û!oªuTí´!O1ä; 9²Ó‰ª/«½VÕXPõiuËÚþ`mqëNJ¬qÕ´%QwbÄ$HZ¦«³›eV0Cà™¾ Ýœ¬)X¢–ãªõiÙ.4E7¢À×ܪM›î÷Õæ:â"Õ´¸æj$OJÃ…jŒa4sf1†Qç㌣ѵ»¨/¼1j£¹AOr««µ¹É¯‰fôáÓÒ<·V˼飬«èg²µç[sEØ—5_•ÎáðZU»ºÿ¼¶¹NÙC €>ЖÔÃuz#îT½<‹k|MÀ¯±5ËcU±õÅN½Áª–àªvµ‡qkrÂ5ÜèŒääx{õ“”ãSÃ~—S«ÌuškíÝC(ÜpcO¶W;ÐR\ÔmK‹¶{Pj\HN9_hCÐc6C2Ü¥Tßp.²LÎÑuN‚šÚ¢b&~Ö4N’¶qn‡€+ÀÐJkÅ™¯%Ôö R%2ÍT`s©á/ à:ý¯ 5Íq¹Àö%I£Ì“s©¦±æYóx´ÂB™"–ÜS̱¨-.Zå.W§ ßÏò£¦!¶Í %¿Ó)oð†¨—æ¢¢…¦ûcu•ææFÈ[‚³5JK߀eèLi XÎ5ºÉ{ä÷, Õ¬îs©¶ŒÁ¾ö Ëø/涘½~†«GcÕƳ¶¾ñ‚ZÌ.ЏÁ—´Á5~‘Ë¡“φ5vBpÁqÙŸ¬)ø3IݵX‘•††©uš-89F‰Ngü™ùÿEõ³²•Á~l_†6ÁŸhlÚZùõ ¦—õØr8Nöápâ6¤Zl–—Å2úNµF£™x2 ð‡OŽq\Í‹ÁÒˆ§ÈPrãÕ sã¸dvÕaÏ ‡ë\j]8nŽê¡¹.Õæ ÷òçøsáNv»XâDõ}rµºD¬MÀãÁ©ºÛÅÖMïö²u3fù{ñ‡º®ÑáŒ×«ÝÃaó÷ªD^CË¥V*¥‹*+TϰÈ·þ¹½^¢aU …QoÁ¯†.棖(él~:%¦ó:¹>¹ÇÔ4úã·ÅHùè!‡ðt#Ï¸м’¡”ÿËPÏiÒ(ò— N÷"gš3­¿êÐ÷ªèûÞk¢ïHUúàeü¸¦ÀÙïç.¥0 ŒÒã#›å?dª«ª¦6xªÏo^8¥ñÿèõ endstream endobj 56 0 obj 4538 endobj 19 0 obj << /Type /Font /Subtype /TrueType /BaseFont /OTDYWK+Symbol /FontDescriptor 57 0 R /Encoding /MacRomanEncoding /FirstChar 165 /LastChar 165 /Widths [ 460 ] >> endobj 57 0 obj << /Type /FontDescriptor /FontName /OTDYWK+Symbol /Flags 32 /FontBBox [-167 -299 1094 827] /ItalicAngle 0 /Ascent 701 /Descent -299 /CapHeight 623 /StemV 103 /XHeight 467 /StemH 38 /AvgWidth 572 /MaxWidth 1042 /FontFile2 58 0 R >> endobj 58 0 obj << /Length 59 0 R /Length1 3704 /Filter /FlateDecode >> stream x½—kxÕÇÿçÌÎìF’°\uMÙ5†kÒ‘›,¸I±±â.ÒpKB°ÄDBR–ÆXÄ–¦4¥b)µHã #µ4yhËÅ Tz¡Zªi)Z‹”CÒ÷üwåOû­³™ßyoç¼ïœ33g²dqmR……àüʹÕà‘¶Fš›æ/]âOè)€îS^½ 2¡w‹ŠŽ‹êÊzÚi©(›[šÐÑ!ímbHèj„´·VT.Y–ÐÓ¢ÒzUÍOúÓ¶ŠîTÎ]–Ì“¢ûœ[Y&­éa¿ºªf U¤•v`õâ²d¼¿Ç[S[U©ÄQSZ9_!0ŠÆr¸ØKË zî<^ñ™c޾óá¨ÙÝÇ}¢zx¸åÈš¨^Í=;¾sû•fO›³YT‡ñÆ!ýìæ+Í’sFçöOOzV]õ¯9t+ÜC&vé¨²Ñ K¹H +DÖ” Ct‘䲃ü”¼L^"ÿM^$?!/ÿ"?&ÿI~D~Hž'ÿAž#ÿ.5Zøå³ø¥°q–š‘-œ¡üWò4ù>ùùòù.ùy’ü#ùò÷äïÈäÛx’ímdJž·h{KdÞ¤üF’Æò:å£äaòJ¯ßP~?!Ÿ#Ì1·aŒxDy+í?dögiÙ’o &HÔŽgj´ðöÛŒ‰"_VÆB3{Ù6Qþ.Ùdîc|· 7ÒòmòiŽ°Þ§È'™ó zÇe‰Œ1ëé}”\Ç51f-¹%rM×Gr­«iùÙ˜¼wq‡øÍ}d¡AfÚÌp#¸nÆba•ÌßIñ¬¢gÚd´(VâQ±%43¼ßÀ8±%43l,æi5Oç×Ézy˜¨ú„Æ<Æb¡Ž–eäÃäR^u­¬¿é_ƒÅÈ—ž5 =ÅÂC¨æê?DO5ª¸úÆf‰ÇÔV…Ñ_ú%4µ‹…¯±O¹€,#瓳Éò«ä,ò~Ì”ÚlÜOÍÈ"”Ãä}ä ò^r:9+UL¹ˆœJN!¿BÞM’“»þ,•~‰ãÐâ3~'åIäD2È«™@ùr<9ŽKŽ!GãN©övÊ£Èd9œ†3”r.ùE2‡ÌÆdñ¡<˜DĹ+m¹ëÌzÙ’ªŒœEÞŠî"gÂ'¼Eîx Úý¸Wä~Œÿ-”o&}÷ÁMœ…™ûFõ%û×'é•ùê-»S–ÔÑ›¶^è)Ož^ÌØ3é36‹²%û™©Ñ+?—Thž®tZÒÈT²y™BzH7FJ¼ƒ£B›îQ¢™15Ÿ-³cºdo3wɹú9b" OÈùŒœq9ÛätC©»׫š!ŸËÏ%Ëÿ5IÎãÆbµ^+ïÝhG‰:‡jÖ©¬ïXy·ïÄ9G!s¬mÓc²ëÓ³pH´r Ó7J;Ó%ªYkZ´«h×éz‚ÚͺY­”•™‰~®yak7*‘§ŸC‰ëÝè–#ý,j•WÞF%z’ž’¢Ñ予Qvì¯ÈŠn³*õw Bê’Œ^?áFêQ˜‡õzžTºOS{Ô õž.Æëj¿êPGìÉü™oÁ¾8o·cöÉ»mè>L°\IÿdÑûaÔoÎrµÁ>¤6ËõÉÕŸÇ0l“bßdO–*†YMȱ¤rù*ù²üYMbɳDÞÇQlÃLÕŒZg…Ì•ø¬=j'ò¬&»A Þ$ÙzªÓNF»z€S";ÉY;®Çëx ú¢DîÆ»öz½M棧ݬԼĜ`Š]Œuözô–™ H;KV¤Ÿ}Åj¯Î×Ú¦¶67ökúŒNu PjŸSçÕ%'×ÉR;íKhPíÎHŒWNžÚçŒvÒe6d÷Õ7®ì’]k(A·c»,­í÷ÆuÖ]¥ñà=aÿÁH 'ûÕïuûã(ЧÕù[»ºŠÂ.Ÿ‰Û7Ç­,OÜ••yê9Oåd…ý­ÊJ›?'$ÆiaÉ Æ,éòC9òÑš]Ø §(ü¢REZUWc+B/››Ù%âödûýù Cq5G””l1 ˆt]¶¿@ê((gFü1ì®Ò˜¿À_1·T c+޲X$WJœ^(œăßU±,#ãt3ãH Ed„’#HKSî JÍ.ôÇ­þEá{ÂñhȆ"¾@ÀŸo+ ÇÛB¾@$"QiW+•ŠW,¼!YsºÔœ6XüÝ£È}qDb13æ´pf Å|1¹Ž¤Þжk ׂIC+Ì2ù­*Z$ƒI“ðCf 3 uFÌ${ÍÜçK¥HŽëÊ­yöÍæÿÈcŽœ/¸Ï,]g’X4Ê;7ºÊí­ò>v£o0ÅGylíBîᓇ‡Á{üðñÃC{õôÈ ô”»ÐQcù:Nwnt§_úx±3ÈŒ®Ð¢ÞÔ®º¡WÐcý6%Õ)Dª÷øû¦ÿ¹¡½FÜ–7¼Ïõ½Ì[ú·´Ô/þ§ËëwèËu-;êë[¤L¹±ÍѹCžÂÿvÿj:”ì_‰+rdÀÔé¡È}…C¦ÕUΫZ„ÿ›)# endstream endobj 59 0 obj 2061 endobj 27 0 obj << /Type /Font /Subtype /TrueType /BaseFont /EGGCDD+Cambria-Bold /FontDescriptor 60 0 R /ToUnicode 61 0 R /FirstChar 33 /LastChar 57 /Widths [ 220 551 314 604 597 525 505 652 597 308 531 618 592 592 639 459 365 592 592 592 592 961 597 569 798 ] >> endobj 61 0 obj << /Length 62 0 R /Filter /FlateDecode >> stream x]’Ínƒ0„ï<…é!Âà‚„ªT‘8ôGMûÆ^R¤b!Þ¾³M¥ÆÒgïŽÇ?ñ±~ª]7‹øÍæL³h;g=MÃÕ ]:%©°™W s¦×c£ù¼L3õµkQ–‘ñ;Z¦Ù/bóh‡†xîÕ[ò»ˆÍçñfÎ×qü¦žÜ,dTUÂR »g=¾èžDZ·µÅz7/[týU|,# $BGr‹dKÓ¨ yí.•RVåéTEäì¿¥µ¡iÍ—öQ™&Še!0X ©Ä eè\k’â¶GÓ®æiZ•,)w¦‚…BRî Æc„¤Ì3Æ=s „[Æ‚sÂX!#Q™j ç°o„€ÁÙ!X).¶@bTÁªBRf;¬*Üæ9+œF…* ª2ËyYØ(ô"  !÷œY! V(Æ…ÿÞß=ÿ‘û›š«÷xÎð‘ÂKó vŽîmF6ú}k·ì endstream endobj 62 0 obj 374 endobj 60 0 obj << /Type /FontDescriptor /FontName /EGGCDD+Cambria-Bold /Flags 4 /FontBBox [-1110 -299 1372 1047] /ItalicAngle 0 /Ascent 950 /Descent -222 /CapHeight 667 /StemV 0 /XHeight 484 /AvgWidth 600 /MaxWidth 1380 /FontFile2 63 0 R >> endobj 63 0 obj << /Length 64 0 R /Length1 12624 /Filter /FlateDecode >> stream x: `Så¹ÿNròNNÞIOÒžô4IÛ´MÛPú°´‡4--¡…BBAR  ïWQJ xu:Ýî/ÛôÔÇV¶«2ÇÔÝ+÷ΉÎm^_SïÔy/sêÐô~ÿIRqÓ›œï;ÿûÿ¿ïÿ^ÿŸlÚ¸yÒ¡ˆFÕƒkÖ#ùãØ ¯™ƒ[6ñr©6!D]µ|ýŠ5Ù¼æBúy+V_·<›w**(Z6ÊæÑyxO‚‚lOwÉКM×fó¼‡V¯ÌÕ;^€üÔ5׿æG¯Až_;°fY¶}M)¼K×o\–«Çq„ÏÅy5;¼yÝ ‡Sk12"D2èf¤Fûƒ(Ä¢0‚Ó¿ÒÏz±\¯üôgÔ=Ó°ÄÔü)Ò©å鎽whI<·÷¡)¿W{N„¶!ûqU÷dÒi¡þí9y¤\¥ü*8†x\ø¸Æ…gòcØ›Oxò g>áÈ',ù„9Ÿ0å†|B›Ohò u>ÁäÊ|B!¾/ONÆgeüŒß‘ñïeü–Œ_—ñ«2~IÆ'eü‚Œ!ãçeü¬ŒOÈø—ñ“2•ñ#2> ãý2NËxŸŒ÷Èx·ŒGd¼KÆ7ÉøFï”ño—ñ6÷ÈxŽŒ»dÜIpxzP+Àl€%ëvÜ pà€§þ@‡Šp ´ÌX°`À­‡x@)ˆ×â7Þt8=§^tý îúÜ/þ Ò[þКõ€V¯tÍZwÍÚ 6m¶Ù=+VZ¾в!·lh÷†÷°ck›Ûw€ê9çsÔÿ‡6=†Oáà+ɧÖ?µó)ÅÝ÷P!ñ¼äüÛ©ÐØÄi‘ýó6j]ƒÏ Òü ÁÔH +fù٣˶7ÞwH(rÝ(o¼ëuÂw¤BìÁV±ñ7±N⤉žnÀ*¬É a&÷VäÞJ±+Bûö¤w3¡wàжíÊÐö‘⢛wãÐ^€‘ÝÊÐ.®Þîšj·×Ù-S즈]_k×ÔØ™j;¶£*ûæÅm-¾@ÐX4™Êq陉Й¿š>û‹ñ“OÕŸUŸ¡NŸÁå!cEÈT,KSa‘‘/2™X³^£Õé•ZO+”z„)=C§Št¦n¥CW ½\³‰Þ«ùzPó;“F‡t´ÎtºB“ û5[èM¦o¡oiî6Óüa.-&{ .UÁÎ: …ÍP4݈}DQ³a€V€ÃOcŸ`*šË›K›Í%ÍÅÍ|sa3×ìj¶7[šMÍšf¦™nFÍs"ó°déFÝó¢’Ã{nTŠ„ºÇh¾Wª uKš9ýñQŒÿ1¥uóFó$ÅÍc¼,m ûãcØMªwsÇÆHêNî¾% y¥T÷ܸ´Ó›jIâ6ouKµ='DC—~†7É%Û6_X3,}Ò.i_9 bÒgí+!“”>bäհTÞ.U´H¥Pbö á‹r¡adç ¯ááÐð¦a’’\R+Ð{qëPhTCŸÓ•¨¶EÝRª·[âæô'¥!Ú-=¹©sú%½ETÛ¼QŠ P|º¢öxœ €À`ÐhÔ €@!ÎJKM}z'õûÔ[©×S¯¦^JL½úEêùÔ³©©gRÇSO¦FS¤¤ö§Ò©}©=©Ý©‘Ô®ÔM©S;S;RÛSÛR=©9©®TgêRº¾R6ïÿñQ¦‰sRö? É)j!ûÐofÓ§'¾ÐÄiRLp¦7›Î·Ë¾™mˆ¥§Mœ¦ ×ÄýÐÂ|qýåsÄÏ·Ð6ô:zž$Ð7ÑN4ïCh?š†’hƒ\úeèÓ/«øòrÜ‚§âJ°ªßEûp5(ª  ­¡¼—¢‡'{nG›Ñ/Ñ}è^ô 4Œ†@k?Fo¢› ~)Z;ÙŠ¬/ _„ÊäÈ؈«Ð'¯ôN¶ûÁÌG‰Ê\+I’µ[²Í‰"±!!1¡K›\%Ñ~öctžÅñí’Â0s %•öÆ}û 7YŸ€a¥‚¶¸ÏÇI”ž.¨‚g柒Ø9PrI—„æÄ ŒM¼Ý…¨Á—Ü— óÙ-KÊ‹<šuü’e^…Óì¨ÞÝ“méß–4;Ý€$Ô,•‚Y÷³’GCa Û>–°UÂöY@ÒÅSno6\†í©UB{j%p4•üœ§§³õñi>Ý7G8ŸO^4XÑžø¨NÛ&´-Óà juP¢#°-ëG±¾Ë JßÞ4J!µØg!Ëm'°J÷'!!Ä€oPcý¼flâø «tË6BÐLNayN‰i“TÙEð+%q@BûùÑŠãéc,Zš éSBj`Q\¢`Q£ˆö·Í“<ÝsB, 9Ä“íŽÉˆlß>ħ!OÚ& 1èzqyjhY’ˆ N 1¨Ó´Å÷úŽsàNã{Û%sH2@wÃÖw8:ÝîZÉ“l:½——îï‰_Xë#m@\•|º]€Ù`°öUQ²cáÉm“¥±+%oޏ€—v.]<ƒgà@^þ}iVÒæƒÝýžD;ƒ ¤’«)« §^|zÿ2™Ô2i ¯|ûªÒ¤õAï…ñö!v~B`ô§ý—öõù$wˆtL§ÛÉR°zÂxÜàaÙ è°ž6Iœ'¿Ð˜Rb{r¥0ˆÏGôiÿ˜ˆ–BFÚÙÏæy´”{‰áìc’ÔÏרûHÍÎ|Íd÷¤ûæ"¥,_&ß`Û'e;m,|#1ì°:xºRÒñy@ã™I “·ÞÚ§9Š4ÅÑ$¥ {h–œ!¹#á XÌ4+ð¿$6$)ÛâǹæÏšÁXbhÓ ‰¤²¿~‰E6VÂÍvrv¸vßÙ•“‚Ä·§“9¼,hJZ§†&U)»xÐ]BPÏ  º\– f‹@(||Þ1ø;ˆ^Á–ÈŒš™ŒÄßIÆ?ÊÖ˵Åy°D ¹=r‚oç‡ÈfK|2&›„GêóÅco&cÄÆA¡ —qô,k/ÅÊŠ¯*è;AÐo<j‚5‰å@_Ó¦·Í‹çÔMÞ'Y `®.BÊÅõ“\Ì·Ãê쓪 ~áA-pÉZÕÝÉÆ° ó€šÉ ¸p2¹./d%Røÿ¬ W&Íó2í¤ºó’ê®|5˜mÜVhŽ,:*à›{FE|óÜ…ñc&ó7Ï‹?Jaª-MŒ–@]üA\ ‡‹d”’&<É n £=J©åöÜ1¡r­B.óƒpP“˲  £A8µÉel¾eŠl™(—?%¶»†À¼ÅØô”$ΉßJ'„ÙÈ‘@l¡I”Ð2Š)F/i…eQI'DIy+)oÍ–3¤\%DAüA9ø1PõtRõGN&RNùù±‰ ° 'Áòú$Æ¿ ¬&”à%¥&´›A Å3¤ƒdDL¡¯Êß5˜Ô“B“.I#hr#@‹¹¸gÒi„u@“P ʱ3!%BdÒøJ²"ž‡x¨Sh’˜@v‘Ê™(œH[„ZÙ0~Iëß =`Ž™²!”K8ÈÂdÄÁ£ÒÃÊh5˜äahp.£"@-Ù7(Y^]§  E–+!‹öë ZISÂCÒº*U˜Bˆ—s{s `nVÒÁа2׸U]d-ðì…Å“¦?%ÃôŒ¡^áZ Ë•§RAµdðw @°í¯ƒâ¾lgKí'EdŒÙR¡\/´óÆ&Ž×%É*+ Í‹ÁDpO€D”H_Z õƒáT_Zj‹Óiµáò²üR&ßd¾}%È*âÁ§™@×ÀþË”Je =…§Ôú‰3Š!”TzQT5Š8Ås(©hEýÔê¢þ5)N¡.Å?¢~(o¦¿z¨?"?¤EfÚNA¬Bmþ„–+žD÷¬Ø0àÛä,‡áK>zÄ fxûJh8Ñi‘ γDA©ÙäÀçgr"´TB/]öÄ }SðýàW©¹Ô'ô>…Y‘TœWƕ瘇TEª‡Ô¥êߨ?ÑŒh^×&uNÝ£ú 伬@OÚ£œ‡JQªFSP©hG#&÷wÐÎÞU¬?¤´;”žbjmmeßcßaßÁáÂïÔTãº)-T} ]7% )•P7uj¤¶²Û c¤ív§]¨ÃfŸ™UÏ8ÊKœÎ4½…¯.qk’ÍûÚ:[<¦’æ >`WYnÃçÇzà|þo‡Ã_^t‡#Bw¯­¤¶ð¦Â*o¤£,Ð2­£ÒW,õ0kx óŽâžsË9û}X=5qv¬X¹€Uië‹‹o*ÂJŸ’5AêpJOc*ÂtÑí"\Dq4Æ­²»h­S£Ñ>Ó W8dF³3âjµ4†átYðQÈlAÕ/ךaUæH„Ý{ü8N,ú˜À>ÃØmN»¯X —…IO…k è÷Ñt0Óç3Z†2}þ†ªüÖᙎÂêÐø«Sjl&‰‡îÇG–”v—/UE£ŠŠ+g(œ»¿»5¨‰F™ªò¢+›~MEˆ”%aÃpßâE7æ8#`×ó`ÌK#6ЖUѪÛY‘5?c 7Eªí ÷-àÀ[(B.ö£r±'€­„?5ÕœÈýA/×+í æH-¡nºÎ<¥Š ÖQkJʪgš:"~Ý>ÇùþQÚCe_Të,m­>ï)é¾®.³:ªu•µVÓ‹Ãb©[  ˜Ü‚(~Ô£tŽº€±‘6šÄ•‰P&šh(Ûƒ1d1sÑÈmg˜ÁlÁ@ã+'ÙWN•@–«•ì6н'T¸6àÄ‚/-',_ì•ÈR–U ¡J)f[!í´ãëËk\LO³.ÖíSܽÏêà ‹#e ë,¢*gùôjú]Oó²J¼$ó@L¬,´hÎsuõÅv³2 ÔrU=Ô èúµ¥Œ¦€vª|,ír9Œ¹h/Г.9X‹™g!ç¤5~¯64Â>[kv Î>(ìŒýt'ÄÚ/;ÐyQ»ÎÊhÏÊŽ ˜l¢Ï.˳G¬Ì£-ÁøkK 3ûþçíÌ'g3/9ŠËyª`J­÷¸èíèLÕbß”E4ª.›¹àÜý½ó}Šd¯È«eù­[?ÞEŸ?7uJ­OZyñð;Öc9ºë ½Gb…ˆÇ¶ºähc5­>Ê0Ê#1†ÑhÃtÈ¢CEƒC­qÒh$®)ÝÅæ¥ÚAÙ½Eƒ¬ºØw‘"À­!‹²¯†¿æ4ùmÈZ›/Ž˜ð_ÈD‡“|}ºz:@©¢ßXþüMïxÝëwôï[ʬ6<¾ï¸éÊ­3žTtΙկùáê…ç¾óáuåÝu­=s·<ñ½ÆNÜ}÷÷ޜꛦ\~˜Cç8ÕHS4=(š¨Ù5Aaõ4õ$ðË(KQ,M™šLÆ#1“É­àGb¶P–µÚëÉ™쉼…‘eðçêÅ6æXTýuÇŸ´<_ L¬¯Žn¡r†Õ»£¿‚_ÌüϪ¿Aãcë6šÑYŠ=—rݧŸž}ÉPÞ¹¿XÓ\bUÅÔã Ó|‹J¶¯MÀjÐ='š“ã†Ýn;³#'V¨h1Ü®¥y2³:dº´iÖ½fU ÔÂὟ‚,–Ö*¼ ÷G2ŽÂb«QAkìryì[Ò2D£*«;Ø.Òúù=õ>›: ?%`²[Šƒ ×è`nu!'ÕH¸ ŽÄ°Û<ê÷—‰ùM¥fc%¸„ƒb%a˜+ KƒÖ‘B"ÆæˆYvs9Ó>@æikD¶‹D€ù¿7b^ÿ#_è KàÛ u YÃÍyŠ?ß•³…’'Ù?(f¸ªcpzJ<Þ½?œñVû Jk°[¶›ô-W¯hì]Ýæ¥õöÕ…º–`ÝŒþ¦ [žÎìX23¤‹FåíüÖL8ujcêÛèúVxáMó3·W̪òÚTÄ¢‚=PD€o&ˆ˜ä8çBVÚzHD Gs‡D «ßårñì.EÞhæTpŠð…½´}^s³ Êâ˜:Bܱ3 ì6ñûrÀÈ0Ôw¼|íÌ‘]óñg[ßÎ<¾$Y7#dY²8Ö`Wüþ‘='vN›øìá7R¦S/M]~kâ×/Ïÿ>Yws¦W±Ö- ôDnÝSˆÒª#"ÃÙZ­ÚrD´šª••tåA±€õéà!Ñçðî*/Ø%à t„&'1ao]@¸þl @üAN ¥¥_u† 9pùÁÊ‹D@z•Sö„IBqdlYŽMvü[6%c ûYZg °ýz“~þÁÙ>ºò—‡V ö% ,XTÙ7õ±î–}4j,žv%}ÍŒærÎ¦Ž©¿AÏí:wöïo.À-×oþécϯê«#ZÓÞ`!p1Œ^Êòð&þð# Û©«06ñ±&›¡VÑê¡=‡¬ððá ±‚¦éC—Ó,Úm2Uw3L «€£' C @¤|µ‚7Í…Rù¤‚™ àëgõýíYÅ GŽÃcØ„UvÀÀ@° Î'Y_kª(PAð±gö”¬®ûµkhA÷,¡giý@gùÐOoè:°nÄY­Š^åé\qõ––æÕwõÿó¿aclzYS]ÈÕÔµ°~áH‡Þö¾ØÁ5O L„‚}ëföl¾Òþ_à¬8K)~‹<è›9鬰jŽÄTV“ ëi“u†Èš<¢žíôx\4|‰_µXàöÏfTÛ²~õYÎØá¼c}6Q$ñh–k¢ïCö’¾y×i ò®Ø}v±H$ꨧ©ømsÞ±m„ÊÿÅÞÌïíµ~OE wm÷´¾K…Ûµ¥m«{ÎnËLÛ°:¢-p9I\¿ÛV¢ý9jƒæJ B•GbÈD«Ãž£:o!­òz$ è±ètajÄŸ7)‘ ã°wÁËÇ ³ŒzÿæXY³A×EV ª¬„RÙÃ…œ¿ þ È9(âÝú⚀¿·‘1—”á=ù¨K¿øö™«v4€‡´ú<ô›ã/'W·z«æ†ñM]3J9}t<–»èù±Ùw_‡×64ÃéÒ¢ŽpŸ1K#~´+¿ÿ:O­¶z±ÒèTúHLcB;MûüôˆiÊ‚!§vj`ËßÑÝ_:àât%M ô瑹ÃiµF¬ÖσwZ…é÷ÿõwÿögGa€Çï‡Ã¬vÛ{?~f—ÍT]¯+ôyýBæÏZj÷øõÔ_;Z8fªËüîiÅ™ê‘ñ¼rêLOy½*Ú¦q•ÏIŒÏúášRÁýM“qz2y+.pJ=]R—sÇJµƒv«\.÷‘˜«1e^“¶Ä„ê­•ÞWM½–ašËJ¬.ÂÄFÑh¼²q†|N''6H˜-ÎFÙ]ÿ½ sÁÓû&°5w—GP>žË èG=]¥8`BœÎúI&2ŒŠúæ¾H7ãnaô– +‹Í%Á̎Ђ–?tðÅœS‡ßiµØV,wY˼­òÊNª$óxxZ1œsT•z»½à;7–\®b8 i:f|„¯äËüv 72û=wì(,sx*Õµ.7ezé•wA|êµð‡!ކ«L…#„OpMW3p£_¯ú9uJy×™Ÿ¨ÚÁo¿ÿûáÜÈ¡"4*.¢À~êµnFJ—²¨Ð¡bœŒ×cWkl8:ê´V­Ó¥dŸÕ&j´j…Þ‹ n»ÙƒXƒžÖ¿fáÞ@G›YÚü+ŸŠt´U˪›œV†Ñ¢p‚'ö &O8yò$×)‘‚“ò枬%w)Ù•‹1f_9O ¦#v¬>¡."\X#Pîƒ7ýãÒŸ½Òø@Cæ}@Oý*ø d± ÐSã[J±+HOÍ|xKf5þ&[°ý|{f-[2b;põ>àO£rükòêœÞ:-N‡h·«*F£ÖüKLí@i£ÑÃåâÜgó.°¸=9 º´Ëd˜>Ùˆá wó!ŸV‚8ÂØébƒ¯åêYçX·¤ÖYĹû‡¦QÚ v6]á·ë¨þ~¥¹¸¥ƒz©¬¤jÆ*ܘ< k^ kvšƒè@nÍev‡Ã¤RˆÊ¢}&SYPer9(íà8Š‹œJTA,t¨‚•Aaγ$ÌÉß°,D‚Ÿ$$|Í!jª~âMÈå¼òá\Êq ‚Z©ìÔÇÓE¿~Øy~uùá«74,훳ÒõøÖôÞÙwüxîßøþ¬=ü§Öp8sO4ùöžÿtûUk·mØúÇš möÞ…³o~ø;Ýw‡@úÑð@àA%ú0ǃN½®XŠéââ@Û„Ã×V›@æ ˆé2ºì0­ZïÂ&ÖÐ.›hƒØæ°Í­×©©Ò6]XvV"·HîK Nž’YñÖ)Ô€º0¤Yœi@Àƒ„Ÿä¢P–„º¯¿Ñæ¾8¶ùòñÖº©Tg™i'Ñ Áºñåf¸M ·±¹Ruûø\ÿäŠØõKÜÚ·á½Úð۞ǽ«æŸ:xhöÃ/œ_3wºI¡ÿhul×⾓UÓüÛ–lzbE™ÿÜÆ˜¹%½Quð–uB×Ì'Ñ7ü›Y±nY9¸m{>Çïf¯Ò¨e# óXU*ýsÏËžw=4éiÖs¯¨RqÆ Œq¬hÖi¼¸šNØPRõ_ëZýVM”Ò¾{ÛáñqÑoƒŒÖƒÅà¢Ï WW©£] Ž6ÂÿPóðä-F-ÎN£î^ÑäÁO‰É^dÛimgYïa™õ›àÒšÆ%b‰’V.qSÈ}ÀdR#»èàÓju)ž–?‰¿Õ-á_In¾!Á^‘ËâúÌ…f‹ ÆŸ…ôcMÔþËXû5(–\N¬/?o¢>+Á9ÑU;œ-1ËA¼,ð èß~½vÁš¡=;j6T,¤fû‹†µ¶ñ{š·õßð“7|ðÝ•¿m9»æš½·ì¿Ýbh ¾§uñ™ŸfYْ̋þÉâr"ÉkaO’`7\¨lò÷‚¥[í¦Ý÷Šjµ‹5`/üa„è˜Æ÷Š.+›Öq‘~0Rí·«åk0rܹàI¸¼Ïš„ìe¹ÿ+Ûe›|é p±Ã ÜQ1Ï 8_[Jêq1\ªOž®é±ßeNWj¯ºïêáž·þýùÖ[~ŽW½›9_3?êÔ._ÙÜSëX¢ä[”™sVL­]6¶u÷¿o¼áã|€·¾ÇŽ/ôÖ5uýh¬jîæ·Þ¿‘8ß@> ü…ÚgÌh‹ÅBmk–n\9P]·:Uÿ !g endstream endobj 64 0 obj 8016 endobj 65 0 obj (Microsoft Word - CGNS_TestingSpecs.docx) endobj 66 0 obj (Mac OS X 10.10.5 Quartz PDFContext) endobj 67 0 obj (Word) endobj 68 0 obj (D:20160224165508Z00'00') endobj 69 0 obj () endobj 70 0 obj [ ] endobj 1 0 obj << /Title 65 0 R /Producer 66 0 R /Creator 67 0 R /CreationDate 68 0 R /ModDate 68 0 R /Keywords 69 0 R /AAPL:Keywords 70 0 R >> endobj xref 0 71 0000000000 65535 f 0000092399 00000 n 0000004838 00000 n 0000021590 00000 n 0000000022 00000 n 0000004818 00000 n 0000004942 00000 n 0000007849 00000 n 0000000000 00000 n 0000039491 00000 n 0000000000 00000 n 0000068634 00000 n 0000000000 00000 n 0000021730 00000 n 0000075405 00000 n 0000000000 00000 n 0000057040 00000 n 0000000000 00000 n 0000051155 00000 n 0000080487 00000 n 0000005113 00000 n 0000007828 00000 n 0000021334 00000 n 0000007885 00000 n 0000021312 00000 n 0000021441 00000 n 0000000000 00000 n 0000083080 00000 n 0000021680 00000 n 0000022890 00000 n 0000022145 00000 n 0000022870 00000 n 0000023128 00000 n 0000039469 00000 n 0000040206 00000 n 0000039737 00000 n 0000040186 00000 n 0000040441 00000 n 0000051133 00000 n 0000051719 00000 n 0000051353 00000 n 0000051699 00000 n 0000051965 00000 n 0000057019 00000 n 0000057841 00000 n 0000057324 00000 n 0000057821 00000 n 0000058081 00000 n 0000068612 00000 n 0000069126 00000 n 0000068797 00000 n 0000069106 00000 n 0000069361 00000 n 0000075384 00000 n 0000075578 00000 n 0000075838 00000 n 0000080466 00000 n 0000080661 00000 n 0000080908 00000 n 0000083059 00000 n 0000083814 00000 n 0000083344 00000 n 0000083794 00000 n 0000084056 00000 n 0000092163 00000 n 0000092184 00000 n 0000092242 00000 n 0000092295 00000 n 0000092318 00000 n 0000092360 00000 n 0000092379 00000 n trailer << /Size 71 /Root 28 0 R /Info 1 0 R /ID [ <400eea66c103acec83e6d159c3fb5c2c> <400eea66c103acec83e6d159c3fb5c2c> ] >> startxref 92543 %%EOF CGNS-4.5.0/release_docs/HISTORY.txt000066400000000000000000001777431474000356600166340ustar00rootroot00000000000000CGNS version 4.2.0 ================================= INTRODUCTION ------------ This document describes the difference between CGNS 4.1.2 and CGNS 4.2.0 and contains information on known problems in CGNS 4.2.0. Links to the CGNS current released source code can be found at: http://cgns.org/download.html User documentation for the current release can be found at: http://cgns.org/CGNS_docs_current/midlevel/index.html For more information, see the CGNS home page: http://cgns.org CONTENTS -------- - New Features - Support for new platforms and languages - Bug Fixes since CGNS 4.1.2 - Known Problems New Features ============ Configuration: ------------- * The default was changed from 32-bit to 64-bit building of CGNS, PR#216 * The minimum CMake version was changed to 3.8. Library: -------- * New C and Fortran APIs that allows for reading/writing datatypes that are different from cgsize_t: cg_section_general_write(_f) cg_section_initialize(_f) cg_parent_data_write(_f) cg_elements_general_write(_f) cg_poly_elements_general_write(_f) cg_elements_general_read(_f) cg_poly_elements_general_read(_f) cg_parent_elements_general_read(_f) cg_parent_elements_position_general_read(_f) CGNS-212 * Added a diskless option for creating a CGNS file in memory (i.e. uses HDF5 "core" file driver), and then to optionally persist the memory to disk. Enablable through cg_configure. CGNS-239 * Mapping of X4/X8 was lost when moving from ADF to HDF5. This fix reintroduces it as an experimental feature. It uses an H5T_COMPOUND and is compatible with the standard C99 complex type. Depending on the application, people can still store each part of a complex number in separate arrays by prefixing with Re or Im the name of the array, CGNS-202 Parallel Library: ----------------- * Tuned the parallel library algorithms to improve metadata type operations, PR#238,#236 Fortran Library: ---------------- * Add Fortran wrapper for cg_configure, CGNS-243 Tools: ------ * Experimental support for conversion of FamilySpecified BC for AFLR3 file format, PR#247 * Added check on node names according to SIDS (check that dot and slash are not at the start of the name, see:https://cgns.github.io/CGNS_docs_current/hdf5/general.html) and added warning if ZoneBC_t is missing while zone surfaces are present in a 3D mesh. Bug Fixes since CGNS 4.1.2 release ================================== Library: ------- * Fixed test_convert_elem failing with NAG 7.0 and gcc 10, CGNS-231 * Fixed cg_configure always reporting a false error when using adfh parameters, CGNS-241 * Made the parameter CG_MODE_CLOSED private since it only used internally, CGNS-240 * Fixed an issue with too many MPI communicators being created when many CGNS files are open, CGNS-109 * Fixed issue of cg_open failing after calling cgp_open, CGNS-141 * Fixed MPI_Recv in test_poly_unstructured, PR#224 * Fixed MPI_Allgather in test_poly_unstructured #223 * VS 2019 issues: Fixed shared library builds on windows, Rearranged header files, fixed #if/#ifdef bug, PR#208 * Misc. compiler issues and added check C99 Complex support at compile time to enable it, PR#202 * Fixed cgio_copy_node() failing with INVALID_DATA_TYPE error when HDF5 backend is employed, PR#198 Fortran: -------- * Fixed test cgread_f03 failing for arch ppc64el, CGNS-179 * Fixed "Fortran types mismatch between actual argument" errors with gfortran 10.x, CGNS-227 Configuration: ------------- * Fixed configure issues with tcl, tk, CGNS-147 * Fixed build failures with HDF 1.10.3, CGNS-143 * Removed zlib and szip header checks when linking directory is provided removed header checking for standard locations, CGNS-233 * Added warning about using gfortran 10.2 as a result of a compiler bug, CGNS-246 Tools: ------ * Fixed issue with cgnstools not being able to read hdf5 files, CGNS-203 * Fixed cgnscheck's strange warning about non-boundary elements, CGNS-234 * Added cgnscheck a warning for BC that should be of type FamilySpecified, PR#206 * Added .desktop startup files for GUI cgnstools, PR#200 * Allow relocation of cgnstools dir, PR#199 Known Problems ============== ************ FORTRAN ************ * A gfortran bug in version 10.2 broke Fortran mapping and caused cg_goto_f to segfault. All other versions of gfortran are suitable. (ref. CGNS-246, GNU BUG 100149) * A bug in gfortran (all versions) causes cg_configure_f to fail, GNU BUG 99982. Other Fortran compilers are fine. ************ FORTRAN END ******** ************ CGNSVIEW ************ * cgnsview for OSX is not viewing properly and cgnsview under Windows may fail to compile due to tcl/tk incompatibility. ************ CGNSVIEW END ******** * For other issues, see https://cgnsorg.atlassian.net Supported Platforms =================== The following platforms are supported and have been tested for this release. They are built with the configure process unless specified otherwise. Linux 3.10.0-1127.10.1.el7 gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39) #1 SMP ppc64 GNU/Linux g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39) (echidna) GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39) Linux 2.6.32-573.18.1.el6 IBM XL C/C++ V13.1 #1 SMP ppc64 GNU/Linux IBM XL Fortran V15.1 (ostrich) Linux 3.10.0-327.10.1.el7 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: (jelly/kituo/moohan) Version 4.8.5 20150623 (Red Hat 4.8.5-39) Versions 4.9.3, 5.3.0, 6.3.0, 7.2.0 8.3.0, 9.1.0, 10.1.0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.0.098 Build 20160721 MPICH 3.3 compiled with GCC 7.2.0 OpenMPI 4.0.0 compiled with GCC 7.2.0 NAG Fortran Compiler Release 7.0(Yurakuchho) Build 7011 SunOS 5.11 11.4.5.12.5.0 Sun C 5.15 SunOS_sparc 2017/05/30 32- and 64-bit Studio 12.6 Fortran 95 8.8 SunOS_sparc 2017/05/30 (hedgehog) Sun C++ 5.15 SunOS_sparc 2017/05/30 Windows 10 x64 Visual Studio 2015 w/ Intel Fortran 18 (cmake) Visual Studio 2017 w/ Intel Fortran 19 (cmake) Visual Studio 2019 w/ Intel Fortran 19 (cmake) Visual Studio 2019 w/ MSMPI 10.1 (cmake) macOS High Sierra 10.13.6 Apple LLVM version 10.0.0 (clang-1000.10.44.4) 64-bit gfortran GNU Fortran (GCC) 6.3.0 (bear) Intel icc/icpc/ifort version 19.0.4.233 20190416 macOS Mojave 10.14.6 Apple LLVM version 10.0.1 (clang-1001.0.46.4) 64-bit gfortran GNU Fortran (GCC) 6.3.0 (bobcat) Intel icc/icpc/ifort version 19.0.4.233 20190416 Tested Configuration Features Summary ===================================== In the table below y = tested n = not tested in this release x = not working in this release | Platform | C | C[1] | Fortran | Fortran [1]| |--------------------------------------|---|------|---------|------------| | SunOS 5.11 32-bit | y | n | y | n | | SunOS 5.11 64-bit | y | n | y | n | | Windows 10 | y | n | n | n | | Windows 10 x64 | y | n | n | n | | Windows 10 Cygwin | n | n | x | n | | Mac OS X El Capitan 10.11.6 64-bit | y | n | y | n | | Mac OS Sierra 10.12.6 64-bit | y | n | y | n | | Mac OS X High Sierra 10.13.6 64-bit | y | n | y | n | | Mac OS X Mojave 10.14.6 64-bit | y | n | y | n | | CentOS 7.2 Linux 3.10.0 x86_64 PGI | y | n | y | n | | CentOS 7.2 Linux 3.10.0 x86_64 GNU | y | y | y | y | | CentOS 7.2 Linux 3.10.0 x86_64 Intel | y | y | y | y | | Linux 2.6.32-573.18.1.el6.ppc64 | y | n | y | n | [1] Parallel CGNS version 4.1.2 (patch) ================================= INTRODUCTION ------------ This document describes the difference between CGNS 4.1.2 and CGNS 4.1.2, and contains information on known problems in CGNS 4.1.2. Links to the CGNS current released source code can be found at: http://cgns.org/download.html User documentation for the current release can be found at: http://cgns.org/CGNS_docs_current/midlevel/index.html For more information, see the CGNS home page: http://cgns.org CONTENTS -------- - New Features - Support for new platforms and languages - Bug Fixes since CGNS 4.1.1 - Known Problems New Features ============ Configuration: ------------- Library: -------- Parallel Library: ----------------- Fortran Library: ---------------- Tools: ------ Bug Fixes since CGNS 4.1.1 release ================================== Library: ------- * (CGNS-214) Fixed the Compatibility issue between v3.4.0 and v4.1.1 * (CGNS-219) Change a wrong check in cg_poly_element_read to load older CGNS file section with CGNS 4.x API Fortran: -------- Configuration: ------------- Tools: ------ Known Problems ============== ************ CGNSVIEW ************ * cgnsview for OSX is not viewing properly, and cgnsview under Windows * may fail to compile due to tcl/tk incompatibility. ********************************** * For other issues, See https://cgnsorg.atlassian.net CGNS version 4.1.1 (patch) ================================= INTRODUCTION ------------ This document describes the difference between CGNS 4.1.1 and CGNS 4.1.1, and contains information on known problems in CGNS 4.1.1. Links to the CGNS current released source code can be found at: http://cgns.org/download.html User documentation for the current release can be found at: http://cgns.org/CGNS_docs_current/midlevel/index.html For more information, see the CGNS home page: http://cgns.org CONTENTS -------- - New Features - Support for new platforms and languages - Bug Fixes since CGNS 4.1.0 - Known Problems New Features ============ Configuration: ------------- Library: -------- Parallel Library: ----------------- Fortran Library: ---------------- - Introduced Fortran wrappers for CPEX42 and CPEX43 Tools: ------ Bug Fixes since CGNS 4.1.0 release ================================== Library: ------- * Fixed the compilation of cgnstools, which still made use the Removed APIs in 4.1.0: cgio_read_all_data, cgio_read_data, cgio_read_block_data cgio_read_all_data_f, cgio_read_data_f, cgio_read_block_data_f * Updated CMake's detection of tcl/tk and opengl * Added CI testing cgnstools Fortran: -------- Configuration: ------------- Tools: ------ Known Problems ============== ************ CGNSVIEW ************ * cgnsview for OSX is not viewing properly, and cgnsview under Windows * may fail to compile due to tcl/tk incompatibility. ********************************** * For other issues, See https://cgnsorg.atlassian.net CGNS version 4.1.0 ================================= INTRODUCTION ------------ This document describes the difference between CGNS 4.0.0 and CGNS 4.1.0, and contains information on known problems in CGNS 4.1.0. Links to the CGNS current released source code can be found at: http://cgns.org/download.html User documentation for the current release can be found at: http://cgns.org/CGNS_docs_current/midlevel/index.html For more information, see the CGNS home page: http://cgns.org CONTENTS -------- - New Features - Support for new platforms and languages - Bug Fixes since CGNS 4.0.0 - Known Problems New Features ============ Configuration: ------------- Library: -------- - Implemented CPEX42 (Storing bounding box of a grid, CGNS-149) - Implemented CPEX43 (Family hierarchy as a tree, CGNS-180) - Switch to using HDF5 Compact storage for smaller datasets Added HDF5 compact storage to CGNS to improve parallel IO performance. The default storage is compact storage unless the dataset does not meet the < 64KiB limit. Also, if the dataset can have partial IO, then it is contiguous storage. Also, removed 'tab' spacing. All changes should be transparent to the application code. (CGNS-160, PR-130) Parallel Library: ----------------- Fortran Library: ---------------- - Introduced Fortran wrappers for CPEX42 and CPEX43 Tools: ------ Bug Fixes since CGNS 4.0.0 release ================================== Library: ------- ****************** REMOVED APIS ************************** Removed the APIs: cgio_read_all_data, cgio_read_data, cgio_read_block_data cgio_read_all_data_f, cgio_read_data_f, cgio_read_block_data_f These APIs should be used instead: cgio_read_all_data_type, cgio_read_data_type, cgio_read_block_data_type cgio_read_all_data_type_f, cgio_read_data_type_f, cgio_read_block_data_type_f (CGNS-192) ****************** REMOVED APIS ************************** * Fixed tests for scoped enum use. (PR-123) * Unified similar defines. (PR-124) * Fixed bad assert. (PR-125) * Corrected print format. (CGNS-152, PR-126) * (CGNS-158, PR #128) Fixed heap buffer overflow in cgi_read_ptset In cgi_read_ptset there is made a difference between point set of list and range type. The 'CellListDonor' type was missing in the list of list types and this led to a heap buffer overflow. Added 'CellListDonor' type to list of list types. * (CGNS-159, PR #127) Fixed global-buffer-overflow in ADFI_string_2_C_string. Added a search loop for an early NULL termination of the string passed to ADFI_string_2_C_string in order to prevent global-buffer-overflow when string literals are given as a parameter. * Fixed return stat after calling MPI_Finalize and switched to using a MPI_AllReduce to get the same exit code on all the processes. * Fixed typo, zc should be z3 * Fixed Problems linking Fortran code with 3.3.1 shared library (w/ CMake) (CGNS-118, PR-131) * Do not read elements when computing partial data size. (PR-137) * Disabled the use of H5Pset_file_space_strategy as it is not compatible with HDF5 v1.8 (CGNS-166) * Use correct MPI communicator (PR-140) The `MPI_Allreduce` call in `cgp_parent_data_write()` is using `MPI_COMM_WORLD`, but would be more correct to use the communicator stored in `cgp_mpi_comm` which is set by the client. If the client is not using `MPI_COMM_WORLD` and calls this function, it will hang since not all ranks will be participating in the call. Expanded open-close test to include mixed serial and parallel open and close * Fixed incorrect variable type (PR-143) Minor fix; only applicable if more than 2.1 billion intervals in a range, but does eliminate a compiler warning -- `npt` should be `cgsize_t` * Fixed compiler warnings about the possible loss of data (PR-144) A few variables defined as `int` should be `ssize_t` to avoid potential loss of data on large models. * Corrupted memory when reading int32 connectivity into an int64 dataspace, (CGNS-157) Fixed by changing the cgio_read* calls internal to the MLL to use the cgio_read*_type APIs instead. Created a new cgio_read_block_data_type API with an added data type parameter. * Removed non-standard unlink call * Make static mpi-related variables consistent (PR-139) Currently, it is possible for the `pcg_mpi_comm` to be inconsistent with `pcg_mpi_comm_rank` and `pcg_mpi_comm_size`. The latter two values are set during a call to `cgp_open,` and the first is set during a call to `cgp_mpi_comm.` If the user is using both parallel and serial file access during the same run, they may call `cgp_mpi_comm` multiple times, and the values of `pcg_mpi_comm_rank` and `pcg_mpi_comm_size` will only be consistent with the communicator in `pcg_mpi_comm` if the user calls `cgp_open.` With this fix, all three values (and the `ParallelMPICommunicator`) will always be consistent. Also, if the user does not call `cgp_mpi_comm()` before calling `cgp_open(),` this will be detected, and everything will be consistent. Initialize communicator to MPI_COMM_NULL * miscellaneous code quality improvements and warning fixes. Fortran: -------- * Added missing BUILD_PARALLEL_F. (ref. PR-124) * Fixed cgiof_f03.F90 test passing literal character instead of NULL character in CGIO_CREATE_LINK_F Configuration: ------------- * Fixed HDF5 CMake feature detection for parallel Collective_metadata and H5Pset_file_space_strategy. (PR-138) * Fixed HDF5 feature detection (PR-138) Tools: ------ * Fix cgnstools install (PR-129) Known Problems ============== * See https://cgnsorg.atlassian.net Supported Platforms =================== The following platforms are supported and have been tested for this release. They are built with the configure process unless specified otherwise. Linux 2.6.32-696.16.1.el6.ppc64 gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18) #1 SMP ppc64 GNU/Linux g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18) (ostrich) GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18) IBM XL C/C++ V13.1 IBM XL Fortran V15.1 Linux 3.10.0-327.10.1.el7 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: (kituo/moohan) Version 4.8.5 20150623 (Red Hat 4.8.5-4) Version 4.9.3, 5.2.0, 7.1.0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.0.098 Build 20160721 MPICH 3.1.4 Linux-3.10.0- spectrum-mpi/rolling-release with cmake>3.10 and 862.14.4.1chaos.ch6.ppc64le clang/3.9,8.0 #1 SMP ppc64le GNU/Linux gcc/7.3 (ray) xl/2016,2019 Linux 3.10.0- openmpi/3.1,4.0 with cmake>3.10 and 957.12.2.1chaos.ch6.x86_64 clang 5.0 #1 SMP x86_64 GNU/Linux gcc/7.3,8.2 (serrano) intel/17.0,18.0/19.0 Linux 3.10.0- openmpi/3.1/4.0 with cmake>3.10 and 1062.1.1.1chaos.ch6.x86_64 clang/3.9,5.0,8.0 #1 SMP x86_64 GNU/Linux gcc/7.3,8.1,8.2 (chama,quartz) intel/16.0,18.0,19.0 Linux 4.4.180-94.100-default cray-mpich/7.7.6 with PrgEnv-*/6.0.5, cmake>3.10 and #1 SMP x86_64 GNU/Linux gcc/7.2.0,8.2.0 (mutrino) intel/17.0,18.0 Linux 4.14.0- spectrum-mpi/rolling-release with cmake>3.10 and 49.18.1.bl6.ppc64le clang/6.0,8.0 #1 SMP ppc64le GNU/Linux gcc/7.3 (lassen) xl/2019 SunOS 5.11 32- and 64-bit Sun C 5.12 SunOS_sparc (emu) Sun Fortran 95 8.6 SunOS_sparc Sun C++ 5.12 SunOS_sparc Windows 10 x64 Visual Studio 2015 w/ Intel Fortran 18 (cmake) Visual Studio 2017 w/ Intel Fortran 19 (cmake) Visual Studio 2019 w/ Intel Fortran 19 (cmake) macOS 10.13.6 High Sierra Apple LLVM version 10.0.0 (clang/clang++-1000.10.44.4) 64-bit gfortran GNU Fortran (GCC) 6.3.0 (bear) Intel icc/icpc/ifort version 19.0.4 macOS 10.14.6 Mohave Apple LLVM version 10.0.1 (clang/clang++-1001.0.46.4) 64-bit gfortran GNU Fortran (GCC) 6.3.0 (bobcat) Intel icc/icpc/ifort version 19.0.4 Tested Configuration Features Summary ===================================== In the table below y = tested n = not tested in this release x = not working in this release | Platform | C | C[1] | Fortran | Fortran [1]| |--------------------------------------|---|------|---------|------------| | SunOS 5.11 32-bit | y | n | y | n | | SunOS 5.11 64-bit | y | n | y | n | | Windows 10 | y | n | n | n | | Windows 10 x64 | y | n | n | n | | Windows 10 Cygwin | n | n | x | n | | Mac OS X 10.13.6 64-bit | y | n | y | n | | Mac OS X 10.14.6 64-bit | y | n | y | n | | CentOS 6.7 Linux 2.6.32 x86_64 GNU | y | y | y | y | | CentOS 6.7 Linux 2.6.32 x86_64 Intel | y | y | y | y | | CentOS 6.7 Linux 2.6.32 x86_64 PGI | y | n | y | n | | CentOS 7.2 Linux 3.10.0 x86_64 GNU | y | y | y | y | | CentOS 7.2 Linux 3.10.0 x86_64 Intel | y | y | y | y | | Linux 2.6.32-431.11.2.el6.ppc64 | y | n | y | n | [1] Parallel # CGNS version 4.0.0 This document describes the difference between CGNS 3.x and CGNS 4.0.0, and contains information on known problems in CGNS 4.0.0. Links to the CGNS 4.0.0 source code can be found at: http://cgns.org/download.html User documentation for the current release can be found at: http://cgns.org/CGNS_docs_current/midlevel/index.html For more information, see the CGNS home page: http://cgns.org # CONTENTS New Features Bug Fixes since CGNS 3.x Known Problems Supported platforms # New Features ## Configuration: None ## Library: Implemented CPEX 41 NGON modification proposal (CGNS-121) v4.0.0 resolves the issue with CPEX 41 in cgnslib 3.4.0 concerning forward compatibility (ref. 1-28-2020 CGNS Steering Committee Minutes). Note: v3.4.1 removed CPEX 41 to maintain compatibility in the 3.x releases, and 4.0.0 added back CPEX 41. ## Parallel Library: None ## Fortran Library: None ## Tools: None # Bug Fixes since CGNS 3.x Release # Configuration: None # Library: ## ISSUE [1] None # Fortran: None # Tools: None ## Known Problems When building with PGI and gcc compilers it might be necessary to set the environment variables: FLIBS="-Wl,--no-as-needed -ldl" LIBS="-Wl,--no-as-needed -ldl" Misc. issues can be found at: https://cgnsorg.atlassian.net Supported Platforms ====================== The following platforms are supported and have been tested for this release. They are built with the configure process unless specified otherwise. Linux 2.6.32-573.22.1.el6 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: Version 4.4.7 20120313 Versions 4.9.3, 5.2.0, 6.2.0 PGI C, Fortran, C++ for 64-bit target on x86-64; Version 16.10-0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.0.098 Build 20160721 MPICH 3.1.4 compiled with GCC 4.9.3 OpenMPI 2.0.1 compiled with GCC 4.9.3 Linux 2.6.32-573.18.1.el6 gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) #1 SMP ppc64 GNU/Linux g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) IBM XL C/C++ V13.1 IBM XL Fortran V15.1 Linux 3.10.0-327.10.1.el7 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: Version 4.8.5 20150623 (Red Hat 4.8.5-4) Versions 4.9.3, 5.3.0, 6.2.0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.4.196 Build 20170411 MPICH 3.1.4 compiled with GCC 4.9.3 SunOS 5.11 32- and 64-bit Sun C 5.12 SunOS_sparc Sun Fortran 95 8.6 SunOS_sparc Sun C++ 5.12 SunOS_sparc Windows 10 x64 Visual Studio 2015 w/ Intel Fortran 16 (cmake) Mac OS X Mt. Lion 10.8.5 Apple LLVM version 5.1 (clang-503.0.40) 64-bit gfortran GNU Fortran (GCC) 4.8.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X Mavericks 10.9.5 Apple LLVM version 6.0 (clang-600.0.57) 64-bit gfortran GNU Fortran (GCC) 4.9.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X Yosemite 10.10.5 Apple LLVM version 6.1 (clang-602.0.53) 64-bit gfortran GNU Fortran (GCC) 4.9.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X El Capitan 10.11.4 Apple LLVM version 7.3.0 (clang-703.0.29) 64-bit gfortran GNU Fortran (GCC) 5.2.0 Intel icc/icpc/ifort version 16.0.2 Tested Configuration Features Summary ===================================== In the table below y = tested n = not tested in this release x = not working in this release dna = does not apply Platform | C | Fortran | Fortran | parallel | | parallel -------------------------------------|-----------|---------|---------- SunOS 5.11 32-bit | n | y | n SunOS 5.11 64-bit | n | y | n Windows 10 | n | n | n Windows 10 x64 | n | n | n Mac OS X Yosemeti 10.10.5 64-bit | n | y | n Mac OS X El Capitan 10.11.6 64-bit | n | y | n MacOS High Sierra 10.13.6 64-bit | n | y | n CentOS 7.1 Linux 3.10.0 x86_64 PGI | n | y | n CentOS 7.1 Linux 3.10.0 x86_64 GNU | y | y | y CentOS 7.1 Linux 3.10.0 x86_64 Intel | n | y | n CentOS 8.1 Linux 4.18.0 x86_64 PGI | n | n | n CentOS 8.1 Linux 4.18.0 x86_64 GNU | n | n | n CentOS 8.1 Linux 4.18.0 x86_64 Intel | n | n | n Linux 2.6.32-431.11.2.el6.ppc64 | n | y | n # CGNS version 3.4.1 This document describes the difference between CGNS 3.4.0 and CGNS 3.4.1 (patch), and contains information on known problems in CGNS 3.4.1 (patch). Links to the CGNS 3.4.1 (patch) source code can be found at: http://cgns.org/download.html User documentation for the current release can be found at: http://cgns.org/CGNS_docs_current/midlevel/index.html For more information, see the CGNS home page: http://cgns.org # CONTENTS New Features Bug Fixes since CGNS 3.4.0 Known Problems Supported platforms # New Features ## Configuration: None ## Library: None ## Parallel Library: None ## Fortran Library: None ## Tools: None # Bug Fixes since CGNS 3.4.0 Release # Configuration: None # Library: ## ISSUE [1] In the cgnslib code, forward compatibility is always ensured by cg_open function, which prevents major version incompatibilities and returns gracefully. This well-designed code provision does not hold for cgnslib v3.4.0, which has the same major version number, but significantly different NGON data structures. Thus, the library cannot protect the API users anymore, and unexpected software behaviors might occur. So, if one upgrades to the new cgnslib 3.4.0, they will create CGNS files that will crash when read by other parties who are still using the previous v3.x libraries. This will lead to problems in the community whose aim is to maintain a general, portable and extensible standard that makes it easier to share files between sites and collaborators. ### RESOLUTION Patch 3.4.0 by removing CPEX 41 NGON modification. Reintroduce CPEX 41 in the 4.0.0 release. ### ACTION Removed CPEX 41 NGON modification proposal (CGNS-121); these commits were removed: * Revert "support new ngon layout" This reverts commit 83fc242833d66dd6bb3b6b0f03dc5d71ae59c162. * Revert "fix uninitialized memory for offset." This reverts commit 3fdc9d89ac1b452fc95abd6849f1b07535b500ba. * Revert "fix cgnscheck due to new memory layout with ngon_n and nface_n" This reverts commit 2c09bad0efc4b0042d1b69c3c59309a6f2ea74b9. [1] 1-28-2020 CGNS Steering Committee Minutes # Fortran: None # Tools: None ## Known Problems When building with PGI and gcc compilers it might be necessary to set the environment variables: FLIBS="-Wl,--no-as-needed -ldl" LIBS="-Wl,--no-as-needed -ldl" Misc. issues can be found at: https://cgnsorg.atlassian.net Supported Platforms ====================== The following platforms are supported and have been tested for this release. They are built with the configure process unless specified otherwise. Linux 2.6.32-573.22.1.el6 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: Version 4.4.7 20120313 Versions 4.9.3, 5.2.0, 6.2.0 PGI C, Fortran, C++ for 64-bit target on x86-64; Version 16.10-0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.0.098 Build 20160721 MPICH 3.1.4 compiled with GCC 4.9.3 OpenMPI 2.0.1 compiled with GCC 4.9.3 Linux 2.6.32-573.18.1.el6 gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) #1 SMP ppc64 GNU/Linux g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) IBM XL C/C++ V13.1 IBM XL Fortran V15.1 Linux 3.10.0-327.10.1.el7 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: Version 4.8.5 20150623 (Red Hat 4.8.5-4) Versions 4.9.3, 5.3.0, 6.2.0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.4.196 Build 20170411 MPICH 3.1.4 compiled with GCC 4.9.3 SunOS 5.11 32- and 64-bit Sun C 5.12 SunOS_sparc Sun Fortran 95 8.6 SunOS_sparc Sun C++ 5.12 SunOS_sparc Windows 10 x64 Visual Studio 2015 w/ Intel Fortran 16 (cmake) Mac OS X Mt. Lion 10.8.5 Apple LLVM version 5.1 (clang-503.0.40) 64-bit gfortran GNU Fortran (GCC) 4.8.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X Mavericks 10.9.5 Apple LLVM version 6.0 (clang-600.0.57) 64-bit gfortran GNU Fortran (GCC) 4.9.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X Yosemite 10.10.5 Apple LLVM version 6.1 (clang-602.0.53) 64-bit gfortran GNU Fortran (GCC) 4.9.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X El Capitan 10.11.4 Apple LLVM version 7.3.0 (clang-703.0.29) 64-bit gfortran GNU Fortran (GCC) 5.2.0 Intel icc/icpc/ifort version 16.0.2 Tested Configuration Features Summary ===================================== In the table below y = tested n = not tested in this release x = not working in this release dna = does not apply Platform | C | Fortran | Fortran | parallel | | parallel -------------------------------------|-----------|---------|---------- SunOS 5.11 32-bit | n | y | n SunOS 5.11 64-bit | n | y | n Windows 7 | n | n | n Windows 7 x64 | n | n | n Windows 7 Cygwin | n | n | n Windows 8.1 | n | n | n Windows 8.1 x64 | n | n | n Windows 10 | n | n | n Windows 10 x64 | n | n | n Mac OS X Yosemeti 10.10.5 64-bit | n | y | n Mac OS X El Capitan 10.11.6 64-bit | n | y | n MacOS High Sierra 10.13.6 64-bit | n | y | n AIX 6.1 32- and 64-bit | n | y | n CentOS 7.1 Linux 3.10.0 x86_64 PGI | n | y | n CentOS 7.1 Linux 3.10.0 x86_64 GNU | y | y | y CentOS 7.1 Linux 3.10.0 x86_64 Intel | n | y | n Linux 2.6.32-431.11.2.el6.ppc64 | n | y | n # CGNS version 3.4.0 This document describes the difference between CGNS 3.3.1 and CGNS 3.4.0, and contains information on known problems in CGNS 3.4.0. Links to the CGNS 3.4.0 source code can be found at: http://cgns.org/download.html User documentation for the current release can be found at: http://cgns.org/CGNS_docs_current/midlevel/index.html For more information, see the CGNS home page: http://cgns.org # CONTENTS New Features Bug Fixes since CGNS 3.3.1 Known Problems Supported platforms # New Features ## Configuration: Enforce the HDF5 version >= 1.8 is used in building HDF5. (CGNS-150). Autotools: CGNS will find and link the compression libraries, szip and zlib, required by HDF5. This occurs automatically if neither --with-zlib or --with-szip are not specified (CGNS-156). ## Library: Changed default CGNS to 1.8 HDF5 file format. -- only for HDF5 versions > 1.10.2. CPEX 40 Rind Plane Indexing (CGNS-87) CPEX 41 NGON modification proposal (CGNS-121) ## Parallel Library: None ## Fortran Library: Added support for NAG Fortran compilers (CGNS-107) ## Tools: None # Bug Fixes since CGNS 3.3.1 Release # Configuration: * Order include directives to get correct includes, cmake (PR 109) * make clean does not remove executables in Test_UserGuideCode (CGNS-99) * Windows builds: CGNS_ENABLE_LFS is ignored (CGNS-117) * Sun's make implementation fails to compile fortran (CGNS-28) * Some systems need to explicitly link to libdl (CGNS-128) * CGNS fails in fortran test with PGI 17 compiler (CGNS-127) * CGNS fails to find the lib64 HDF5 library (CGNS-123) * CGNS fails to compile on Windows with Fortran enabled (CGNS-148) * Can't compile using MSVC & IVF on windows (MSVS 14) (CGNS-146) * Fix szip linking (PR 97) * RPATH handling for MacOSX (Darwin) (PR 88) * fix tests failing when compiled for 64bit (PR 85) * remove variable length array to be able to build pcgnslib.c with VC (CGNS-147) * Build parallel CGNS on Windows (PR 69) * Cmake fixups (PR 58) * If check needs to link, then need library path (PR 52) * Specify STATIC when adding cgns_static lib (PR 46) * _stat32i64 is msvc-specific (PR 45) # Library: * Eliminate potential integer overflow / undefined behavior (PR 106) * Partial write of unstructured MIXED element sets fails with CGNS > 3.3.1 (CGNS-151) * If processor has no data, set end = start = 0 (CGNS-133) * Large files fail on 64-bit windows (CGNS-83) * mesh_dim may be exceed the limit of 32-bit integer (CGNS-131) * RUNPARALLEL is defined but never used. (CGNS-96) * typo in cgnscheck print_units cg_TemperatureUnitsName index (CGNS-126) * cgp_mpi_comm return value unclear (CGNS-111) * Changed ADFH_Read_Data and ADFH_Write_Data to honor the cgp_pio_mode (PR 98) * Support for std C on linux (PR 96) * Null check fix (PR 94) * Eliminate dead / unreachable code (PR 93) * Fix parallel write (PR 86) * Add missing argument to cgi_error call (PR 84) * Fix BC type string constant FamilySpecified_s (PR 83) * Remove double condition test (PR 82) * remove some gcc warnings (PR 78) * remove variable length array to be able to build pcgnslib.c with VC (PR 76) * Fix bad if test (PR 70) * Eliminate memory leaks in cgi_read_ziter (PR 68) * Improve error messages, fix error check (fixed) (PR 66) * Drop obsolete matherr hack (PR 55) # Fortran: * Add missing dll export symbols from Fortran module. (PR 59) # Tools: * Update cgnsutil.c (PR 89) * patch cgnscheck (PR 72) * Fix cgnsview linking to HDF5 libs. (PR 56) ## Known Problems When building with PGI and gcc compilers it might be necessary to set the environment variables: FLIBS="-Wl,--no-as-needed -ldl" LIBS="-Wl,--no-as-needed -ldl" Misc. issues can be found at: https://cgnsorg.atlassian.net Supported Platforms ====================== The following platforms are supported and have been tested for this release. They are built with the configure process unless specified otherwise. Linux 2.6.32-573.22.1.el6 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: Version 4.4.7 20120313 Versions 4.9.3, 5.2.0, 6.2.0 PGI C, Fortran, C++ for 64-bit target on x86-64; Version 16.10-0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.0.098 Build 20160721 MPICH 3.1.4 compiled with GCC 4.9.3 OpenMPI 2.0.1 compiled with GCC 4.9.3 Linux 2.6.32-573.18.1.el6 gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) #1 SMP ppc64 GNU/Linux g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) IBM XL C/C++ V13.1 IBM XL Fortran V15.1 Linux 3.10.0-327.10.1.el7 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: Version 4.8.5 20150623 (Red Hat 4.8.5-4) Versions 4.9.3, 5.3.0, 6.2.0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.4.196 Build 20170411 MPICH 3.1.4 compiled with GCC 4.9.3 SunOS 5.11 32- and 64-bit Sun C 5.12 SunOS_sparc Sun Fortran 95 8.6 SunOS_sparc Sun C++ 5.12 SunOS_sparc Windows 10 x64 Visual Studio 2015 w/ Intel Fortran 16 (cmake) Mac OS X Mt. Lion 10.8.5 Apple LLVM version 5.1 (clang-503.0.40) 64-bit gfortran GNU Fortran (GCC) 4.8.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X Mavericks 10.9.5 Apple LLVM version 6.0 (clang-600.0.57) 64-bit gfortran GNU Fortran (GCC) 4.9.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X Yosemite 10.10.5 Apple LLVM version 6.1 (clang-602.0.53) 64-bit gfortran GNU Fortran (GCC) 4.9.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X El Capitan 10.11.4 Apple LLVM version 7.3.0 (clang-703.0.29) 64-bit gfortran GNU Fortran (GCC) 5.2.0 Intel icc/icpc/ifort version 16.0.2 Tested Configuration Features Summary ===================================== In the table below y = tested n = not tested in this release x = not working in this release dna = does not apply Platform | C | Fortran | Fortran | parallel | | parallel -------------------------------------|-----------|---------|---------- SunOS 5.11 32-bit | n | y | n SunOS 5.11 64-bit | n | y | n Windows 7 | n | n | n Windows 7 x64 | n | n | n Windows 7 Cygwin | n | n | n Windows 8.1 | n | n | n Windows 8.1 x64 | n | n | n Windows 10 | n | n | n Windows 10 x64 | n | n | n Mac OS X Yosemeti 10.10.5 64-bit | n | y | n Mac OS X El Capitan 10.11.6 64-bit | n | y | n MacOS High Sierra 10.13.6 64-bit | n | y | n AIX 6.1 32- and 64-bit | n | y | n CentOS 7.1 Linux 3.10.0 x86_64 PGI | n | y | n CentOS 7.1 Linux 3.10.0 x86_64 GNU | y | y | y CentOS 7.1 Linux 3.10.0 x86_64 Intel | n | y | n Linux 2.6.32-431.11.2.el6.ppc64 | n | y | n CGNS 3.3.1 ============ INTRODUCTION =============== This document describes the difference between CGNS 3.3.0 and CGNS 3.3.1, and contains information on known problems in CGNS 3.3.1. Links to the CGNS 3.3.1 source code can be found at: http://cgns.org/download.html User documentation for the current release can be found at: http://cgns.org/CGNS_docs_current/midlevel/index.html For more information, see the CGNS home page: http://cgns.org CONTENTS ============ - New Features - Support for new platforms and languages - Bug Fixes since CGNS 3.3.0 - Known Problems New Features ============== Configuration: ------------------ * Windows Parallel CGNS with Fortran enabled, PR-40. Library: ------------ - None Parallel Library: --------------------- - None Fortran Library: -------------------- - None Tools: ---------- - None Bug Fixes since CGNS 3.3.0 Release ================================== Configuration: ------------------ * Implement FortranCInterface_HEADER in cmake, CGNS-78. * Cmake target link libraries need to be set on systems other than just WIN32 and CYGWIN, CGNS-64. * Support Mac's dylib shared library suffix with CMake, CGNS-61. * CMake needs to be updated to handle new fortran features, CGNS-10. * Add missing dependency in cgns_to_plot3d (cmake build), CGNS-16. * Add missing include path, fix hdf5, PR 18. Library: ------------ * Hang in parallel read/write, CGNS-105. * Header files contain functions not existing in code, CGNS-115. * Fixes for CGNS-83: Large files fail on 64-bit windows. * Remove incorrect semicolon, PR-13. * Add missing close paren, PR-15. * Fix incorrect structured field array access -- cut paste error, PR-17. * Fix a few missing CGNS_ENUMV uses, PR-20. * Fix to avoid hang due to collective requirement, PR-21. * Freeing incorrect pointer, PR-23 * Initialize err, add missing return, PR-25. * Handle case where wbuf or rbuf is NULL, PR-26. * Tests can run with ENUM_SCOPING enabled, PR-34. * Implementation and test for cgp_parent_data_write, PR-36. * Add cmake support for memory debugging; fix memory debug routines, PR-39. Fortran: ------------ * Missing C binding for cg_conversion_write_f Tools: ---------- * cgnsconvert fails to process a file written by the parallel CGNS library, CGNS-77. Known Problems ================ * When building with PGI and gcc compilers it might be necassary to set the environment variables: FLIBS="-Wl,--no-as-needed -ldl" LIBS="-Wl,--no-as-needed -ldl" Supported Platforms ====================== The following platforms are supported and have been tested for this release. They are built with the configure process unless specified otherwise. Linux 2.6.32-573.22.1.el6 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: Version 4.4.7 20120313 Versions 4.9.3, 5.2.0, 6.2.0 PGI C, Fortran, C++ for 64-bit target on x86-64; Version 16.10-0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.0.098 Build 20160721 MPICH 3.1.4 compiled with GCC 4.9.3 OpenMPI 2.0.1 compiled with GCC 4.9.3 Linux 2.6.32-573.18.1.el6 gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) #1 SMP ppc64 GNU/Linux g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) IBM XL C/C++ V13.1 IBM XL Fortran V15.1 Linux 3.10.0-327.10.1.el7 GNU C (gcc), Fortran (gfortran), C++ (g++) #1 SMP x86_64 GNU/Linux compilers: Version 4.8.5 20150623 (Red Hat 4.8.5-4) Versions 4.9.3, 5.3.0, 6.2.0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 17.0.4.196 Build 20170411 MPICH 3.1.4 compiled with GCC 4.9.3 SunOS 5.11 32- and 64-bit Sun C 5.12 SunOS_sparc Sun Fortran 95 8.6 SunOS_sparc Sun C++ 5.12 SunOS_sparc Windows 10 x64 Visual Studio 2015 w/ Intel Fortran 16 (cmake) Mac OS X Mt. Lion 10.8.5 Apple LLVM version 5.1 (clang-503.0.40) 64-bit gfortran GNU Fortran (GCC) 4.8.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X Mavericks 10.9.5 Apple LLVM version 6.0 (clang-600.0.57) 64-bit gfortran GNU Fortran (GCC) 4.9.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X Yosemite 10.10.5 Apple LLVM version 6.1 (clang-602.0.53) 64-bit gfortran GNU Fortran (GCC) 4.9.2 Intel icc/icpc/ifort version 15.0.3 Mac OS X El Capitan 10.11.4 Apple LLVM version 7.3.0 (clang-703.0.29) 64-bit gfortran GNU Fortran (GCC) 5.2.0 Intel icc/icpc/ifort version 16.0.2 Tested Configuration Features Summary ===================================== In the table below y = tested n = not tested in this release x = not working in this release dna = does not apply Platform | C | F90/ | F90 | parallel | F2003 | parallel -------------------------------------|-----------|-------|---------- SunOS 5.11 32-bit | n | y/y n SunOS 5.11 64-bit | n | y/y | n Windows 7 | n | n/n | n Windows 7 x64 | n | n/n | n Windows 7 Cygwin | n | n/n | n Windows 8.1 | n | n/n | n Windows 8.1 x64 | n | n/n | n Windows 10 | n | n/n | n Windows 10 x64 | n | n/n | n Mac OS X Mountain Lion 10.8.5 64-bit | n | y/y | n Mac OS X Mavericks 10.9.5 64-bit | n | y/y | n Mac OS X Yosemeti 10.10.5 64-bit | n | y/y | n AIX 6.1 32- and 64-bit | n | y/n | n CentOS 6.7 Linux 2.6.32 x86_64 GNU | y | y/y | y CentOS 6.7 Linux 2.6.32 x86_64 Intel | n | y/y | n CentOS 6.7 Linux 2.6.32 x86_64 PGI | n | y/y | n CentOS 7.1 Linux 3.10.0 x86_64 GNU | y | y/y | y CentOS 7.1 Linux 3.10.0 x86_64 Intel | n | y/y | n Linux 2.6.32-431.11.2.el6.ppc64 | n | y/n | n CGNS 3.3.0 ============ INTRODUCTION =============== This document describes the difference between CGNS 3.2.1 and CGNS 3.3.0, and contains information on known problems in CGNS 3.3.0. Links to the CGNS 3.3.0 source code can be found at: http://cgns.org/download.html User documentation for the current release can be found at: http://cgns.org/CGNS_docs_current/midlevel/index.html For more information, see the CGNS home page: http://cgns.org CONTENTS ============ - New Features - Support for new platforms and languages - Bug Fixes since CGNS 3.2.1 - Known Problems New Features ============== Configuration: ------------------ * Example build scripts for supercomputer systems can be found in src/SampleScripts of the CGNS source code. They include scripts for building zlib, hdf5 (assuming the user does not already have them installed system wide) and a script for building CGNS. All the scripts use autotools; cmake remains untested. * The Fortran compiler environment variable can now be set with "FC", this is the preferred method. * The Fortran compiler flags can now be set with "FCFLAGS", this is the preferred method. If both FFLAGS (which predates FCFLAGS) and FCFLAGS are set then FCFLAGS is ignored. (CGNS-23) Library: ------------ * Replaced the hid_t to double (and vice-versa) utilities to_HDF_ID and to_ADF_ID from a type cast to a function which uses memcpy for the conversion. This is needed for the upcoming release of HDF5 1.10 where hid_t was changed from a 32 bit integer to a 64 bit integer. Should be transparent to user. * Implemented CPEX0039 : To enable with CGNS_ENABLE_BASE_SCOPE * Implemented CPEX0038 : Quadratic Elements for High Order Parallel Library: --------------------- * The default parallel input/output mode was changed from CGP_INDEPENDENT to CGP_COLLECTIVE. * A new function was added for passing MPI info to the CGNS library: cgp_mpi_info (cgp_mpi_info_f) * A new parallel example benchmark program, benchmark_hdf5.c, was added to directory ptests. * The cgp_*_read/write_dataset APIs now excepts non-allocated arrays, or NULL, as valid parameters for the datasets. Additionally, the dimensional arrays, rmin and rmax, can also be NULL. If the data array is NULL and the dimensional arrays are not NULL, then the validity of the dimensional arrays, rmin and rmax, is not checked. For collective parallel IO, this is used as a mechanism to indicated that processes with NULL API parameters will not write any data to the file. * cgp_queue_set and cgp_queue_flush were depreciated in this release. Fortran Library: -------------------- * SUPPORT WAS DROPPED FOR NON-FORTRAN 2003 COMPLIANT COMPILERS. * Configure was changed to check if the Fortran compiler is Fortran 2003 compliant. * The predefined CGNS constant parameters data types were changed from INTEGER to ENUM, BIND(C) for better C interoperability. The users should use the predefined constants whenever possible and not the numerical value represented by the constants. A variable expecting an enum value returned from a Fortran API should be declared, INTEGER(cgenum_t). * INCLUDE "cgslib_h" was changed in favor of using a module, USE CGNS. - This allows defining a KIND type for integers instead of the current way of using the preprocessor dependent cgsize_t. * The user should be sure to declare the arguments declared int in the C APIs as INTEGER in Fortran. The ONLY Fortran arguments declared as type cgsize_t should be the arguments which are also declared cgsize_t in the C APIs. This is very important when building with option --enable-64bit. The test programs were updated in order to conform to this convention. * Assuming the rules in step [enu:int64] were followed, users should not need to use parameter CG_BUILD_64BIT since Fortran's cgsize_t is now guaranteed to match C's cgsize_t. * Fortran programs defining CGNS data types with a default INTEGER size of 8 bytes also then need to compile the CGNS library with the default INTEGER size of 8 bytes. This is independent of whether or not --enable-64bit is being used. For clarification, using --enable-64bit allows for data types (i.e. those declared as cgsize_t) to be able to store values which are too large to be stored as 4 byte integers (i.e. numbers greater than 2,147,483,647). It is not necessary, or advisable (since it waste memory), to have CGNS INTEGER types (types declared int in C) to be 8 bytes; the variables declared as cgsize_t will automatically handle data types that can not be stored as 4 byte integers when --enable-64bit is being used. If the CGNS library was not compiled with a default INTEGER of 8 bytes, but the calling program was, then all integers passed to CGNS with C type int should be declared INTEGER(C_INT). * A new Fortran API was added for determining the CGNS data type of a variable which is interoperable with the C data type. Function cg_get_type(var) type, INTENT(IN) :: var INTEGER(KIND(enumvar)) :: cg_get_type An example of using the new function to automatically specify the CGNS type corresponding to the Fortran data type is, INTEGER, DIMENSION(1:10) :: Array_i CALL cgp_array_write_f("ArrayI",cg_get_type(Array_i(1)),1,INT(nijk(1),cgsize_t),Ai, err) * Removed all parallel flush/queue functions (CGNS-9) * Removed support of "include cgns_f.h", all examples and tests were updated to reflect these changes (CGNS-34) Tools: ---------- - None Bug Fixes since CGNS 3.2.1 release ================================== Configuration: ------------------ * Fixed issue with autotools putting a blank "-l" in "MPILIBS =" when compiling the library using mpi. * Added a new PGI fortran compiler flag fix issue when passing to C varags (CGNS-40) * CMake find_package was added for HDF5, users should use -D CMAKE_PREFIX_PATH=$HDF_DIR to specify a specific version of HDF5. Library: ------------ * Generally improved the performance of cgp_open (cgp_open_f). * Fixed elemtest.c to compile for SunOS 5.12 (CGNS-29) * Fixed parallel issue when not all processors involved in reading/writing (CGNS-51) * Fixed argument being passed to H5Pget_driver in ADFH.c (CGNS-50) * Fixed issue with writing/reading 4D and higher arrays in parallel (CGNS-19) Fortran: ------------ * cgio_link_size_f -- file_len and name_len were changed from cgsize_t to integer to match the C API, CGNS-37. * cgio_is_link_f -- cgio_num was changed from type cgsize_t to an integer to match the C API, CGNS-36. * cgio_is_supported_f -- ier changed from cgsize_t to integer to match the C API, CGNS-35. * Added PGI flag to fix cg_goto_f failing with the PGI compilers on x86_64 platforms, CGNS-40. Tools: ---------- * None Known Problems ================ * Building CGNS with Fortran enabled is not working on Windows. * When building with PGI and gcc compilers it might be necassary to set the environment variables: FLIBS="-Wl,--no-as-needed -ldl" LIBS="-Wl,--no-as-needed -ldl" Supported Platforms ====================== The following platforms are supported and have been tested for this release. They are built with the configure process unless specified otherwise. Linux 2.6.32-573.3.1.el6 GNU C (gcc), Fortran (gfortran) compilers: #1 SMP x86_64 GNU/Linux Version 4.4.7 20120313 (platypus) Version 4.8.4, Version 5.2.0 PGI C, Fortran for 64-bit target on x86-64; Version 15.7-0 Intel(R) C (icc), C++ (icpc), Fortran (icc) compilers: Version 15.0.3.187 Build 20150407 MPICH 3.1.4 compiled with GCC 4.9.3 Linux 2.6.32-504.8.1.el6.ppc64 gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11) #1 SMP ppc64 GNU/Linux GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11) (ostrich) IBM XL C/C++ V13.1 IBM XL Fortran V15.1 Linux 3.10.0-229.14.1.el7 GNU C (gcc), Fortran (gfortran) #1 SMP x86_64 GNU/Linux compilers: (kituo/moohan) Version 4.8.3 20140911 (Red Hat 4.8.3-9) Version 5.2.0 Intel(R) C (icc), Fortran (icc) compilers: Version 15.0.3.187 Build 20150407 MPICH 3.1.4 compiled with GCC 4.9.3 SunOS 5.11 32- and 64-bit Sun C 5.12 SunOS_sparc (emu) Sun Fortran 95 8.6 SunOS_sparc Mac OS X Yosemite 10.10.5 Apple clang/clang++ version 6.0 from Xcode 7.0.0 64-bit gfortran GNU Fortran (GCC) 4.9.2 (osx1010dev/osx1010test) Intel icc/icpc/ifort version 15.0.3 Tested Configuration Features Summary ===================================== In the table below y = tested n = not tested in this release x = not working in this release dna = does not apply Platform | C | F90/ | F90 | parallel | F2003 | parallel -------------------------------------|-----------|-------|---------- SunOS 5.11 32-bit | n | y/y n SunOS 5.11 64-bit | n | y/y | n Windows 7 | n | x/x | n Windows 7 x64 | n | x/x | n Windows 7 Cygwin | n | x/x | n Windows 8.1 | n | x/x | n Windows 8.1 x64 | n | x/x | n Windows 10 | n | x/x | n Windows 10 x64 | n | x/x | n Mac OS X Mountain Lion 10.8.5 64-bit | n | y/y | n Mac OS X Mavericks 10.9.5 64-bit | n | y/y | n Mac OS X Yosemeti 10.10.5 64-bit | n | y/y | n AIX 6.1 32- and 64-bit | n | y/n | n CentOS 6.7 Linux 2.6.32 x86_64 GNU | y | y/y | y CentOS 6.7 Linux 2.6.32 x86_64 Intel | n | y/y | n CentOS 6.7 Linux 2.6.32 x86_64 PGI | n | y/y | n CentOS 7.1 Linux 3.10.0 x86_64 GNU | y | y/y | y CentOS 7.1 Linux 3.10.0 x86_64 Intel | n | y/y | n Linux 2.6.32-431.11.2.el6.ppc64 | n | y/n | n == 3.2.1 == - fixed problem with IS_FIXED_SIZE macro for cubic elements - added check for open file to routines that don't take a file number (suggestion from Marc Poinet) - added HTMLHelp interface to cmake scripts - added AdditionalFamilyName to UserDefinedData - fixed compiler complaint about comparison between int and enum - added routines to set MPI communicator for parallel I/O - updated CMake scripts to work within other scripts (remove conflicts) - updates to some cgnstools utility conversion routines - fixes and updates to tests and cgnscheck - updates to support CG_FILE_ADF2 (2.5 compatibility) - fix for point set subregions == 3.2 === - full integration of parallel I/O using HDF5 with MPI - implemented CPEX 0033 and 0034 - compression (rewriting) of file to remove unused space is no longer automatically done, since may interfere with parallel I/O. Added cgnscompress program to tools to do this afterwards. - removed cgnsversion program from tools since support was getting out of hand (N squared problem with versions). - added routines to convert to and from AFLR3, FAST, and TetGen - implemented cubic elements (CPEX 0036) - CGNStools documentation no longer included with source. The NASA Glenn website (or local copy) is now used instead. == 3.1.4-2 == - fixes to cmake scripts for Fortran - added check for open file to routines that don't take a file number (suggestion from Marc Poinet) - CGNStools documentation no longer included with source. The NASA Glenn website (or local copy) is now used instead. - save window size for cgnsview - fix to computing path lists in CMake script == 3.1.4 == - added some const definitions to library - moved unlink of filename when using CG_MODE_WRITE on open to cgio - fixed goto for FamilyBCDataset for UserData, .etc - added cg_get_cgio_f and cg_root_id_f Fortran routines - fixed cmake and configure scripts to allow MPI with HDF5 and fixed bugs in those scripts - updated CGNSplot to handle all element types and 1-d and 2-d cases - fixes to cgnscheck - cleaned up some compiler warnings - added cgnsBuild.defs Makefile include to installation - removed unneeded tools directory from cgnstools - cgnstools no longer built automatically - need to set configure flag - allow CellCenter for BCs - added cg_precision and cg_precision_f functions to get integer size used to create the file (32 or 64) == 3.0.8 == - Fix flag - Test for v3.0 release == 3.0.7 == - Internal updates == 3.0.6 == - Internal updates == 3.0.5 == - Added install.txt and install.lyx - Added readme.txt and readme.lyx - Re-integrated the automake build system into the src directory so that the old build system can be used by invoking ./configure make, make install in the src directory. - Added license.txt == 3.0.4 == - Fixed a compilation problem with gcc-4.1 == 3.0.3 - Internal debugging release == 3.0.2 == - Fixed BUILD_HDF5 flag in CMakeLists.txt - Fixed file prop list scope problem in ADFH.c CGNS-4.5.0/release_docs/INSTALL_Cygwin.txt000066400000000000000000000160731474000356600201050ustar00rootroot00000000000000************************************************************************ CGNS Build and Install Instructions for Cygwin ************************************************************************ This document is a instruction on how to build, test and install CGNS with HDF5 support on Cygwin. Preconditions: -------------- 1. Installed Cygwin 1.7.25 or higher To install the Cygwin net release, go to http://www.cygwin.com and click on "setup-x86.exe" (32-bit installation) or "setup-x86_64.exe" (64-bit installation) at https://cygwin.com/install.html. This will download a GUI installer called setup-x86.exe or setup-x86_64,exe which can be run to download a complete Cygwin installation via the internet. Then follow the instructions on each screen to install Cygwin. Cygwin uses packages to manage installing various software. Users can choose to install or uninstall certain packages by running setup.exe. http://www.cygwin.com/packages/ provides detailed information about Cygwin packages. Most required dependencies can be satisfied by installing all packages in the "Devel" category. 2. Compilers, Libraries and Utilities Installed 2.1 Compilers Supported The following compilers are supported by CGNS/HDF5 and included in the Cygwin package system: gcc (4.7.3 and 4.9.2), which includes: gcc4-core : C compiler gcc4-g++ : C++ compiler gcc4-fortran : fortran compiler 2.1.1 Using Compilers Not Supported By default the current configuration uses vendor compilers; to use another compiler run the following commands before running configure: setenv CC "foo -flags" setenv FC "fffoo -flags" For example, if users want to use pgf90 as fortran compiler, then setenv FC pgf90 See the configure help page (configure --help) for a list of environment variables that have an affect on building the library. 2.2 HDF5 External Library Dependencies 2.2.1 Zlib zlib-1.2.5 or later is supported and tested on Cygwin. 2.2.2 Szip The HDF5 library has a predefined compression filter that uses the extended-Rice lossless compression algorithm for chunked datasets. For more information about Szip compression and license terms see http://hdfgroup.org/HDF5/doc_resource/SZIP/index.html. The latest supported public release of SZIP is available from ftp://ftp.hdfgroup.org/lib-external/szip/2.1. 2.3 Additional Utilities The following standard utilities are also required to build and test HDF5: bison : yacc implementation flex : flex utility make : make utility Build, Test and Install HDF5 on Cygwin -------------------------------------- 1. Get HDF5 source code package Users can download HDF5 source code package from HDF website (http://hdfgroup.org). 2. Unpacking the distribution The HDF5 source code is distributed in a variety of formats which can be unpacked with the following commands, each of which creates an `hdf5-1.8.x' directory. 2.1 Non-compressed tar archive (*.tar) $ tar xf hdf5-1.8.x.tar 2.2 Gzip'd tar archive (*.tar.gz) $ gunzip < hdf5-1.8.x.tar.gz | tar xf - 2.3 Bzip'd tar archive (*.tar.bz2) $ bunzip2 < hdf5-1.8.x.tar.bz2 | tar xf - 3. Setup Environment In Cygwin, most compilers and setting are automatically detected during the configure script. However, if you are building Fortran we recommend that you explicitly set the "FC" variable in your environment to use the gfortran compiler. For example, issue the command: $ export FC=gfortran 4. Configuring To build HDF5 for use with CGNS it is recommended to disable Fortran and the high level library. $ ./configure --disable-fortran --disable-hl To configure HDF5 C without Zlib, To disable zlib, using $ ./configure --without-zlib Two ways to configure HDF5 C with specified Zlib Using $ ./configure --with-zlib=INCDIR,LIBDIR For example, if the zlib library is installed in /cygdrive/c/usr, which is the parent directory of directories "include" and "lib", $ ./configure --with-zlib=/cygdrive/c/usr/include,/cygdrive/c/usr/lib Through the CPPFLAGS and LDFLAGS Variables For example, if zlib was installed in the directory /cygdrive/c/usr then using the following command to configure HDF5 with zib $ CPPFLAGS=-I/cygdrive/c/usr/include \ $ LDFLAGS=-L/cygdrive/c/usr/lib \ $ ./configure To specify the installation directories, using $ ./configure --prefix="path for installation" By default, HDF5 library, header files, examples, and support programs will be installed in /usr/local/lib, /usr/local/include, /usr/local/doc/hdf5/examples, and /usr/local/bin. To use a path other than /usr/local specify the path with the `--prefix=PATH' switch as in the above command. 5. Make and Make Check After configuration is done successfully, run the following series of commands to build, test and install HDF5 $ make > "output file name" $ make check > "output file name" Before run "make install", check output file for "make check", there should be no failures at all. 6. Make Install $ make install > "output file name" 7. Check installed HDF5 library After step 6, go to your installation directory, there should be three subdirectories: "bin" "include" and "lib". 8. Known Problems dt_arith tests may fail due to the use of fork. This is a known issue with cygwin on Windows. "make check" fails when building shared lib files is enabled. The default on Cygwin has been changed to disable shared. It can be enabled with the --enable-shared configure option but is likely to fail "make check" with GCC compilers. Build, Test and Install HDF5 on Cygwin -------------------------------------- 1. Download the current stable release from: https://github.com/CGNS/CGNS/releases 2. You may need to specify the compilers in the environment: $ export CC="gcc" $ export FC="gfortran" 3. Specify the configure options, below is an example configure line: $ ./configure \ --prefix= \ --with-fortran \ --with-hdf5= \ --enable-lfs \ --disable-shared \ --enable-debug \ --disable-cgnstools \ --with-zlib= \ --enable-64bit 4. Build the CGNS library using $ make $ make install $ make test ----------------------------------------------------------------------- Submit bug reports at: https://cgnsorg.atlassian.net/secure/Dashboard.jspaCGNS-4.5.0/release_docs/RELEASE.md000066400000000000000000000231161474000356600163140ustar00rootroot00000000000000# INTRODUCTION This document describes the difference between CGNS 4.4.0 and CGNS 4.5.0, and contains information on known problems in CGNS 4.5.0. Links to the CGNS current released source code can be found at: Download User MLL documentation for the current release can be found at: MLL Documentation For more general information, see the CGNS home page: CGNS.org ## CONTENTS - New Features - Bug Fixes since CGNS 4.4.0 - Known Problems # New Features > [!NOTE] > This release includes new Doxygen descriptions of the MLL APIs, which are now utilized in the updated documentation at cgns.org. > [!IMPORTANT] > All new Fortran APIs introduced in this release that expect a character string are required to pass a scalar > character string (i.e.,` CHARACTER(LEN=*) `) and not an array of character strings (i.e., `CHARACTER(LEN=*), DIMENSION(*)`). Configuration: -------------------- N/A Library: --------------- * New CPEX0046 Particle extension, the inclusion of particle data in CGNS. - For Details, see: https://cgns.org/_downloads/74b6fa06432163b5730964340e3084bc/CPEX0046-v2-rev1.pdf - Numerous new MLL APIs, both parallel and serial, were added. See the MLL documentation at cgns.org for more details. > [!NOTE] > We appreciate Convergent Science's contributions to CPEX 0046 and its implementation. * Added Fortran support for `cg_configure_f` to allow a callback function, such as in the case of CG_CONFIG_ERROR. Parallel Library: ------------------------ * Added new PointList Functions: `cgp_parent_data_write(_f)`, `cgp_ptlist_write_data(_f)` and `cgp_ptlist_read_data(_f)`, PR #730, Issue #728. - Parallel writing/reading of any PointSet is possible via a `cg_goto` statement rather than just pointsets associated with `BC_t` nodes. * Added poly elements read/parent elements read-write APIs: - `cgp_poly_section_write(_f)`, `cgp_poly_elements_write_data(_f)` - `cgp_poly_elements_read_data_elements`, `cgp_poly_elements_read_data_offsets(_f)`,`cgp_parentelements_read_data(_f)` Fortran Library: ----------------------- See section _Parallel Library_. Tools: ------------- N/A # Bug Fixes since CGNS 4.4.0 release Configuration: -------------------- * Fixed compilation issues due to missing _POSIX_SOURCE define, Issue #810. * Add cgns-config.cmake file. - Also change hdf5 target names to match those from find_package(HDF5) * Fix for HDF5 1.14.3 and onward with the NAG compiler. - IEEE standard arithmetic enables software to raise exceptions such as overflow, division by zero, and other illegal operations without interrupting or halting the program flow. The HDF5 C library intentionally performs these exceptions. Therefore, the "-ieee=full" nagfor switch is necessary when compiling a program to avoid stopping on an exception. * Improve cmake packaging - Set an installed rpath that handles install location differently from "lib" for multiple arch support, for instance. * Update cmake requirement - Update cmake requirement to 3.20 - Fix conversion issue with vs2022 compiler - Handle F2C string on ARM64 - Hidden parameters should be handled through a size_t according to https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gfortran/Argument-passing-conventions.html * Remove the deprecated build system on Windows (i.e., .bat); CMake is the current focus of development. * Bumped the Autotools prerequisite to 2.71, and fixed the check to allow for HDF5 version 2.0.0 Library: -------------- * [CGNS-284] Fixed cgi_warning - modify return status when the bounding box is not found. - No more cgi_warning shown see [CGNS-284] - removed outdated documentation * Do not force Elements_t node to be contiguous - Only data arrays are forced to be contiguous in the Elements_t node * fixed uninitialized warnings * Fix issue https://github.com/CGNS/CGNS/issues/754 (https://github.com/CGNS/CGNS/pull/756) - use C99 types int64_t - define cgsize_t as a intxx_t type - provide PRIdCGSIZE - follow hdf5 changes * Corrected int types for MPI_Allgather in ptests - Fixed cgsize_t type for MPI _Allgather, in tests, depending on how CGNS was built. * Misc windows fixes - Make cmakelist more robust to Multi-configuration generators - Improve Win32 ctest support - Remove the redefinition of MACRO; the MACRO is already defined in glib.h * use size_t casting to prevent allocation failure - the cast to size_t is done before multiplying with size_of - size_of now returns a size_t - This prevents capacity reduction in 32-bit mode when cgsize_t is an int. * Remove access() calls in the CGNS library - Remove ACCESS calls due to possible race condition * Address miscellaneous CodeQL issues and warnings. Fortran: --------------- * made Fortran Test_Family example output valid for cgnscheck Tools: ------------- * backport gcc14 fedora patch for tkogl * [cgnscheck] check multiple grid coordinates nodes & null pointer # Known Problems ************ FORTRAN ************ * A gfortran bug in version 10.2 broke Fortran mapping and caused cg_goto_f to segfault. All other versions of gfortran are suitable. (ref. CGNS-246, GNU BUG 100149) * A bug in gfortran (all versions) causes cg_configure_f to fail, GNU BUG 99982. Other Fortran compilers are OK. * Building CGNS with parallel enabled, with Fortran enabled, and as a shared library on Windows is not working. Some C parallel tests fail on Windows with the Intel Compiler. ************ FORTRAN END ******** ************ CGNSVIEW ************ * cgnsview for OSX is not viewing properly, and cgnsview under Windows may fail to compile due to tcl/tk incompatibility. ************ CGNSVIEW END ******** * For details on these and other issues, see https://github.com/CGNS/CGNS/issues # Supported Platforms The following platforms are supported and have been tested for this release. They are built with autotools unless specified otherwise. > [!NOTE] > CGNS is not testing on any 32-bit Linux systems |Platform | Configuration | |-- | -- | | Centos7
#1 SMP x86_64 GNU/Linux
| GNU C (gcc), Fortran (gfortran), C++ (g++)
compilers:
Version 4.8.5 20150623 (Red Hat 4.8.5-4)
Version 4.9.3, Version 7.2.0, Version 8.3.0,
Version 9.1.0, Version 10.2.0
| | | Intel(R) C (icc), C++ (icpc), Fortran (icc)
compilers:
Version 17.0.0.098 Build 20160721 | | | GNU C (gcc) and C++ (g++) 4.8.5 compilers
   with NAG Fortran Compiler Release 7.1(Hanzomon)| | | Intel(R) C (icc) and C++ (icpc) 17.0.0.098| | | GNU C (gcc) and C++ (g++) 4.8.5 compilers with NAG Fortran Compiler Release 7.1(Hanzomon) | | | Intel(R) C (icc) and C++ (icpc) 17.0.0.098 compilers with NAG Fortran Compiler Release 7.1(Hanzomon)| | | MPICH 3.1.4 compiled with GCC 4.9.3 | | | MPICH 3.3 compiled with GCC 7.2.0 | | | OpenMPI 3.1.3 compiled with GCC 7.2.0, and 4.1.2 compiled with GCC 9.1.0 | | | NVIDIA nvc, nvfortran and nvc++ version 22.5-0 (autotools and cmake) | | Ubuntu 24.04
#1 SMP x86_64 GNU/Linux
| GNU C (gcc), Fortran (gfortran), C++ (g++)
compilers: 13.2 | | | OpenMPI 4.1.6 | > [!NOTE] > CGNS is not testing on any 32-bit Windows systems |Platform | Configuration | |---------------- | ----------------------------------------------- | | Windows 11 x64 | Visual Studio 2019 w/ Intel OneAPI 2025 (CMake) | | | Visual Studio 2019 w/ MSMPI 10.1 (CMake) | > [!NOTE] > CGNS is tested with the two latest macOS versions that are available > on GitHub runners. As new major macOS versions become available, CGNS > will discontinue support for the older version and add the latest > version to its list of compatible systems and the previous version. |Platform | Configuration | |-------------------------- | ----------------------------------------- | |macOS Sonoma 14.7.2 64-bit | Apple LLVM
gfortran GNU Fortran (GCC) | |macOS Sequoia 15.2 64-bit | Apple LLVM
gfortran GNU Fortran (GCC) | # Tested Configuration Features Summary
In the table below
      y   = tested
      n   = not tested in this release
      x   = not working in this release
Platform | C | C[1] | Fortran | Fortran [1] -- | -- | -- | -- | -- Windows 11 | n | n | n | n Windows 11 x64 | y | n | n | n Windows 11 Cygwin | n | n | x | n Mac OS X Sonoma 64-bit | y | n | y | n Mac OS X Sequoia 64-bit | y | n | y | n CentOS 7.2 Linux 3.10.0 x86_64 PGI | y | n | y | n CentOS 7.2 Linux 3.10.0 x86_64 GNU | y | y | y | y CentOS 7.2 Linux 3.10.0 x86_64 Intel | y | y | y | y Linux 2.6.32-573.18.1.el6.ppc64 | y | n | y | n

[1] Parallel # Acknowledgements * Thank you, Mickael Philit, for contributing to updating the documentation and resolving various issues in the CGNS library for this release. * We appreciate all the CGNS users who reported issues and submitted pull requests. CGNS-4.5.0/src/000077500000000000000000000000001474000356600130465ustar00rootroot00000000000000CGNS-4.5.0/src/CMakeLists.txt000066400000000000000000000546021474000356600156150ustar00rootroot00000000000000 ########## # Global # ########## if (WIN32) add_compile_definitions(_CRT_SECURE_NO_WARNINGS) endif (WIN32) ################################ # create configured header files # ################################ if("${SIZEOF_INT64_T}" EQUAL "8") set(CGLONGT "int64_t") set(CGULONGT "uint64_t") elseif("${SIZEOF_LONG}" EQUAL "8") set(CGLONGT "long") set(CGULONGT "unsigned long") elseif("${SIZEOF_LONG_LONG}" EQUAL "8") set(CGLONGT "long long") set(CGULONGT "unsigned long long") else() message(FATAL_ERROR "Can't find suitable int64_t") endif() message(STATUS "Found int64_t: ${CGLONGT}") set(BUILDLEGACY 0) set(BUILD64BIT 0) set(BUILDSCOPE 0) set(BUILDFORTRAN 0) set(BUILDBASESCOPE 0) if (CGNS_ENABLE_LEGACY) set(BUILDLEGACY 1) else () if (CGNS_ENABLE_64BIT) set(BUILD64BIT 1) else () endif () endif () if (CGNS_ENABLE_SCOPING) set(BUILDSCOPE 1) endif () if (CGNS_ENABLE_FORTRAN) set(BUILDFORTRAN 1) endif () if (CGNS_ENABLE_BASE_SCOPE) set(BUILDBASESCOPE 1) endif () set(SYSCFLAGS "") set(CFGFLAGS "") set(LIBS "") file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/lib LIBDIR) file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/include INCLUDEDIR) file(TO_NATIVE_PATH ${CMAKE_C_COMPILER} CC) if (WIN32) set(CGNSLIB cgns.lib) else () set(CGNSLIB libcgns.a) set(LIBS -lm) endif () set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) include(CheckCCompilerFlag) macro(check_and_add_compiler_option _option) message(STATUS "Checking C compiler flag ${_option}") string(REPLACE "=" "-" _temp_option_variable ${_option}) string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable}) check_c_compiler_flag("${_option}" ${_option_variable}) if(${${_option_variable}}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_option}") endif() endmacro() if (CMAKE_C_COMPILER_ID MATCHES "GNU") check_and_add_compiler_option("-std=gnu99") elseif (CMAKE_C_COMPILER_ID MATCHES "XL") check_and_add_compiler_option("-qlanglvl=extc99") elseif(CMAKE_C_COMPILER_ID MATCHES "Sun") check_and_add_compiler_option("-xc99") endif() if (NOT DEFINED CMAKE_CONFIGURATION_TYPES) # Buggy section used for generating buildConfig.def # A CMake generator with conditional could be used # as using CMAKE_BUILD_TYPE is not good practise string(COMPARE EQUAL ${CMAKE_BUILD_TYPE} Debug IS_DEBUG) if (IS_DEBUG) set(BUILDDEBUG 1) set(CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}") set(LDFLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_DEBUG}") else () set(BUILDDEBUG 0) set(CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}") set(LDFLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_RELEASE}") endif () else () set(BUILDDEBUG 0) set(CFLAGS "") set(LDFLAGS "") endif () set(BUILDHDF5 0) set(H5NEEDMPI 0) set(H5NEEDSZIP 0) set(H5NEEDZLIB 0) set(BUILDPARALLEL 0) set(HDF5INC "") set(HDF5LIB "") set(SZIPLIB "") set(ZLIBLIB "") set(MPIINC "") set(MPILIBS "") set(HAVE_FORTRAN_95 0) set(HAVE_FORTRAN_2003 0) set(HAVE_FORTRAN_2008 0) set(HAVE_FORTRAN_2008TS 0) set(HDF5_HAVE_MULTI_DATASETS 0) set(HDF5_HAVE_COLL_METADATA 0) set(HDF5_HAVE_FILE_SPACE_STRATEGY 0) set(FORTRAN_DEFAULT_INTEGER_C_INT64_T 0) set(HAVE_STAT64_STRUCT 0) set(HAVE_COMPLEX_C99_EXT 0) #For cg_hash_types.h.in CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) set(SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) include(CheckCSourceCompiles) check_c_source_compiles(" #include int main(int argc, char *argv[]){ #if !defined(_MSC_VER) float _Complex a[2]; __real__(a[1]) = (float) 1.0; __imag__(a[1]) = (float) 0.0; #endif return 0; } " HAVE_COMPLEX_C99_EXT ) if (BUILDFORTRAN) #----------- Determine if the Fortran compiler pgi ------------------------ # The PGI compiler segfaults when va_start is called, so we need to add # a special compiler flag, see CGNS-40. #-------------------------------------------------------------------------- if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI") SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mx,125,0x200") endif() #----------- Determine if the Fortran compiler NAG ------------------------ # The NAG compiler needs an additional flag for Fortran calls to C APIs. #-------------------------------------------------------------------------- if(CMAKE_Fortran_COMPILER_ID MATCHES "NAG") SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mismatch_all") if ("${HDF5_VERSION}" VERSION_GREATER_EQUAL "1.14.3") SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ieee=full") endif() endif() ENABLE_LANGUAGE(Fortran) #----------------------------------------------------------------------------- # The provided CMake Fortran macros don't provide a general check function # so use this one. #----------------------------------------------------------------------------- macro (CHECK_FORTRAN_FEATURE FUNCTION CODE VARIABLE) if(NOT DEFINED ${VARIABLE}) if(CMAKE_REQUIRED_LIBRARIES) set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") else() set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) endif() file (WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.F90 "${CODE}" ) try_compile (${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.F90 CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" OUTPUT_VARIABLE OUTPUT ) # message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") # message ( "Test result ${OUTPUT}") # message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") if(${VARIABLE}) set (${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}") message (STATUS "Testing Fortran ${FUNCTION} - OK") file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n" "${OUTPUT}\n\n" ) else() message (STATUS "Testing Fortran ${FUNCTION} - Fail") set (${VARIABLE} "" CACHE INTERNAL "Have Fortran function ${FUNCTION}") file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n" "${OUTPUT}\n\n") endif() endif() endmacro (CHECK_FORTRAN_FEATURE) #----------------------------------------------------------------------------- # Configure Checks which require Fortran compilation must go in here # not in the main ConfigureChecks.cmake files, because if the user has # no Fortran compiler, problems arise. # #----------------------------------------------------------------------------- CHECK_FORTRAN_FEATURE(Fortran2003 " PROGRAM testf03 USE iso_c_binding IMPLICIT NONE INTEGER(C_INT) :: a INTEGER(C_INT32_T) :: b INTEGER(C_INT64_T) :: c REAL(C_FLOAT) :: d REAL(C_DOUBLE) :: e CHARACTER(LEN=1,KIND=C_CHAR), TARGET :: f TYPE(C_PTR) :: g INTERFACE INTEGER(C_INT) FUNCTION test(A, UserDataName1) BIND(C, name='cg_goto') USE ISO_C_BINDING INTEGER(C_INT) , INTENT(IN), VALUE :: A CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: UserDataName1 END FUNCTION test END INTERFACE g = C_LOC(f(1:1)) END PROGRAM testf03 " CHECK_FORTRAN_2003 ) if (CHECK_FORTRAN_2003) set(HAVE_FORTRAN_2003 1) endif () if (HAVE_FORTRAN_2003) CHECK_FORTRAN_FEATURE(Fortran2008TS " PROGRAM testf03 USE ISO_C_BINDING INTERFACE INTEGER(C_INT) FUNCTION test(A) BIND(C, name='test') USE ISO_C_BINDING INTEGER(C_INT), OPTIONAL :: A END FUNCTION test END INTERFACE END PROGRAM testf03 " CHECK_FORTRAN_2008TS ) if (CHECK_FORTRAN_2008TS) set(HAVE_FORTRAN_2008TS 1) endif (CHECK_FORTRAN_2008TS) CHECK_FORTRAN_FEATURE(Fortran2008 " MODULE test USE ISO_C_BINDING INTERFACE binding FUNCTION bind1(x) BIND(C, name='Cfunc') IMPORT :: C_FLOAT REAL(C_FLOAT) :: x END FUNCTION bind1 FUNCTION bind2(x) BIND(C, name='Cfunc') IMPORT :: C_DOUBLE REAL(C_DOUBLE) :: x END FUNCTION bind2 END INTERFACE END MODULE test PROGRAM main USE test IMPLICIT NONE END PROGRAM " CHECK_FORTRAN_2008 ) if (CHECK_FORTRAN_2008) set(HAVE_FORTRAN_2008 1) endif () CHECK_FORTRAN_FEATURE(Sizeof_int " MODULE mod INTERFACE test_integer MODULE PROCEDURE test_int MODULE PROCEDURE test_c_int64 END INTERFACE CONTAINS SUBROUTINE test_c_int64(a) USE ISO_C_BINDING INTEGER(C_INT64_T) :: a END SUBROUTINE test_c_int64 SUBROUTINE test_int(a) USE ISO_C_BINDING INTEGER :: a END SUBROUTINE test_int END MODULE mod PROGRAM main USE mod INTEGER :: a CALL test_integer(a) END PROGRAM main " CHECK_FORTRAN_DEFAULT_INTEGER_C_INT32_T ) if (NOT CHECK_FORTRAN_DEFAULT_INTEGER_C_INT32_T) set(FORTRAN_DEFAULT_INTEGER_C_INT64_T 1) endif () else () CHECK_FORTRAN_FEATURE(Fortran95 " PROGRAM testf95 IMPLICIT NONE INTEGER, PARAMETER :: cgint_kind = SELECTED_INT_KIND(5) END PROGRAM testf95 " CHECK_FORTRAN_95 ) if (CHECK_FORTRAN_95) set(HAVE_FORTRAN_95 1) endif () endif () CHECK_FORTRAN_FEATURE(FortranConcat " # define CONCATENATE(a,b) a##b CONCATENATE(PRO,GRAM) testconcat IMPLICIT NONE integer a a = 10 END PROGRAM testconcat " CHECK_FORTRAN_CONCAT ) if (NOT CHECK_FORTRAN_CONCAT) SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DNO_CONCATENATION") endif () endif () macro(native_paths INPUT_PATH_VARIABLE RESULT_VARIABLE) set(${RESULT_VARIABLE} "") foreach(PATH ${${INPUT_PATH_VARIABLE}}) file(TO_NATIVE_PATH ${PATH} NATIVE_PATH) list(APPEND ${RESULT_VARIABLE} ${NATIVE_PATH}) endforeach() endmacro() #----------------------------------------------------------------------------- # The provided CMake macros don't provide a general HDF5 check function # so use this one. #----------------------------------------------------------------------------- macro (CHECK_HDF5_FEATURE FUNCTION CODE VARIABLE) if(NOT DEFINED ${VARIABLE}) file (WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_HDF.c "${CODE}" ) set (CHECK_FUNCTION_EXISTS_ADD_INCLUDE "-DINCLUDE_DIRECTORIES:STRING=${HDF5_INCLUDE_DIR}") try_compile (${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test_HDF.c LINK_LIBRARIES ${HDF5_LIBRARY} CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_INCLUDE}" OUTPUT_VARIABLE OUTPUT ) # message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") # message ( "Test result ${OUTPUT}") # message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") if(${VARIABLE}) set (${VARIABLE} 1 CACHE INTERNAL "Have HDF5 function ${FUNCTION}") message (STATUS "Testing HDF5 ${FUNCTION} - OK") file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the HDF5 ${FUNCTION} exists passed with the following output:\n" "${OUTPUT}\n\n" ) else() message (STATUS "Testing HDF5 ${FUNCTION} - NOT FOUND") set (${VARIABLE} "" CACHE INTERNAL "Have HDF5 function ${FUNCTION}") file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the HDF5 ${FUNCTION} exists failed with the following output:\n" "${OUTPUT}\n\n") endif() endif() endmacro () if (CGNS_ENABLE_HDF5) set(BUILDHDF5 1) if (HDF5_INCLUDE_PATH) native_paths(HDF5_INCLUDE_PATH HDF5INC) endif () if (HDF5_LIBRARY) native_paths(HDF5_LIBRARY HDF5LIB) endif () if (HDF5_NEED_SZIP) set(H5NEEDSZIP 1) if (SZIP_LIBRARY) native_paths(SZIP_LIBRARY SZIPLIB) endif () endif () if (HDF5_NEED_ZLIB) set(H5NEEDZLIB 1) if (ZLIB_LIBRARY) native_paths(ZLIB_LIBRARY ZLIBLIB) endif () endif () if (HDF5_NEED_MPI) set(H5NEEDMPI 1) if (MPI_INC) native_paths(MPI_INC MPIINC) endif () if (MPI_LIBS) native_paths(MPI_LIBS MPILIBS) endif () if (CGNS_ENABLE_PARALLEL) set(BUILDPARALLEL 1) endif () endif () set(cgns_C_FILES ${cgns_C_FILES} adfh/ADFH.c) if (CGNS_ENABLE_PARALLEL) set(cgns_C_FILES ${cgns_C_FILES} pcgnslib.c) endif () # Check if HDF5 library has multi-dataset read/write APIs, HDF5 >= 1.14.0 # -------------------------------------------------------------------- CHECK_HDF5_FEATURE(Multi_Dataset " #include \"hdf5.h\" int main(void) { H5Dwrite_multi(0, NULL, NULL, NULL, NULL, 0, NULL); return 0; } " CHECK_HDF5_HAVE_MULTI_DATASETS ) if (CHECK_HDF5_HAVE_MULTI_DATASETS) set(HDF5_HAVE_MULTI_DATASETS 1) endif () # Check if HDF5 library has collective metadata APIs, HDF5 >= 1.10.0 # -------------------------------------------------------------------- CHECK_HDF5_FEATURE(Collective_metadata " #include \"hdf5.h\" int main(void) { hid_t foo; H5Pset_coll_metadata_write(foo, 1); H5Pset_all_coll_metadata_ops(foo, 1); return 0; } " CHECK_HDF5_HAVE_COLL_METADATA ) if (CHECK_HDF5_HAVE_COLL_METADATA) set(HDF5_HAVE_COLL_METADATA 1) endif () # Check if HDF5 library has H5Pset_file_space_strategy, HDF5 >= 1.10.1 # -------------------------------------------------------------------- CHECK_HDF5_FEATURE(H5Pset_file_space_strategy " #include \"hdf5.h\" int main(void) { hid_t foo; H5Pset_file_space_strategy(foo, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1); return 0; } " CHECK_HDF5_HAVE_FILE_SPACE_STRATEGY ) if (CHECK_HDF5_HAVE_FILE_SPACE_STRATEGY) set(HDF5_HAVE_FILE_SPACE_STRATEGY 1) endif () endif () # Check for stat64 struct ## -------------------------------------------------------------------- # stat64 is deprecated for OS X if (NOT APPLE) include(CheckStructHasMember) if ( WIN32 ) CHECK_STRUCT_HAS_MEMBER("struct _stat64" st_atime sys/stat.h CHECK_HAVE_STAT64_STRUCT LANGUAGE C) else () CHECK_STRUCT_HAS_MEMBER("struct stat64" st_atime sys/stat.h CHECK_HAVE_STAT64_STRUCT LANGUAGE C) endif() if (CHECK_HAVE_STAT64_STRUCT) set(HAVE_STAT64_STRUCT 1) endif () endif() #create these in build directory so it doesn't mess up the #source directory, then add the path to them configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cgnstypes.h.in ${CMAKE_CURRENT_BINARY_DIR}/cgnstypes.h ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cgnstypes_f.h.in ${CMAKE_CURRENT_BINARY_DIR}/cgnstypes_f.h ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cgnstypes_f03.h.in ${CMAKE_CURRENT_BINARY_DIR}/cgnstypes_f03.h ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cgnsconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/cgnsconfig.h ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cg_hash_types.h.in ${CMAKE_CURRENT_BINARY_DIR}/cg_hash_types.h ) # The following is only useful with Unix Makefile Generator configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cgnsBuild.defs.in ${CMAKE_CURRENT_BINARY_DIR}/cgnsBuild.defs ) ########### # Library # ########### # All the C files needed by the cgns library set(cgns_C_FILES cgns_error.c cgns_internals.c cgns_io.c cgnslib.c cg_hashmap.c adf/ADF_interface.c adf/ADF_internals.c) if (CGNS_ENABLE_MEM_DEBUG) set(cgns_C_FILES ${cgns_C_FILES} cg_malloc.c) endif() if (CGNS_ENABLE_HDF5) set(cgns_C_FILES ${cgns_C_FILES} adfh/ADFH.c) if (CGNS_ENABLE_PARALLEL) set(cgns_C_FILES ${cgns_C_FILES} pcgnslib.c) endif () endif () # All the Fortran files need by the cgns library (if enabled) set(cgns_F_FILES cg_ftoc.c cgio_ftoc.c) # Only build those files that are needed if (CGNS_ENABLE_FORTRAN) if (FORTRAN_NAMING) set_property(SOURCE ${cgns_F_FILES} PROPERTY COMPILE_DEFINITIONS ${FORTRAN_NAMING}) endif () set(cgns_FILES ${cgns_C_FILES} ${cgns_F_FILES}) add_library(cgns_f2c OBJECT cgns_f.F90) # shared libraries need PIC set_property(TARGET cgns_f2c PROPERTY POSITION_INDEPENDENT_CODE 1) target_include_directories(cgns_f2c BEFORE PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) else () set(cgns_FILES ${cgns_C_FILES}) endif () option(CGNS_USE_SHARED "Link programs to the CGNS shared library" "ON") # Build a static version of the library add_library(cgns_static STATIC ${cgns_FILES} $<$:$>) add_library(CGNS::cgns-static ALIAS cgns_static) # Needed to work around a CMake > 3.8 bug on Windows with MSVS and Intel Fortran set_property(TARGET cgns_static PROPERTY LINKER_LANGUAGE C) target_link_libraries(cgns_static PRIVATE $<$:hdf5-${CG_HDF5_LINK_TYPE}>) # Build a shared version of the library if(CGNS_BUILD_SHARED) mark_as_advanced(CLEAR CGNS_USE_SHARED) add_library(cgns_shared SHARED ${cgns_FILES} $<$:$>) add_library(CGNS::cgns-shared ALIAS cgns_shared) if (MSVC AND CGNS_ENABLE_FORTRAN) target_compile_definitions(cgns_f2c PRIVATE BUILD_CGNS_DLL) endif() if (WIN32 OR CYGWIN) target_compile_definitions(cgns_shared PRIVATE -DBUILD_DLL) target_compile_definitions(cgns_shared INTERFACE -DUSE_DLL) endif () if (CGNS_ENABLE_HDF5 AND HDF5_LIBRARY) target_link_libraries(cgns_shared PUBLIC hdf5-${CG_HDF5_LINK_TYPE} $<$>:${CMAKE_DL_LIBS}>) if(HDF5_NEED_ZLIB AND ZLIB_LIBRARY) target_link_libraries(cgns_shared PUBLIC ${ZLIB_LIBRARY}) endif() if(HDF5_NEED_SZIP AND SZIP_LIBRARY) target_link_libraries(cgns_shared PUBLIC ${SZIP_LIBRARY}) endif() if(HDF5_NEED_MPI AND MPI_LIBS) target_link_libraries(cgns_shared PUBLIC ${MPI_LIBS}) endif() endif () else() set(CGNS_USE_SHARED "OFF") mark_as_advanced(FORCE CGNS_USE_SHARED) endif() # Include the local directory target_include_directories(cgns_static BEFORE PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} INTERFACE $ $ $) if (CGNS_ENABLE_HDF5) if(HDF5_NEED_MPI AND MPI_INC) target_include_directories(cgns_static PRIVATE ${MPI_INC}) endif() endif () if (CGNS_BUILD_SHARED) target_include_directories(cgns_shared BEFORE PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} INTERFACE $ $ $) if (CGNS_ENABLE_HDF5) if(HDF5_NEED_MPI AND MPI_INC) target_include_directories(cgns_shared PRIVATE ${MPI_INC}) endif() endif () endif() if (CGNS_ENABLE_MEM_DEBUG) target_compile_definitions(cgns_static PRIVATE "-DMEM_DEBUG") if (CGNS_BUILD_SHARED) target_compile_definitions(cgns_shared PRIVATE "-DMEM_DEBUG") endif() endif() # Change the output name of the library to be libcgns set_target_properties(cgns_static PROPERTIES OUTPUT_NAME cgns) set_target_properties(cgns_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) if(CGNS_BUILD_SHARED) # for windows we need to change the name of the shared library # for both static and shared version to coexist if (CMAKE_STATIC_LIBRARY_SUFFIX STREQUAL CMAKE_IMPORT_LIBRARY_SUFFIX) set_target_properties(cgns_shared PROPERTIES OUTPUT_NAME cgnsdll) else () set_target_properties(cgns_shared PROPERTIES OUTPUT_NAME cgns) endif () set_target_properties(cgns_shared PROPERTIES CLEAN_DIRECT_OUTPUT 1) endif() # Set the version numbers set_target_properties(cgns_static PROPERTIES VERSION "${CGNS_VERSION}") set_target_properties(cgns_static PROPERTIES SOVERSION "${CGNS_VERSION}") if(CGNS_BUILD_SHARED) set_target_properties(cgns_shared PROPERTIES VERSION "${CGNS_VERSION}") set_target_properties(cgns_shared PROPERTIES SOVERSION "${CGNS_VERSION}") endif() set (install_targets cgns_static) if(CGNS_BUILD_SHARED) set(install_targets ${install_targets} cgns_shared) endif () # Set the install path of the static and shared library # for windows, need to install both cgnsdll.dll and cgnsdll.lib install (TARGETS ${install_targets} EXPORT cgns-targets LIBRARY DESTINATION lib COMPONENT libraries ARCHIVE DESTINATION lib COMPONENT libraries RUNTIME DESTINATION bin COMPONENT libraries INCLUDES DESTINATION include) # Set the install path of the header files set(headers cgnslib.h cgns_io.h cgnswin_f.h ${CMAKE_CURRENT_BINARY_DIR}/cgnsconfig.h ${CMAKE_CURRENT_BINARY_DIR}/cgnstypes.h ${CMAKE_CURRENT_BINARY_DIR}/cgnstypes_f.h ${CMAKE_CURRENT_BINARY_DIR}/cgnstypes_f03.h ${CMAKE_CURRENT_BINARY_DIR}/cgnsBuild.defs) if (CGNS_ENABLE_FORTRAN) if(DEFINED CMAKE_Fortran_MODULE_DIRECTORY) list(APPEND headers ${CMAKE_Fortran_MODULE_DIRECTORY}/cgns.mod) else() list(APPEND headers $/cgns.mod) endif() endif () if (CGNS_ENABLE_PARALLEL) list(APPEND headers pcgnslib.h) endif () if (CGNS_ENABLE_LEGACY) list(APPEND headers adf/ADF.h) if (CGNS_ENABLE_HDF5) list(APPEND headers adfh/ADFH.h) endif () endif () # Set the install path of the header files install(FILES ${headers} DESTINATION include) #if (NOT CGNS_EXTERNALLY_CONFIGURE) include(CMakePackageConfigHelpers) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/cgns-config-version.cmake VERSION ${CGNS_VERSION} COMPATIBILITY SameMajorVersion ) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cgns-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cgns-config.cmake INSTALL_DESTINATION lib/cmake/cgns ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cgns-config-version.cmake ${CMAKE_CURRENT_BINARY_DIR}/cgns-config.cmake DESTINATION lib/cmake/cgns) install(EXPORT cgns-targets FILE cgns-targets.cmake NAMESPACE CGNS:: DESTINATION lib/cmake/cgns ) #endif() ######### # Tools # ######### add_subdirectory(tools) ######### # Tests # ######### if (CGNS_ENABLE_TESTS) add_subdirectory(tests) add_subdirectory(Test_UserGuideCode/C_code) if (CGNS_ENABLE_FORTRAN) add_subdirectory(Test_UserGuideCode/Fortran_code) endif () if (CGNS_ENABLE_PARALLEL) add_subdirectory(ptests) add_subdirectory(Test_UserGuideCode/C_code_parallel) endif () endif () ############## # CGNS Tools # ############## set(CGNS_BUILD_CGNSTOOLS "OFF" CACHE BOOL "Build the CGNSTools package") if(CGNS_BUILD_CGNSTOOLS) add_subdirectory(cgnstools) endif() CGNS-4.5.0/src/LICENSE000066400000000000000000000026461474000356600140630ustar00rootroot00000000000000The distribution and use of the CGNS software is covered by the following license: ----------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ----------------------------------------------------------------------- This license is borrowed from the zlib/libpng License: http://www.opensource.org/licenses/zlib-license.php and supersedes the GNU Lesser General Public License (LGPL) which previously governed the use and distribution of the software. For details on the policy governing the distribution of the CGNS standard and software see: http://www.grc.nasa.gov/www/cgns/charter/principles.html CGNS-4.5.0/src/Makefile.in000066400000000000000000000160131474000356600151140ustar00rootroot00000000000000# makefile for the CGNS Library include make.defs CGNSVER = @CGNSVERS@ .SUFFIXES : .SUFFIXES : .c .F90 .$(O) $(EXE) OBJDIR = @BUILDDIR@ COPTS = $(CFLAGS) $(CFGFLAGS) -I. @BUILDOPTS@ FOPTS = $(FFLAGS) -I. @BUILDOPTS@ D_PRE = @FC_D_PRE@ CGNSLIB = $(LIBCGNS) INSTLIB = @CGNSLIB@ # Prepend to "-D" if necessary (xlf compilers) FOPTS_MOD=$(subst -D,$(D_PRE)-D,$(FOPTS)) #---------- CGNSOBJS=\ $(OBJDIR)/cgns_error.$(O) \ $(OBJDIR)/cg_hashmap.$(O) \ $(OBJDIR)/cgns_internals.$(O) \ $(OBJDIR)/cgns_io.$(O) \ $(OBJDIR)/cgnslib.$(O) # ADF/ADFH routines ADFOBJS=@ADFOBJS@ \ $(OBJDIR)/ADF_interface.$(O) \ $(OBJDIR)/ADF_internals.$(O) # Fortran interface routines @FGNSOBJS@=$(OBJDIR)/cgns_f.$(O) @F2COBJS@=$(OBJDIR)/cg_ftoc.$(O) $(OBJDIR)/cgio_ftoc.$(O) #---------- FORTRAN_TESTS= ifeq ("$(BUILDFORTRAN)" , "1") FORTRAN_TESTS=cd examples/fortran && $(MAKE) test && cd ../../Test_UserGuideCode/Fortran_code && $(MAKE) test endif MakeTests = runtests @PTESTS@ all : $(CGNSLIB) tools @CGNSTOOLS@ cgns : $(CGNSLIB) test : $(MakeTests) check : $(MakeTests) install : install-cgns @INSTALLCGNSTOOLS@ #---------- $(CGNSLIB) : $(OBJDIR) $(CGNSOBJS) $(FGNSOBJS) $(ADFOBJS) $(F2COBJS) -@$(RM) $@ @AR_LIB@ $@ $(CGNSOBJS) $(FGNSOBJS) $(ADFOBJS) $(F2COBJS) @RAN_LIB@ $@ $(OBJDIR) : -$(MKDIR) $(OBJDIR) #---------- tools : $(CGNSLIB) cd tools && $(MAKE) cgnstools : $(CGNSLIB) cd cgnstools && $(MAKE) tests : $(CGNSLIB) cd tests && $(MAKE) ptests : $(CGNSLIB) cd ptests && $(MAKE) runtests : $(CGNSLIB) cd tests && $(MAKE) test cd Test_UserGuideCode/C_code && $(MAKE) test $(FORTRAN_TESTS) runptests : $(CGNSLIB) cd ptests && $(MAKE) test cd Test_UserGuideCode/C_code_parallel && $(MAKE) test #---------- clean : -$(RM) $(OBJDIR)/*.$(O) -cd tools && $(MAKE) clean -cd tests && $(MAKE) clean -cd examples/fortran && $(MAKE) clean -cd Test_UserGuideCode/C_code && $(MAKE) clean -cd Test_UserGuideCode/Fortran_code && $(MAKE) clean -cd ptests && $(MAKE) clean -cd cgnstools && $(MAKE) clean allclean : distclean distclean : -cd tools && $(MAKE) allclean -$(RM) tools/Makefile -cd tests && $(MAKE) allclean -cd examples/fortran && $(MAKE) clean -cd Test_UserGuideCode/C_code && $(MAKE) clean -cd Test_UserGuideCode/Fortran_code && $(MAKE) clean -$(RM) tests/Makefile -cd ptests && $(MAKE) allclean -$(RM) ptests/Makefile -cd cgnstools && $(MAKE) allclean -$(RM) $(CGNSLIB) -$(RM) $(OBJDIR)/*.$(O) -$(RMDIR) $(OBJDIR) -$(RM) cgnsconfig.h cgnstypes.h cgnstypes_f.h cgnstypes_f03.h -$(RM) config.log config.status -$(RM) make.defs cgnsBuild.defs Makefile -$(RM) *~ *.bak *.mod install-all : install install-cgns : $(CGNSLIB) $(INCLUDEDIR) $(LIBDIR) @INSTALLPCGNS@ @INSTALLADF@ $(INSTALL_DATA) cgnstypes.h $(INCLUDEDIR)/cgnstypes.h $(INSTALL_DATA) cgnstypes_f.h $(INCLUDEDIR)/cgnstypes_f.h $(INSTALL_DATA) cgnstypes_f03.h $(INCLUDEDIR)/cgnstypes_f03.h $(INSTALL_DATA) cgnslib.h $(INCLUDEDIR)/cgnslib.h $(INSTALL_DATA) cgnswin_f.h $(INCLUDEDIR)/cgnswin_f.h $(INSTALL_DATA) cgns_io.h $(INCLUDEDIR)/cgns_io.h $(INSTALL_DATA) cgnsconfig.h $(INCLUDEDIR)/cgnsconfig.h $(INSTALL_DATA) cgnsBuild.defs $(INCLUDEDIR)/cgnsBuild.defs $(INSTALL_DATA) $(CGNSLIB) $(LIBDIR)/$(INSTLIB) @if test -f cgns.mod; then \ $(INSTALL_DATA) cgns.mod $(INCLUDEDIR)/cgns.mod; \ fi install-tools : -cd tools && $(MAKE) install install-cgnstools : install-tools -cd cgnstools && $(MAKE) install install-adf : $(INCLUDEDIR)/adf $(INSTALL_DATA) adf/ADF.h $(INCLUDEDIR)/adf/ADF.h install-adfh : $(INCLUDEDIR)/adfh $(INSTALL_DATA) adfh/ADFH.h $(INCLUDEDIR)/adfh/ADFH.h install-pcgns : $(INCLUDEDIR) $(INSTALL_DATA) pcgnslib.h $(INCLUDEDIR)/pcgnslib.h $(INCLUDEDIR) : @if [ ! -d $(INCLUDEDIR) ] ; then \ echo "Making directory $(INCLUDEDIR)"; \ mkdir -p $(INCLUDEDIR); \ chmod 755 $(INCLUDEDIR); \ fi; $(LIBDIR) : @if [ ! -d $(LIBDIR) ] ; then \ echo "Making directory $(LIBDIR)"; \ mkdir -p $(LIBDIR); \ chmod 755 $(LIBDIR); \ fi; $(INCLUDEDIR)/adf : $(INCLUDEDIR) @if [ ! -d $(INCLUDEDIR)/adf ] ; then \ echo "Making directory $(INCLUDEDIR)/adf"; \ mkdir -p $(INCLUDEDIR)/adf; \ chmod 755 $(INCLUDEDIR)/adf; \ fi; $(INCLUDEDIR)/adfh : $(INCLUDEDIR) @if [ ! -d $(INCLUDEDIR)/adfh ] ; then \ echo "Making directory $(INCLUDEDIR)/adfh"; \ mkdir -p $(INCLUDEDIR)/adfh; \ chmod 755 $(INCLUDEDIR)/adfh; \ fi; uninstall : -cd tools && $(MAKE) uninstall -cd cgnstools && $(MAKE) uninstall -$(RM) $(INCLUDEDIR)/cgnstypes.h -$(RM) $(INCLUDEDIR)/cgnstypes_f.h -$(RM) $(INCLUDEDIR)/cgnslib.h -$(RM) $(INCLUDEDIR)/cgnswin_f.h -$(RM) $(INCLUDEDIR)/cgns_io.h -$(RM) $(INCLUDEDIR)/cgnsconfig.h -$(RM) $(INCLUDEDIR)/cgnsBuild.defs @if [ -f $(INCLUDEDIR)/cgns.mod ] ; then \ $(RM) $(INCLUDEDIR)/cgns.mod \ fi; -$(RM) $(INCLUDEDIR)/cgns.mod -$(RM) $(LIBDIR)/$(INSTLIB) @if [ -f $(INCLUDEDIR)/adf/ADF.h ] ; then \ $(RM) $(INCLUDEDIR)/adf/ADF.h; \ $(RMDIR) $(INCLUDEDIR)/adf; \ fi; \ if [ -f $(INCLUDEDIR)/adfh/ADFH.h ] ; then \ $(RM) $(INCLUDEDIR)/adfh/ADFH.h; \ $(RMDIR) $(INCLUDEDIR)/adfh; \ fi; \ if [ -f $(INCLUDEDIR)/pcgnslib.h ] ; then \ $(RM) $(INCLUDEDIR)/pcgnslib.h; \ fi; #---------- mid-level library $(OBJDIR)/cgns_error.$(O) : cgns_error.c cgnslib.h cgns_header.h cgns_io.h $(CC) $(COPTS) $(COOUT)$@ -c cgns_error.c $(OBJDIR)/cg_hashmap.$(O) : cg_hashmap.c cg_hashmap.h cg_hash_types.h $(CC) $(COPTS) $(HDF5INC) $(COOUT)$@ -c cg_hashmap.c $(OBJDIR)/cgns_internals.$(O) : cgns_internals.c cg_hashmap.h cgnslib.h cgns_header.h \ cgns_io.h $(CC) $(COPTS) $(HDF5INC) $(COOUT)$@ -c cgns_internals.c $(OBJDIR)/cgnslib.$(O) : cgnslib.c cgnslib.h cgns_header.h cgns_io.h cg_hashmap.h $(CC) $(COPTS) $(HDF5INC) $(MPIINC) $(COOUT)$@ -c cgnslib.c $(OBJDIR)/cgns_io.$(O) : cgns_io.c cgnslib.h cgns_io.h \ adf/ADF.h @ADFINCS@ $(CC) $(COPTS) $(HDF5INC) $(COOUT)$@ -c cgns_io.c $(OBJDIR)/cg_ftoc.$(O) : cg_ftoc.c fortran_macros.h cgnslib.h \ cgns_header.h cgns_io.h $(CC) $(COPTS) $(HDF5INC) $(F2CFLAGS) $(COOUT)$@ -c cg_ftoc.c $(OBJDIR)/cgio_ftoc.$(O) : cgio_ftoc.c fortran_macros.h cgns_io.h $(CC) $(COPTS) $(HDF5INC) $(F2CFLAGS) $(COOUT)$@ -c cgio_ftoc.c $(OBJDIR)/cg_malloc.$(O) : cg_malloc.c cg_malloc.h $(CC) $(COPTS) $(COOUT)$@ -c cg_malloc.c $(OBJDIR)/cgns_f.$(O) : cgns_f.F90 cgnstypes_f.h $(F77) $(FOPTS_MOD) $(COOUT)$@ -c cgns_f.F90 cgnslib.h : cgnstypes.h cgns_header.h : cgnstypes.h cgns_io.h : cgnstypes.h #---------- ADF $(OBJDIR)/ADF_interface.$(O) : adf/ADF_interface.c \ adf/ADF.h adf/ADF_internals.h $(CC) $(COPTS) -Iadf $(COOUT)$@ -c adf/ADF_interface.c $(OBJDIR)/ADF_internals.$(O) : adf/ADF_internals.c \ adf/ADF.h adf/ADF_internals.h $(CC) $(COPTS) -Iadf $(COOUT)$@ -c adf/ADF_internals.c adf/ADF.h : cgnstypes.h adf/ADF_internals.h : cgnstypes.h #---------- HDF5 $(OBJDIR)/ADFH.$(O) : adfh/ADFH.c adfh/ADFH.h $(CC) $(COPTS) -Iadfh $(HDF5INC) $(MPIINC) $(COOUT)$@ -c adfh/ADFH.c adfh/ADFH.h : cgnstypes.h #---------- PCGNS $(OBJDIR)/pcgnslib.$(O) : pcgnslib.c pcgnslib.h $(CC) $(COPTS) $(HDF5INC) $(MPIINC) $(COOUT)$@ -c pcgnslib.c pcgnslib.h : cgnslib.h CGNS-4.5.0/src/README.config000066400000000000000000000223441474000356600151770ustar00rootroot00000000000000================================================================= To compile the CGNS library under Unix, Linux, Cygwin, Mac, .etc: ================================================================= chmod +x configure ./configure [options] make [target] The arguments in [] are optional, and if given should be specified without the []. The recognized options to configure are: ***** basic options ***** --enable-gcc Normally, the configure script will search for the native C compiler (cc) before trying to find gcc. This option reverses this order. --enable-debug[=OPTS] This enables a debug version of the library. Normally, this just sets the -g option for compiling, and prevents stripping the library and executables. If 'OPTS' is given, this is taken as the compile options to be used instead. i.e. --enable-debug=-g gives the default. --with-system=XXX overrides the default system type (see below) and sets the system type to 'XXX'. If not given, the system type will be determined from the 'cgsystem' script. --enable-legacy build the code using legacy settings. Defines cgsize_t as int and turns of enumeration value scoping (CGNS_ENUM in cgnslib.h) --enable-scope enables scoping of all enumeration values in cgnslib.h by prefixing them with a CG_. For example, ZoneType_t becomes CG_ZoneType_t and Structured becomes CG_Structured. --enable-64bit This option turns on 64-bit compilation, where applicable. If legacy is turned off, then cgsize_t will be a 64-bit integer typedef, otherwise it will be typedef'd as an int. --enable-lfs This enables large file support (files larger than 2 Gb), where applicable. Your kernel must also be capable of LFS for this to make a difference. --with-fortran[=F2C] By default the Fortran interface is enabled, and the configure script tries to determine the proper Fortran to C interface. If you specify --without-fortran or --with-fortran=no, the Fortran interface will not be built. To change the Fortran to C interface, specify 'F2C' as one of LOWERCASE, LOWERCASE_, LOWERCASE__, UPPERCASE, UPPERCASE_, or UPPERCASE__. *** NOTE *** If you are using g77, and want to use the compiler without the -fno-second-underscore flag, then use --with-fortran=LOWERCASE__. This should work fine with the MLL routines, but you will NOT be able to use the ADF routines, since you will get unresolved external references when you try to link. The reason is that g77 appends 2 underscores to names which have an underscore in them (the cg_* routines), but only 1 underscore to names that don't (the adf* routines). I don't know why - but that what's happening (at least with my version of g77). You may play around with the test case in the f2c subdirectory and see if you can come up with a solution - if so, let me know. ************ --enable-shared[=all] This enables the building of a shared library. Currently, only Linux, HP, SGI and SUN OS's are supported. If you specify --enable-shared=all, then the script will also attempt to use shared libraries for HDF5, zlib, and sziplib if HDF5 support is being built. ***** HDF5 options ***** --with-hdf5[=DIR] This enables the CGNS interface to HDF5. If 'DIR' is specified, then it should be the top-level directory of the HDF5 distribution. If not given, the script will check if HDF5 is installed and use that. If not installed, then the script will search for a local distribution. --with-zlib[=LIB] This specifies that zlib is to be used with HDF5. This is only needed if HDF5 was built with zlib support. If 'LIB' is given,it should be the pathname to the zlib library. If not given, the script will check for first an installed version, and then a local distribution. --with-szip[=LIB] This specifies that szip is to be used with HDF5. This is only needed if HDF5 was built with szip support. If 'LIB' is given,it should be the pathname to the szip library. If not given, the script will check for first an installed version, and then a local distribution. ***** cgnstools options ***** --enable-cgnstools This enables the building of CGNStools. If built, a Tcl/Tk installation is required. --with-tcl=TCLdir --with-tk=TKdir This sets the path to the Tcl and/or Tk source distribution. If not given, 'configure' will try first to find an installed version to use, then locally for a source distribution. If only one of these are given, the other will be set from that value. For example: "--with-tcl=$HOME/tcl8.3.1" will automatically set "--with-tk=$HOME/tk8.3.1". The "tkConfig.sh" file from either the installed or source distribution version is used to set the link options to be used in linking the cgiowish, plotwish, and calcwish executable. --disable-cut This sets the NO_CUTTING_PLANE compiler flag to disable a cutting plane is cgnsplot. A cutting plane results in more memory being used by the program since the entire volume mesh is saved rather than just the boundary mesh. --disable-mesh This sets the NO_MESH_BOUNDARIES compiler flag to disable the generation of imin,imax,jmin,jmax,kmin and kmax boundary regions for structured zones. ***** installation options ***** --prefix=PREFIX --exec_prefix=EPREFIX --libdir=LIBDIR --includedir=INCLUDEDIR These set the installation directories for the CGNS library, headers and modules. By default, the library will be installed as: /usr/local/lib/libcgns.a and the headers as: /usr/local/include/cgnslib.h /usr/local/include/cgnswin_f.h and the modules as: /usr/local/include/cgns.mod See the autoconf documentation for a description of these options, or run './configure --help' for a brief overview. Use absolute paths or shell environment variables when specifying a directory, since the 'configure' is interpreted by 'sh' not 'csh'. i.e: use --prefix=$HOME instead of --prefix=~ . In addition to creating the required Makefiles, the configure script will create the file 'make.defs', which contains all the system specific information for building the library. If problems are encountered, this is the file to edit. Make will build put all the object modules in the subdirectory 'lib' along with the CGNS library. The main make targets are: all This is the default target (if target is not given). This builds the CGNS library, the executables in the 'tools' subdirectory, and CGNStools if the --enable-cgnstools option to the script was given. cgns Builds just the CGNS library test Builds and runs the executables in the 'tests' subdirectory install Installs the CGNS library and header files. If the --enable-cgnstools option was given, this will also install the executables in the 'tools' subdirectory and CGNStools. You will need write permission to the installation directories. clean This removes all the object files. The library is not affected. allclean distclean Removes the object files, library and files generated by 'configure' and any generated,object or executable files in the subdirectories uninstall Uninstalls the library and headers and CGNStools if installed. You will need write permission to the installation directories. Additional targets: tools builds the code in the tools subdirectory tests builds the code in the tests subdirectory cgnstools builds the code in the cgnstools subdirectory install-cgns Installs library and headers install-tools Installs the executables in the 'tools' subdirectory install-cgnstools Installs CGNStools ---------------------------------------------------------------------- The system type is determined by executing the 'cgsystem' script. ./cgsystem [[-][enable-]64[bit]] [[-]cur[rent]] [[-]conf[igure]] Again, everything in [] are optional, and the [] are not included. If no arguments are given, then 'cgsystem' returns the default system type. The '[-][enable-]64[bit]' option enables 64-bit as for the 'configure' script. The '[-]cur[rent]' option returns the current system type, which is that defined in 'make.system', and the '[-]conf[igure]' option will update the 'make.system' file. Currently defined system types are: ALPHA DEC Alpha/OSF APOLLO HP 300 running Domain/OS BSD386 80[345]86 running BSD BSDM68K Motorola 68K running NetBSD BSDMIPS Mips running NetBSD CONVEX Convex CRAY Cray, Cray-2, Cray XMP CYGWIN POSIX emulation on top of Windows DARWIN Macintosh running Darwin DEC DEC FREEBSD FreeBSD HPPA HP 9000 PA-Risc HPPA10 HP 9000 PA-Risc running OS 10.x HPPA11 HP 9000 PA-Risc running OS 11.x (32-bit) HPPA64 HP 9000 PA-Risc running OS 11.x (64-bit) HPIT HP with 64-bit Intel processor (32-bit) HPIT64 HP with 64-bit Intel processor (64-bit) HP HP I860 Intel Hypercube IBM IBM running AIX IBM64 IBM with AIX 4.3 or above (64-bit) LINUX Linux LINUX64 64-bit Linux M88K Motorola M88100 running Real/IX MACOSX Power Macintosh running OSx NETBSD NetBSD not defined elseware NEXT NeXT OS2 OS/2 PGON Intel Paragon SGI5 Silicon Graphics running OS 5.x SGI6 Silicon Graphics running OS 6.x SGI64 Silicon Graphics (64-bit) SGI Silicon Graphics SUN3 Sun 3 SUN4 Sun 4, 4c, sparc, .etc SUN64 Sun 4 (64-bit) SUN Sun VAX DEC/Microvax UNKNOWN couldn't determine system type Executing './cgsystem [-]help', will display the above information. CGNS-4.5.0/src/SampleScripts/000077500000000000000000000000001474000356600156375ustar00rootroot00000000000000CGNS-4.5.0/src/SampleScripts/CRAY_BlueWaters/000077500000000000000000000000001474000356600205325ustar00rootroot00000000000000CGNS-4.5.0/src/SampleScripts/CRAY_BlueWaters/build_cgns000077500000000000000000000022661474000356600225770ustar00rootroot00000000000000#!/bin/csh # ___ __ _ __ __ # / _ )/ /_ _____ | | /| / /__ _/ /____ _______ # / _ / / // / -_) | |/ |/ / _ `/ __/ -_) __(_-< #/____/_/\_,_/\__/ |__/|__/\_,_/\__/\__/_/ /___/ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # Build script for CGNS on Blue Waters (Cray XE/XK) # using cray compilers. # NCSA, University of Illinois Urbana-Champaign # Note: I created a bin directory which contains # mpi links (mpif90, mpicc) to the system compilers # since configure expects only those names (need to fix # this in configure) module swap cce cce/8.3.9 module unload cray-libsci atp module load xpmem dmapp ugni udreg module swap cray-mpich/7.0.3 cray-mpich/7.1.3 module list # use the system zlib set ZLIB=/usr/lib64 # location of the installed HDF5 library set HDF5=$HOME/packages/phdf5_trunk_cray setenv LD_LIBRARY_PATH "$ZLIB" setenv CFLAGS "-O3 " setenv CC "cc" setenv FC "ftn" setenv F77 "ftn" setenv FFLAGS "-O3 " setenv FLIBS "-lz -ldl -I../lib" setenv CLIBS "-lz" setenv LIBS "-lz -ldl" ./configure --verbose \ --enable-parallel \ --with-fortran \ --with-hdf5=$HDF5 \ --with-mpi=$HOME/bin \ --enable-64bit \ --enable-lfs \ --disable-cgnstools \ --disable-x CGNS-4.5.0/src/SampleScripts/IBM_BlueGene_xl/000077500000000000000000000000001474000356600205175ustar00rootroot00000000000000CGNS-4.5.0/src/SampleScripts/IBM_BlueGene_xl/README.txt000066400000000000000000000025731474000356600222240ustar00rootroot00000000000000This example assumes all the needed packages are in ${HOME}/packages and the all the scripts are placed in ${HOME}/packages. NOTE (1): If the system already has HDF5 installed then you can use it instead, as long as it was build with --enable-parallel. (1) Building zlib from source: Download and extract the zlib source: http://www.zlib.net/ (a) cd into the top level zlib source directory. (b) modify and run the script: ../build_zlib (2) Building hdf5 from source: (a) From the top level of the hdf5 library, change the ${HOME}/packages to where zlib was installed in STEP 1. ../build_hdf5 --without-pthread --disable-shared --enable-parallel --enable-production \ --enable-fortran --enable-fortran2003 \ --disable-stream-vfd --disable-direct-vfd \ --with-zlib=${HOME}/packages/zlib-1.2.8/lib --prefix=${HOME}/packages/phdf5-trunk where prefix is set for where the hdf5 library will get installed. There should be no need to modify in the script. (3) Building cgns from source: (a) cd into the cgns/src directory (b) modify and run: /build_cgns (c) make (d) To make the tests: cd ptests make (4) IMPORTANT PARAMETERS FOR GOOD PERFORMANCE (i) The environment variable BGLOCKLESSMPIO_F_TYPE=0x47504653 should be set. * Set using qsub --env BGLOCKLESSMPIO_F_TYPE=0x47504653 (ii) does CGNS_FILETYPE need to be set ???? CGNS-4.5.0/src/SampleScripts/IBM_BlueGene_xl/build_cgns000077500000000000000000000012401474000356600225530ustar00rootroot00000000000000#!/bin/tcsh set HDF5=$HOME/packages/phdf5-1_8 setenv LD_LIBRARY_PATH "HOME/packages/zlib-1.2.8/lib" setenv CFLAGS "-O2 " setenv CC "mpixlc" setenv FC "mpixlf2003" setenv F77 "mpixlf2003" setenv FFLAGS "-O2 " setenv LDFLAGS "-I$HOME/packages/zlib-1.2.8/lib/include" setenv FLIBS "-L$HOME/packages/zlib-1.2.8/lib/lib -lz" setenv CLIBS "-I$HOME/packages/zlib-1.2.8/lib/include -L$HOME/packages/zlib-1.2.8/lib/lib -lz" ./configure --verbose \ --enable-parallel \ --with-fortran \ --with-hdf5=$HDF5 \ --with-mpi="/soft/compilers/wrappers/xl" \ --with-zlib="$HOME/packages/zlib-1.2.8/lib" \ --enable-64bit \ --enable-lfs \ --disable-cgnstools \ --disable-x # --enable-debug CGNS-4.5.0/src/SampleScripts/IBM_BlueGene_xl/build_hdf5000077500000000000000000000143751474000356600224640ustar00rootroot00000000000000#!/bin/sh # Do the HDF5 library configure, make, and tests for Blue Gene/P # Usage: bgmakeh5 USAGE() { cat <> "$resultfile" 2>&1 if [ $? -ne 0 ]; then echo "error in '$banner'. makeh5 aborted." exit 1 fi } # Main body # Setup exit steps and print starting time trap TIMESTAMP 0 TIMESTAMP # Make sure we are at the library root level # by checking couple typical files. Not bullet-proof. if [ ! \( -d $SRCDIR/src -a -d $SRCDIR/config -a -f $SRCDIR/configure \) ] then echo "Could not find the source dir or configure script. Abort." exit 1 fi # no configure if already done. if [ ! -f config.status ]; then echo "$CONFIGURE $@ ..." (TIMESTAMP; nerror=0; $CONFIGURE $@ < /dev/null || nerror=1; TIMESTAMP; exit $nerror) > '#config' 2>&1 if [ $? -ne 0 ]; then echo "error in Configure. Aborted." exit 1 fi else echo configure.status already exists. Skip configure. fi # need to edit the src/H5pubconf.h file. # fork() compile okay but does not exec. xfile=src/H5pubconf.h for macro in H5_HAVE_FORK; do echo comment out $macro from $xfile ed -s $xfile <> '#make' 2>&1 # Compile the library # Okay to use parallel gmake for compiling gmake -i -j 8 >> '#make' 2>&1 gmake -i install #test_log="#test.$$" # Do make check #env HDF5_Make_Ignore=yes gmake check > $test_log 2>&1 #if grep FAILED $test_log; then # echo "***FAILED detected in " $test_log #fi CGNS-4.5.0/src/SampleScripts/IBM_BlueGene_xl/build_zlib000077500000000000000000000002511474000356600225620ustar00rootroot00000000000000#!/bin/tcsh setenv CC mpixlc setenv CFLAGS "-O3 -qsimd=auto -qhot=level=1 -qprefetch -qunroll=yes" ./configure --prefix=$PROJECTS_DIR/zlib-1.2.8/lib make make install CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/000077500000000000000000000000001474000356600200675ustar00rootroot00000000000000CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/Intel/000077500000000000000000000000001474000356600211425ustar00rootroot00000000000000CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/Intel/README.txt000066400000000000000000000036761474000356600226540ustar00rootroot000000000000002.2 Building on SGI (Lustre) 0. Module Enviromnment: 1) comp-intel/2015.0.090 2) mpi-intel/5.0.1.035 (mpi-sgi/mpt.2.11r13 generates strange error messages at run time) 1. Building zlib from source: Download and extract the zlib source: http://www.zlib.net/ (a) cd into the top level zlib source directory. (b) modify and run the script: ../build_zlib (c) Note: if you get errors in steps 2 or 3 below because it cannot find the zlib.h or zlib.a files, it may be necessary to do the following: cd $HOME/packages/zlib-1.2.8 ln -s lib/include/zlib.h . ln -s lib/lib/libz.a . 2. Building hdf5 from source (version 1.8.14) (a) From the top level of the hdf5 library, change the ${HOME}/packages to where zlib was installed in STEP 1. (b) ../build_hdf5 3. Building cgns from source: Note before compiling: CGNS expects the compilers to be mpicc and mpif90. Therefore, create a directory 'bin' in your home directory and add symbolic links to the mpi/intel wrappers: mpicc -> /nasa/intel/impi/5.0.1.035/bin64/mpiicc* mpif90 -> /nasa/intel/impi/5.0.1.035/bin64/mpiifort* The script will point to these symbolic links. (a) cd into the cgns/src directory (b) modify and run: /build_cgns (need to point to your own bin directory as noted above) (c) make (d) To make the tests: cd ptests; make 4. Running: (a) tests need to be submitted as a job; see, e.g.: run_cgns.sh 5. IMPORTANT PARAMETERS FOR GOOD PERFORMANCE (a) The Lustre parameters have not been fully tested. (b) It is best to create a directory with the lustre file parameters, for example: On Pleiades, cd to /nobackupp8/: mkdir 2M lfs setstripe -c 64 -s 2m 2M Then run in subdirectory 2M, using example submit script run_cgns.sh (appropriately modified) This will use a count of 64 and a strip size of 2M, which has shown good performance. CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/Intel/build_cgns000077500000000000000000000015771474000356600232130ustar00rootroot00000000000000#!/bin/csh set HDF5=$HOME/packages/phdf5-1_8_14 setenv LD_LIBRARY_PATH "$HOME/packages/zlib-1.2.8/lib" setenv CFLAGS "-O2 " #setenv CC "mpicc" #setenv FC "mpif90" #setenv F77 "mpif90" setenv CC "/nasa/intel/impi/5.0.1.035/bin64/mpiicc" setenv FC "/nasa/intel/impi/5.0.1.035/bin64/mpiifort" setenv F77 "/nasa/intel/impi/5.0.1.035/bin64/mpiifort" setenv FFLAGS "-O2 " setenv LDFLAGS "-I$HOME/packages/zlib-1.2.8/lib/include" setenv FLIBS "-lmpi -L$HOME/packages/zlib-1.2.8/lib/lib -lz" setenv CLIBS "-lmpi -I$HOME/packages/zlib-1.2.8/lib/include -L$HOME/packages/zlib-1.2.8/lib/lib -lz" ./configure --verbose \ --enable-parallel \ --with-fortran \ --with-hdf5=$HDF5 \ --with-mpi="/home1/mbreiten/bin" \ --with-zlib="$LD_LIBRARY_PATH" \ --enable-64bit \ --enable-lfs \ --disable-cgnstools \ --disable-x # --enable-debug # --enable-64bit \ # --with-mpi="/nasa/intel/impi/5.0.1.035/intel64/bin/" \ CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/Intel/build_hdf5000077500000000000000000000007111474000356600230740ustar00rootroot00000000000000#!/bin/csh #setenv CC mpicc #setenv FC mpif90 setenv CC /nasa/intel/impi/5.0.1.035/bin64/mpiicc setenv FC /nasa/intel/impi/5.0.1.035/bin64/mpiifort setenv CFLAGS "-O3" setenv FCFLAGS "-O3" ./configure --without-pthread --disable-shared --enable-parallel --enable-production --enable-fortran --enable-fortran2003 --disable-stream-vfd --disable-direct-vfd --with-zlib=${HOME}/packages/zlib-1.2.8/lib --prefix=${HOME}/packages/phdf5-1_8_14 make make install CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/Intel/build_zlib000077500000000000000000000002311474000356600232030ustar00rootroot00000000000000#!/bin/csh setenv CC /nasa/intel/impi/5.0.1.035/bin64/mpiicc setenv CFLAGS "-O2 " ./configure --prefix=$HOME/packages/zlib-1.2.8/lib make make install CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/Intel/run_cgns.sh000077500000000000000000000011441474000356600233170ustar00rootroot00000000000000#PBS -S /bin/csh #PBS -l select=4:ncpus=16:mpiprocs=16:model=san #PBS -l walltime=01:00:00 #PBS -j oe #PBS -q debug #PBS -W group_list=a1519 module purge module load comp-intel/2015.0.090 module load mpi-intel/5.0.1.035 # By default, PBS executes your job from your home directory. # However, you can use the environment variable # PBS_O_WORKDIR to change to the directory where # you submitted your job. cd $PBS_O_WORKDIR #mpiexec_mpt ./benchmark_hdf5 /nasa/intel/impi/5.0.1.035/bin64/mpiexec.hydra -env I_MPI_EXTRA_FILESYSTEM on -env I_MPI_EXTRA_FILESYSTEM_LIST lustre ./benchmark_hdf5 # -end of script- CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/README.txt000066400000000000000000000021231474000356600215630ustar00rootroot000000000000002.2 Building on SGI (Lustre) 1. Building zlib from source: Download and extract the zlib source: http://www.zlib.net/ (a) cd into the top level zlib source directory. (b) modify and run the script: ../build_zlib (c) Note: if you get errors in steps 2 or 3 below because it cannot find the zlib.h or zlib.a files, it may be necessary to do the following: cd $HOME/packages/zlib-1.2.8 ln -s lib/include/zlib.h . ln -s lib/lib/libz.a . 2. Building hdf5 from source (a) From the top level of the hdf5 library, change the ${HOME}/packages to where zlib was installed in STEP 1. (b) ../build_hdf5 3. Building cgns from source: (a) cd into the cgns/src directory (b) modify and run: /build_cgns (c) make (d) To make the tests: cd ptests; make 4. Running: (a) tests need to be submitted as a job; see, e.g.: run_cgns.sh 5. IMPORTANT PARAMETERS FOR GOOD PERFORMANCE (a) The Lustre parameters have not been fully tested. (b) On Pleiades, lfs setstripe -c 64 -s 0 /nobackupp8/

, has shown good performance. CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/build_cgns000077500000000000000000000012021474000356600221210ustar00rootroot00000000000000#!/bin/csh set HDF5=$HOME/packages/phdf5-1_8 setenv LD_LIBRARY_PATH "$HOME/packages/zlib-1.2.8/lib:/nasa/sgi/mpt/2.12r26/lib" setenv CFLAGS "-O2 " setenv CC "mpicc" setenv FC "mpif90" setenv F77 "mpif90" setenv FFLAGS "-O2 " setenv FLIBS "-lmpi -L$HOME/packages/zlib-1.2.8/lib/lib -lz" setenv CLIBS "-lmpi -I$HOME/packages/zlib-1.2.8/lib/include -L$HOME/packages/zlib-1.2.8/lib/lib -lz" ./configure --verbose \ --prefix="$HOME/scratch/cgns_1_8" \ --enable-parallel \ --with-fortran \ --with-hdf5=$HDF5 \ --with-mpi="/nasa/sgi/mpt/2.12r26" \ --with-zlib="$HOME/packages/zlib-1.2.8/lib" \ --enable-64bit \ --enable-lfs \ --disable-cgnstools CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/build_hdf5000077500000000000000000000011661474000356600220260ustar00rootroot00000000000000#!/bin/csh # modules loaded (Pleiades) # # module load comp-intel/2016.2.181 # module load mpi-sgi/mpt.2.12r26 setenv CC mpicc setenv FC mpif90 setenv CFLAGS "-O3" setenv FCFLAGS "-O3" grep -q "1.10" ./configure.ac if ( $? == 0 ) then set CONFIG_OPT = "--enable-build-mode=production --enable-fortran" set VERS = "1_10" else set CONFIG_OPT = "--enable-production --enable-fortran --enable-fortran2003" set VERS = "1_8" endif ./configure --without-pthread --disable-shared --enable-parallel $CONFIG_OPT --disable-direct-vfd --with-zlib=$HOME/packages/zlib-1.2.8/lib --prefix=$HOME/packages/phdf5-$VERS make make install CGNS-4.5.0/src/SampleScripts/SGI_Pleiades/build_zlib000077500000000000000000000001661474000356600221370ustar00rootroot00000000000000#!/bin/csh setenv CC mpicc setenv CFLAGS "-O2 " ./configure --prefix=$HOME/packages/zlib-1.2.8/lib make make installCGNS-4.5.0/src/SampleScripts/SGI_Pleiades/run_cgns.sh000066400000000000000000000007441474000356600222460ustar00rootroot00000000000000#PBS -S /bin/csh #PBS -l select=1024:ncpus=16:mpiprocs=16:model=san #PBS -l walltime=00:15:00 #PBS -j oe #PBS -q low #PBS -W group_list=a1519 module load mpi-sgi/mpt.2.12r26 module load comp-intel/2016.2.181 # By default, PBS executes your job from your home directory. # However, you can use the environment variable # PBS_O_WORKDIR to change to the directory where # you submitted your job. cd $PBS_O_WORKDIR mpiexec_mpt ./benchmark_hdf5 # -end of script- CGNS-4.5.0/src/SampleScripts/cmake.xl.mpich.sh000077500000000000000000000025551474000356600210060ustar00rootroot00000000000000#!/bin/tcsh # # This script uses cmake to build cgns, parallel build, # it should be executed some place other then in the # source directory. # Note: # Does szip support # set to where hdf5 is installed. set HDF5=/mnt/scr1/trunk/hdf5 # set to where the mpi compilers are set MPI=/mnt/hdf/packages/mpich/3.1.3_xl15.1.0/ppc64/bin # set to where the source is located set CGNS=/mnt/scr1/HDF5_Parallel cmake \ -D CMAKE_C_COMPILER:PATH=$MPI/mpicc \ -D CMAKE_Fortran_COMPILER:PATH=$MPI/mpif90 \ $CGNS ccmake \ -D CGNS_BUILD_SHARED:BOOL=OFF \ -D CGNS_USE_SHARED:BOOL=OFF \ -D HDF5_NEED_ZLIB:BOOL=ON \ -D CMAKE_EXE_LINKER_FLAGS:STRING="" \ -D CMAKE_STATIC_LINKER_FLAGS:STRING="" \ -D MPIEXEC:STRING=$MPI/mpiexec \ -D MPI_C_COMPILER:STRING=$MPI/mpicc \ -D MPI_Fortran_COMPILER:STRING=$MPI/mpif90 \ -D CGNS_ENABLE_HDF5:BOOL=ON \ -D CGNS_ENABLE_TESTS:BOOL=ON \ -D CGNS_BUILD_CGNSTOOLS:BOOL=OFF \ -D HDF5_LIBRARY_DIR:PATH=$HDF5/lib \ -D HDF5_LIBRARY:STRING=$HDF5/lib/libhdf5.a \ -D HDF5_INCLUDE_DIR:PATH=$HDF5/include \ -D HDF5_INCLUDE_PATH:PATH=$HDF5/include \ -D HDF5_NEED_MPI:BOOL=ON \ -D CGNS_ENABLE_FORTRAN:BOOL=ON \ -D CGNS_ENABLE_64BIT:BOOL=ON \ -D CMAKE_C_COMPILER:PATH=$MPI/mpicc \ -D CMAKE_Fortran_COMPILER:PATH=$MPI/mpif90 \ -D CGNS_ENABLE_PARALLEL:BOOL=ON \ -D CMAKE_INSTALL_PREFIX:PATH="./" \ . # then do: # make # make install CGNS-4.5.0/src/Test_UserGuideCode/000077500000000000000000000000001474000356600165345ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code/000077500000000000000000000000001474000356600177105ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code/CMakeLists.txt000066400000000000000000000043721474000356600224560ustar00rootroot00000000000000######### # Tests # ######### # Link all the executables to cgns and hdf5 if(CGNS_BUILD_SHARED) set(C_EXAMPLE_LK_LIBS cgns_shared) else() set(C_EXAMPLE_LK_LIBS cgns_static) endif() if (CGNS_ENABLE_HDF5 AND HDF5_LIBRARY) list(APPEND C_EXAMPLE_LK_LIBS ${HDF5_LIBRARY}) if(HDF5_NEED_ZLIB AND ZLIB_LIBRARY) list(APPEND C_EXAMPLE_LK_LIBS ${ZLIB_LIBRARY}) endif() if(HDF5_NEED_SZIP AND SZIP_LIBRARY) list(APPEND C_EXAMPLE_LK_LIBS ${SZIP_LIBRARY}) endif() if(HDF5_NEED_MPI AND MPI_LIBS) list(APPEND C_EXAMPLE_LK_LIBS ${MPI_LIBS}) endif() endif () if (NOT WIN32) list(APPEND C_EXAMPLE_LK_LIBS m) endif () # Set the files needed by each test set (examples write_grid_str write_bc_str write_bcpnts_str write_bcpnts_unst write_con2zn_str write_con2zn_genrl_str write_convergence write_descriptor write_dimensional write_flowcent_str write_flowcentrind_str write_discreteface_str write_floweqn_str write_flowvert_str write_flowvert_unst write_grid2zn_str write_grid_unst write_nondimensional write_timevert_str read_bc_str read_bcpnts_str read_bcpnts_unst read_con2zn_genrl_str read_con2zn_str read_convergence read_descriptor read_dimensional read_flowcent_str read_flowcentrind_str read_discreteface_str read_floweqn_str read_flowvert_str read_flowvert_unst read_grid2zn_str read_grid_str read_grid_unst read_nondimensional read_timevert_str ) # Build each test foreach (example ${examples}) add_executable (${example} ${example}.c) target_link_libraries(${example} PRIVATE ${C_EXAMPLE_LK_LIBS}) endforeach (example ${examples}) # Add the tests so that ctest can find them #if (CGNS_ENABLE_TESTS) # foreach (example ${examples}) # add_test (${example} ${example}) # endforeach (example ${examples}) #endif (CGNS_ENABLE_TESTS) # write_grid_str # write_flowvert_str # write_nondimensional # write_descriptor # write_convergence # write_floweqn_str # write_bcpnts_str # write_grid_unst # write_flowvert_unst # write_dimensional # write_descriptor # write_convergence # write_bcpnts_unst # write_grid_str # write_timevert_str # write_grid_str # write_flowcent_str # write_bc_str # write_grid_str # write_flowcentrind_str # write_discreteface_str # write_grid2zn_str # write_con2zn_str # write_grid2zn_str # write_con2zn_genrl_str CGNS-4.5.0/src/Test_UserGuideCode/C_code/Makefile000066400000000000000000000012331474000356600213470ustar00rootroot00000000000000 DIRS = \ Test_Grid_Str \ Test_Grid_Unstr \ Test_Grid_Str_Timeacc \ Test_Grid_Str_FlowCent \ Test_Grid_Str_FlowCentRind \ Test_Grid_Str_2zn \ Test_Grid_Str_2zngenrl #---------- all : @status=0;for d in $(DIRS) ; do \ cd $$d && $(MAKE); \ status=`expr $$status + $$?`; \ cd ..; \ done;\ if [ $$status -ne 0 ]; then \ exit $$status; \ fi test : $(TESTS) @status=0;for d in $(DIRS) ; do \ cd $$d && $(MAKE); \ status=`expr $$status + $$?`; \ cd ..; \ done;\ if [ $$status -ne 0 ]; then \ exit $$status; \ fi;\ ./test.sh; \ exit $$?; clean : $(CLEAN) -@for d in $(DIRS) ; do \ cd $$d && $(MAKE) clean; \ cd ..; \ done; CGNS-4.5.0/src/Test_UserGuideCode/C_code/README000066400000000000000000000021251474000356600205700ustar00rootroot00000000000000This contains a set of C test cases from UserGuideCode. (modified for use with V3.3) If CGNS is compiled with --enable-64bit, then the created "grid_c.cgns" file will use 64-bit integers as appropriate Currently, the testing (make test) only compares output files of some of the variables written to and read from the grid_c.cgns file. It does not check whether the 64-bit integers were necessarily written as I8 or not. To check this, one could use "cgnsview" to look at the grid_c.cgns file(s) directly. For example, with 64-bit integers, in the cgns file under Test_Grid_Str, the PointList data type under the BC_t nodes (under ZoneBC_t) should be I8 rather than I4. ***** NOTE ***** You will first have to edit the Makefile include to set up your CGNS location and compiler and options Edit 'make.defs' for Linux/Unix Not checked for Windows yet. To just build the code, use make on linux/Unix To build and run the tests, use make test Note: executables, output files, and the resulting CGNS file are put in each Subdirectory/build/ directory To clean everything up, use make clean CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str/000077500000000000000000000000001474000356600224245ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str/Makefile000066400000000000000000000052221474000356600240650ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_str$(EXE) WRITE2 = write_flowvert_str$(EXE) WRITE3 = write_nondimensional$(EXE) WRITE4 = write_descriptor$(EXE) WRITE5 = write_convergence$(EXE) WRITE6 = write_floweqn_str$(EXE) WRITE7 = write_bcpnts_str$(EXE) READ1 = read_grid_str$(EXE) READ2 = read_flowvert_str$(EXE) READ3 = read_nondimensional$(EXE) READ4 = read_descriptor$(EXE) READ5 = read_convergence$(EXE) READ6 = read_floweqn_str$(EXE) READ7 = read_bcpnts_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) $(WRITE3) $(WRITE4) $(WRITE5) $(WRITE6) $(WRITE7) READ_PROGS = $(READ1) $(READ2) $(READ3) $(READ4) $(READ5) $(READ6) $(READ7) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(WRITE3) $(READ3) > $(OUTDIR)/output3 -$(DIFF) OUTPUT3 $(OUTDIR)/output3 $(WRITE4) $(READ4) > $(OUTDIR)/output4 -$(DIFF) OUTPUT4 $(OUTDIR)/output4 $(WRITE4) $(READ4) > $(OUTDIR)/output5 -$(DIFF) OUTPUT5 $(OUTDIR)/output5 $(WRITE6) $(READ6) > $(OUTDIR)/output6 -$(DIFF) OUTPUT6 $(OUTDIR)/output6 $(WRITE7) $(READ7) > $(OUTDIR)/output7 -$(DIFF) OUTPUT7 $(OUTDIR)/output7 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_grid_str.c $(LIBS) $(WRITE2) : ../write_flowvert_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_flowvert_str.c $(LIBS) $(WRITE3) : ../write_nondimensional.c $(CC) $(COPTS) $(FEOUT)$@ ../write_nondimensional.c $(LIBS) $(WRITE4) : ../write_descriptor.c $(CC) $(COPTS) $(FEOUT)$@ ../write_descriptor.c $(LIBS) $(WRITE5) : ../write_convergence.c $(CC) $(COPTS) $(FEOUT)$@ ../write_convergence.c $(LIBS) $(WRITE6) : ../write_floweqn_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_floweqn_str.c $(LIBS) $(WRITE7) : ../write_bcpnts_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_bcpnts_str.c $(LIBS) $(READ1) : ../read_grid_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_grid_str.c $(LIBS) $(READ2) : ../read_flowvert_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_flowvert_str.c $(LIBS) $(READ3) : ../read_nondimensional.c $(CC) $(COPTS) $(FEOUT)$@ ../read_nondimensional.c $(LIBS) $(READ4) : ../read_descriptor.c $(CC) $(COPTS) $(FEOUT)$@ ../read_descriptor.c $(LIBS) $(READ5) : ../read_convergence.c $(CC) $(COPTS) $(FEOUT)$@ ../read_convergence.c $(LIBS) $(READ6) : ../read_floweqn_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_floweqn_str.c $(LIBS) $(READ7) : ../read_bcpnts_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_bcpnts_str.c $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str/OUTPUT1000066400000000000000000000002271474000356600234710ustar00rootroot00000000000000 Successfully read grid from file grid_c.cgns For example, zone 1 x,y,z[8][16][20]= 20.000000, 16.000000, 8.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str/OUTPUT2000066400000000000000000000002151474000356600234670ustar00rootroot00000000000000 Successfully read flow solution from file grid_c.cgns For example, r,p[8][16][20]= 20.000000, 16.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str/OUTPUT3000066400000000000000000000016071474000356600234760ustar00rootroot00000000000000 DataClass = NormalizedByUnknownDimensional ReferenceState = ReferenceQuantities Variable=Mach data= 4.60000000 Variable=Reynolds data= 6000000.00000000 Variable=Mach_Velocity data= 4.60000000 Variable=Mach_VelocitySound data= 1.00000000 Variable=Reynolds_Velocity data= 4.60000000 Variable=Reynolds_Length data= 1.00000000 Variable=Reynolds_ViscosityKinematic data= 0.00000077 Variable=Density data= 1.00000000 Variable=Pressure data= 0.71428571 Variable=VelocitySound data= 1.00000000 Variable=ViscosityMolecular data= 0.00000077 Variable=LengthReference data= 1.00000000 Variable=VelocityX data= 4.60000000 Variable=VelocityY data= 0.00000000 Variable=VelocityZ data= 0.00000000 Successfully read nondimensional info from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str/OUTPUT4000066400000000000000000000002031474000356600234660ustar00rootroot00000000000000 The descriptor is: Supersonic vehicle with landing gear M=4.6, Re=6 million Successfully read descriptors from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str/OUTPUT5000066400000000000000000000002651474000356600234770ustar00rootroot00000000000000 Successfully read cl history from file grid_c.cgns values are: 1.000000, 2.000000, 3.000000, 4.000000, 5.000000 6.000000, 7.000000, 8.000000, 9.000000, 10.000000 CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str/OUTPUT6000066400000000000000000000004661474000356600235030ustar00rootroot00000000000000 Eqn dimension = 3 Gov eqn = NSTurbulent diffusion= 0, 1, 0, 0, 0, 0 Gas model type = Ideal gamma = 1.400000 Turbulence closure type = EddyViscosity turb prandtl number = 0.900000 Turbulence model type = OneEquation_SpalartAllmaras Successfully read equation set info from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str/OUTPUT7000066400000000000000000000060751474000356600235060ustar00rootroot00000000000000 BC number: 1 name= Ilo type= BCTunnelInflow no of pts= 153 (these points read here, but only some printed out:) ipnts[0][0], [0][1], [0][2]=1,1,1 ipnts[1][0], [1][1], [1][2]=1,1,2 ipnts[2][0], [2][1], [2][2]=1,1,3 ipnts[3][0], [3][1], [3][2]=1,1,4 ipnts[4][0], [4][1], [4][2]=1,1,5 ipnts[5][0], [5][1], [5][2]=1,1,6 ipnts[6][0], [6][1], [6][2]=1,1,7 ipnts[7][0], [7][1], [7][2]=1,1,8 ipnts[8][0], [8][1], [8][2]=1,1,9 ipnts[9][0], [9][1], [9][2]=1,2,1 BC number: 2 name= Ihi type= BCExtrapolate no of pts= 153 (these points read here, but only some printed out:) ipnts[0][0], [0][1], [0][2]=21,1,1 ipnts[1][0], [1][1], [1][2]=21,1,2 ipnts[2][0], [2][1], [2][2]=21,1,3 ipnts[3][0], [3][1], [3][2]=21,1,4 ipnts[4][0], [4][1], [4][2]=21,1,5 ipnts[5][0], [5][1], [5][2]=21,1,6 ipnts[6][0], [6][1], [6][2]=21,1,7 ipnts[7][0], [7][1], [7][2]=21,1,8 ipnts[8][0], [8][1], [8][2]=21,1,9 ipnts[9][0], [9][1], [9][2]=21,2,1 BC number: 3 name= Jlo type= BCWallInviscid no of pts= 189 (these points read here, but only some printed out:) ipnts[0][0], [0][1], [0][2]=1,1,1 ipnts[1][0], [1][1], [1][2]=1,1,2 ipnts[2][0], [2][1], [2][2]=1,1,3 ipnts[3][0], [3][1], [3][2]=1,1,4 ipnts[4][0], [4][1], [4][2]=1,1,5 ipnts[5][0], [5][1], [5][2]=1,1,6 ipnts[6][0], [6][1], [6][2]=1,1,7 ipnts[7][0], [7][1], [7][2]=1,1,8 ipnts[8][0], [8][1], [8][2]=1,1,9 ipnts[9][0], [9][1], [9][2]=2,1,1 BC number: 4 name= Jhi type= BCWallInviscid no of pts= 189 (these points read here, but only some printed out:) ipnts[0][0], [0][1], [0][2]=1,17,1 ipnts[1][0], [1][1], [1][2]=1,17,2 ipnts[2][0], [2][1], [2][2]=1,17,3 ipnts[3][0], [3][1], [3][2]=1,17,4 ipnts[4][0], [4][1], [4][2]=1,17,5 ipnts[5][0], [5][1], [5][2]=1,17,6 ipnts[6][0], [6][1], [6][2]=1,17,7 ipnts[7][0], [7][1], [7][2]=1,17,8 ipnts[8][0], [8][1], [8][2]=1,17,9 ipnts[9][0], [9][1], [9][2]=2,17,1 BC number: 5 name= Klo type= BCWallInviscid no of pts= 357 (these points read here, but only some printed out:) ipnts[0][0], [0][1], [0][2]=1,1,1 ipnts[1][0], [1][1], [1][2]=1,2,1 ipnts[2][0], [2][1], [2][2]=1,3,1 ipnts[3][0], [3][1], [3][2]=1,4,1 ipnts[4][0], [4][1], [4][2]=1,5,1 ipnts[5][0], [5][1], [5][2]=1,6,1 ipnts[6][0], [6][1], [6][2]=1,7,1 ipnts[7][0], [7][1], [7][2]=1,8,1 ipnts[8][0], [8][1], [8][2]=1,9,1 ipnts[9][0], [9][1], [9][2]=1,10,1 BC number: 6 name= Khi type= BCWallInviscid no of pts= 357 (these points read here, but only some printed out:) ipnts[0][0], [0][1], [0][2]=1,1,9 ipnts[1][0], [1][1], [1][2]=1,2,9 ipnts[2][0], [2][1], [2][2]=1,3,9 ipnts[3][0], [3][1], [3][2]=1,4,9 ipnts[4][0], [4][1], [4][2]=1,5,9 ipnts[5][0], [5][1], [5][2]=1,6,9 ipnts[6][0], [6][1], [6][2]=1,7,9 ipnts[7][0], [7][1], [7][2]=1,8,9 ipnts[8][0], [8][1], [8][2]=1,9,9 ipnts[9][0], [9][1], [9][2]=1,10,9 Successfully read BCs (PointList format) from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_2zn/000077500000000000000000000000001474000356600232155ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_2zn/Makefile000066400000000000000000000017201474000356600246550ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid2zn_str$(EXE) WRITE2 = write_con2zn_str$(EXE) READ1 = read_grid2zn_str$(EXE) READ2 = read_con2zn_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) READ_PROGS = $(READ1) $(READ2) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid2zn_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_grid2zn_str.c $(LIBS) $(WRITE2) : ../write_con2zn_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_con2zn_str.c $(LIBS) $(READ1) : ../read_grid2zn_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_grid2zn_str.c $(LIBS) $(READ2) : ../read_con2zn_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_con2zn_str.c $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_2zn/OUTPUT1000066400000000000000000000003361474000356600242630ustar00rootroot00000000000000 Successfully read grid from file grid_c.cgns For example, zone 1 x,y,z[8][16][20]= 20.000000, 16.000000, 8.000000 zone 2 x,y,z[8][16][20]= 40.000000, 16.000000, 8.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_2zn/OUTPUT2000066400000000000000000000004721474000356600242650ustar00rootroot00000000000000 In zone 1: donor name=Zone 2 range (this zone)=21,1,1,21,17,9 range (donor zone)=1,1,1,1,17,9 transform=1,2,3 In zone 2: donor name=Zone 1 range (this zone)=1,1,1,1,17,9 range (donor zone)=21,1,1,21,17,9 transform=1,2,3 Successfully read 1-to-1 connectivity info from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_2zngenrl/000077500000000000000000000000001474000356600242455ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_2zngenrl/Makefile000066400000000000000000000017651474000356600257160ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid2zn_str$(EXE) WRITE2 = write_con2zn_genrl_str$(EXE) READ1 = read_grid2zn_str$(EXE) READ2 = read_con2zn_genrl_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) READ_PROGS = $(READ1) $(READ2) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid2zn_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_grid2zn_str.c $(LIBS) $(WRITE2) : ../write_con2zn_genrl_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_con2zn_genrl_str.c $(LIBS) $(READ1) : ../read_grid2zn_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_grid2zn_str.c $(LIBS) $(READ2) : ../read_con2zn_genrl_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_con2zn_genrl_str.c $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_2zngenrl/OUTPUT1000066400000000000000000000003361474000356600253130ustar00rootroot00000000000000 Successfully read grid from file grid_c.cgns For example, zone 1 x,y,z[8][16][20]= 20.000000, 16.000000, 8.000000 zone 2 x,y,z[8][16][20]= 40.000000, 16.000000, 8.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_2zngenrl/OUTPUT2000066400000000000000000000043301474000356600253120ustar00rootroot00000000000000 In zone 1: donor name=Zone 2 number of connectivity pts=153 grid location=Vertex connectivity type=Abutting1to1 pointset type=PointList donor zonetype=Structured donor pointset type=PointListDonor ipnts and ipntsdonor arrays read, only some written out here: ipnts[0][0], [0][1], [0][2]=21,1,1 ipntsdonor[0][0], [0][1], [0][2]=1,1,1 ipnts[1][0], [1][1], [1][2]=21,1,2 ipntsdonor[1][0], [1][1], [1][2]=1,1,2 ipnts[2][0], [2][1], [2][2]=21,1,3 ipntsdonor[2][0], [2][1], [2][2]=1,1,3 ipnts[3][0], [3][1], [3][2]=21,1,4 ipntsdonor[3][0], [3][1], [3][2]=1,1,4 ipnts[4][0], [4][1], [4][2]=21,1,5 ipntsdonor[4][0], [4][1], [4][2]=1,1,5 ipnts[5][0], [5][1], [5][2]=21,1,6 ipntsdonor[5][0], [5][1], [5][2]=1,1,6 ipnts[6][0], [6][1], [6][2]=21,1,7 ipntsdonor[6][0], [6][1], [6][2]=1,1,7 ipnts[7][0], [7][1], [7][2]=21,1,8 ipntsdonor[7][0], [7][1], [7][2]=1,1,8 ipnts[8][0], [8][1], [8][2]=21,1,9 ipntsdonor[8][0], [8][1], [8][2]=1,1,9 ipnts[9][0], [9][1], [9][2]=21,2,1 ipntsdonor[9][0], [9][1], [9][2]=1,2,1 In zone 2: donor name=Zone 1 number of connectivity pts=153 grid location=Vertex connectivity type=Abutting1to1 pointset type=PointList donor zonetype=Structured donor pointset type=PointListDonor ipnts and ipntsdonor arrays read, only some written out here: ipnts[0][0], [0][1], [0][2]=1,1,1 ipntsdonor[0][0], [0][1], [0][2]=21,1,1 ipnts[1][0], [1][1], [1][2]=1,1,2 ipntsdonor[1][0], [1][1], [1][2]=21,1,2 ipnts[2][0], [2][1], [2][2]=1,1,3 ipntsdonor[2][0], [2][1], [2][2]=21,1,3 ipnts[3][0], [3][1], [3][2]=1,1,4 ipntsdonor[3][0], [3][1], [3][2]=21,1,4 ipnts[4][0], [4][1], [4][2]=1,1,5 ipntsdonor[4][0], [4][1], [4][2]=21,1,5 ipnts[5][0], [5][1], [5][2]=1,1,6 ipntsdonor[5][0], [5][1], [5][2]=21,1,6 ipnts[6][0], [6][1], [6][2]=1,1,7 ipntsdonor[6][0], [6][1], [6][2]=21,1,7 ipnts[7][0], [7][1], [7][2]=1,1,8 ipntsdonor[7][0], [7][1], [7][2]=21,1,8 ipnts[8][0], [8][1], [8][2]=1,1,9 ipntsdonor[8][0], [8][1], [8][2]=21,1,9 ipnts[9][0], [9][1], [9][2]=1,2,1 ipntsdonor[9][0], [9][1], [9][2]=21,2,1 Successfully read general 1-to-1 connectivity info from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_FlowCent/000077500000000000000000000000001474000356600242255ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_FlowCent/Makefile000066400000000000000000000024061474000356600256670ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_str$(EXE) WRITE2 = write_flowcent_str$(EXE) WRITE3 = write_bc_str$(EXE) READ1 = read_grid_str$(EXE) READ2 = read_flowcent_str$(EXE) READ3 = read_bc_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) $(WRITE3) READ_PROGS = $(READ1) $(READ2) $(READ3) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(WRITE3) $(READ3) > $(OUTDIR)/output3 -$(DIFF) OUTPUT3 $(OUTDIR)/output3 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_grid_str.c $(LIBS) $(WRITE2) : ../write_flowcent_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_flowcent_str.c $(LIBS) $(WRITE3) : ../write_bc_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_bc_str.c $(LIBS) $(READ1) : ../read_grid_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_grid_str.c $(LIBS) $(READ2) : ../read_flowcent_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_flowcent_str.c $(LIBS) $(READ3) : ../read_bc_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_bc_str.c $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_FlowCent/OUTPUT1000066400000000000000000000002271474000356600252720ustar00rootroot00000000000000 Successfully read grid from file grid_c.cgns For example, zone 1 x,y,z[8][16][20]= 20.000000, 16.000000, 8.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_FlowCent/OUTPUT2000066400000000000000000000002151474000356600252700ustar00rootroot00000000000000 Successfully read flow solution from file grid_c.cgns For example, r,p[7][15][19]= 19.000000, 15.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_FlowCent/OUTPUT3000066400000000000000000000012361474000356600252750ustar00rootroot00000000000000 BC number: 1 name= Ilo type= BCTunnelInflow i-range= 1,1 j-range= 1,17 k-range= 1,9 BC number: 2 name= Ihi type= BCExtrapolate i-range= 21,21 j-range= 1,17 k-range= 1,9 BC number: 3 name= Jlo type= BCWallInviscid i-range= 1,21 j-range= 1,1 k-range= 1,9 BC number: 4 name= Jhi type= BCWallInviscid i-range= 1,21 j-range= 17,17 k-range= 1,9 BC number: 5 name= Klo type= BCWallInviscid i-range= 1,21 j-range= 1,17 k-range= 1,1 BC number: 6 name= Khi type= BCWallInviscid i-range= 1,21 j-range= 1,17 k-range= 9,9 Successfully read BCs (PointRange format) from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_FlowCentRind/000077500000000000000000000000001474000356600250425ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_FlowCentRind/Makefile000066400000000000000000000017421474000356600265060ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_str$(EXE) WRITE2 = write_flowcentrind_str$(EXE) READ1 = read_grid_str$(EXE) READ2 = read_flowcentrind_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) READ_PROGS = $(READ1) $(READ2) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_grid_str.c $(LIBS) $(WRITE2) : ../write_flowcentrind_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_flowcentrind_str.c $(LIBS) $(READ1) : ../read_grid_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_grid_str.c $(LIBS) $(READ2) : ../read_flowcentrind_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_flowcentrind_str.c $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_FlowCentRind/OUTPUT1000066400000000000000000000002271474000356600261070ustar00rootroot00000000000000 Successfully read grid from file grid_c.cgns For example, zone 1 x,y,z[8][16][20]= 20.000000, 16.000000, 8.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_FlowCentRind/OUTPUT2000066400000000000000000000003761474000356600261150ustar00rootroot00000000000000 Successfully read flow solution from file grid_c.cgns For example, r,p[7][16][20]= 19.000000, 15.000000 rind: r,p[7][16][0]= 1055.000000, 1056.000000 rind: r,p[7][16][21]= -1055.000000, -1056.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_Timeacc/000077500000000000000000000000001474000356600240515ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_Timeacc/Makefile000066400000000000000000000017121474000356600255120ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_str$(EXE) WRITE2 = write_timevert_str$(EXE) READ1 = read_grid_str$(EXE) READ2 = read_timevert_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) READ_PROGS = $(READ1) $(READ2) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_grid_str.c $(LIBS) $(WRITE2) : ../write_timevert_str.c $(CC) $(COPTS) $(FEOUT)$@ ../write_timevert_str.c $(LIBS) $(READ1) : ../read_grid_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_grid_str.c $(LIBS) $(READ2) : ../read_timevert_str.c $(CC) $(COPTS) $(FEOUT)$@ ../read_timevert_str.c $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_Timeacc/OUTPUT1000066400000000000000000000002271474000356600251160ustar00rootroot00000000000000 Successfully read grid from file grid_c.cgns For example, zone 1 x,y,z[8][16][20]= 20.000000, 16.000000, 8.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Str_Timeacc/OUTPUT2000066400000000000000000000012411474000356600251140ustar00rootroot00000000000000 number of time steps stored = 3 Times stored are: 10.000000 20.000000 50.000000 Flow solution names corresponding to each are: FlowSolution1 FlowSolution2 FlowSolution3 Simulation type is: TimeAccurate Successfully read 3 flow solutions from file grid_c.cgns For example, r1,p1[0][0][0]=0.000000, 0.000000 r2,p2[0][0][0]=1.000000, 1.000000 r3,p3[0][0][0]=2.000000, 2.000000 For example, r1,p1[8][16][20]=20.000000, 16.000000 r2,p2[8][16][20]=21.000000, 17.000000 r3,p3[8][16][20]=22.000000, 18.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Unstr/000077500000000000000000000000001474000356600227675ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Unstr/Makefile000066400000000000000000000045041474000356600244320ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_unst$(EXE) WRITE2 = write_flowvert_unst$(EXE) WRITE3 = write_dimensional$(EXE) WRITE4 = write_descriptor$(EXE) WRITE5 = write_convergence$(EXE) WRITE6 = write_bcpnts_unst$(EXE) READ1 = read_grid_unst$(EXE) READ2 = read_flowvert_unst$(EXE) READ3 = read_dimensional$(EXE) READ4 = read_descriptor$(EXE) READ5 = read_convergence$(EXE) READ6 = read_bcpnts_unst$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) $(WRITE3) $(WRITE4) $(WRITE5) $(WRITE6) READ_PROGS = $(READ1) $(READ2) $(READ3) $(READ4) $(READ5) $(READ6) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(WRITE3) $(READ3) > $(OUTDIR)/output3 -$(DIFF) OUTPUT3 $(OUTDIR)/output3 $(WRITE4) $(READ4) > $(OUTDIR)/output4 -$(DIFF) OUTPUT4 $(OUTDIR)/output4 $(WRITE5) $(READ5) > $(OUTDIR)/output5 -$(DIFF) OUTPUT5 $(OUTDIR)/output5 $(WRITE6) $(READ6) > $(OUTDIR)/output6 -$(DIFF) OUTPUT6 $(OUTDIR)/output6 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_unst.c $(CC) $(COPTS) $(FEOUT)$@ ../write_grid_unst.c $(LIBS) $(WRITE2) : ../write_flowvert_unst.c $(CC) $(COPTS) $(FEOUT)$@ ../write_flowvert_unst.c $(LIBS) $(WRITE3) : ../write_dimensional.c $(CC) $(COPTS) $(FEOUT)$@ ../write_dimensional.c $(LIBS) $(WRITE4) : ../write_descriptor.c $(CC) $(COPTS) $(FEOUT)$@ ../write_descriptor.c $(LIBS) $(WRITE5) : ../write_convergence.c $(CC) $(COPTS) $(FEOUT)$@ ../write_convergence.c $(LIBS) $(WRITE6) : ../write_bcpnts_unst.c $(CC) $(COPTS) $(FEOUT)$@ ../write_bcpnts_unst.c $(LIBS) $(READ1) : ../read_grid_unst.c $(CC) $(COPTS) $(FEOUT)$@ ../read_grid_unst.c $(LIBS) $(READ2) : ../read_flowvert_unst.c $(CC) $(COPTS) $(FEOUT)$@ ../read_flowvert_unst.c $(LIBS) $(READ3) : ../read_dimensional.c $(CC) $(COPTS) $(FEOUT)$@ ../read_dimensional.c $(LIBS) $(READ4) : ../read_descriptor.c $(CC) $(COPTS) $(FEOUT)$@ ../read_descriptor.c $(LIBS) $(READ5) : ../read_convergence.c $(CC) $(COPTS) $(FEOUT)$@ ../read_convergence.c $(LIBS) $(READ6) : ../read_bcpnts_unst.c $(CC) $(COPTS) $(FEOUT)$@ ../read_bcpnts_unst.c $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Unstr/OUTPUT1000066400000000000000000000015201474000356600240310ustar00rootroot00000000000000 number of sections=4 Reading section data... section name=Elem section type=HEXA_8 istart,iend=1, 2560 reading element data for this element Reading section data... section name=InflowElem section type=QUAD_4 istart,iend=2561, 2688 not reading element data for this element Reading section data... section name=OutflowElem section type=QUAD_4 istart,iend=2689, 2816 not reading element data for this element Reading section data... section name=SidewallElem section type=QUAD_4 istart,iend=2817, 3776 not reading element data for this element Successfully read unstructured grid from file grid_c.cgns for example, element 1 is made up of nodes: 1, 2, 23, 22, 358, 359, 380, 379 x,y,z of node 357 are: 0.000000, 0.000000, 1.000000 x,y,z of node 1357 are: 13.000000, 13.000000, 3.000000 CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Unstr/OUTPUT2000066400000000000000000000002651474000356600240370ustar00rootroot00000000000000 Successfully read flow solution from file grid_c.cgns For example, r,p[379] = 1.000000, 1.000000 r,p[3212]= 20.000000, 16.000000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Unstr/OUTPUT3000066400000000000000000000011711474000356600240350ustar00rootroot00000000000000 DataClass = Dimensional Units= Kilogram Meter Second Kelvin Degree For Density, exponents are: 1.000000 -3.000000 0.000000 0.000000 0.000000 For Pressure, exponents are: 1.000000 -1.000000 -2.000000 0.000000 0.000000 For CoordinateX, exponents are: 0.000000 1.000000 0.000000 0.000000 0.000000 For CoordinateY, exponents are: 0.000000 1.000000 0.000000 0.000000 0.000000 For CoordinateZ, exponents are: 0.000000 1.000000 0.000000 0.000000 0.000000 Successfully read dimensional data from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Unstr/OUTPUT4000066400000000000000000000002031474000356600240310ustar00rootroot00000000000000 The descriptor is: Supersonic vehicle with landing gear M=4.6, Re=6 million Successfully read descriptors from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Unstr/OUTPUT5000066400000000000000000000002651474000356600240420ustar00rootroot00000000000000 Successfully read cl history from file grid_c.cgns values are: 1.000000, 2.000000, 3.000000, 4.000000, 5.000000 6.000000, 7.000000, 8.000000, 9.000000, 10.000000 CGNS-4.5.0/src/Test_UserGuideCode/C_code/Test_Grid_Unstr/OUTPUT6000066400000000000000000000023011474000356600240340ustar00rootroot00000000000000 GridLocation=FaceCenter means BC data refers to elements, not nodes BC number: 1 name= Ilo type= BCTunnelInflow no of elements= 128 (these elements read here, but only some printed out:) ipnts[0]=2561 ipnts[1]=2562 ipnts[2]=2563 ipnts[3]=2564 ipnts[4]=2565 ipnts[5]=2566 ipnts[6]=2567 ipnts[7]=2568 ipnts[8]=2569 ipnts[9]=2570 GridLocation=FaceCenter means BC data refers to elements, not nodes BC number: 2 name= Ihi type= BCExtrapolate no of elements= 128 (these elements read here, but only some printed out:) ipnts[0]=2689 ipnts[1]=2690 ipnts[2]=2691 ipnts[3]=2692 ipnts[4]=2693 ipnts[5]=2694 ipnts[6]=2695 ipnts[7]=2696 ipnts[8]=2697 ipnts[9]=2698 GridLocation=FaceCenter means BC data refers to elements, not nodes BC number: 3 name= Walls type= BCWallInviscid no of elements= 960 (these elements read here, but only some printed out:) ipnts[0]=2817 ipnts[1]=2818 ipnts[2]=2819 ipnts[3]=2820 ipnts[4]=2821 ipnts[5]=2822 ipnts[6]=2823 ipnts[7]=2824 ipnts[8]=2825 ipnts[9]=2826 Successfully read BCs (PointList format) from file grid_c.cgns CGNS-4.5.0/src/Test_UserGuideCode/C_code/make.defs000066400000000000000000000010161474000356600214660ustar00rootroot00000000000000# location for the CGNS includes and required libraries CGNSDIR = ../../.. include $(CGNSDIR)/make.defs include $(CGNSDIR)/cgnsBuild.defs CGNSLIB = $(CGNSDIR)/$(LIBCGNS) CGNSinclude = ../../../ CGNSlibs = $(CGNSLIB) $(HDF5LIB) # C compiler and options COPTS = -I$(CGNSinclude) $(CFLAGS) LIBS = $(CGNSlibs) $(SZIPLIB) $(ZLIBLIB) $(HDF5LIB_DEP) -lm $(CLIBS) # how to name output executable and extension FEOUT = -o EXE = # working directory for output OUTDIR = build # additional commands MKDIR = mkdir DIFF = diff -w CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_bc_str.c000066400000000000000000000051531474000356600223270ustar00rootroot00000000000000/* Program read_bc_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid + BCs (in PointRange format), and reads the BCs The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c), and the BCs must also already have been written (using write_bc_str.c). Note: whether the existing CGNS file has a flow solution in it already or not is irrelevant. Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_bc_str.c cc -o read_bc_str_c read_bc_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { int index_file,index_base,index_zone,nbocos,ib; int normalindex[3],ndataset; int normallist; char boconame[33]; CGNS_ENUMT(BCType_t) ibocotype; CGNS_ENUMT(PointSetType_t) iptset; CGNS_ENUMT(DataType_t) normaldatatype; cgsize_t ipnts[2][3]; cgsize_t npts,normallistflag; /* READ BOUNDARY CONDITIONS FROM EXISTING CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* find out number of BCs that exist under this zone */ cg_nbocos(index_file,index_base,index_zone,&nbocos); /* do loop over the total number of BCs */ for (ib=1; ib <= nbocos; ib++) { /* get BC info */ cg_boco_info(index_file,index_base,index_zone,ib,boconame,&ibocotype, &iptset,&npts,normalindex,&normallistflag,&normaldatatype,&ndataset); if (iptset != CGNS_ENUMV(PointRange)) { printf("\nError. For this program, BCs must be set up as PointRange type %s\n", PointSetTypeName[iptset]); return 1; } printf("\nBC number: %i\n",ib); printf(" name= %s\n",boconame); printf(" type= %s\n",BCTypeName[ibocotype]); /* read point range in here */ cg_boco_read(index_file,index_base,index_zone,ib,ipnts[0],&normallist); printf(" i-range= %i,%i\n",(int)ipnts[0][0],(int)ipnts[1][0]); printf(" j-range= %i,%i\n",(int)ipnts[0][1],(int)ipnts[1][1]); printf(" k-range= %i,%i\n",(int)ipnts[0][2],(int)ipnts[1][2]); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read BCs (PointRange format) from file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_bcpnts_str.c000066400000000000000000000056501474000356600232360ustar00rootroot00000000000000/* Program read_bcpnts_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid + BCs (in PointList format), and reads the BCs The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c), and the BCs must also already have been written (using write_bcpnts_str.c). Note: whether the existing CGNS file has a flow solution in it already or not is irrelevant. Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_bcpnts_str.c cc -o read_bcpnts_str_c read_bcpnts_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif #define maxpnts 400 int main() { int index_file,index_base,index_zone,nbocos,ib; int normalindex[3],ndataset; int i,normallist; char boconame[33]; CGNS_ENUMT(BCType_t) ibocotype; CGNS_ENUMT(PointSetType_t) iptset; CGNS_ENUMT(DataType_t) normaldatatype; cgsize_t npts,normallistflag; cgsize_t ipnts[maxpnts][3]; /* READ BOUNDARY CONDITIONS FROM EXISTING CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* find out number of BCs that exist under this zone */ cg_nbocos(index_file,index_base,index_zone,&nbocos); /* do loop over the total number of BCs */ for (ib=1; ib <= nbocos; ib++) { /* get BC info */ cg_boco_info(index_file,index_base,index_zone,ib,boconame,&ibocotype, &iptset,&npts,normalindex,&normallistflag,&normaldatatype,&ndataset); if (iptset != CGNS_ENUMV(PointList)) { printf("\nError. For this program, BCs must be set up as PointList type %s\n", PointSetTypeName[iptset]); return 1; } printf("\nBC number: %i\n",ib); printf(" name= %s\n",boconame); printf(" type= %s\n",BCTypeName[ibocotype]); printf(" no of pts= %i\n",(int)npts); if (npts > maxpnts) { printf("\nError. Must increase maxpnts to at least %i\n",(int)npts); return 1; } /* read point list in here (nothing done with them in this program) */ cg_boco_read(index_file,index_base,index_zone,ib,ipnts[0],&normallist); printf(" (these points read here, but only some printed out:)\n"); for (i=0; i < 10; i++) { printf(" ipnts[%i][0], [%i][1], [%i][2]=%i,%i,%i\n", i,i,i,(int)ipnts[i][0],(int)ipnts[i][1],(int)ipnts[i][2]); } } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read BCs (PointList format) from file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_bcpnts_unst.c000066400000000000000000000063341474000356600234170ustar00rootroot00000000000000/* Program read_bcpnts_unst */ /* Opens an existing CGNS file that contains a simple 3-D unstructured grid + BCs (in PointList+GridLocation=FaceCenter format), and reads the BCs The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_unst.c), and the BCs must also already have been written (using write_bcpnts_unst.c). Note: whether the existing CGNS file has a flow solution in it already or not is irrelevant. Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_bcpnts_unst.c cc -o read_bcpnts_unst_c read_bcpnts_unst.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif #define maxpnts 960 int main() { int index_file,index_base,index_zone,nbocos,ib; int normalindex[3],ndataset; int i,normallist; char boconame[33]; CGNS_ENUMT(BCType_t) ibocotype; CGNS_ENUMT(PointSetType_t) iptset; CGNS_ENUMT(DataType_t) normaldatatype; CGNS_ENUMT(GridLocation_t) igr; cgsize_t npts,normallistflag; cgsize_t ipnts[maxpnts]; /* READ BOUNDARY CONDITIONS FROM EXISTING CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* find out number of BCs that exist under this zone */ cg_nbocos(index_file,index_base,index_zone,&nbocos); /* do loop over the total number of BCs */ for (ib=1; ib <= nbocos; ib++) { /* find out what BC grid location is (expecting FaceCenter) */ cg_goto(index_file,index_base,"Zone_t",1,"ZoneBC_t",1,"BC_t",ib,"end"); cg_gridlocation_read(&igr); if (igr == CGNS_ENUMV(FaceCenter)) { printf("\nGridLocation=FaceCenter means BC data refers to elements, not nodes\n"); } /* get BC info */ cg_boco_info(index_file,index_base,index_zone,ib,boconame,&ibocotype, &iptset,&npts,normalindex,&normallistflag,&normaldatatype,&ndataset); if (iptset != CGNS_ENUMV(PointList)) { printf("\nError. For this program, BCs must be set up as PointList type %s\n", PointSetTypeName[iptset]); return 1; } printf("\nBC number: %i\n",ib); printf(" name= %s\n",boconame); printf(" type= %s\n",BCTypeName[ibocotype]); printf(" no of elements= %i\n",(int)npts); if (npts > maxpnts) { printf("\nError. Must increase maxpnts to at least %i\n",(int)npts); return 1; } /* read point list in here (nothing done with them in this program) */ cg_boco_read(index_file,index_base,index_zone,ib,ipnts,&normallist); printf(" (these elements read here, but only some printed out:)\n"); for (i=0; i < 10; i++) { printf(" ipnts[%i]=%i\n",i,(int)ipnts[i]); } } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read BCs (PointList format) from file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_con2zn_genrl_str.c000066400000000000000000000074371474000356600243520ustar00rootroot00000000000000/* Program read_con2zn_genrl_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid (2 zones) plus 1-to-1 connectivity information (written in GENERAL form), and reads the connectivity info. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid2zn_str.c plus write_con2zn_genrl_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_con2zn_genrl_str.c cc -o read_con2zn_genrl_str_c read_con2zn_genrl_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif #define maxpnts 400 int main() { int i,index_file,index_base,nzone,index_zone,nconns,index_conn; char donorname[33],connectname[33]; CGNS_ENUMT(GridLocation_t) location; CGNS_ENUMT(GridConnectivityType_t) iconnect_type; CGNS_ENUMT(PointSetType_t) iptset_type,idonor_ptset_type; CGNS_ENUMT(ZoneType_t) idonor_zonetype; CGNS_ENUMT(DataType_t) idonor_datatype; cgsize_t npts,ndata_donor; cgsize_t ipnts[maxpnts][3],ipntsdonor[maxpnts][3]; /* READ GENERAL CONNECTIVITY INFORMATION FROM EXISTING CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* get number of zones (should be 2 for our case) */ cg_nzones(index_file,index_base,&nzone); if (nzone != 2) { printf("\nError. This program expects 2 zones. %d read.\n",nzone); return 1; } /* loop over zones */ for (index_zone=1; index_zone <= nzone; ++index_zone) { /* find out how many general interfaces there are in this zone */ /* (for this program, there should only be one) */ cg_nconns(index_file,index_base,index_zone,&nconns); if (nconns != 1) { printf("\nError. Expecting one general interface. %i read\n",nconns); return 1; } index_conn=nconns; /* read general connectivity info */ cg_conn_info(index_file,index_base,index_zone,index_conn,connectname,&location, &iconnect_type,&iptset_type,&npts,donorname,&idonor_zonetype, &idonor_ptset_type,&idonor_datatype,&ndata_donor); if (npts > maxpnts) { printf("\nError. Must increase maxpnts to at least %i\n",(int)npts); return 1; } cg_conn_read(index_file,index_base,index_zone,index_conn,ipnts[0], idonor_datatype,ipntsdonor[0]); printf("\nIn zone %i:\n",index_zone); printf(" donor name=%s\n",donorname); printf(" number of connectivity pts=%i\n",(int)npts); printf(" grid location=%s\n",GridLocationName[location]); printf(" connectivity type=%s\n",GridConnectivityTypeName[iconnect_type]); printf(" pointset type=%s\n",PointSetTypeName[iptset_type]); printf(" donor zonetype=%s\n",ZoneTypeName[idonor_zonetype]); printf(" donor pointset type=%s\n",PointSetTypeName[idonor_ptset_type]); /* printf(" data type=%s\n",DataTypeName[idonor_datatype]); */ printf(" ipnts and ipntsdonor arrays read, only some written out here:\n"); for (i=0; i < 10; i++) { printf(" ipnts[%i][0], [%i][1], [%i][2]=%i,%i,%i", i,i,i,(int)ipnts[i][0],(int)ipnts[i][1],(int)ipnts[i][2]); printf(" ipntsdonor[%i][0], [%i][1], [%i][2]=%i,%i,%i\n", i,i,i,(int)ipntsdonor[i][0],(int)ipntsdonor[i][1],(int)ipntsdonor[i][2]); } } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read general 1-to-1 connectivity info from file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_con2zn_str.c000066400000000000000000000052141474000356600231520ustar00rootroot00000000000000/* Program read_con2zn_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid (2 zones) plus 1-to-1 connectivity information, and reads the connectivity info. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid2zn_str.c plus write_con2zn_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_con2zn_str.c cc -o read_con2zn_str_c read_con2zn_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { int itranfrm[3]; int index_file,index_base,nzone,index_zone,n1to1,index_conn; char donorname[33],connectname[33]; cgsize_t ipnts[2][3],ipntsdonor[2][3]; /* READ 1-TO-1 CONNECTIVITY INFORMATION FROM EXISTING CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* get number of zones (should be 2 for our case) */ cg_nzones(index_file,index_base,&nzone); if (nzone != 2) { printf("\nError. This program expects 2 zones. %d read.\n",nzone); return 1; } /* loop over zones */ for (index_zone=1; index_zone <= nzone; ++index_zone) { /* find out how many 1-to-1 interfaces there are in this zone */ /* (for this program, there should only be one) */ cg_n1to1(index_file,index_base,index_zone,&n1to1); if (n1to1 != 1) { printf("\nError. Expecting one 1-to-1 interface. %i read\n",n1to1); return 1; } index_conn=n1to1; /* read 1-to-1 info */ cg_1to1_read(index_file,index_base,index_zone,index_conn,connectname,donorname, ipnts[0],ipntsdonor[0],itranfrm); printf("\nIn zone %i:\n",index_zone); printf(" donor name=%s\n",donorname); printf(" range (this zone)=%i,%i,%i,%i,%i,%i\n",(int)ipnts[0][0], (int)ipnts[0][1],(int)ipnts[0][2],(int)ipnts[1][0], (int)ipnts[1][1],(int)ipnts[1][2]); printf(" range (donor zone)=%i,%i,%i,%i,%i,%i\n",(int)ipntsdonor[0][0], (int)ipntsdonor[0][1],(int)ipntsdonor[0][2],(int)ipntsdonor[1][0], (int)ipntsdonor[1][1],(int)ipntsdonor[1][2]); printf(" transform=%i,%i,%i\n",itranfrm[0],itranfrm[1],itranfrm[2]); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read 1-to-1 connectivity info from file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_convergence.c000066400000000000000000000044211474000356600233460ustar00rootroot00000000000000/* Program read_convergence */ /* Reads convergence history from an existing CGNS file. The CGNS grid file 'grid_c.cgns' must already exist and a convergence history should be in it (using write_convergence.c). Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_convergence.c cc -o read_convergence_c read_convergence.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif #define ntt 20 int main() { float cl[ntt]; int index_file,index_base,narrays,index_array,ndim; char arrayname[33]; CGNS_ENUMT(DataType_t) itype; cgsize_t idim; /* READ CONVERGENCE HISTORY INFORMATION FROM EXISTING CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* go to base node */ cg_goto(index_file,index_base,"end"); /* go to history node (we assume it exists and that there is only one - */ /* real working code would check!) */ cg_goto(index_file,index_base,"ConvergenceHistory_t",1,"end"); /* find out how many arrays are here (there should be only one!): */ cg_narrays(&narrays); index_array=narrays; /* some checks: */ if (narrays != 1) { printf("\nError! Expecting only one array, read %i\n",narrays); return 1; } cg_array_info(index_array,arrayname,&itype,&ndim,&idim); if (idim > ntt) { printf("\nError! must increase ntt to at least %i\n",(int)idim); return 1; } if (strcmp(arrayname,"CoefLift") != 0) { printf("\nError! expecting CoefLift, read %s\n",arrayname); return 1; } /* read lift coefficient array */ cg_array_read_as(index_array,CGNS_ENUMV(RealSingle),cl); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read cl history from file grid_c.cgns\n"); printf(" values are: %f, %f, %f, %f, %f\n",cl[0],cl[1],cl[2],cl[3],cl[4]); printf(" %f, %f, %f, %f, %f\n",cl[5],cl[6],cl[7],cl[8],cl[9]); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_descriptor.c000066400000000000000000000026141474000356600232300ustar00rootroot00000000000000/* Program read_descriptor */ /* Reads descriptor node (under CGNSBase_t) from an existing CGNS file. The CGNS grid file 'grid_c.cgns' must already exist. and a descriptor node should be in it (using write_descriptor.c). Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_descriptor.c cc -o read_descriptor_c read_descriptor.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { int index_file,index_base,ndescriptors,n; char *text,name[33]; /* READ DESCRIPTOR FROM EXISTING CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* go to base node */ cg_goto(index_file,index_base,"end"); /* find out how many descriptors are here: */ cg_ndescriptors(&ndescriptors); for (n=1; n <= ndescriptors; n++) { /* read descriptor */ cg_descriptor_read(n,name,&text); printf("\nThe descriptor is:\n\n%s\n",text); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read descriptors from file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_dimensional.c000066400000000000000000000072411474000356600233550ustar00rootroot00000000000000/* Program read_dimensional */ /* Opens an existing CGNS file that contains a simple 3-D grid plus a flow solution WITH DIMENSIONALITY, and reads the dimensionality. The CGNS grid file 'grid_c.cgns' must already exist (for example, created using write_grid_str.f followed by write_flowcent_str.f or write_grid_str.f followed by write_flowvert_str.f or write_grid_str.f followed by write_flowcentrind_str.f or write_grid_unst.f followed by write_flowvert_unst.f followed by write_dimensional.f) Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_dimensional.c cc -o read_dimensional_c read_dimensional.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib_f.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { int index_file,index_base,index_zone,index_flow,nfields,ncoords; int iff,ic; float exponents[5]; char fieldname[33],coordname[33]; CGNS_ENUMT(DataClass_t) id; CGNS_ENUMT(MassUnits_t) im; CGNS_ENUMT(LengthUnits_t) il; CGNS_ENUMT(TimeUnits_t) it; CGNS_ENUMT(TemperatureUnits_t) ix; CGNS_ENUMT(AngleUnits_t) ia; CGNS_ENUMT(DataType_t) idatatype; /* READ DIMENSIONAL INFO FOR GRID AND FLOW SOLN */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* we know there is only one FlowSolution_t (real working code would check!) */ index_flow=1; /* read DataClass and DimensionalUnits under Base */ cg_goto(index_file,index_base,"end"); cg_dataclass_read(&id); printf("\nDataClass = %s\n",DataClassName[id]); if (strcmp(DataClassName[id],"Dimensional") != 0) { printf("\nError! Expecting Dimensional\n"); return 1; } cg_units_read(&im,&il,&it,&ix,&ia); printf("\nUnits=\n %s\n %s\n %s\n %s\n %s\n", MassUnitsName[im],LengthUnitsName[il],TimeUnitsName[it], TemperatureUnitsName[ix],AngleUnitsName[ia]); /* read fields */ cg_nfields(index_file,index_base,index_zone,index_flow,&nfields); if (nfields != 2) { printf("\nError! expecting 2 fields, read %i\n",nfields); return 1; } for (iff=1; iff <= nfields; iff++) { /* read DimensionalExponents */ cg_goto(index_file,index_base,"Zone_t",1,"FlowSolution_t",1,"DataArray_t",iff,"end"); cg_exponents_read(exponents); /* get field name */ cg_field_info(index_file,index_base,index_zone,index_flow,iff,&idatatype,fieldname); printf("\nFor %s, exponents are:\n %f\n %f\n %f\n %f\n %f\n", fieldname,exponents[0],exponents[1],exponents[2],exponents[3],exponents[4]); } /* read grid */ cg_ncoords(index_file,index_base,index_zone,&ncoords); for (ic=1; ic <=ncoords; ic++) { /* read DimensionalExponents */ cg_goto(index_file,index_base,"Zone_t",1,"GridCoordinates_t",1, "DataArray_t",ic,"end"); cg_exponents_read(&exponents); /* get coord name */ cg_coord_info(index_file,index_base,index_zone,ic,&idatatype,coordname); printf("\nFor %s, exponents are:\n %f\n %f\n %f\n %f\n %f\n", coordname,exponents[0],exponents[1],exponents[2],exponents[3],exponents[4]); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read dimensional data from file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_discreteface_str.c000066400000000000000000000074321474000356600243660ustar00rootroot00000000000000/* Program read_discreteface_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid plus discrete data (at K-DIR FACE CENTERS PLUS RIND CELLS IN THE I AND J DIRECTIONS), and reads it. In memory, rind cells also exist in the K direction, necessitating use of cg_array_general_read. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c followed by write_discreteface_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_discreteface_str.c cc -o read_discreteface_str_c read_discreteface_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that there are no restrictions on tri-dimensional array f because because a general write interface is used). In the file, rind cells are stored in array locations [k][0][i], [k][17][i], [k][j][0], [k][j][21] In memory, rind cells are stored in array locations [0][j][i], [10][j][i], [k][0][i], [k][17][i], [k][j][0], [k][j][21] */ float f[9+2][16+2][20+2]; int irinddata[3][2]; int n,index_file,index_base,index_zone,index_discrete; char zonename[33]; cgsize_t isize[3][3],irmin[3],irmax[3],m_dims[3],m_rmin[3],m_rmax[3]; /* clear f since only partial read */ for (n=0; n<(9+2)*(16+2)*(20+2); n++) { (&f[0][0][0])[n] = -0.123456f; } /* READ FLOW SOLUTION FROM CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* we know there is only one DiscreteData_t (real working code would check!) */ index_discrete=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); /* go to position within tree at DiscreteData_t node */ cg_goto(index_file,index_base,"Zone_t",index_zone,"DiscreteData_t",index_discrete,"end"); /* read rind data */ cg_rind_read(irinddata[0]); /* dimensions of array in memory */ m_dims[0] = 20+2; m_dims[1] = 16+2; m_dims[2] = 9+2; /* in file space the core cells ALWAYS start at index 1 */ /* lower range index in file */ irmin[0]=1-irinddata[0][0]; irmin[1]=1-irinddata[1][0]; irmin[2]=1-irinddata[2][0]; /* upper range index in file - use vertex dimensions for k */ irmax[0]=isize[1][0]+irinddata[0][1]; irmax[1]=isize[1][1]+irinddata[1][1]; irmax[2]=isize[0][2]+irinddata[2][1]; /* in memory space, the lower bound ALWAYS starts at index 1 (in this example, * core cells start at 2) */ /* lower range index in memory */ m_rmin[0] = 2-irinddata[0][0]; m_rmin[1] = 2-irinddata[1][0]; m_rmin[2] = 2-irinddata[2][0]; /* upper range index in memory */ m_rmax[0] = 1+20+irinddata[0][1]; m_rmax[1] = 1+16+irinddata[1][1]; m_rmax[2] = 1+ 9+irinddata[2][1]; /* read discrete data */ if (cg_array_general_read(1, irmin, irmax, CGNS_ENUMV(RealSingle), 3, m_dims, m_rmin, m_rmax, f[0][0])) cg_error_exit(); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read discrete data from file grid_c.cgns\n"); printf(" For example, f[ 9][16][20]= %f\n",f[ 9][16][20]); printf(" rind: f[ 9][16][ 0]= %f\n",f[ 9][16][ 0]); printf(" rind: f[ 9][16][21]= %f\n",f[ 9][16][21]); printf(" unmodified: f[10][16][ 0]= %f\n",f[10][16][ 0]); printf("\nProgram successful... ending now\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_flowcent_str.c000066400000000000000000000057001474000356600235620ustar00rootroot00000000000000/* Program read_flowcent_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid plus a flow solution (at CELL CENTERS), and reads it. (Compare this program with read_flowvert_str) The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c followed by write_flowcent_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_flowcent_str.c cc -o read_flowcent_str_c read_flowcent_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays r and p must be dimensioned exactly as [N-1][17-1][21-1] (N>=9) for this particular case or else they will be read from the CGNS file incorrectly! Other options are to use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ double r[8][16][20],p[8][16][20]; cgsize_t isize[3][3],irmin[3],irmax[3]; int index_file,index_base,index_zone,index_flow; char zonename[33],solname[33]; CGNS_ENUMT(GridLocation_t) loc; /* READ FLOW SOLUTION FROM CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* we know there is only one FlowSolution_t (real working code would check!) */ index_flow=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); /* lower range index */ irmin[0]=1; irmin[1]=1; irmin[2]=1; /* upper range index - use cell dimensions */ /* checking GridLocation first (real working code would check */ /* to make sure there are no Rind cells also!): */ cg_sol_info(index_file,index_base,index_zone,index_flow,solname,&loc); if (loc != CGNS_ENUMV(CellCenter)) { printf("\nError, GridLocation must be CellCenter! Currently: %s\n", GridLocationName[loc]); return 1; } irmax[0]=isize[1][0]; irmax[1]=isize[1][1]; irmax[2]=isize[1][2]; /* read flow solution */ cg_field_read(index_file,index_base,index_zone,index_flow,"Density", \ CGNS_ENUMV(RealDouble),irmin,irmax,r[0][0]); cg_field_read(index_file,index_base,index_zone,index_flow,"Pressure", \ CGNS_ENUMV(RealDouble),irmin,irmax,p[0][0]); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read flow solution from file grid_c.cgns\n"); printf(" For example, r,p[7][15][19]= %f, %f\n",r[7][15][19],p[7][15][19]); printf("\nProgram successful... ending now\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_flowcentrind_str.c000066400000000000000000000066661474000356600244530ustar00rootroot00000000000000/* Program read_flowcentrind_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid plus a flow solution (at CELL CENTERS PLUS RIND CELLS IN THE I AND J DIRECTIONS), and reads it. (Compare this program with read_flowcent_str) The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c followed by write_flowcentrind_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_flowcentrind_str.c cc -o read_flowcentrind_str_c read_flowcentrind_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays r and p must be dimensioned exactly as [N-1][17-1+2][21-1+2] (N>=9) for this particular case or else they will be read from the CGNS file incorrectly! Other options are to use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): Rind cells are stored in array locations [k][0][i], [k][17][i], [k][j][0], [k][j][21] */ float r[8][18][22],p[8][18][22]; int irinddata[6]; int index_file,index_base,index_zone,index_flow; char zonename[33],solname[33]; CGNS_ENUMT(GridLocation_t) loc; cgsize_t isize[3][3],irmin[3],irmax[3]; /* READ FLOW SOLUTION FROM CGNS FILE */ /* open CGNS file for read-only */ cg_open("grid_c.cgns",CG_MODE_READ,&index_file); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* we know there is only one FlowSolution_t (real working code would check!) */ index_flow=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); /* go to position within tree at FlowSolution\_t node */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowSolution_t",index_flow,"end"); /* read rind data */ cg_rind_read(irinddata); /* lower range index */ irmin[0]=1-irinddata[0]; irmin[1]=1-irinddata[2]; irmin[2]=1-irinddata[4]; /* upper range index - use cell dimensions */ /* checking GridLocation first: */ cg_sol_info(index_file,index_base,index_zone,index_flow,solname,&loc); if (loc != CGNS_ENUMV(CellCenter)) { printf("\nError, GridLocation must be CellCenter! Currently: %s\n", GridLocationName[loc]); return 1; } irmax[0]=isize[1][0]+irinddata[1]; irmax[1]=isize[1][1]+irinddata[3]; irmax[2]=isize[1][2]+irinddata[5]; /* read flow solution */ cg_field_read(index_file,index_base,index_zone,index_flow,"Density", CGNS_ENUMV(RealSingle),irmin,irmax,r[0][0]); cg_field_read(index_file,index_base,index_zone,index_flow,"Pressure", CGNS_ENUMV(RealSingle),irmin,irmax,p[0][0]); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read flow solution from file grid_c.cgns\n"); printf(" For example, r,p[7][16][20]= %f, %f\n",r[7][16][20],p[7][16][20]); printf(" rind: r,p[7][16][0]= %f, %f\n",r[7][16][0],p[7][16][0]); printf(" rind: r,p[7][16][21]= %f, %f\n",r[7][16][21],p[7][16][21]); printf("\nProgram successful... ending now\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_floweqn_str.c000066400000000000000000000066361474000356600234250ustar00rootroot00000000000000/* Program read_floweqn_str */ /* Opens an existing CGNS file and reads flow equation info The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c followed by write_floweqn_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_floweqn_str.c cc -o read_floweqn_str_c read_floweqn_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { int idata[6]; int index_file,index_base,index_zone; int id,ige,igm,ivm,itcm,itc,itm; float gamma,prandtl; CGNS_ENUMT(GoverningEquationsType_t) itype; CGNS_ENUMT(ModelType_t) mtype; /* READ FLOW EQUATION SET INFO */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* existing file must be 3D structured (real working code would check!) */ /* Read info from 'FlowEquationSet' node under 'Zone_t' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"end"); if (cg_equationset_read(&id,&ige,&igm,&ivm,&itcm,&itc,&itm)) { printf("\nError! FlowEquationSet node does not exist.\n"); return 1; } printf("\nEqn dimension = %i\n",id); /* Read 'GoverningEquations' node */ if (ige == 1) { cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1,"end"); cg_governing_read(&itype); printf(" Gov eqn = %s\n",GoverningEquationsTypeName[itype]); /* Read 'DiffusionModel' node */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1, \ "GoverningEquations_t",1,"end"); cg_diffusion_read(idata); printf(" diffusion= %i, %i, %i, %i, %i, %i\n",idata[0],idata[1], \ idata[2],idata[3],idata[4],idata[5]); } /* Read gas model */ if (igm == 1) { cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1,"end"); cg_model_read("GasModel_t",&mtype); printf(" Gas model type = %s\n",ModelTypeName[mtype]); cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1, \ "GasModel_t",1,"end"); cg_array_read_as(1,CGNS_ENUMV(RealSingle),&gamma); printf(" gamma = %f\n",gamma); } /* Read turbulence closure */ if (itc == 1) { cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1,"end"); cg_model_read("TurbulenceClosure_t",&mtype); printf(" Turbulence closure type = %s\n",ModelTypeName[mtype]); cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1, \ "TurbulenceClosure_t",1,"end"); cg_array_read_as(1,CGNS_ENUMV(RealSingle),&prandtl); printf(" turb prandtl number = %f\n",prandtl); } if (itm == 1) { cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1,"end"); cg_model_read("TurbulenceModel_t",&mtype); printf(" Turbulence model type = %s\n",ModelTypeName[mtype]); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read equation set info from file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_flowvert_str.c000066400000000000000000000055741474000356600236220ustar00rootroot00000000000000/* Program read_flowvert_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid plus a flow solution (at VERTICES), and reads it. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c followed by write_flowvert_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_flowvert_str.c cc -o read_flowvert_str_c read_flowvert_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays r and p must be dimensioned exactly as [N][17][21] (N>=9) for this particular case or else they will be read from the CGNS file incorrectly! Other options are to use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ float r[9][17][21],p[9][17][21]; cgsize_t isize[3][3],irmin[3],irmax[3]; int index_file,index_base,index_zone,index_flow; char zonename[33],solname[33]; CGNS_ENUMT(GridLocation_t) loc; /* READ FLOW SOLUTION FROM CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* we know there is only one FlowSolution_t (real working code would check!) */ index_flow=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); /* lower range index */ irmin[0]=1; irmin[1]=1; irmin[2]=1; /* upper range index - use vertex dimensions */ /* checking GridLocation first (real working code would check */ /* to make sure there are no Rind cells also!): */ cg_sol_info(index_file,index_base,index_zone,index_flow,solname,&loc); if (loc != CGNS_ENUMV(Vertex)) { printf("\nError, GridLocation must be Vertex! Currently: %s\n", GridLocationName[loc]); return 1; } irmax[0]=isize[0][0]; irmax[1]=isize[0][1]; irmax[2]=isize[0][2]; /* read flow solution */ cg_field_read(index_file,index_base,index_zone,index_flow,"Density", CGNS_ENUMV(RealSingle),irmin,irmax,r[0][0]); cg_field_read(index_file,index_base,index_zone,index_flow,"Pressure", CGNS_ENUMV(RealSingle),irmin,irmax,p[0][0]); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read flow solution from file grid_c.cgns\n"); printf(" For example, r,p[8][16][20]= %f, %f\n",r[8][16][20],p[8][16][20]); printf("\nProgram successful... ending now\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_flowvert_unst.c000066400000000000000000000052451474000356600237760ustar00rootroot00000000000000/* Program read_flowvert_unst */ /* Opens an existing CGNS file that contains a simple 3-D unstructured grid plus a flow solution (at VERTICES), and reads it. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_unst.c followed by write_flowvert_unst.c) Note that, other than the dimensions of the variables r and p, this program is very similar to that for reading flow solutions from a structured zone: read_flowvert_str.c Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_flowvert_unst.c cc -o read_flowvert_unst_c read_flowvert_unst.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { float r[9*17*21],p[9*17*21]; cgsize_t isize[3][1],irmin,irmax; int index_file,index_base,index_zone,index_flow; char zonename[33],solname[33]; CGNS_ENUMT(GridLocation_t) loc; /* READ FLOW SOLUTION FROM CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* we know there is only one FlowSolution_t (real working code would check!) */ index_flow=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); /* lower range index */ irmin=1; /* upper range index - use vertex dimensions */ /* checking GridLocation first (real working code would check */ /* to make sure there are no Rind cells also!): */ cg_sol_info(index_file,index_base,index_zone,index_flow,solname,&loc); if (loc != CGNS_ENUMV(Vertex)) { printf("\nError, GridLocation must be Vertex! Currently: %s\n", GridLocationName[loc]); return 1; } irmax=isize[0][0]; /* read flow solution */ cg_field_read(index_file,index_base,index_zone,index_flow,"Density", \ CGNS_ENUMV(RealSingle),&irmin,&irmax,r); cg_field_read(index_file,index_base,index_zone,index_flow,"Pressure", \ CGNS_ENUMV(RealSingle),&irmin,&irmax,p); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read flow solution from file grid_c.cgns\n"); printf(" For example, r,p[379] = %f, %f\n",r[379],p[379]); printf(" r,p[3212]= %f, %f\n",r[3212],p[3212]); printf("\nProgram successful... ending now\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_grid2zn_str.c000066400000000000000000000064571474000356600233320ustar00rootroot00000000000000/* Program read_grid2zn_str */ /* Reads simple 3-D structured 2-zone grid from CGNS file (companion program to write_grid2zn_str.c) The CGNS grid file 'grid_c.cgns' must already exist. Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_grid2zn_str.c cc -o read_grid2zn_str_c read_grid2zn_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays x,y,z must be dimensioned exactly as [N][17][21] (N>=9) for this particular case or else they will be read from the CGNS file incorrectly! Other options are to use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ float x[9][17][21],y[9][17][21],z[9][17][21]; float xsav[2][9][17][21],ysav[2][9][17][21],zsav[2][9][17][21]; cgsize_t isize[3][3],irmin[3],irmax[3]; int index_file,index_base,nzone,index_zone,i,j,k; char zonename[33]; /* READ X, Y, Z GRID POINTS FROM CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* get number of zones (should be 2 for our case) */ cg_nzones(index_file,index_base,&nzone); if (nzone != 2) { printf("\nError. This program expects 2 zones. %i read\n",nzone); return 1; } /* do loop over the zones */ for (index_zone=1; index_zone <= nzone; index_zone++) { /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); /* lower range index */ irmin[0]=1; irmin[1]=1; irmin[2]=1; /* upper range index of vertices */ irmax[0]=isize[0][0]; irmax[1]=isize[0][1]; irmax[2]=isize[0][2]; /* read grid coordinates */ cg_coord_read(index_file,index_base,index_zone,"CoordinateX", \ CGNS_ENUMV(RealSingle),irmin,irmax,x[0][0]); cg_coord_read(index_file,index_base,index_zone,"CoordinateY", \ CGNS_ENUMV(RealSingle),irmin,irmax,y[0][0]); cg_coord_read(index_file,index_base,index_zone,"CoordinateZ", \ CGNS_ENUMV(RealSingle),irmin,irmax,z[0][0]); /* store grid coordinates in xsav,ysav,zsav array: */ for (i=0; i < isize[0][0]; i++) { for (j=0; j < isize[0][1]; j++) { for (k=0; k < isize[0][2]; k++) { xsav[index_zone-1][k][j][i]=x[k][j][i]; ysav[index_zone-1][k][j][i]=y[k][j][i]; zsav[index_zone-1][k][j][i]=z[k][j][i]; } } } } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read grid from file grid_c.cgns\n"); printf(" For example, zone 1 x,y,z[8][16][20]= %f, %f, %f\n", \ xsav[0][8][16][20],ysav[0][8][16][20],zsav[0][8][16][20]); printf(" zone 2 x,y,z[8][16][20]= %f, %f, %f\n", \ xsav[1][8][16][20],ysav[1][8][16][20],zsav[1][8][16][20]); printf("\nProgram successful... ending now\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_grid_str.c000066400000000000000000000046401474000356600226700ustar00rootroot00000000000000/* Program read_grid_str */ /* Reads simple 3-D structured grid from CGNS file (companion program to write_grid_str.c) The CGNS grid file 'grid_c.cgns' must already exist. Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_grid_str.c cc -o read_grid_str_c read_grid_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays x,y,z must be dimensioned exactly as [N][17][21] (N>=9) for this particular case or else they will be read from the CGNS file incorrectly! Other options are to use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ float x[9][17][21],y[9][17][21],z[9][17][21]; cgsize_t isize[3][3],irmin[3],irmax[3]; int index_file,index_base,index_zone; char zonename[33]; /* READ X, Y, Z GRID POINTS FROM CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); /* lower range index */ irmin[0]=1; irmin[1]=1; irmin[2]=1; /* upper range index of vertices */ irmax[0]=isize[0][0]; irmax[1]=isize[0][1]; irmax[2]=isize[0][2]; /* read grid coordinates */ cg_coord_read(index_file,index_base,index_zone,"CoordinateX", CGNS_ENUMV(RealSingle),irmin,irmax,x[0][0]); cg_coord_read(index_file,index_base,index_zone,"CoordinateY", CGNS_ENUMV(RealSingle),irmin,irmax,y[0][0]); cg_coord_read(index_file,index_base,index_zone,"CoordinateZ", CGNS_ENUMV(RealSingle),irmin,irmax,z[0][0]); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read grid from file grid_c.cgns\n"); printf(" For example, zone 1 x,y,z[8][16][20]= %f, %f, %f\n", \ x[8][16][20],y[8][16][20],z[8][16][20]); printf("\nProgram successful... ending now\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_grid_unst.c000066400000000000000000000064751474000356600230610ustar00rootroot00000000000000/* Program read_grid_unst */ /* Reads simple 3-D unstructured grid from a CGNS file (created using write_grid_unst.c). The CGNS grid file 'grid_c.cgns' must already exist. Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_grid_unst.c cc -o read_grid_unst_c read_grid_unst.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { float x[21*17*9],y[21*17*9],z[21*17*9]; cgsize_t isize[3][1],ielem[20*16*8][8]; int index_file,index_base,index_zone; cgsize_t irmin,irmax,istart,iend; int nsections,index_sect,nbndry,iparent_flag; cgsize_t iparentdata; char zonename[33],sectionname[33]; CGNS_ENUMT(ElementType_t) itype; /* READ X, Y, Z GRID POINTS FROM CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); /* lower range index */ irmin=1; /* upper range index of vertices */ irmax=isize[0][0]; /* read grid coordinates */ cg_coord_read(index_file,index_base,index_zone,"CoordinateX", CGNS_ENUMV(RealSingle),&irmin,&irmax,x); cg_coord_read(index_file,index_base,index_zone,"CoordinateY", CGNS_ENUMV(RealSingle),&irmin,&irmax,y); cg_coord_read(index_file,index_base,index_zone,"CoordinateZ", CGNS_ENUMV(RealSingle),&irmin,&irmax,z); /* find out how many sections */ cg_nsections(index_file,index_base,index_zone,&nsections); printf("\nnumber of sections=%i\n",nsections); /* read element connectivity */ for (index_sect=1; index_sect <= nsections; index_sect++) { cg_section_read(index_file,index_base,index_zone,index_sect,sectionname, &itype,&istart,&iend,&nbndry,&iparent_flag); printf("\nReading section data...\n"); printf(" section name=%s\n",sectionname); printf(" section type=%s\n",ElementTypeName[itype]); printf(" istart,iend=%i, %i\n",(int)istart,(int)iend); if (itype == CGNS_ENUMV(HEXA_8)) { printf(" reading element data for this element\n"); cg_elements_read(index_file,index_base,index_zone,index_sect,ielem[0], \ &iparentdata); } else { printf(" not reading element data for this element\n"); } } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read unstructured grid from file grid_c.cgns\n"); printf(" for example, element 1 is made up of nodes: %i, %i, %i, %i, %i, %i, %i, %i\n", (int)ielem[0][0],(int)ielem[0][1],(int)ielem[0][2],(int)ielem[0][3], (int)ielem[0][4],(int)ielem[0][5],(int)ielem[0][6],(int)ielem[0][7]); printf(" x,y,z of node 357 are: %f, %f, %f\n",x[357],y[357],z[357]); printf(" x,y,z of node 1357 are: %f, %f, %f\n",x[1357],y[1357],z[1357]); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_nondimensional.c000066400000000000000000000044161474000356600240710ustar00rootroot00000000000000/* Program read_nondimensional */ /* Opens an existing CGNS file and reads the DataClass and ReferenceState appropriate for a completely NONDIMENSIONAL data set. The CGNS grid file 'grid_c.cgns' must already exist, processed further using write_nondimensional.c. Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_nondimensional.c cc -o read_nondimensional_c read_nondimensional.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { double data; int index_file,index_base,narrays,n,idim; char *state,arrayname[33]; CGNS_ENUMT(DataClass_t) id; CGNS_ENUMT(DataType_t) idata; cgsize_t idimvec; /* READ NONDIMENSIONAL INFO */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* read DataClass under Base */ cg_goto(index_file,index_base,"end"); cg_dataclass_read(&id); printf("\nDataClass = %s\n",DataClassName[id]); if (id != CGNS_ENUMV(NormalizedByUnknownDimensional)) { printf("\nError! Expecting NormalizedByUnknownDimensional\n"); return 1; } /* read ReferenceState under Base */ cg_state_read(&state); printf("\nReferenceState = %s\n",state); /* Go to ReferenceState node, read Mach array and its dataclass */ cg_goto(index_file,index_base,"ReferenceState_t",1,"end"); /* find out how many data arrays */ cg_narrays(&narrays); for (n=1; n <= narrays; n++) { cg_array_info(n,arrayname,&idata,&idim,&idimvec); if (idim != 1 || idimvec != 1) { printf("\nError! expecting idim,idimvec=1,1\n"); printf(" they are idim,idimvec= %i, %i\n",idim,(int)idimvec); return 1; } cg_array_read_as(n,CGNS_ENUMV(RealDouble),&data); printf("Variable=%s\n",arrayname); printf(" data=%18.8f\n",data); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read nondimensional info from file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/read_timevert_str.c000066400000000000000000000147141474000356600236050ustar00rootroot00000000000000/* Program read_timevert_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid plus 3 different flow solutions (at VERTICES), along with time-accurate info, and reads it. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c followed by write_timevert_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c read_timevert_str.c cc -o read_timevert_str_c read_timevert_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays r1, r2, r3 and p1, p2, p3 must be dimensioned exactly as [N][17][21] (N>=9) for this particular case or else they will be written to the CGNS file incorrectly! Other options are to use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ float r1[9][17][21],p1[9][17][21]; float r2[9][17][21],p2[9][17][21]; float r3[9][17][21],p3[9][17][21]; float time[3]; cgsize_t isize[3][3],irmin[3],irmax[3]; int index_file,index_base,index_zone,nsteps,narrays; int id1,n; cgsize_t idims[2],id2; char zonename[33],bitername[33],zitername[33]; char arrayname[33]; char solname[97],solname2[33]; char sn[3][33]; CGNS_ENUMT(DataType_t) idatatype; CGNS_ENUMT(SimulationType_t) isim; CGNS_ENUMT(GridLocation_t) loc; /* READ FLOW SOLUTION FROM CGNS FILE */ /* open CGNS file for read-only */ if (cg_open("grid_c.cgns",CG_MODE_READ,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); /* lower range index */ irmin[0]=1; irmin[1]=1; irmin[2]=1; /* upper range index - use vertex dimensions */ irmax[0]=isize[0][0]; irmax[1]=isize[0][1]; irmax[2]=isize[0][2]; /* read BaseIterativeData */ cg_biter_read(index_file,index_base,bitername,&nsteps); printf("\nnumber of time steps stored = %i\n",nsteps); if (nsteps != 3) { printf("\nError, expecting nsteps=3!\n"); return 1; } cg_goto(index_file,index_base,"BaseIterativeData_t",1,"end"); cg_narrays(&narrays); if (narrays != 1) { printf("\nError, expecting 1 array in BaseIterativeData... there are %i\n",narrays); return 1; } cg_array_info(1,arrayname,&idatatype,&id1,&id2); if (id1 != 1 || id2 != 3) { printf("\nError, expecting data dimension and vector to be 1 and 3 in " "BaseIterativeData... read %i, %i\n",id1,(int)id2); return 1; } cg_array_read_as(1,CGNS_ENUMV(RealSingle),time); printf("\nTimes stored are:\n"); for (n=0; n < nsteps; n++) { printf(" %f\n",time[n]); } /* read ZoneIterativeData */ cg_ziter_read(index_file,index_base,index_zone,zitername); cg_goto(index_file,index_base,"Zone_t",index_zone,"ZoneIterativeData_t",1,"end"); cg_narrays(&narrays); if (narrays != 1) { printf("\nError, expecting 1 array in ZoneIterativeData... there are %i\n",narrays); return 1; } cg_array_info(1,arrayname,&idatatype,&id1,idims); if (id1 != 2 || idims[0] != 32) { printf("\nError, expecting data dimension and vector to be 2 and 32 in " "ZoneIterativeData... read %i, %i\n",id1,(int)idims[0]); return 1; } cg_array_read_as(1,CGNS_ENUMV(Character),solname); strncpy(sn[0],&solname[0],32); strncpy(sn[1],&solname[32],32); strncpy(sn[2],&solname[64],32); printf("\nFlow solution names corresponding to each are:\n"); for (n=0; n < nsteps; n++) { printf(" %.32s\n",sn[n]); } /* read SimulationType */ cg_simulation_type_read(index_file,index_base,&isim); printf("\nSimulation type is: %s\n",SimulationTypeName[isim]); /* do loop to read flow solutions */ for (n=1; n <= nsteps; n++) { /* check that soln names match, and also check GridLocation (real */ /* working code would check to make sure there are no Rind cells */ /* also!): */ cg_sol_info(index_file,index_base,index_zone,n,solname2,&loc); if (strncmp(solname2,sn[n-1],strlen(solname2)) != 0) { printf("\nError, soln names do not match\n"); printf(" solname2=%s\n",solname2); printf(" sn[%i]=%s\n",n-1,sn[n-1]); return 1; } if (loc != CGNS_ENUMV(Vertex)) { printf("\nError, GridLocation must be Vertex! Currently: %s\n", GridLocationName[loc]); return 1; } if (n == 1) { cg_field_read(index_file,index_base,index_zone,n,"Density", CGNS_ENUMV(RealSingle),irmin,irmax,r1[0][0]); cg_field_read(index_file,index_base,index_zone,n,"Pressure", CGNS_ENUMV(RealSingle),irmin,irmax,p1[0][0]); } else if (n == 2) { cg_field_read(index_file,index_base,index_zone,n,"Density", CGNS_ENUMV(RealSingle),irmin,irmax,r2[0][0]); cg_field_read(index_file,index_base,index_zone,n,"Pressure", CGNS_ENUMV(RealSingle),irmin,irmax,p2[0][0]); } else { cg_field_read(index_file,index_base,index_zone,n,"Density", CGNS_ENUMV(RealSingle),irmin,irmax,r3[0][0]); cg_field_read(index_file,index_base,index_zone,n,"Pressure", CGNS_ENUMV(RealSingle),irmin,irmax,p3[0][0]); } } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully read 3 flow solutions from file grid_c.cgns\n"); printf(" For example, r1,p1[0][0][0]=%f, %f\n",r1[0][0][0],p1[0][0][0]); printf(" r2,p2[0][0][0]=%f, %f\n",r2[0][0][0],p2[0][0][0]); printf(" r3,p3[0][0][0]=%f, %f\n",r3[0][0][0],p3[0][0][0]); printf(" For example, r1,p1[8][16][20]=%f, %f\n",r1[8][16][20],p1[8][16][20]); printf(" r2,p2[8][16][20]=%f, %f\n",r2[8][16][20],p2[8][16][20]); printf(" r3,p3[8][16][20]=%f, %f\n",r3[8][16][20],p3[8][16][20]); printf("\nProgram successful... ending now\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/test.sh000077500000000000000000000076001474000356600212310ustar00rootroot00000000000000#! /bin/bash NO_COLOR="\033[0m" OK_COLOR="\033[32;01m" ERROR_COLOR="\033[31;01m" echoresults() { padlimit=40 pad=$(printf '%*s' "$padlimit") pad=${pad// /.} padlength=40 printf ' %*.*s' 0 $((padlength - ${#x} )) "$pad" if test $status -ne 0 then printf " [${ERROR_COLOR}FAILED${NO_COLOR}]\n" status=1 else printf " [${OK_COLOR}PASSED${NO_COLOR}]" printf "%+12s\n" "$itime" fi } TIMING_AVAIL=$(/usr/bin/time -a -o CGNS_timing.txt -f "%e" pwd > /dev/null; echo $?) run_tests() { printf "%-40s \n" "Testing $dir..." cd "$dir" # loop through tests size_arr=${#w_arr[@]} #Number of elements in the array itime="" for i in $(seq 1 $size_arr);do x=" Program: ${w_arr[$i-1]}" printf "$x" if [ "$TIMING_AVAIL" = "0" ]; then /usr/bin/time -a -o ../CGNS_timing.txt -f "$dir.${w_arr[$i-1]} %e" "./${w_arr[$i-1]}" >/dev/null 2>&1 itime=$(tail -n1 ../CGNS_timing.txt | awk '{print $2}' | sed -e 's/$/ sec/') else "./${w_arr[$i-1]}" >/dev/null 2>&1 fi status=$? echoresults return_val=$((status + return_val)) x=" Program: ${r_arr[$i-1]}" printf "$x" if [ "$TIMING_AVAIL" = "0" ]; then /usr/bin/time -a -o ../CGNS_timing.txt -f "$dir.${r_arr[$i-1]} %e" "./${r_arr[$i-1]}" > "build/output$i" itime=$(tail -n1 ../CGNS_timing.txt | awk '{print $2}' | sed -e 's/$/ sec/') else "./${r_arr[$i-1]}" > build/output$i fi diff <( sed '/Library/ d' "build/output$i") <( sed '/Library/ d' "./OUTPUT$i") > "build/results$i.txt" status=$? echoresults return_val=$((status + return_val)) done cd .. } return_val=0 rm -f CGNS_timing.txt ############################### # Special cases ############################### ## declare an array of tests declare -a w_arr=("write_grid_str" "write_flowvert_str" "write_nondimensional" "write_descriptor" \ "write_convergence" "write_floweqn_str" "write_bcpnts_str") declare -a r_arr=("read_grid_str" "read_flowvert_str" "read_nondimensional" "read_descriptor" \ "read_convergence" "read_floweqn_str" "read_bcpnts_str") dir=Test_Grid_Str run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid_unst" "write_flowvert_unst" "write_dimensional" "write_descriptor" "write_convergence" "write_bcpnts_unst") declare -a r_arr=("read_grid_unst" "read_flowvert_unst" "read_dimensional" "read_descriptor" "read_convergence" "read_bcpnts_unst") dir=Test_Grid_Unstr run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid_str" "write_timevert_str") declare -a r_arr=("read_grid_str" "read_timevert_str") dir=Test_Grid_Str_Timeacc run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid_str" "write_flowcent_str" "write_bc_str") declare -a r_arr=("read_grid_str" "read_flowcent_str" "read_bc_str") dir=Test_Grid_Str_FlowCent run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid_str" "write_flowcentrind_str") declare -a r_arr=("read_grid_str" "read_flowcentrind_str") dir=Test_Grid_Str_FlowCentRind run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid2zn_str" "write_con2zn_str") declare -a r_arr=("read_grid2zn_str" "read_con2zn_str") dir=Test_Grid_Str_2zn run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid2zn_str" "write_con2zn_genrl_str") declare -a r_arr=("read_grid2zn_str" "read_con2zn_genrl_str") dir=Test_Grid_Str_2zngenrl run_tests ############################### echo "=== finished ===" if test $return_val != 0; then printf "$ERROR_COLOR" else printf "$OK_COLOR" fi printf "$return_val tests failed $NO_COLOR \n" exit $return_val CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_bc_str.c000066400000000000000000000101621474000356600225420ustar00rootroot00000000000000/* Program write_bc_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid, and adds BC definitions (defined over a range of points = PointRange) The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c). Note: whether the existing CGNS file has a flow solution in it already or not is irrelevant. Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_bc_str.c cc -o write_bc_str_c write_bc_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { cgsize_t isize[3][3],ipnts[2][3]; int index_file,index_base,index_zone,index_bc; int ilo,ihi,jlo,jhi,klo,khi; char zonename[33]; printf("\nProgram write_bc_str\n"); /* WRITE BOUNDARY CONDITIONS TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); printf("zonename=%s\n",zonename); ilo=1; ihi=isize[0][0]; jlo=1; jhi=isize[0][1]; klo=1; khi=isize[0][2]; /* write boundary conditions for ilo face, defining range first */ /* (user can give any name) */ /* lower point of range */ ipnts[0][0]=ilo; ipnts[0][1]=jlo; ipnts[0][2]=klo; /* upper point of range */ ipnts[1][0]=ilo; ipnts[1][1]=jhi; ipnts[1][2]=khi; cg_boco_write(index_file,index_base,index_zone,"Ilo",CGNS_ENUMV(BCTunnelInflow), CGNS_ENUMV(PointRange),2,ipnts[0],&index_bc); /* write boundary conditions for ihi face, defining range first */ /* (user can give any name) */ /* lower point of range */ ipnts[0][0]=ihi; ipnts[0][1]=jlo; ipnts[0][2]=klo; /* upper point of range */ ipnts[1][0]=ihi; ipnts[1][1]=jhi; ipnts[1][2]=khi; cg_boco_write(index_file,index_base,index_zone,"Ihi",CGNS_ENUMV(BCExtrapolate), CGNS_ENUMV(PointRange),2,ipnts[0],&index_bc); /* write boundary conditions for jlo face, defining range first */ /* (user can give any name) */ /* lower point of range */ ipnts[0][0]=ilo; ipnts[0][1]=jlo; ipnts[0][2]=klo; /* upper point of range */ ipnts[1][0]=ihi; ipnts[1][1]=jlo; ipnts[1][2]=khi; cg_boco_write(index_file,index_base,index_zone,"Jlo",CGNS_ENUMV(BCWallInviscid), CGNS_ENUMV(PointRange),2,ipnts[0],&index_bc); /* write boundary conditions for jhi face, defining range first */ /* (user can give any name) */ /* lower point of range */ ipnts[0][0]=ilo; ipnts[0][1]=jhi; ipnts[0][2]=klo; /* upper point of range */ ipnts[1][0]=ihi; ipnts[1][1]=jhi; ipnts[1][2]=khi; cg_boco_write(index_file,index_base,index_zone,"Jhi",CGNS_ENUMV(BCWallInviscid), CGNS_ENUMV(PointRange),2,ipnts[0],&index_bc); /* write boundary conditions for klo face, defining range first */ /* (user can give any name) */ /* lower point of range */ ipnts[0][0]=ilo; ipnts[0][1]=jlo; ipnts[0][2]=klo; /* upper point of range */ ipnts[1][0]=ihi; ipnts[1][1]=jhi; ipnts[1][2]=klo; cg_boco_write(index_file,index_base,index_zone,"Klo",CGNS_ENUMV(BCWallInviscid), CGNS_ENUMV(PointRange),2,ipnts[0],&index_bc); /* write boundary conditions for khi face, defining range first */ /* (user can give any name) */ /* lower point of range */ ipnts[0][0]=ilo; ipnts[0][1]=jlo; ipnts[0][2]=khi; /* upper point of range */ ipnts[1][0]=ihi; ipnts[1][1]=jhi; ipnts[1][2]=khi; cg_boco_write(index_file,index_base,index_zone,"Khi",CGNS_ENUMV(BCWallInviscid), CGNS_ENUMV(PointRange),2,ipnts[0],&index_bc); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added BCs (PointRange) to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_bcpnts_str.c000066400000000000000000000125331474000356600234530ustar00rootroot00000000000000/* Program write_bcpnts_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid, and adds BC definitions (defined as individual points = PointList) The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c). Note: whether the existing CGNS file has a flow solution in it already or not is irrelevant. Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_bcpnts_str.c cc -o write_bcpnts_str_c write_bcpnts_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif #define maxcount 400 int main() { cgsize_t isize[3][3],ipnts[maxcount][3],icounts; int index_file,index_base,index_zone,index_bc; int ilo,ihi,jlo,jhi,klo,khi; int icount,i,j,k; char zonename[33]; printf("\nProgram write_bcpnts_str\n"); /* WRITE BOUNDARY CONDITIONS TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* get zone size (and name - although not needed here) */ cg_zone_read(index_file,index_base,index_zone,zonename,isize[0]); printf("zonename=%s\n",zonename); ilo=1; ihi=isize[0][0]; jlo=1; jhi=isize[0][1]; klo=1; khi=isize[0][2]; /* write boundary conditions for ilo face, defining pointlist first */ /* (user can give any name) */ icount=0; for (j=jlo; j <= jhi; j++) { for (k=klo; k <= khi; k++) { ipnts[icount][0]=ilo; ipnts[icount][1]=j; ipnts[icount][2]=k; icount=icount+1; } } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } icounts=icount; cg_boco_write(index_file,index_base,index_zone,"Ilo",CGNS_ENUMV(BCTunnelInflow), CGNS_ENUMV(PointList),icounts,ipnts[0],&index_bc); /* write boundary conditions for ihi face, defining pointlist first */ /* (user can give any name) */ icount=0; for (j=jlo; j <= jhi; j++) { for (k=klo; k <= khi; k++) { ipnts[icount][0]=ihi; ipnts[icount][1]=j; ipnts[icount][2]=k; icount=icount+1; } } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } icounts=icount; cg_boco_write(index_file,index_base,index_zone,"Ihi",CGNS_ENUMV(BCExtrapolate), CGNS_ENUMV(PointList),icounts,ipnts[0],&index_bc); /* write boundary conditions for jlo face, defining pointlist first */ /* (user can give any name) */ icount=0; for (i=ilo; i <= ihi; i++) { for (k=klo; k <= khi; k++) { ipnts[icount][0]=i; ipnts[icount][1]=jlo; ipnts[icount][2]=k; icount=icount+1; } } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } icounts=icount; cg_boco_write(index_file,index_base,index_zone,"Jlo",CGNS_ENUMV(BCWallInviscid), CGNS_ENUMV(PointList),icounts,ipnts[0],&index_bc); /* write boundary conditions for jhi face, defining pointlist first */ /* (user can give any name) */ icount=0; for (i=ilo; i <= ihi; i++) { for (k=klo; k <= khi; k++) { ipnts[icount][0]=i; ipnts[icount][1]=jhi; ipnts[icount][2]=k; icount=icount+1; } } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } icounts=icount; cg_boco_write(index_file,index_base,index_zone,"Jhi",CGNS_ENUMV(BCWallInviscid), CGNS_ENUMV(PointList),icounts,ipnts[0],&index_bc); /* write boundary conditions for klo face, defining pointlist first */ /* (user can give any name) */ icount=0; for (i=ilo; i <= ihi; i++) { for (j=jlo; j <= jhi; j++) { ipnts[icount][0]=i; ipnts[icount][1]=j; ipnts[icount][2]=klo; icount=icount+1; } } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } icounts=icount; cg_boco_write(index_file,index_base,index_zone,"Klo",CGNS_ENUMV(BCWallInviscid), CGNS_ENUMV(PointList),icounts,ipnts[0],&index_bc); /* write boundary conditions for khi face, defining pointlist first */ /* (user can give any name) */ icount=0; for (i=ilo; i <= ihi; i++) { for (j=jlo; j <= jhi; j++) { ipnts[icount][0]=i; ipnts[icount][1]=j; ipnts[icount][2]=khi; icount=icount+1; } } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } icounts=icount; cg_boco_write(index_file,index_base,index_zone,"Khi",CGNS_ENUMV(BCWallInviscid), CGNS_ENUMV(PointList),icounts,ipnts[0],&index_bc); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added BCs (PointList) to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_bcpnts_unst.c000066400000000000000000000100221474000356600236230ustar00rootroot00000000000000/* Program write_bcpnts_unst */ /* Opens an existing CGNS file that contains a simple 3-D unstructured grid, and adds BC definitions (defined as individual FaceCenter "points" = PointList+GridLocation=FaceCenter) The BCs are added as FaceCenter points, associated with face elements (QUAD_4), rather than associated to nodes For the following, be sure you are using Version 2.0 or later release of the API The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_unst.c). Note: whether the existing CGNS file has a flow solution in it already or not is irrelevant. Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_bcpnts_unst.c cc -o write_bcpnts_unst_c write_bcpnts_unst.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif #define maxcount 960 int main() { int index_file,index_base,index_zone; int nelem_start,nelem_end,icount,index_bc,ibc,n; cgsize_t ipnts[maxcount],icounts; printf("\nProgram write_bcpnts_unst\n"); /* WRITE BOUNDARY CONDITIONS TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* we know that for the unstructured zone, the following face elements */ /* have been defined as inflow (real working code would check!): */ nelem_start=2561; nelem_end=2688; icount=0; for (n=nelem_start; n <= nelem_end; n++) { ipnts[icount]=n; icount=icount+1; } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } /* write boundary conditions for ilo face */ icounts=icount; cg_boco_write(index_file,index_base,index_zone,"Ilo",CGNS_ENUMV(BCTunnelInflow), CGNS_ENUMV(PointList),icounts,ipnts,&index_bc); /* we know that for the unstructured zone, the following face elements */ /* have been defined as outflow (real working code would check!): */ nelem_start=2689; nelem_end=2816; icount=0; for (n=nelem_start; n <= nelem_end; n++) { ipnts[icount]=n; icount=icount+1; } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } /* write boundary conditions for ihi face */ icounts=icount; cg_boco_write(index_file,index_base,index_zone,"Ihi",CGNS_ENUMV(BCExtrapolate), CGNS_ENUMV(PointList),icounts,ipnts,&index_bc); /* we know that for the unstructured zone, the following face elements */ /* have been defined as walls (real working code would check!): */ nelem_start=2817; nelem_end=3776; icount=0; for (n=nelem_start; n <= nelem_end; n++) { ipnts[icount]=n; icount=icount+1; } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } /* write boundary conditions for wall faces */ icounts=icount; cg_boco_write(index_file,index_base,index_zone,"Walls",CGNS_ENUMV(BCWallInviscid), CGNS_ENUMV(PointList),icounts,ipnts,&index_bc); /* the above are all face-center locations for the BCs - must indicate this, */ /* otherwise Vertices will be assumed! */ for (ibc=1; ibc <= index_bc; ibc++) { /* (the following call positions you in BC_t - it assumes there */ /* is only one Zone_t and one ZoneBC_t - real working code would check!) */ cg_goto(index_file,index_base,"Zone_t",1,"ZoneBC_t",1,"BC_t",ibc,"end"); cg_gridlocation_write(CGNS_ENUMV(FaceCenter)); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added FaceCenter BCs (PointList) to unstructured grid file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_con2zn_genrl_str.c000066400000000000000000000107711474000356600245640ustar00rootroot00000000000000/* Program write_con2zn_genrl_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid (2 zones), and adds 1-to-1 connectivity information to it (using GENERAL method, as opposed to specific 1-to-1 method). The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid2zn_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_con2zn_genrl_str.c cc -o write_con2zn_genrl_str_c write_con2zn_genrl_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif #define maxcount 400 int main() { int ilo[2],ihi[2],jlo[2],jhi[2],klo[2],khi[2]; int icount,j,k; int index_file,index_base,nzone,index_zone,nconns,n1to1,index_conn,iz; char donorname[33],zonename0[33],zonename1[33],zn[33]; cgsize_t isize[3][3],ipnts[maxcount][3],ipntsdonor[maxcount][3]; cgsize_t icounts; printf("\nProgram write_con2zn_genrl_str\n"); /* WRITE GENERAL CONNECTIVITY INFORMATION TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* get number of zones (should be 2 for our case) */ cg_nzones(index_file,index_base,&nzone); if (nzone != 2) { printf("\nError. This program expects 2 zones. %d read.\n",nzone); return 1; } /* loop over zones to get zone sizes and names */ for (index_zone=0; index_zone < nzone; ++index_zone) { iz=index_zone+1; cg_zone_read(index_file,index_base,iz,zn,isize[0]); if (index_zone == 0) { strcpy(zonename0,zn); } else { strcpy(zonename1,zn); } ilo[index_zone]=1; ihi[index_zone]=isize[0][0]; jlo[index_zone]=1; jhi[index_zone]=isize[0][1]; klo[index_zone]=1; khi[index_zone]=isize[0][2]; } /* loop over zones again */ for (index_zone=0; index_zone < nzone; ++index_zone) { iz=index_zone+1; /* for this program, there should be no existing connectivity info: */ cg_nconns(index_file,index_base,iz,&nconns); if (nconns != 0) { printf("\nError. This program expects no interfaces yet. %d read.\n",nconns); return 1; } cg_n1to1(index_file,index_base,iz,&n1to1); if (n1to1 != 0) { printf("\nError. This program expects no interfaces yet. %d read.\n",n1to1); return 1; } /* set up point lists */ if (index_zone == 0) { strcpy(donorname,zonename1); icount=0; for (j=jlo[index_zone]; j <= jhi[index_zone]; j++) { for (k=klo[index_zone]; k <= khi[index_zone]; k++) { ipnts[icount][0]=ihi[0]; ipnts[icount][1]=j; ipnts[icount][2]=k; ipntsdonor[icount][0]=ilo[1]; ipntsdonor[icount][1]=j; ipntsdonor[icount][2]=k; icount=icount+1; } } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } } else { strcpy(donorname,zonename0); icount=0; for (j=jlo[index_zone]; j <= jhi[index_zone]; j++) { for (k=klo[index_zone]; k <= khi[index_zone]; k++) { ipnts[icount][0]=ilo[1]; ipnts[icount][1]=j; ipnts[icount][2]=k; ipntsdonor[icount][0]=ihi[0]; ipntsdonor[icount][1]=j; ipntsdonor[icount][2]=k; icount=icount+1; } } if (icount > maxcount) { printf("\nError. Need to increase maxcount to at least %i\n",icount); return 1; } } /* write integer connectivity info (user can give any name) */ icounts=icount; cg_conn_write(index_file,index_base,iz,"GenInterface",CGNS_ENUMV(Vertex),CGNS_ENUMV(Abutting1to1), CGNS_ENUMV(PointList),icounts,ipnts[0],donorname,CGNS_ENUMV(Structured), CGNS_ENUMV(PointListDonor),CGNS_ENUMV(Integer),icounts,ipntsdonor[0],&index_conn); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added 1-to-1 connectivity info to file grid_c.cgns (using GENERAL method)\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_con2zn_str.c000066400000000000000000000101221474000356600233630ustar00rootroot00000000000000/* Program write_con2zn_str.c */ /* Opens an existing CGNS file that contains a simple 3-D structured grid (2 zones), and adds 1-to-1 connectivity information to it. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid2zn_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_con2zn_str.c cc -o write_con2zn_str_c write_con2zn_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { int ilo[2],ihi[2],jlo[2],jhi[2],klo[2],khi[2]; int itranfrm[3]; int index_file,index_base,nzone,index_zone,nconns,n1to1,index_conn,iz; char donorname[33],zonename0[33],zonename1[33],zn[33]; cgsize_t isize[3][3],ipnts[2][3],ipntsdonor[2][3]; printf("\nProgram write_con2zn_str\n"); /* WRITE 1-TO-1 CONNECTIVITY INFORMATION TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* get number of zones (should be 2 for our case) */ cg_nzones(index_file,index_base,&nzone); if (nzone != 2) { printf("\nError. This program expects 2 zones. %d read.\n",nzone); return 1; } /* loop over zones to get zone sizes and names */ for (index_zone=0; index_zone < nzone; ++index_zone) { iz=index_zone+1; cg_zone_read(index_file,index_base,iz,zn,isize[0]); if (index_zone == 0) { strcpy(zonename0,zn); } else { strcpy(zonename1,zn); } ilo[index_zone]=1; ihi[index_zone]=isize[0][0]; jlo[index_zone]=1; jhi[index_zone]=isize[0][1]; klo[index_zone]=1; khi[index_zone]=isize[0][2]; } /* loop over zones again */ for (index_zone=0; index_zone < nzone; ++index_zone) { iz=index_zone+1; /* for this program, there should be no existing connectivity info: */ cg_nconns(index_file,index_base,iz,&nconns); if (nconns != 0) { printf("\nError. This program expects no interfaces yet. %d read.\n",nconns); return 1; } cg_n1to1(index_file,index_base,iz,&n1to1); if (n1to1 != 0) { printf("\nError. This program expects no interfaces yet. %d read.\n",n1to1); return 1; } /* set up index ranges */ if (index_zone == 0) { strcpy(donorname,zonename1); /* lower point of receiver range */ ipnts[0][0]=ihi[0]; ipnts[0][1]=jlo[0]; ipnts[0][2]=klo[0]; /* upper point of receiver range */ ipnts[1][0]=ihi[0]; ipnts[1][1]=jhi[0]; ipnts[1][2]=khi[0]; /* lower point of donor range */ ipntsdonor[0][0]=ilo[1]; ipntsdonor[0][1]=jlo[1]; ipntsdonor[0][2]=klo[1]; /* upper point of donor range */ ipntsdonor[1][0]=ilo[1]; ipntsdonor[1][1]=jhi[1]; ipntsdonor[1][2]=khi[1]; } else { strcpy(donorname,zonename0); /* lower point of receiver range */ ipnts[0][0]=ilo[1]; ipnts[0][1]=jlo[1]; ipnts[0][2]=klo[1]; /* upper point of receiver range */ ipnts[1][0]=ilo[1]; ipnts[1][1]=jhi[1]; ipnts[1][2]=khi[1]; /* lower point of donor range */ ipntsdonor[0][0]=ihi[0]; ipntsdonor[0][1]=jlo[0]; ipntsdonor[0][2]=klo[0]; /* upper point of donor range */ ipntsdonor[1][0]=ihi[0]; ipntsdonor[1][1]=jhi[0]; ipntsdonor[1][2]=khi[0]; } /* set up Transform */ itranfrm[0]=1; itranfrm[1]=2; itranfrm[2]=3; /* write 1-to-1 info (user can give any name) */ cg_1to1_write(index_file,index_base,iz,"Interface",donorname, ipnts[0],ipntsdonor[0],itranfrm,&index_conn); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added 1-to-1 connectivity info to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_convergence.c000066400000000000000000000032441474000356600235670ustar00rootroot00000000000000/* Program write_convergence */ /* Adds convergence history to an existing CGNS file. The CGNS grid file 'grid_c.cgns' must already exist. Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_convergence.c cc -o write_convergence_c write_convergence.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif #define ntt 20 int main() { double cl[ntt]; int n,index_file,index_base; cgsize_t nuse; printf("\nProgram write_convergence\n"); /* create history array simple example: */ for (n=0; n < ntt; n++) { cl[n]=(float)n+1.; } printf("\ncreated simple cl history\n"); /* WRITE CONVERGENCE HISTORY INFORMATION TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* go to base node */ cg_goto(index_file,index_base,"end"); /* create history node (SIDS names it GlobalConvergenceHistory at base level) */ cg_convergence_write(ntt,""); /* go to new history node */ cg_goto(index_file,index_base,"ConvergenceHistory_t",1,"end"); /* write lift coefficient array (user must use SIDS-standard name here) */ nuse=ntt; cg_array_write("CoefLift",CGNS_ENUMV(RealDouble),1,&nuse,&cl); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully wrote cl history to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_descriptor.c000066400000000000000000000025461474000356600234530ustar00rootroot00000000000000/* Program write_descriptor */ /* Adds descriptor node to an existing CGNS file (under the CGNSBase_t node). The CGNS grid file 'grid_c.cgns' must already exist. Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_descriptor.c cc -o write_descriptor_c write_descriptor.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { int index_file,index_base; char textstring[74]; printf("\nProgram write_descriptor\n"); /* WRITE DESCRIPTOR NODE AT BASE LEVEL */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* go to base node */ cg_goto(index_file,index_base,"end"); /* write descriptor node (user can give any name) */ strcpy(textstring,"Supersonic vehicle with landing gear\n"); strcat(textstring,"M=4.6, Re=6 million"); cg_descriptor_write("Information",textstring); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully wrote descriptor node to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_dimensional.c000066400000000000000000000066311474000356600235760ustar00rootroot00000000000000/* Program write_dimensional */ /* Opens an existing CGNS file that contains a simple 3-D grid plus a flow solution and adds its dimensionality (dimensional data). The CGNS grid file 'grid_c.cgns' must already exist (for example, created using write_grid_str.c followed by write_flowcent_str.c or write_grid_str.c followed by write_flowvert_str.c or write_grid_str.c followed by write_flowcentrind_str.c or write_grid_unst.c followed by write_flowvert_unst.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_dimensional.c cc -o write_dimensional_c write_dimensional.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { float exponents[5]; int index_file,index_base,index_zone,index_flow; int nfields,iff,icc,ncoords; char fieldname[33]; CGNS_ENUMT(DataType_t) idatatype; printf("\nProgram write_dimensional\n"); /* WRITE DIMENSIONAL INFO FOR GRID AND FLOW SOLN */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* we know there is only one FlowSolution_t (real working code would check!) */ index_flow=1; /* put DataClass and DimensionalUnits under Base */ cg_goto(index_file,index_base,"end"); cg_dataclass_write(CGNS_ENUMV(Dimensional)); cg_units_write(CGNS_ENUMV(Kilogram),CGNS_ENUMV(Meter),CGNS_ENUMV(Second),CGNS_ENUMV(Kelvin),CGNS_ENUMV(Degree)); /* read fields */ cg_nfields(index_file,index_base,index_zone,index_flow,&nfields); if (nfields != 2) { printf("\nError! expecting 2 fields, read %d\n",nfields); return 1; } for (iff=1; iff <= nfields; iff++) { cg_field_info(index_file,index_base,index_zone,index_flow,iff,&idatatype,fieldname); printf("fieldname=%s\n",fieldname); if (strcmp(fieldname,"Density") == 0) { exponents[0]=1.; exponents[1]=-3.; exponents[2]=0.; exponents[3]=0.; exponents[4]=0.; } else if (strcmp(fieldname,"Pressure") == 0) { exponents[0]=1.; exponents[1]=-1.; exponents[2]=-2.; exponents[3]=0.; exponents[4]=0.; } else { printf("\nError! this fieldname not expected: %s\n",fieldname); return 1; } /* write DimensionalExponents */ cg_goto(index_file,index_base,"Zone_t",1,"FlowSolution_t",1,"DataArray_t",iff,"end"); cg_exponents_write(CGNS_ENUMV(RealSingle),exponents); } /* read grid */ cg_ncoords(index_file,index_base,index_zone,&ncoords); exponents[0]=0.; exponents[1]=1.; exponents[2]=0.; exponents[3]=0.; exponents[4]=0.; for (icc=1; icc <= ncoords; icc++) { /* write DimensionalExponents */ cg_goto(index_file,index_base,"Zone_t",1,"GridCoordinates_t",1,"DataArray_t",icc,"end"); cg_exponents_write(CGNS_ENUMV(RealSingle),exponents); } /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully wrote dimensional data to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_discreteface_str.c000066400000000000000000000116221474000356600246010ustar00rootroot00000000000000/* Program write_discreteface_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid, and adds discrete data (at K-DIR FACE CENTERS PLUS RIND CELLS IN I AND J DIRECTIONS) to it. In memory, rind cells also exist in the K direction, necessitating use of cg_array_general_write. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_discreteface_str.c cc -o write_discreteface_str_c write_discreteface_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that there are no restrictions on tri-dimensional array f because because a general write interface is used). Rind cells are stored in array locations [0][j][i], [10][j][i], [k][0][i], [k][17][i], [k][j][0], [k][j][21] */ double f[9+2][16+2][20+2]; int ni,nj,nk,i,j,k,kk,index_file,index_base,index_zone,index_discrete; int irinddata[3][2]; cgsize_t dims[3], rmin[3], rmax[3], m_dims[3], m_rmin[3], m_rmax[3]; printf("\nProgram write_discreteface_str\n"); /* create fake discrete data AT I-DIR CELL FACES for simple example: */ ni=20; nj=16; nk=9; for (k=0; k < nk; k++) { for (j=0; j < nj; j++) { for (i=0; i < ni; i++) { f[k+1][j+1][i+1]=(double)i; } } } /* create rind cell data: */ for (j=0; j < nj+2; j++) { for (i=0; i < ni+2; i++) { f[0 ][j][i]= 999.; f[nk+1][j][i]=-999.; } } for (k=0; k < nk+2; k++) { kk=k+1; for (j=0; j < nj+2; j++) { f[k][j][0 ]= 999.+(float)j+(5.*(float)kk); f[k][j][ni+1]=-999.-(float)j-(5.*(float)kk); } } for (k=0; k < nk+2; k++) { kk=k+1; for (i=0; i < ni+2; i++) { f[k][0 ][i]= 888.+(float)i+(5.*(float)kk); f[k][nj+1][i]=-888.-(float)i-(5.*(float)kk); } } printf("\ncreated simple 3-D flux with rind data\n"); /* WRITE DISCRETE DATA TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* create discrete data node */ cg_discrete_write(index_file,index_base,index_zone,"DiscreteData",&index_discrete); /* go to position within tree at DiscreteData_t node */ cg_goto(index_file,index_base,"Zone_t",index_zone,"DiscreteData_t",index_discrete,"end"); /* write data location under DiscreteData_t node */ cg_gridlocation_write(CGNS_ENUMV(KFaceCenter)); /* write rind information under DiscreteData_t node (ilo,ihi,jlo,jhi,klo,khi) */ irinddata[0][0]=1; irinddata[0][1]=1; irinddata[1][0]=1; irinddata[1][1]=1; irinddata[2][0]=0; /* note that we are not writing k-direction rind */ irinddata[2][1]=0; /* planes */ cg_rind_write(irinddata[0]); /* write array data (use of cg_array_general_write allows for defining a hyperslab in memory that excludes the k-direction rind planes) */ /* dimensions of array in file */ dims[0] = ni+2; dims[1] = nj+2; dims[2] = nk; /* no k-direction rind planes in file */ /* dimensions of array in memory */ m_dims[0] = ni+2; m_dims[1] = nj+2; m_dims[2] = nk+2; /* in file space the core cells ALWAYS start at index 1 */ /* lower range index in file */ rmin[0] = 1-irinddata[0][0]; rmin[1] = 1-irinddata[1][0]; rmin[2] = 1-irinddata[2][0]; /* upper range index in file */ rmax[0] = ni+irinddata[0][1]; rmax[1] = nj+irinddata[1][1]; rmax[2] = nk+irinddata[2][1]; /* in memory space, the lower bound ALWAYS starts at index 1 (in this example, * core cells start at 2) */ /* lower range index in memory */ m_rmin[0] = 2-irinddata[0][0]; m_rmin[1] = 2-irinddata[1][0]; m_rmin[2] = 2-irinddata[2][0]; /* upper range index in memory */ m_rmax[0] = 1+ni+irinddata[0][0]; m_rmax[1] = 1+nj+irinddata[1][0]; m_rmax[2] = 1+nk+irinddata[2][0]; if (cg_array_general_write("K-Flux", CGNS_ENUMV(RealDouble), 3, dims, rmin, rmax, CGNS_ENUMV(RealDouble), 3, m_dims, m_rmin, m_rmax, f)) cg_error_exit(); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added discrete data to file grid_c.cgns\n"); printf("\nNote: if the original CGNS file already had a DiscreteData_t node,"); printf("\n it has been overwritten\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_flowcent_str.c000066400000000000000000000055201474000356600240010ustar00rootroot00000000000000/* Program write_flowcent_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid, and adds a flow solution (at CELL CENTERS) to it. (Compare this program with write_flowvert_str) The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_flowcent_str.c cc -o write_flowcent_str_c write_flowcent_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays r and p must be dimensioned exactly as [N-1][17-1][21-1] (N>=9) for this particular case or else they will be written to the CGNS file incorrectly! Other options are to use cg_field_general_write, use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ double r[8][16][20],p[8][16][20]; int ni,nj,nk,i,j,k,index_file,index_base,index_zone,index_flow,index_field; char solname[33]; printf("\nProgram write_flowcent_str\n"); /* create fake flow solution AT CELL CENTERS for simple example: */ ni=20; nj=16; nk=8; for (k=0; k < nk; k++) { for (j=0; j < nj; j++) { for (i=0; i < ni; i++) { r[k][j][i]=(float)i; p[k][j][i]=(float)j; } } } printf("\ncreated simple 3-D rho and p flow solution\n"); /* WRITE FLOW SOLUTION TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* define flow solution node name (user can give any name) */ strcpy(solname,"FlowSolution"); /* create flow solution node (NOTE USE OF CGNS_ENUMV(CellCenter) HERE) */ cg_sol_write(index_file,index_base,index_zone,solname,CGNS_ENUMV(CellCenter),&index_flow); /* write flow solution (user must use SIDS-standard names here) */ cg_field_write(index_file,index_base,index_zone,index_flow, CGNS_ENUMV(RealDouble),"Density",r[0][0],&index_field); cg_field_write(index_file,index_base,index_zone,index_flow, CGNS_ENUMV(RealDouble),"Pressure",p[0][0],&index_field); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added CellCenter flow solution data to file grid_c.cgns\n"); printf("\nNote: if the original CGNS file already had a FlowSolution_t node,"); printf("\n it has been overwritten\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_flowcentrind_str.c000066400000000000000000000100161474000356600246520ustar00rootroot00000000000000/* Program write_flowcentrind_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid, and adds a flow solution (at CELL CENTERS PLUS RIND CELLS IN I AND J DIRECTIONS) to it. (Compare this program with write_flowcent_str) The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_flowcentrind_str.c cc -o write_flowcentrind_str_c write_flowcentrind_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays r and p must be dimensioned exactly as [N-1][17-1+2][21-1+2] (N>=9) for this particular case or else they will be written to the CGNS file incorrectly! Other options are to use cg_field_general_write, use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): Rind cells are stored in array locations [k][0][i], [k][17][i], [k][j][0], [k][j][21] */ double r[8][18][22],p[8][18][22]; int ni,nj,nk,i,j,k,kk,index_file,index_base,index_zone,index_flow,index_field; int irinddata[6]; char solname[33]; printf("\nProgram write_flowcentrind_str\n"); /* create fake flow solution AT CELL CENTERS for simple example: */ ni=20; nj=16; nk=8; for (k=0; k < nk; k++) { for (j=0; j < nj; j++) { for (i=0; i < ni; i++) { r[k][j+1][i+1]=(float)i; p[k][j+1][i+1]=(float)j; } } } /* create rind cell data: */ for (k=0; k < nk; k++) { kk=k+1; for (j=0; j <= nj+1; j++) { r[k][j][0]=999.+(float)j+(5.*(float)kk); p[k][j][0]=999.+(float)j+(5.*(float)kk)+1.; r[k][j][ni+1]=-999.-(float)j-(5.*(float)kk); p[k][j][ni+1]=-999.-(float)j-(5.*(float)kk)-1.; } } for (k=0; k < nk; k++) { kk=k+1; for (i=0; i <= ni+1; i++) { r[k][0][i]=888.+(float)i+(5.*(float)kk); p[k][0][i]=888.+(float)i+(5.*(float)kk)+1.; r[k][nj+1][i]=-888.-(float)i-(5.*(float)kk); p[k][nj+1][i]=-888.-(float)i-(5.*(float)kk)-1.; } } printf("\ncreated simple 3-D rho and p flow solution with rind data\n"); /* WRITE FLOW SOLUTION TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* define flow solution node name (user can give any name) */ strcpy(solname,"FlowSolution"); /* create flow solution node (NOTE USE OF CGNS_ENUMV(CellCenter) HERE) */ cg_sol_write(index_file,index_base,index_zone,solname,CGNS_ENUMV(CellCenter),&index_flow); /* go to position within tree at FlowSolution_t node */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowSolution_t",index_flow,"end"); /* write rind information under FlowSolution_t node (ilo,ihi,jlo,jhi,klo,khi) */ irinddata[0]=1; irinddata[1]=1; irinddata[2]=1; irinddata[3]=1; irinddata[4]=0; irinddata[5]=0; cg_rind_write(irinddata); /* write flow solution (user must use SIDS-standard names here) */ cg_field_write(index_file,index_base,index_zone,index_flow, CGNS_ENUMV(RealDouble),"Density",r[0][0],&index_field); cg_field_write(index_file,index_base,index_zone,index_flow, CGNS_ENUMV(RealDouble),"Pressure",p[0][0],&index_field); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added flow solution data to file grid_c.cgns\n"); printf("\nNote: if the original CGNS file already had a FlowSolution_t node,"); printf("\n it has been overwritten\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_floweqn_str.c000066400000000000000000000071071474000356600236360ustar00rootroot00000000000000/* Program write_floweqn_str */ /* Opens an existing CGNS file and writes flow eqn info The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.f) Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_floweqn_str.c cc -o write_floweqn_str_c write_floweqn_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { int idata[6],index_file,index_base,index_zone,ieq_dim; float gamma,prandtl; cgsize_t nuse; printf("\nProgram write_floweqn_str\n"); /* data for writing */ gamma=1.4; prandtl=0.90; /* WRITE FLOW EQUATION SET INFO */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* existing file must be 3D structured (real working code would check!) */ /* Create 'FlowEquationSet' node under 'Zone_t' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"end"); /* equation dimension = 3 */ ieq_dim=3; cg_equationset_write(ieq_dim); /* Create 'GoverningEquations' node under 'FlowEquationSet' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1,"end"); cg_governing_write(CGNS_ENUMV(NSTurbulent)); /* Create 'DiffusionModel' node under 'GoverningEquations' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1, "GoverningEquations_t",1,"end"); idata[0]=0; idata[1]=1; idata[2]=0; idata[3]=0; idata[4]=0; idata[5]=0; cg_diffusion_write(idata); nuse=1; /* Create 'GasModel' under 'FlowEquationSet' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1,"end"); cg_model_write("GasModel_t",CGNS_ENUMV(Ideal)); /* Create 'SpecificHeatRatio' under GasModel */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1, "GasModel_t",1,"end"); cg_array_write("SpecificHeatRatio",CGNS_ENUMV(RealSingle),1,&nuse,&gamma); /* Create 'DataClass' under 'SpecificHeatRatio' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1, "GasModel_t",1,"DataArray_t",1,"end"); cg_dataclass_write(CGNS_ENUMV(NondimensionalParameter)); /* Create 'TurbulenceClosure' under 'FlowEquationSet' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1,"end"); cg_model_write("TurbulenceClosure_t",CGNS_ENUMV(EddyViscosity)); /* Create 'PrandtlTurbulent' under 'TurbulenceClosure' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1, "TurbulenceClosure_t",1,"end"); cg_array_write("PrandtlTurbulent",CGNS_ENUMV(RealSingle),1,&nuse,&prandtl); /* Create 'DataClass' under 'PrandtlTurbulent' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1, "TurbulenceClosure_t",1,"DataArray_t",1,"end"); cg_dataclass_write(CGNS_ENUMV(NondimensionalParameter)); /* Create 'TurbulenceModel' under 'FlowEquationSet' */ cg_goto(index_file,index_base,"Zone_t",index_zone,"FlowEquationSet_t",1,"end"); cg_model_write("TurbulenceModel_t",CGNS_ENUMV(OneEquation_SpalartAllmaras)); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully wrote equation set info to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_flowvert_str.c000066400000000000000000000053701474000356600240330ustar00rootroot00000000000000/* Program write_flowvert_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid, and adds a flow solution (at VERTICES) to it. (Compare this program with write_flowcent_str) The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_flowvert_str.c cc -o write_flowvert_str_c write_flowvert_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays r and p must be dimensioned exactly as [N][17][21] (N>=9) for this particular case or else they will be written to the CGNS file incorrectly! Other options are to use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ double r[9][17][21],p[9][17][21]; int ni,nj,nk,i,j,k,index_file,index_base,index_zone,index_flow,index_field; char solname[33]; printf("\nProgram write_flowvert_str\n"); /* create fake flow solution AT CELL CENTERS for simple example: */ ni=21; nj=17; nk=9; for (k=0; k < nk; k++) { for (j=0; j < nj; j++) { for (i=0; i < ni; i++) { r[k][j][i]=(float)i; p[k][j][i]=(float)j; } } } printf("\ncreated simple 3-D rho and p flow solution\n"); /* WRITE FLOW SOLUTION TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* define flow solution node name (user can give any name) */ strcpy(solname,"FlowSolution"); /* create flow solution node */ cg_sol_write(index_file,index_base,index_zone,solname,CGNS_ENUMV(Vertex),&index_flow); /* write flow solution (user must use SIDS-standard names here) */ cg_field_write(index_file,index_base,index_zone,index_flow, CGNS_ENUMV(RealDouble),"Density",r[0][0],&index_field); cg_field_write(index_file,index_base,index_zone,index_flow, CGNS_ENUMV(RealDouble),"Pressure",p[0][0],&index_field); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added Vertex flow solution data to file grid_c.cgns\n"); printf("\nNote: if the original CGNS file already had a FlowSolution_t node,"); printf("\n it has been overwritten\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_flowvert_unst.c000066400000000000000000000051201474000356600242050ustar00rootroot00000000000000/* Program write_flowvert_unst */ /* Opens an existing CGNS file that contains a simple 3-D unstructured grid, and adds a flow solution (at VERTICES) to it. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_unst.c) Note that, other than the dimensions of the variables r and p, this program is essentially identical to that for writing flow solutions to a structured zone: write_flowvert_str.c Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_flowvert_unst.c cc -o write_flowvert_unst_c write_flowvert_unst.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { double r[9*17*21],p[9*17*21]; int ni,nj,nk,i,j,k,index_file,index_base,index_zone,index_flow,index_field,iset; char solname[33]; printf("\nProgram write_flowvert_unst\n"); /* create fake flow solution AT CELL CENTERS for simple example: */ ni=21; nj=17; nk=9; iset=0; for (k=0; k < nk; k++) { for (j=0; j < nj; j++) { for (i=0; i < ni; i++) { r[iset]=(float)i; p[iset]=(float)j; iset=iset+1; } } } printf("\ncreated simple 3-D rho and p flow solution\n"); /* WRITE FLOW SOLUTION TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* define flow solution node name (user can give any name) */ strcpy(solname,"FlowSolution"); /* create flow solution node */ cg_sol_write(index_file,index_base,index_zone,solname,CGNS_ENUMV(Vertex),&index_flow); /* write flow solution (user must use SIDS-standard names here) */ cg_field_write(index_file,index_base,index_zone,index_flow, CGNS_ENUMV(RealDouble),"Density",r,&index_field); cg_field_write(index_file,index_base,index_zone,index_flow, CGNS_ENUMV(RealDouble),"Pressure",p,&index_field); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added Vertex flow solution data to file grid_c.cgns (unstructured)\n"); printf("\nNote: if the original CGNS file already had a FlowSolution_t node,"); printf("\n it has been overwritten\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_grid2zn_str.c000066400000000000000000000071631474000356600235440ustar00rootroot00000000000000/* Program write_grid2zn_str.c */ /* Creates simple 3-D structured grid WITH 2 ZONES and writes it to a CGNS file. Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_grid2zn_str.c cc -o write_grid2zn_str_c write_grid2zn_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays x,y,z must be dimensioned exactly as [N][17][21] (N>=9) for this particular case or else they will be written to the CGNS file incorrectly! Other options are to use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ double x1[9][17][21],y1[9][17][21],z1[9][17][21]; double x2[9][17][21],y2[9][17][21],z2[9][17][21]; cgsize_t isize[3][3]; int ni,nj,nk,i,j,k; int index_file,icelldim,iphysdim,index_base; int index_zone,index_coord; char basename[33],zonename[33]; printf("\nProgram write_grid2zn_str\n"); /* create gridpoints for simple example: */ ni=21; nj=17; nk=9; for (k=0; k < nk; ++k) { for (j=0; j < nj; ++j) { for (i=0; i < ni; ++i) { x1[k][j][i]=i; y1[k][j][i]=j; z1[k][j][i]=k; x2[k][j][i]=x1[k][j][i]+20.; y2[k][j][i]=y1[k][j][i]; z2[k][j][i]=z1[k][j][i]; } } } printf("\ncreated simple 3-D grid points (2 zones)"); /* WRITE X, Y, Z GRID POINTS TO CGNS FILE */ /* open CGNS file for write */ if (cg_open("grid_c.cgns",CG_MODE_WRITE,&index_file)) cg_error_exit(); /* create base (user can give any name) */ strcpy(basename,"Base"); icelldim=3; iphysdim=3; cg_base_write(index_file,basename,icelldim,iphysdim,&index_base); /* vertex size */ isize[0][0]=21; isize[0][1]=17; isize[0][2]=9; /* cell size */ isize[1][0]=isize[0][0]-1; isize[1][1]=isize[0][1]-1; isize[1][2]=isize[0][2]-1; /* boundary vertex size (always zero for structured grids) */ isize[2][0]=0; isize[2][1]=0; isize[2][2]=0; /* define zone 1 name (user can give any name) */ strcpy(zonename,"Zone 1"); /* create zone */ cg_zone_write(index_file,index_base,zonename,*isize,CGNS_ENUMV(Structured),&index_zone); /* write grid coordinates (user must use SIDS-standard names here) */ cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateX", x1,&index_coord); cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateY", y1,&index_coord); cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateZ", z1,&index_coord); /* define zone 2 name (user can give any name) */ strcpy(zonename,"Zone 2"); /* create zone */ cg_zone_write(index_file,index_base,zonename,*isize,CGNS_ENUMV(Structured),&index_zone); /* write grid coordinates (user must use SIDS-standard names here) */ cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateX", x2,&index_coord); cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateY", y2,&index_coord); cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateZ", z2,&index_coord); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully wrote grid to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_grid_str.c000066400000000000000000000054241474000356600231100ustar00rootroot00000000000000/* Program write_grid_str.c */ /* Creates simple 3-D structured grid and writes it to a CGNS file. Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_grid_str.c cc -o write_grid_str_c write_grid_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays x,y,z must be dimensioned exactly as [N][17][21] (N>=9) for this particular case or else they will be written to the CGNS file incorrectly! Other options are to use cg_coord_general_write, 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ double x[9][17][21],y[9][17][21],z[9][17][21]; cgsize_t isize[3][3]; int ni,nj,nk,i,j,k; int index_file,icelldim,iphysdim,index_base; int index_zone,index_coord; char basename[33],zonename[33]; printf("\nProgram write_grid_str\n"); /* create gridpoints for simple example: */ ni=21; nj=17; nk=9; for (k=0; k < nk; ++k) { for (j=0; j < nj; ++j) { for (i=0; i < ni; ++i) { x[k][j][i]=i; y[k][j][i]=j; z[k][j][i]=k; } } } printf("\ncreated simple 3-D grid points"); /* WRITE X, Y, Z GRID POINTS TO CGNS FILE */ /* open CGNS file for write */ if (cg_open("grid_c.cgns",CG_MODE_WRITE,&index_file)) cg_error_exit(); /* create base (user can give any name) */ strcpy(basename,"Base"); icelldim=3; iphysdim=3; cg_base_write(index_file,basename,icelldim,iphysdim,&index_base); /* define zone name (user can give any name) */ strcpy(zonename,"Zone 1"); /* vertex size */ isize[0][0]=21; isize[0][1]=17; isize[0][2]=9; /* cell size */ isize[1][0]=isize[0][0]-1; isize[1][1]=isize[0][1]-1; isize[1][2]=isize[0][2]-1; /* boundary vertex size (always zero for structured grids) */ isize[2][0]=0; isize[2][1]=0; isize[2][2]=0; /* create zone */ cg_zone_write(index_file,index_base,zonename,*isize,CGNS_ENUMV(Structured),&index_zone); /* write grid coordinates (user must use SIDS-standard names here) */ cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateX", x,&index_coord); cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateY", y,&index_coord); cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateZ", z,&index_coord); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully wrote grid to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_grid_unst.c000066400000000000000000000176621474000356600233000ustar00rootroot00000000000000/* Program write_grid_unst */ /* Creates simple 3-D unstructured grid and writes it to a CGNS file. Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_grid_unst.c cc -o write_grid_unst_c write_grid_unst.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif #define maxelemi 20*16*8 #define maxelemj 1216 int main() { double x[21*17*9],y[21*17*9],z[21*17*9]; cgsize_t isize[3][1],ielem[maxelemi][8],jelem[maxelemj][4]; cgsize_t nelem_start,nelem_end; int ni,nj,nk,iset,i,j,k,index_file,icelldim,iphysdim; int index_base,index_zone,index_coord,ielem_no; int ifirstnode,nbdyelem,index_section; char basename[33],zonename[33]; printf("\nProgram write_grid_unst\n"); /* create gridpoints for simple example: */ ni=21; nj=17; nk=9; iset=0; for (k=1; k <= nk; k++) { for (j=1; j <=nj; j++) { for (i=1; i <= ni; i++) { x[iset]=(float)i-1.; y[iset]=(float)j-1.; z[iset]=(float)k-1.; iset=iset+1; } } } printf("\ncreated simple 3-D grid points\n"); /* WRITE X, Y, Z GRID POINTS TO CGNS FILE */ /* open CGNS file for write */ if (cg_open("grid_c.cgns",CG_MODE_WRITE,&index_file)) cg_error_exit(); /* create base (user can give any name) */ strcpy(basename,"Base"); icelldim=3; iphysdim=3; cg_base_write(index_file,basename,icelldim,iphysdim,&index_base); /* define zone name (user can give any name) */ strcpy(zonename,"Zone 1"); /* vertex size */ isize[0][0]=ni*nj*nk; /* cell size */ isize[1][0]=(ni-1)*(nj-1)*(nk-1); /* boundary vertex size (zero if elements not sorted) */ isize[2][0]=0; /* create zone */ cg_zone_write(index_file,index_base,zonename,isize[0],CGNS_ENUMV(Unstructured),&index_zone); /* write grid coordinates (user must use SIDS-standard names here) */ cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateX", x,&index_coord); cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateY", y,&index_coord); cg_coord_write(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble),"CoordinateZ", z,&index_coord); /* set element connectivity: */ /* ---------------------------------------------------------- */ /* do all the HEXA_8 elements (this part is mandatory): */ /* maintain SIDS-standard ordering */ ielem_no=0; /* index no of first element */ nelem_start=1; for (k=1; k < nk; k++) { for (j=1; j < nj; j++) { for (i=1; i < ni; i++) { /* in this example, due to the order in the node numbering, the hexahedral elements can be reconstructed using the following relationships: */ ifirstnode=i+(j-1)*ni+(k-1)*ni*nj; ielem[ielem_no][0]=ifirstnode; ielem[ielem_no][1]=ifirstnode+1; ielem[ielem_no][2]=ifirstnode+1+ni; ielem[ielem_no][3]=ifirstnode+ni; ielem[ielem_no][4]=ifirstnode+ni*nj; ielem[ielem_no][5]=ifirstnode+ni*nj+1; ielem[ielem_no][6]=ifirstnode+ni*nj+1+ni; ielem[ielem_no][7]=ifirstnode+ni*nj+ni; ielem_no=ielem_no+1; } } } /* index no of last element (=2560) */ nelem_end=ielem_no; if (nelem_end > maxelemi) { printf("\nError, must increase maxelemi to at least %lu\n",(unsigned long)nelem_end); return 1; } /* unsorted boundary elements */ nbdyelem=0; /* write CGNS_ENUMV(HEXA_8) element connectivity (user can give any name) */ cg_section_write(index_file,index_base,index_zone,"Elem",CGNS_ENUMV(HEXA_8),nelem_start, nelem_end,nbdyelem,ielem[0],&index_section); /* ---------------------------------------------------------- */ /* do boundary (QUAD) elements (this part is optional, but you must do it if you eventually want to define BCs at element faces rather than at nodes): maintain SIDS-standard ordering */ /* INFLOW: */ ielem_no=0; /* index no of first element */ nelem_start=nelem_end+1; i=1; for (k=1; k < nk; k++) { for (j=1; j < nj; j++) { ifirstnode=i+(j-1)*ni+(k-1)*ni*nj; jelem[ielem_no][0]=ifirstnode; jelem[ielem_no][1]=ifirstnode+ni*nj; jelem[ielem_no][2]=ifirstnode+ni*nj+ni; jelem[ielem_no][3]=ifirstnode+ni; ielem_no=ielem_no+1; } } /* index no of last element */ nelem_end=nelem_start+ielem_no-1; if (ielem_no > maxelemj) { printf("\nError, must increase maxelemj to at least %d\n",ielem_no); return 1; } /* write QUAD element connectivity for inflow face (user can give any name) */ cg_section_write(index_file,index_base,index_zone,"InflowElem",CGNS_ENUMV(QUAD_4),nelem_start, nelem_end,nbdyelem,jelem[0],&index_section); /* OUTFLOW: */ ielem_no=0; /* index no of first element */ nelem_start=nelem_end+1; i=ni-1; for (k=1; k < nk; k++) { for (j=1; j < nj; j++) { ifirstnode=i+(j-1)*ni+(k-1)*ni*nj; jelem[ielem_no][0]=ifirstnode+1; jelem[ielem_no][1]=ifirstnode+1+ni; jelem[ielem_no][2]=ifirstnode+ni*nj+1+ni; jelem[ielem_no][3]=ifirstnode+ni*nj+1; ielem_no=ielem_no+1; } } /* index no of last element */ nelem_end=nelem_start+ielem_no-1; if (ielem_no > maxelemj) { printf("\nError, must increase maxelemj to at least %d\n",ielem_no); return 1; } /* write QUAD element connectivity for outflow face (user can give any name) */ cg_section_write(index_file,index_base,index_zone,"OutflowElem",CGNS_ENUMV(QUAD_4),nelem_start, nelem_end,nbdyelem,jelem[0],&index_section); /* SIDEWALLS: */ ielem_no=0; /* index no of first element */ nelem_start=nelem_end+1; j=1; for (k=1; k < nk; k++) { for (i=1; i < ni; i++) { ifirstnode=i+(j-1)*ni+(k-1)*ni*nj; jelem[ielem_no][0]=ifirstnode; jelem[ielem_no][1]=ifirstnode+ni*nj; jelem[ielem_no][2]=ifirstnode+ni*nj+1; jelem[ielem_no][3]=ifirstnode+1; ielem_no=ielem_no+1; } } j=nj-1; for (k=1; k < nk; k++) { for (i=1; i < ni; i++) { ifirstnode=i+(j-1)*ni+(k-1)*ni*nj; jelem[ielem_no][0]=ifirstnode+1+ni; jelem[ielem_no][1]=ifirstnode+ni; jelem[ielem_no][2]=ifirstnode+ni*nj+ni; jelem[ielem_no][3]=ifirstnode+ni*nj+1+ni; ielem_no=ielem_no+1; } } k=1; for (j=1; j < nj; j++) { for (i=1; i < ni; i++) { ifirstnode=i+(j-1)*ni+(k-1)*ni*nj; jelem[ielem_no][0]=ifirstnode; jelem[ielem_no][1]=ifirstnode+1; jelem[ielem_no][2]=ifirstnode+1+ni; jelem[ielem_no][3]=ifirstnode+ni; ielem_no=ielem_no+1; } } k=nk-1; for (j=1; j < nj; j++) { for (i=1; i < ni; i++) { ifirstnode=i+(j-1)*ni+(k-1)*ni*nj; jelem[ielem_no][0]=ifirstnode+ni*nj; jelem[ielem_no][1]=ifirstnode+ni*nj+ni; jelem[ielem_no][2]=ifirstnode+ni*nj+1+ni; jelem[ielem_no][3]=ifirstnode+ni*nj+1; ielem_no=ielem_no+1; } } /* index no of last element */ nelem_end=nelem_start+ielem_no-1; if (ielem_no > maxelemj) { printf("\nError, must increase maxelemj to at least %d\n",ielem_no); return 1; } /* write QUAD element connectivity for sidewall face (user can give any name) */ cg_section_write(index_file,index_base,index_zone,"SidewallElem",CGNS_ENUMV(QUAD_4),nelem_start, nelem_end,nbdyelem,jelem[0],&index_section); /* ---------------------------------------------------------- */ /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully wrote unstructured grid to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_nondimensional.c000066400000000000000000000103731474000356600243070ustar00rootroot00000000000000/* Program write_nondimensional */ /* Opens an existing CGNS file and adds the DataClass and ReferenceState appropriate for a completely NONDIMENSIONAL data set. The CGNS grid file 'grid_c.cgns' must already exist (for example, created using write_grid_str.c or write_grid_unst.c). In this case, the flow solution does not need to be present. Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_nondimensional.c cc -o write_nondimensional_c write_nondimensional.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { double xmach,reue,xmv,xmc,rev,rel,renu,rho0; double p0,c0,vm0,xlength0,vx,vy,vz; double gamma; int index_file,index_base; CGNS_ENUMT(DataClass_t) idata; cgsize_t nuse; printf("\nProgram write_nondimensional\n"); /* define nondimensional parameters */ xmach=4.6; reue=6000000.; xmv=xmach; xmc=1.; rev=xmach; rel=1.; renu=xmach/reue; rho0=1.; gamma=1.4; p0=1./gamma; c0=1.; vm0=xmach/reue; xlength0=1.; vx=xmach; vy=0.; vz=0.; nuse=1; /* WRITE NONDIMENSIONAL INFO */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* put DataClass under Base */ cg_goto(index_file,index_base,"end"); /* check first if a dataclass has already been written */ if (CG_OK == cg_dataclass_read(&idata)) { printf("\nError! DataClass already exists!\n"); printf(" Re-make CGNS file without it and related info, then try again\n"); return 1; } cg_dataclass_write(CGNS_ENUMV(NormalizedByUnknownDimensional)); /* put ReferenceState under Base */ cg_state_write("ReferenceQuantities"); /* Go to ReferenceState node, write Mach array and its dataclass */ cg_goto(index_file,index_base,"ReferenceState_t",1,"end"); cg_array_write("Mach",CGNS_ENUMV(RealDouble),1,&nuse,&xmach); cg_goto(index_file,index_base,"ReferenceState_t",1,"DataArray_t",1,"end"); cg_dataclass_write(CGNS_ENUMV(NondimensionalParameter)); /* Go to ReferenceState node, write Reynolds array and its dataclass */ cg_goto(index_file,index_base,"ReferenceState_t",1,"end"); cg_array_write("Reynolds",CGNS_ENUMV(RealDouble),1,&nuse,&reue); cg_goto(index_file,index_base,"ReferenceState_t",1,"DataArray_t",2,"end"); cg_dataclass_write(CGNS_ENUMV(NondimensionalParameter)); /* Go to ReferenceState node to write reference quantities: */ cg_goto(index_file,index_base,"ReferenceState_t",1,"end"); /* First, write reference quantities that make up Mach and Reynolds: */ /* Mach_Velocity */ cg_array_write("Mach_Velocity",CGNS_ENUMV(RealDouble),1,&nuse,&xmv); /* Mach_VelocitySound */ cg_array_write("Mach_VelocitySound",CGNS_ENUMV(RealDouble),1,&nuse,&xmc); /* Reynolds_Velocity */ cg_array_write("Reynolds_Velocity",CGNS_ENUMV(RealDouble),1,&nuse,&rev); /* Reynolds_Length */ cg_array_write("Reynolds_Length",CGNS_ENUMV(RealDouble),1,&nuse,&rel); /* Reynolds_ViscosityKinematic */ cg_array_write("Reynolds_ViscosityKinematic",CGNS_ENUMV(RealDouble),1,&nuse,&renu); /* Next, write flow field reference quantities: */ /* Density */ cg_array_write("Density",CGNS_ENUMV(RealDouble),1,&nuse,&rho0); /* Pressure */ cg_array_write("Pressure",CGNS_ENUMV(RealDouble),1,&nuse,&p0); /* VelocitySound */ cg_array_write("VelocitySound",CGNS_ENUMV(RealDouble),1,&nuse,&c0); /* ViscosityMolecular */ cg_array_write("ViscosityMolecular",CGNS_ENUMV(RealDouble),1,&nuse,&vm0); /* LengthReference */ cg_array_write("LengthReference",CGNS_ENUMV(RealDouble),1,&nuse,&xlength0); /* VelocityX */ cg_array_write("VelocityX",CGNS_ENUMV(RealDouble),1,&nuse,&vx); /* VelocityY */ cg_array_write("VelocityY",CGNS_ENUMV(RealDouble),1,&nuse,&vy); /* VelocityZ */ cg_array_write("VelocityZ",CGNS_ENUMV(RealDouble),1,&nuse,&vz); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully wrote nondimensional info to file grid_c.cgns\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code/write_timevert_str.c000066400000000000000000000126341474000356600240230ustar00rootroot00000000000000/* Program write_timevert_str */ /* Opens an existing CGNS file that contains a simple 3-D structured grid, and adds 3 different flow solutions (at VERTICES) to it, along with time-accurate info. In this example, r1 & p1, r2 & p2, r3 & p3 correspond with solutions at 3 different time steps. The CGNS grid file 'grid_c.cgns' must already exist (created using write_grid_str.c) Example compilation for this program is (change paths if needed!): cc -I ../.. -c write_timevert_str.c cc -o write_timevert_str_c write_timevert_str.o -L ../../lib -lcgns (../../lib is the location where the compiled library libcgns.a is located) */ #include #include /* cgnslib.h file must be located in directory specified by -I during compile: */ #include "cgnslib.h" #if CGNS_VERSION < 3100 # define cgsize_t int #endif int main() { /* dimension statements (note that tri-dimensional arrays r1, r2, r3 and p1, p2, p3 must be dimensioned exactly as [N][17][21] (N>=9) for this particular case or else they will be written to the CGNS file incorrectly! Other options are to use 1-D arrays, use dynamic memory, or pass index values to a subroutine and dimension exactly there): */ double r1[9][17][21],p1[9][17][21]; double r2[9][17][21],p2[9][17][21]; double r3[9][17][21],p3[9][17][21]; double time[3]; int ni,nj,nk,i,j,k,index_file,index_base,index_zone; cgsize_t idata[2],nuse; int index_flow,index_field,nsteps,n; char sn[3][33]; char solname[97]; /* need an extra byte for the terminating 0 */ printf("\nProgram write_timevert_str\n"); /* set up the times corresponding to the 3 solutions to be stored: */ time[0]=10.; time[1]=20.; time[2]=50.; /* create fake flow solution AT VERTICES for simple example: */ ni=21; nj=17; nk=9; for (k=0; k < nk; k++) { for (j=0; j < nj; j++) { for (i=0; i < ni; i++) { /* soln at time 1: */ r1[k][j][i]=(float)i; p1[k][j][i]=(float)j; /* soln at time 2: */ r2[k][j][i]=r1[k][j][i]+1.; p2[k][j][i]=p1[k][j][i]+1.; /* soln at time 3: */ r3[k][j][i]=r2[k][j][i]+1.; p3[k][j][i]=p2[k][j][i]+1.; } } } printf("\ncreated simple 3-D rho and p flow solution\n"); /* WRITE FLOW SOLUTION TO EXISTING CGNS FILE */ /* open CGNS file for modify */ if (cg_open("grid_c.cgns",CG_MODE_MODIFY,&index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base=1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* define 3 different solution names (user can give any names) */ strcpy(sn[0],"FlowSolution1"); strcpy(sn[1],"FlowSolution2"); strcpy(sn[2],"FlowSolution3"); /* sprintf(solname, "%-32s%-32s%-32s", "FlowSolution1", "FlowSolution2", "FlowSolution3"); */ sprintf(solname,"%-32s%-32s%-32s",sn[0],sn[1],sn[2]); /* do loop for the 3 solutions: */ for (n=0; n < 3; n++) { /* create flow solution node */ cg_sol_write(index_file,index_base,index_zone,sn[n],CGNS_ENUMV(Vertex),&index_flow); printf("\n ...writing solution number %d\n",index_flow); /* write flow solution (user must use SIDS-standard names here) */ if (n == 0) { cg_field_write(index_file,index_base,index_zone,index_flow,CGNS_ENUMV(RealDouble),"Density", r1[0][0],&index_field); cg_field_write(index_file,index_base,index_zone,index_flow,CGNS_ENUMV(RealDouble),"Pressure", p1[0][0],&index_field); } else if (n == 1) { cg_field_write(index_file,index_base,index_zone,index_flow,CGNS_ENUMV(RealDouble),"Density", r2[0][0],&index_field); cg_field_write(index_file,index_base,index_zone,index_flow,CGNS_ENUMV(RealDouble),"Pressure", p2[0][0],&index_field); } else { cg_field_write(index_file,index_base,index_zone,index_flow,CGNS_ENUMV(RealDouble),"Density", r3[0][0],&index_field); cg_field_write(index_file,index_base,index_zone,index_flow,CGNS_ENUMV(RealDouble),"Pressure", p3[0][0],&index_field); } } /* create BaseIterativeData */ nsteps=3; cg_biter_write(index_file,index_base,"TimeIterValues",nsteps); /* go to BaseIterativeData level and write time values */ cg_goto(index_file,index_base,"BaseIterativeData_t",1,"end"); nuse=3; cg_array_write("TimeValues",CGNS_ENUMV(RealDouble),1,&nuse,&time); /* create ZoneIterativeData */ cg_ziter_write(index_file,index_base,index_zone,"ZoneIterativeData"); /* go to ZoneIterativeData level and give info telling which */ /* flow solution corresponds with which time (solname(1) corresponds */ /* with time(1), solname(2) with time(2), and solname(3) with time(3)) */ cg_goto(index_file,index_base,"Zone_t",index_zone,"ZoneIterativeData_t",1,"end"); idata[0]=32; idata[1]=3; cg_array_write("FlowSolutionPointers",CGNS_ENUMV(Character),2,idata,solname); /* add SimulationType */ cg_simulation_type_write(index_file,index_base,CGNS_ENUMV(TimeAccurate)); /* close CGNS file */ cg_close(index_file); printf("\nSuccessfully added 3 times of flow solution data and time info to file grid_c.cgns\n"); printf(" Note: if the original CGNS file already had a FlowSolution_t node,\n"); printf(" it has been overwritten\n"); return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/000077500000000000000000000000001474000356600215645ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/CMakeLists.txt000066400000000000000000000024601474000356600243260ustar00rootroot00000000000000######### # Tests # ######### # Link all the executables to cgns and hdf5 if(CGNS_BUILD_SHARED) set(C_PARA_EXAMPLE_LK_LIBS cgns_shared) else() set(C_PARA_EXAMPLE_LK_LIBS cgns_static) endif() if (CGNS_ENABLE_HDF5 AND HDF5_LIBRARY) list(APPEND C_PARA_EXAMPLE_LK_LIBS ${HDF5_LIBRARY}) if(HDF5_NEED_ZLIB AND ZLIB_LIBRARY) list(APPEND C_PARA_EXAMPLE_LK_LIBS ${ZLIB_LIBRARY}) endif() if(HDF5_NEED_SZIP AND SZIP_LIBRARY) list(APPEND C_PARA_EXAMPLE_LK_LIBS ${SZIP_LIBRARY}) endif() if(HDF5_NEED_MPI AND MPI_LIBS) list(APPEND C_PARA_EXAMPLE_LK_LIBS ${MPI_LIBS}) endif() endif () if (NOT WIN32) list(APPEND C_PARA_EXAMPLE_LK_LIBS m) endif () # Set the files needed by each test set (examples write_grid_str_parinzone write_grid_str_paroverzone write_flowcentrind_str_parinzone write_flowcentrind_str_paroverzone read_grid_str_parinzone read_grid_str_paroverzone read_flowcentrind_str_parinzone read_flowcentrind_str_paroverzone ) # Build each test foreach (example ${examples}) add_executable (${example} ${example}.c) target_link_libraries(${example} PRIVATE ${C_PARA_EXAMPLE_LK_LIBS}) add_test(NAME test-${example} COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} "2" ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endforeach (example ${examples}) CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/Makefile.in000066400000000000000000000073231474000356600236360ustar00rootroot00000000000000NO_COLOR=\033[0m OK_COLOR=\033[32;01m ERROR_COLOR=\033[31;01m CGNSDIR = ../../ include $(CGNSDIR)/make.defs CGNSLIB = $(CGNSDIR)/$(LIBCGNS) COPTS = $(CFLAGS) -I$(CGNSDIR) $(MPIINC) @BUILDOPTS@ LDLIBS = $(CGNSLIB) $(BUILDLIBS) #---------- CALL = write_grid_str_parinzone$(EXE) \ write_grid_str_paroverzone$(EXE) \ write_flowcentrind_str_parinzone$(EXE) \ write_flowcentrind_str_paroverzone$(EXE) \ read_grid_str_parinzone$(EXE) \ read_grid_str_paroverzone$(EXE) \ read_flowcentrind_str_parinzone$(EXE) \ read_flowcentrind_str_paroverzone$(EXE) ALL = $(CALL) TESTS = $(ALL) TIMING_AVAIL:=$(shell /usr/bin/time -a -o CGNS_timing.txt -f "%e" pwd > /dev/null; echo $$?) ifeq ("$(TIMING_AVAIL)" , "0") TIMING = /usr/bin/time -a -o CGNS_timing.txt -f "$$x %e" $(MPIEXEC) ./$$x >/dev/null 2>&1 TIMING_ARGS = /usr/bin/time -a -o CGNS_timing.txt -f "$$x %e" $(MPIEXEC) ./$$x $$args >/dev/null 2>&1 else TIMING = $(MPIEXEC) ./$$x >/dev/null 2>&1 TIMING_ARGS = $(MPIEXEC) ./$$x $$args >/dev/null 2>&1 endif all : $(ALL) #---------- test : $(TESTS) @echo " "; \ status=0; \ echo "=== running user guide parallel tests ==="; \ if test -f CGNS_timing.txt; then \ $(RM) CGNS_timing.txt; \ fi; \ padlimit=40; \ pad=$$(printf '%*s' "$$padlimit"); \ pad=$${pad// /.}; \ padlength=36; \ time=""; \ for x in $(TESTS) ; do \ args=""; \ printf "$$x"; \ printf ' %*.*s' 0 $$((padlength - $${#x} )) "$$pad"; \ if `$(TIMING)` ; then \ printf " [$(OK_COLOR)PASSED$(NO_COLOR)]"; \ if [ -f "CGNS_timing.txt" ]; then \ itime=$$(tail -n1 CGNS_timing.txt | awk '{print $$2}' | sed -e 's/$$/ sec/'); \ printf " %+12s" "$$itime";\ fi; \ printf "\n";\ else \ printf " [$(ERROR_COLOR)FAILED$(NO_COLOR)]\n"; \ status=`expr $$status + 1`; \ fi; \ done; \ echo "=== finished ==="; \ if [ $$status -ne 0 ]; then \ printf "$(ERROR_COLOR)"; \ stat=1; \ else \ printf "$(OK_COLOR)"; \ stat=0; \ fi; \ printf "$$status tests failed $(NO_COLOR) \n"; \ exit $$stat; #---------- read_flowcentrind_str_parinzone$(EXE) : read_flowcentrind_str_parinzone.c $(CGNSLIB) $(CC) $(COPTS) $(CEOUT)$@ read_flowcentrind_str_parinzone.c $(LDLIBS) $(CLIBS) $(STRIP) $@ #---------- read_flowcentrind_str_paroverzone$(EXE) : read_flowcentrind_str_paroverzone.c $(CGNSLIB) $(CC) $(COPTS) $(CEOUT)$@ read_flowcentrind_str_paroverzone.c $(LDLIBS) $(CLIBS) $(STRIP) $@ #---------- read_grid_str_parinzone$(EXE) : read_grid_str_parinzone.c $(CGNSLIB) $(CC) $(COPTS) $(CEOUT)$@ read_grid_str_parinzone.c $(LDLIBS) $(CLIBS) $(STRIP) $@ #---------- read_grid_str_paroverzone$(EXE) : read_grid_str_paroverzone.c $(CGNSLIB) $(CC) $(COPTS) $(CEOUT)$@ read_grid_str_paroverzone.c $(LDLIBS) $(CLIBS) $(STRIP) $@ #---------- write_flowcentrind_str_parinzone$(EXE) : write_flowcentrind_str_parinzone.c $(CGNSLIB) $(CC) $(COPTS) $(CEOUT)$@ write_flowcentrind_str_parinzone.c $(LDLIBS) $(CLIBS) $(STRIP) $@ #---------- write_flowcentrind_str_paroverzone$(EXE) : write_flowcentrind_str_paroverzone.c $(CGNSLIB) $(CC) $(COPTS) $(CEOUT)$@ write_flowcentrind_str_paroverzone.c $(LDLIBS) $(CLIBS) $(STRIP) $@ #---------- write_grid_str_parinzone$(EXE) : write_grid_str_parinzone.c $(CGNSLIB) $(CC) $(COPTS) $(CEOUT)$@ write_grid_str_parinzone.c $(LDLIBS) $(CLIBS) $(STRIP) $@ #---------- write_grid_str_paroverzone$(EXE) : write_grid_str_paroverzone.c $(CGNSLIB) $(CC) $(COPTS) $(CEOUT)$@ write_grid_str_paroverzone.c $(LDLIBS) $(CLIBS) $(STRIP) $@ #---------- clean : -$(RM) *.$(O) allclean : clean -$(RM) $(ALL) -$(RM) *~ *.bak -$(RM) *.cgns *.cg? -$(RM) CGNS_timing.txt CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/read_flowcentrind_str_parinzone.c000066400000000000000000000121031474000356600303730ustar00rootroot00000000000000/* Program read_flowcentrind_str_parinzone */ /* Opens an existing CGNS file that contains a simple 3-D structured grid plus a flow solution (at CELL CENTERS PLUS RIND CELLS IN I AND J DIRECTIONS) and reads it. Each processor reads a slab of data from one zone (parallelism within a zone). The CGNS grid file 'grid_piz_c.cgns' must already exist (created using write_grid_str_parinzone.c followed by write_flowcentrind_str_parinzone.c)) Example compilation for this program is (change paths!): mpicxx read_flowcentrind_str_parinzone.c -lcgns -lhdf5 -lsz -lz -o read_flowcentrind_str_parinzone mpirun -np 2 read_flowcentrind_str_parinzone */ #include #include #include #include "pcgnslib.h" #include "mpi.h" int main(int argc, const char* argv[]) { int n, comm_size, comm_rank; int index_file, index_base, index_zone, index_flow; char zonename[33]; MPI_Init(&argc, (char***)(&argv)); MPI_Comm_size(MPI_COMM_WORLD, &comm_size); MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank); cgp_mpi_comm(MPI_COMM_WORLD); /* open CGNS file for read-only */ if (cgp_open("grid_piz_c.cgns", CG_MODE_READ, &index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base = 1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* we know there is only one FlowSolution_t (real working code would check!) */ index_flow=1; /* COLLECTIVE READING OF FILE DATA -- each processor reads a part of the zone */ /* get zone size (and name - although not needed here) */ cgsize_t zoneSize[3][3]; if (cg_zone_read(index_file, index_base, index_zone, zonename, (cgsize_t*)zoneSize)) cg_error_exit(); /* partition the k-index of the zone among the processes. Note that the partitions do not include the k-direction rind planes. */ int kIdxBeg; /* beginning k-index for this processor */ int numLocalkIdx = zoneSize[1][2]/comm_size; /* the number of k-indices local to this process */ { int numUnevenkIdx = zoneSize[1][2] - numLocalkIdx*comm_size; if (comm_rank < numUnevenkIdx) { ++numLocalkIdx; kIdxBeg = comm_rank*numLocalkIdx; } else { kIdxBeg = numUnevenkIdx*(numLocalkIdx + 1); kIdxBeg += (comm_rank - numUnevenkIdx)*numLocalkIdx; } } cgsize_t s_rmin[3], s_rmax[3], m_dimvals[3], m_rmin[3], m_rmax[3]; double *r = NULL; double *p = NULL; int ni, nj, nk; if (numLocalkIdx > 0) { /* create fake flow solution AT CELL CENTERS for simple example. In memory, there are two rind cells in each direction: */ ni = zoneSize[1][0] + 2; nj = zoneSize[1][1] + 2; nk = numLocalkIdx; const int num_vertex = ni*nj*nk; r = (double*)malloc(2*num_vertex*sizeof(double)); p = r + num_vertex; /* shape in file space (core cells start at 1) */ for (n = 0; n < 2; ++n) { s_rmin[n] = 0; s_rmax[n] = zoneSize[1][n] + 1; } s_rmin[2] = kIdxBeg + 1; /* but no rind cells in k-direction */ s_rmax[2] = kIdxBeg + numLocalkIdx; /* shape in memory (array starts at 1)*/ for (n = 0; n < 2; ++n) { m_dimvals[n] = zoneSize[1][n] + 2; m_rmin[n] = 1; m_rmax[n] = zoneSize[1][n] + 2; } m_dimvals[2] = numLocalkIdx; m_rmin[2] = 1; m_rmax[2] = numLocalkIdx; } /* if there is nothing for this process to write, a valid zone index must be provided and data array = NULL */ if (cgp_field_general_read_data(index_file, index_base, index_zone, index_flow, 1, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, r)) cgp_error_exit(); if (cgp_field_general_read_data(index_file, index_base, index_zone, index_flow, 2, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, p)) cgp_error_exit(); if (7 >= kIdxBeg && 7 < kIdxBeg + numLocalkIdx) { printf("\nSuccessfully read flow solution from file grid_piz_c.cgns\n"); printf(" For example, r,p[7][18][20]= %f, %f\n", r[((7 - kIdxBeg)*nj + 18)*ni + 20], p[((7 - kIdxBeg)*nj + 18)*ni + 20]); printf(" rind: r,p[7][18][ 0]= %f, %f\n", r[((7 - kIdxBeg)*nj + 18)*ni + 0], p[((7 - kIdxBeg)*nj + 18)*ni + 0]); printf(" rind: r,p[7][18][21]= %f, %f\n", r[((7 - kIdxBeg)*nj + 18)*ni + 21], p[((7 - kIdxBeg)*nj + 18)*ni + 21]); } if (numLocalkIdx > 0) { free(r); } /* close CGNS file */ cg_close(index_file); MPI_Finalize(); if (comm_rank == 0) { printf("\nProgram successful... ending now\n"); } return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/read_flowcentrind_str_paroverzone.c000066400000000000000000000141301474000356600307420ustar00rootroot00000000000000/* Program read_flowcentrind_str_paroverzone */ /* Opens an existing CGNS file that contains a simple two-zone 3-D structured grid plus a flow solution (at CELL CENTERS PLUS RIND CELLS IN I AND J DIRECTIONS) and reads it. Each processor reads data from one zone (parallelism over zones). The CGNS grid file 'grid_poz_c.cgns' must already exist (created using write_grid_str_paroverzone.c followed by write_flowcentrind_str_paroverzone.c) Example compilation for this program is (change paths!): mpicxx read_flowcentrind_str_paroverzone.c -lcgns -lhdf5 -lsz -lz -o read_flowcentrind_str_paroverzone mpirun -np 2 read_flowcentrind_str_paroverzone */ #include #include #include #include "pcgnslib.h" #include "mpi.h" int main(int argc, const char* argv[]) { int n, comm_size, comm_rank; int index_file, index_base, index_zone, index_flow; char zonename[33]; MPI_Init(&argc, (char***)(&argv)); MPI_Comm_size(MPI_COMM_WORLD, &comm_size); MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank); cgp_mpi_comm(MPI_COMM_WORLD); /* open CGNS file for read-only */ if (cgp_open("grid_poz_c.cgns", CG_MODE_READ, &index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base = 1; /* get the number of zones (should be 2) */ int numZone; if (cg_nzones(index_file, index_base, &numZone)) cg_error_exit(); /* we know there is only one FlowSolution_t (real working code would check!) */ index_flow=1; /* COLLECTIVE READING OF FILE DATA -- each processor reads from a separate zone */ /* partition the zones among the processes */ int maxLocalZone; /* the maximum number of zones on any process */ int idxGlobalZoneBeg; /* the global index of the first zone on this process */ int numLocalZone = numZone/comm_size; /* the number of zones local to this process */ { int numUnevenZone = numZone - numLocalZone*comm_size; maxLocalZone = numLocalZone + (numUnevenZone > 0); if (comm_rank < numUnevenZone) { ++numLocalZone; idxGlobalZoneBeg = comm_rank*numLocalZone; } else { idxGlobalZoneBeg = numUnevenZone*(numLocalZone + 1); idxGlobalZoneBeg += (comm_rank - numUnevenZone)*numLocalZone; } } int idxLocalZone; for (idxLocalZone = 0; idxLocalZone < maxLocalZone; ++idxLocalZone) { const int idxGlobalZone = idxGlobalZoneBeg + idxLocalZone; cgsize_t zoneSize[3][3]; cgsize_t s_rmin[3], s_rmax[3], m_dimvals[3], m_rmin[3], m_rmax[3]; double *r = NULL; double *p = NULL; int ni, nj, nk; /* if there is nothing for this process to read, a valid zone index must be provided and data array = NULL */ index_zone = (idxGlobalZone < numZone) ? idxGlobalZone + 1 : 1; if (idxGlobalZone < numZone) { /* get zone size (and name - although not needed here) */ if (cg_zone_read(index_file, index_base, index_zone, zonename, (cgsize_t*)zoneSize)) cg_error_exit(); /* allocate memory for reading (all rind planes) */ ni = zoneSize[1][0] + 2; nj = zoneSize[1][1] + 2; nk = zoneSize[1][2] + 2; const int num_vertex = ni*nj*nk; r = (double*)malloc(2*num_vertex*sizeof(double)); p = r + num_vertex; /* shape in file space (core cells start at 1) */ for (n = 0; n < 2; ++n) { s_rmin[n] = 0; s_rmax[n] = zoneSize[1][n] + 1; } s_rmin[2] = 1; /* but no rind cells in k-direction */ s_rmax[2] = zoneSize[1][n]; /* shape in memory (array starts at 1)*/ for (n = 0; n < 2; ++n) { m_dimvals[n] = zoneSize[1][n] + 2; m_rmin[n] = 1; m_rmax[n] = zoneSize[1][n] + 2; } m_dimvals[2] = zoneSize[1][n] + 2; m_rmin[2] = 2; /* but no rind cells in k-direction */ m_rmax[2] = zoneSize[1][n] + 1; } if (cgp_field_general_read_data(index_file, index_base, index_zone, index_flow, 1, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, r)) cgp_error_exit(); if (cgp_field_general_read_data(index_file, index_base, index_zone, index_flow, 2, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, p)) cgp_error_exit(); for (n = 0; n < comm_size; ++n) { if (n == comm_rank) { if (idxGlobalZone < numZone) { int imax = zoneSize[1][0]; printf("\nProcess %d successfully read flow solution from " "zone %d in file grid_poz_c.cgns\n", comm_rank, index_zone); printf(" For example, r,p[8][18][%d]= %f, %f\n", imax, r[(8*nj + 18)*ni + imax], p[(8*nj + 18)*ni + imax]); printf(" rind: r,p[8][18][ 0]= %f, %f\n", r[(8*nj + 18)*ni + 0], p[(8*nj + 18)*ni + 0]); printf(" rind: r,p[8][18][%d]= %f, %f\n", imax+1, r[(8*nj + 18)*ni + imax+1], p[(8*nj + 18)*ni + imax+1]); fflush(stdout); } } /* this does not guarantee output is written in order but may help */ MPI_Barrier(MPI_COMM_WORLD); } if (idxGlobalZone < numZone) { free(r); } } /* close CGNS file */ cg_close(index_file); MPI_Finalize(); if (comm_rank == 0) { printf("\nProgram successful... ending now\n"); } return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/read_grid_str_parinzone.c000066400000000000000000000105661474000356600266350ustar00rootroot00000000000000/* Program read_grid_str_parinzone.c */ /* Reads a simple 3-D structured grid from a CGNS file. Each processor reads a slab of data from one zone (parallelism within a zone). The CGNS grid file 'grid_piz_c.cgns' must already exist. mpicxx read_grid_str_parinzone.c -lcgns -lhdf5 -lsz -lz -o read_grid_str_parinzone mpirun -np 2 write_grid_str_parinzone */ #include #include #include #include "pcgnslib.h" #include "mpi.h" int main(int argc, const char* argv[]) { cgsize_t zoneSize[3][3]; int n, comm_size, comm_rank; int index_file, index_base, index_zone; char zonename[33]; MPI_Init(&argc, (char***)(&argv)); MPI_Comm_size(MPI_COMM_WORLD, &comm_size); MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank); cgp_mpi_comm(MPI_COMM_WORLD); /* open CGNS file for read-only */ if (cgp_open("grid_piz_c.cgns", CG_MODE_READ, &index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base = 1; /* we know there is only one zone (real working code would check!) */ index_zone = 1; /* get zone size (and name - although not needed here) */ if (cg_zone_read(index_file, index_base, index_zone, zonename, (cgsize_t*)zoneSize)) cg_error_exit(); /* COLLECTIVE READING OF FILE DATA -- each processor reads a part of the zone */ /* partition the k-index of the zone among the processes */ int kIdxBeg; /* beginning k-index for this processor */ int numLocalkIdx = zoneSize[0][2]/comm_size; /* the number of k-indices local to this process */ { int numUnevenkIdx = zoneSize[0][2] - numLocalkIdx*comm_size; if (comm_rank < numUnevenkIdx) { ++numLocalkIdx; kIdxBeg = comm_rank*numLocalkIdx; } else { kIdxBeg = numUnevenkIdx*(numLocalkIdx + 1); kIdxBeg += (comm_rank - numUnevenkIdx)*numLocalkIdx; } } cgsize_t s_rmin[3], s_rmax[3], m_dimvals[3], m_rmin[3], m_rmax[3]; double *x = NULL; double *y = NULL; double *z = NULL; int ni, nj, nk; if (numLocalkIdx > 0) { /* allocate memory for reading */ ni = zoneSize[0][0]; nj = zoneSize[0][1]; nk = numLocalkIdx; const int num_vertex = ni*nj*nk; x = (double*)malloc(3*num_vertex*sizeof(double)); y = x + num_vertex; z = y + num_vertex; // shape in file space for (n = 0; n < 2; ++n) { s_rmin[n] = 1; s_rmax[n] = zoneSize[0][n]; } s_rmin[2] = kIdxBeg + 1; s_rmax[2] = kIdxBeg + numLocalkIdx; // shape in memory for (n = 0; n < 2; ++n) { m_dimvals[n] = zoneSize[0][n]; m_rmin[n] = 1; m_rmax[n] = zoneSize[0][n]; } m_dimvals[2] = numLocalkIdx; m_rmin[2] = 1; m_rmax[2] = numLocalkIdx; } /* the file data is defined as single but will be read as double */ if (cgp_coord_general_read_data(index_file, index_base, index_zone, 1, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, x)) cgp_error_exit(); if (cgp_coord_general_read_data(index_file, index_base, index_zone, 2, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, y)) cgp_error_exit(); if (cgp_coord_general_read_data(index_file, index_base, index_zone, 3, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, z)) cgp_error_exit(); if (8 >= kIdxBeg && 8 < kIdxBeg + numLocalkIdx) { printf("\nSuccessfully read grid from file grid_piz_c.cgns\n"); printf(" For example, from process %d, zone 1 x,y,z[8][18][16]= " "%f, %f, %f\n", comm_rank, x[((8 - kIdxBeg)*nj + 18)*ni + 16], y[((8 - kIdxBeg)*nj + 18)*ni + 16], z[((8 - kIdxBeg)*nj + 18)*ni + 16]); } if (numLocalkIdx > 0) { free(x); } /* close CGNS file */ cgp_close(index_file); MPI_Finalize(); if (comm_rank == 0) { printf("\nProgram successful... ending now\n"); } return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/read_grid_str_paroverzone.c000066400000000000000000000125501474000356600271750ustar00rootroot00000000000000/* Program read_grid_str_paroverzone.c */ /* Reads a simple 3-D structured grid from a CGNS file. Each processor reads data from one zone (parallelism over zones). The CGNS grid file 'grid_poz_c.cgns' must already exist. mpicxx read_grid_str_paroverzone.c -lcgns -lhdf5 -lsz -lz -o read_grid_str_paroverzone mpirun -np 2 write_grid_str_paroverzone */ #include #include #include #include "pcgnslib.h" #include "mpi.h" int main(int argc, const char* argv[]) { int n, comm_size, comm_rank; int index_file, index_base, index_zone; char zonename[33]; MPI_Init(&argc, (char***)(&argv)); MPI_Comm_size(MPI_COMM_WORLD, &comm_size); MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank); cgp_mpi_comm(MPI_COMM_WORLD); /* open CGNS file for read-only */ if (cgp_open("grid_poz_c.cgns", CG_MODE_READ, &index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base = 1; /* get the number of zones (should be 2) */ int numZone; if (cg_nzones(index_file, index_base, &numZone)) cg_error_exit(); /* COLLECTIVE READING OF FILE DATA -- each processor reads from a separate zone */ /* partition the zones among the processes */ int maxLocalZone; /* the maximum number of zones on any process */ int idxGlobalZoneBeg; /* the global index of the first zone on this process */ int numLocalZone = numZone/comm_size; /* the number of zones local to this process */ { int numUnevenZone = numZone - numLocalZone*comm_size; maxLocalZone = numLocalZone + (numUnevenZone > 0); if (comm_rank < numUnevenZone) { ++numLocalZone; idxGlobalZoneBeg = comm_rank*numLocalZone; } else { idxGlobalZoneBeg = numUnevenZone*(numLocalZone + 1); idxGlobalZoneBeg += (comm_rank - numUnevenZone)*numLocalZone; } } int idxLocalZone; for (idxLocalZone = 0; idxLocalZone < maxLocalZone; ++idxLocalZone) { const int idxGlobalZone = idxGlobalZoneBeg + idxLocalZone; cgsize_t zoneSize[3][3]; cgsize_t s_rmin[3], s_rmax[3], m_dimvals[3], m_rmin[3], m_rmax[3]; double *x = NULL; double *y = NULL; double *z = NULL; int ni, nj, nk; /* if there is nothing for this process to read, a valid zone index must be provided and data array = NULL */ index_zone = (idxGlobalZone < numZone) ? idxGlobalZone + 1 : 1; if (idxGlobalZone < numZone) { /* get zone size (and name - although not needed here) */ if (cg_zone_read(index_file, index_base, index_zone, zonename, (cgsize_t*)zoneSize)) cg_error_exit(); /* allocate memory for reading */ ni = zoneSize[0][0]; nj = zoneSize[0][1]; nk = zoneSize[0][2]; const int num_vertex = ni*nj*nk; x = (double*)malloc(3*num_vertex*sizeof(double)); y = x + num_vertex; z = y + num_vertex; /* shape in file space */ for (n = 0; n < 3; ++n) { s_rmin[n] = 1; s_rmax[n] = zoneSize[0][n]; } /* shape in memory */ for (n = 0; n < 3; ++n) { m_dimvals[n] = zoneSize[0][n]; m_rmin[n] = 1; m_rmax[n] = zoneSize[0][n]; } } /* the file data is defined as single but will be read as double */ if (cgp_coord_general_read_data(index_file, index_base, index_zone, 1, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, x)) cgp_error_exit(); if (cgp_coord_general_read_data(index_file, index_base, index_zone, 2, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, y)) cgp_error_exit(); if (cgp_coord_general_read_data(index_file, index_base, index_zone, 3, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, z)) cgp_error_exit(); for (n = 0; n < comm_size; ++n) { if (n == comm_rank) { if (idxGlobalZone < numZone) { printf("\nProcess %d successfully read grid from file " "grid_poz_c.cgns\n", comm_rank); printf(" For example, zone %d x,y,z[8][18][16]= " "%f, %f, %f\n", index_zone, x[(8*nj + 18)*ni + 16], y[(8*nj + 18)*ni + 16], z[(8*nj + 18)*ni + 16]); fflush(stdout); } } /* this does not guarantee output is written in order but may help */ MPI_Barrier(MPI_COMM_WORLD); } if (idxGlobalZone < numZone) { free(x); } } /* close CGNS file */ cgp_close(index_file); MPI_Finalize(); if (comm_rank == 0) { printf("\nProgram successful... ending now\n"); } return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/write_flowcentrind_str_parinzone.c000066400000000000000000000160531474000356600306220ustar00rootroot00000000000000/* Program write_flowcentrind_str_parinzone */ /* Opens an existing CGNS file that contains a simple 3-D structured grid, and adds a flow solution (at CELL CENTERS PLUS RIND CELLS IN I AND J DIRECTIONS) to it. The CGNS grid file 'grid_piz_c.cgns' must already exist (created using write_grid_str_parinzone.c) Example compilation for this program is (change paths!): mpicxx write_flowcentrind_str_parinzone.c -lcgns -lhdf5 -lsz -lz -o write_flowcentrind_str_parinzone mpirun -np 2 write_flowcentrind_str_parinzone */ #include #include #include #include "pcgnslib.h" #include "mpi.h" int main(int argc, const char* argv[]) { int i, j, k, n, comm_size, comm_rank; int index_file, index_base, index_zone, index_flow, index_field; char solname[33], zonename[33]; MPI_Init(&argc, (char***)(&argv)); MPI_Comm_size(MPI_COMM_WORLD, &comm_size); MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank); cgp_mpi_comm(MPI_COMM_WORLD); /* open CGNS file for modify */ if (cgp_open("grid_piz_c.cgns", CG_MODE_MODIFY, &index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base = 1; /* we know there is only one zone (real working code would check!) */ index_zone=1; /* CREATION OF FILE STRUCTURE -- all processors write the same information. Only meta-data is written to the library at this stage */ /* define flow solution node name (user can give any name) */ strcpy(solname, "FlowSolution"); /* create flow solution node (NOTE USE OF CGNS_ENUMV(CellCenter) HERE) */ cg_sol_write(index_file, index_base, index_zone, solname, CGNS_ENUMV(CellCenter), &index_flow); /* go to position within tree at FlowSolution_t node */ cg_goto(index_file, index_base, "Zone_t", index_zone, "FlowSolution_t", index_flow, "end"); /* write rind information under FlowSolution_t node (ilo,ihi,jlo,jhi,klo,khi) */ int irinddata[6] = { 1, 1, 1, 1, 0, 0 }; cg_rind_write(irinddata); if (cgp_field_write(index_file, index_base, index_zone, index_flow, CGNS_ENUMV(RealDouble), "Density", &index_field)) cgp_error_exit(); if (cgp_field_write(index_file, index_base, index_zone, index_flow, CGNS_ENUMV(RealDouble), "Pressure", &index_field)) cgp_error_exit(); /* COLLECTIVE WRITING OF FILE DATA -- each processor writes to a separate zone */ /* get zone size (and name - although not needed here) */ cgsize_t zoneSize[3][3]; if (cg_zone_read(index_file, index_base, index_zone, zonename, (cgsize_t*)zoneSize)) cg_error_exit(); /* partition the k-index of the zone among the processes. Note that the partitions do not include the k-direction rind planes. */ int kIdxBeg; /* beginning k-index for this processor */ int numLocalkIdx = zoneSize[1][2]/comm_size; /* the number of k-indices local to this process */ { int numUnevenkIdx = zoneSize[1][2] - numLocalkIdx*comm_size; if (comm_rank < numUnevenkIdx) { ++numLocalkIdx; kIdxBeg = comm_rank*numLocalkIdx; } else { kIdxBeg = numUnevenkIdx*(numLocalkIdx + 1); kIdxBeg += (comm_rank - numUnevenkIdx)*numLocalkIdx; } } cgsize_t s_rmin[3], s_rmax[3], m_dimvals[3], m_rmin[3], m_rmax[3]; double *r = NULL; double *p = NULL; int ni, nj, nk; if (numLocalkIdx > 0) { /* create fake flow solution AT CELL CENTERS for simple example. In memory, there are two rind cells in each direction: */ ni = zoneSize[1][0] + 2; nj = zoneSize[1][1] + 2; nk = numLocalkIdx; const int num_vertex = ni*nj*nk; r = (double*)malloc(2*num_vertex*sizeof(double)); p = r + num_vertex; for (k = kIdxBeg; k < kIdxBeg + numLocalkIdx; ++k) { for (j = 1; j < nj-1; ++j) { for (i = 1; i < ni-1; ++i) { int idx = ((k - kIdxBeg)*nj + j)*ni + i; r[idx] = (float)(i - 1); p[idx] = (float)(j - 1); } } } /* create rind cell data: */ /* k rind planes are not even allocated */ for (k = kIdxBeg; k < kIdxBeg + numLocalkIdx; ++k) /* i planes */ { for (j = 0; j < nj; ++j) { int idx = ((k - kIdxBeg)*nj + j)*ni + 0; r[idx] = 999. + (float)j + (5.*(float)k); p[idx] = 999. + (float)j + (5.*(float)k) + 1.; idx = ((k - kIdxBeg)*nj + j)*ni + (ni-1); r[idx] = -999. - (float)j - (5.*(float)k); p[idx] = -999. - (float)j - (5.*(float)k) - 1.; } } for (k = kIdxBeg; k < kIdxBeg + numLocalkIdx; ++k) /* j planes */ { for (i = 0; i < ni; ++i) { int idx = ((k - kIdxBeg)*nj + 0)*ni + i; r[idx] = 888. + (float)i + (5.*(float)k); p[idx] = 888. + (float)i + (5.*(float)k) + 1.; idx = ((k - kIdxBeg)*nj + (nj-1))*ni + i; r[idx] = -888. - (float)i - (5.*(float)k); p[idx] = -888. - (float)i - (5.*(float)k) - 1.; } } /* shape in file space (core cells start at 1) */ for (n = 0; n < 2; ++n) { s_rmin[n] = 0; s_rmax[n] = zoneSize[1][n] + 1; } s_rmin[2] = kIdxBeg + 1; /* but no rind cells in k-direction */ s_rmax[2] = kIdxBeg + numLocalkIdx; /* shape in memory (array starts at 1)*/ for (n = 0; n < 2; ++n) { m_dimvals[n] = zoneSize[1][n] + 2; m_rmin[n] = 1; m_rmax[n] = zoneSize[1][n] + 2; } m_dimvals[2] = numLocalkIdx; m_rmin[2] = 1; m_rmax[2] = numLocalkIdx; } /* if there is nothing for this process to write, a valid zone index must be provided and data array = NULL */ if (cgp_field_general_write_data(index_file, index_base, index_zone, index_flow, 1, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, r)) cgp_error_exit(); if (cgp_field_general_write_data(index_file, index_base, index_zone, index_flow, 2, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, p)) cgp_error_exit(); if (numLocalkIdx > 0) { free(r); } /* close CGNS file */ cg_close(index_file); MPI_Finalize(); if (comm_rank == 0) { printf("\nSuccessfully added flow solution data to file " "grid_piz_c.cgns\n"); printf("\nNote: if the original CGNS file already had a FlowSolution_t " "node,"); printf("\n it has been overwritten\n"); } return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/write_flowcentrind_str_paroverzone.c000066400000000000000000000205701474000356600311660ustar00rootroot00000000000000/* Program write_flowcentrind_str_paroverzone */ /* Opens an existing CGNS file that contains a simple two-zone 3-D structured grid, and adds a flow solution (at CELL CENTERS PLUS RIND CELLS IN I AND J DIRECTIONS) to it. The CGNS grid file 'grid_poz_c.cgns' must already exist (created using write_grid_str_paroverzone.c) Example compilation for this program is (change paths!): mpicxx write_flowcentrind_str_paroverzone.c -lcgns -lhdf5 -lsz -lz -o write_flowcentrind_str_paroverzone mpirun -np 2 write_flowcentrind_str_paroverzone */ #include #include #include #include "pcgnslib.h" #include "mpi.h" int main(int argc, const char* argv[]) { int i, j, k, n, comm_size, comm_rank; int index_file, index_base, index_zone, index_flow, index_field; char solname[33], zonename[33]; MPI_Init(&argc, (char***)(&argv)); MPI_Comm_size(MPI_COMM_WORLD, &comm_size); MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank); cgp_mpi_comm(MPI_COMM_WORLD); /* open CGNS file for modify */ if (cgp_open("grid_poz_c.cgns", CG_MODE_MODIFY, &index_file)) cg_error_exit(); /* we know there is only one base (real working code would check!) */ index_base = 1; /* set the number of zones (should be 2, real working code would check!) */ int numZone = 2; /* CREATION OF FILE STRUCTURE -- all processors write the same information. Only meta-data is written to the library at this stage */ int idxZone; for (idxZone = 0; idxZone != numZone; ++idxZone) { index_zone = idxZone + 1; /* define flow solution node name (user can give any name) */ strcpy(solname, "FlowSolution"); /* create flow solution node (NOTE USE OF CGNS_ENUMV(CellCenter) HERE) */ cg_sol_write(index_file, index_base, index_zone, solname, CGNS_ENUMV(CellCenter), &index_flow); /* go to position within tree at FlowSolution_t node */ cg_goto(index_file, index_base, "Zone_t", index_zone, "FlowSolution_t", index_flow, "end"); /* write rind information under FlowSolution_t node (ilo,ihi,jlo,jhi,klo,khi) */ int irinddata[6] = { 1, 1, 1, 1, 0, 0 }; cg_rind_write(irinddata); if (cgp_field_write(index_file, index_base, index_zone, index_flow, CGNS_ENUMV(RealDouble), "Density", &index_field)) cgp_error_exit(); if (cgp_field_write(index_file, index_base, index_zone, index_flow, CGNS_ENUMV(RealDouble), "Pressure", &index_field)) cgp_error_exit(); } /* COLLECTIVE WRITING OF FILE DATA -- each processor writes to a separate zone */ /* partition the zones among the processes */ int maxLocalZone; /* the maximum number of zones on any process */ int idxGlobalZoneBeg; /* the global index of the first zone on this process */ int numLocalZone = numZone/comm_size; /* the number of zones local to this process */ { int numUnevenZone = numZone - numLocalZone*comm_size; maxLocalZone = numLocalZone + (numUnevenZone > 0); if (comm_rank < numUnevenZone) { ++numLocalZone; idxGlobalZoneBeg = comm_rank*numLocalZone; } else { idxGlobalZoneBeg = numUnevenZone*(numLocalZone + 1); idxGlobalZoneBeg += (comm_rank - numUnevenZone)*numLocalZone; } } int idxLocalZone; for (idxLocalZone = 0; idxLocalZone < maxLocalZone; ++idxLocalZone) { const int idxGlobalZone = idxGlobalZoneBeg + idxLocalZone; cgsize_t zoneSize[3][3]; cgsize_t s_rmin[3], s_rmax[3], m_dimvals[3], m_rmin[3], m_rmax[3]; double *r = NULL; double *p = NULL; int ni, nj, nk; /* if there is nothing for this process to read, a valid zone index must be provided and data array = NULL */ index_zone = (idxGlobalZone < numZone) ? idxGlobalZone + 1 : 1; if (idxGlobalZone < numZone) { /* get zone size (and name - although not needed here) */ if (cg_zone_read(index_file, index_base, index_zone, zonename, (cgsize_t*)zoneSize)) cg_error_exit(); /* create fake flow solution AT CELL CENTERS for simple example. In memory, there are two rind cells in each direction: */ ni = zoneSize[1][0] + 2; nj = zoneSize[1][1] + 2; nk = zoneSize[1][2] + 2; const int num_vertex = ni*nj*nk; const int iOffset = idxGlobalZone*20; r = (double*)malloc(2*num_vertex*sizeof(double)); p = r + num_vertex; for (k = 1; k < nk-1; ++k) { for (j = 1; j < nj-1; ++j) { for (i = 1; i < ni-1; ++i) { int idx = (k*nj + j)*ni + i; r[idx] = (float)(i - 1 + iOffset); p[idx] = (float)(j - 1); } } } /* create rind cell data: */ for (j = 0; j < nj; ++j) /* k planes */ { for (i = 0; i < ni; ++i) { int idx = (0*nj + j)*ni + i; r[idx] = 777.; p[idx] = 777.; idx = ((nk-1)*nj + j)*ni + i; r[idx] = 777.; p[idx] = 777.; } } for (k = 1; k < nk-1; ++k) /* i planes */ { for (j = 0; j < nj; ++j) { int idx = (k*nj + j)*ni + 0; r[idx] = 999. + (float)j + (5.*(float)k); p[idx] = 999. + (float)j + (5.*(float)k) + 1.; idx = (k*nj + j)*ni + (ni-1); r[idx] = -999. - (float)j - (5.*(float)k); p[idx] = -999. - (float)j - (5.*(float)k) - 1.; } } for (k = 1; k < nk-1; ++k) /* j planes */ { for (i = 0; i < ni; ++i) { int idx = (k*nj + 0)*ni + i; r[idx] = 888. + (float)i + (5.*(float)k); p[idx] = 888. + (float)i + (5.*(float)k) + 1.; idx = (k*nj + (nj-1))*ni + i; r[idx] = -888. - (float)i - (5.*(float)k); p[idx] = -888. - (float)i - (5.*(float)k) - 1.; } } /* shape in file space (core cells start at 1) */ for (n = 0; n < 2; ++n) { s_rmin[n] = 0; s_rmax[n] = zoneSize[1][n] + 1; } s_rmin[2] = 1; /* but no rind cells in k-direction */ s_rmax[2] = zoneSize[1][n]; /* shape in memory (array starts at 1)*/ for (n = 0; n < 2; ++n) { m_dimvals[n] = zoneSize[1][n] + 2; m_rmin[n] = 1; m_rmax[n] = zoneSize[1][n] + 2; } m_dimvals[2] = zoneSize[1][n] + 2; m_rmin[2] = 2; /* but no rind cells in k-direction */ m_rmax[2] = zoneSize[1][n] + 1; } /* if there is nothing for this process to write, a valid zone index must be provided and data array = NULL */ if (cgp_field_general_write_data(index_file, index_base, index_zone, index_flow, 1, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, r)) cgp_error_exit(); if (cgp_field_general_write_data(index_file, index_base, index_zone, index_flow, 2, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, p)) cgp_error_exit(); if (idxGlobalZone < numZone) { free(r); } } /* close CGNS file */ cg_close(index_file); MPI_Finalize(); if (comm_rank == 0) { printf("\nSuccessfully added flow solution data to file " "grid_poz_c.cgns\n"); printf("\nNote: if the original CGNS file already had a FlowSolution_t " "node,"); printf("\n it has been overwritten\n"); } return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/write_grid_str_parinzone.c000066400000000000000000000132261474000356600270500ustar00rootroot00000000000000/* Program write_grid_str_parinzone.c */ /* Creates simple 3-D structured grid and writes it to a CGNS file. Each processor writes a slab of data to one zone (parallelism within a zone) mpicxx write_grid_str_parinzone.c -lcgns -lhdf5 -lsz -lz -o write_grid_str_parinzone mpirun -np 2 write_grid_str_parinzone */ #include #include #include #include "pcgnslib.h" #include "mpi.h" int main(int argc, const char* argv[]) { /* dimension statements for the zone are given here */ const cgsize_t zoneSize[3][3] = /* vertices cells boundary vertex */ { {21, 19, 9}, {20, 18, 8}, {0, 0, 0} }; int i, j, k, n, comm_size, comm_rank; int index_file, index_base; int index_zone, index_grid, index_coordx, index_coordy, index_coordz; char basename[33], zonename[33]; MPI_Init(&argc, (char***)(&argv)); MPI_Comm_size(MPI_COMM_WORLD, &comm_size); MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank); cgp_mpi_comm(MPI_COMM_WORLD); /* open CGNS file for write */ if (cgp_open("grid_piz_c.cgns", CG_MODE_WRITE, &index_file)) cg_error_exit(); /* create base (user can give any name) */ strcpy(basename, "Base"); int icelldim = 3; int iphysdim = 3; cg_base_write(index_file, basename, icelldim, iphysdim, &index_base); /* CREATION OF FILE STRUCTURE -- all processors write the same information. Only zone meta-data is written to the library at this stage */ /* define zone name (user can give any name) */ sprintf(zonename, "Zone %d", 1); /* create zone */ if (cg_zone_write(index_file, index_base, zonename, (cgsize_t*)zoneSize, CGNS_ENUMV(Structured), &index_zone)) cg_error_exit(); if (cg_grid_write(index_file, index_base, index_zone, "GridCoordinates", &index_grid)) cg_error_exit(); /* construct the grid coordinates nodes (user must use SIDS-standard names here) */ if (cgp_coord_write(index_file, index_base, index_zone, CGNS_ENUMV(RealSingle), "CoordinateX", &index_coordx)) cgp_error_exit(); if (cgp_coord_write(index_file, index_base, index_zone, CGNS_ENUMV(RealSingle), "CoordinateY", &index_coordy)) cgp_error_exit(); if (cgp_coord_write(index_file, index_base, index_zone, CGNS_ENUMV(RealSingle), "CoordinateZ", &index_coordz)) cgp_error_exit(); /* COLLECTIVE WRITING OF FILE DATA -- each processor writes a part of the zone */ /* partition the k-index of the zone among the processes */ int kIdxBeg; /* beginning k-index for this processor */ int numLocalkIdx = zoneSize[0][2]/comm_size; /* the number of k-indices local to this process */ { int numUnevenkIdx = zoneSize[0][2] - numLocalkIdx*comm_size; if (comm_rank < numUnevenkIdx) { ++numLocalkIdx; kIdxBeg = comm_rank*numLocalkIdx; } else { kIdxBeg = numUnevenkIdx*(numLocalkIdx + 1); kIdxBeg += (comm_rank - numUnevenkIdx)*numLocalkIdx; } } cgsize_t s_rmin[3], s_rmax[3], m_dimvals[3], m_rmin[3], m_rmax[3]; double *x = NULL; double *y = NULL; double *z = NULL; if (numLocalkIdx > 0) { /* create gridpoints for simple example: */ const int ni = zoneSize[0][0]; const int nj = zoneSize[0][1]; const int nk = numLocalkIdx; const int num_vertex = ni*nj*nk; x = (double*)malloc(3*num_vertex*sizeof(double)); y = x + num_vertex; z = y + num_vertex; for (k = kIdxBeg; k < kIdxBeg + numLocalkIdx; ++k) { for (j = 0; j < nj; ++j) { for (i = 0; i < ni; ++i) { int idx = ((k - kIdxBeg)*nj + j)*ni + i; x[idx] = i; y[idx] = j; z[idx] = k; } } } // shape in file space for (n = 0; n < 2; ++n) { s_rmin[n] = 1; s_rmax[n] = zoneSize[0][n]; } s_rmin[2] = kIdxBeg + 1; s_rmax[2] = kIdxBeg + numLocalkIdx; // shape in memory for (n = 0; n < 2; ++n) { m_dimvals[n] = zoneSize[0][n]; m_rmin[n] = 1; m_rmax[n] = zoneSize[0][n]; } m_dimvals[2] = numLocalkIdx; m_rmin[2] = 1; m_rmax[2] = numLocalkIdx; } /* if there is nothing for this process to write, a valid zone index must be provided and data array = NULL */ /* the data is defined as double but will be written as single */ if (cgp_coord_general_write_data(index_file, index_base, index_zone, 1, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, x)) cgp_error_exit(); if (cgp_coord_general_write_data(index_file, index_base, index_zone, 2, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, y)) cgp_error_exit(); if (cgp_coord_general_write_data(index_file, index_base, index_zone, 3, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, z)) cgp_error_exit(); if (numLocalkIdx > 0) { free(x); } /* close CGNS file */ cgp_close(index_file); MPI_Finalize(); if (comm_rank == 0) { printf("\nSuccessfully wrote grid to file grid_piz_c.cgns\n"); } return 0; } CGNS-4.5.0/src/Test_UserGuideCode/C_code_parallel/write_grid_str_paroverzone.c000066400000000000000000000151571474000356600274220ustar00rootroot00000000000000/* Program write_grid_str_paroverzone.c */ /* Creates simple 3-D structured grid and writes it to a CGNS file. Each processor writes data to one zone (parallelism over zones) mpicxx write_grid_str_paroverzone.c -lcgns -lhdf5 -lsz -lz -o write_grid_str_paroverzone mpirun -np 2 write_grid_str_paroverzone */ #include #include #include #include "pcgnslib.h" #include "mpi.h" int main(int argc, const char* argv[]) { /* dimension statements for the zones are given here */ const int numZone = 2; const cgsize_t zoneSize[2][3][3] = { /* zone 1 */ /* vertices cells boundary vertex */ { {21, 19, 9}, {20, 18, 8}, {0, 0, 0} }, /* zone 2 */ /* vertices cells boundary vertex */ { {17, 19, 9}, {16, 18, 8}, {0, 0, 0} } }; int i, j, k, n, comm_size, comm_rank; int index_file, index_base; int index_zone, index_grid, index_coordx, index_coordy, index_coordz; char basename[33], zonename[33]; MPI_Init(&argc, (char***)(&argv)); MPI_Comm_size(MPI_COMM_WORLD, &comm_size); MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank); cgp_mpi_comm(MPI_COMM_WORLD); /* open CGNS file for writing */ if (cgp_open("grid_poz_c.cgns", CG_MODE_WRITE, &index_file)) cg_error_exit(); /* create base (user can give any name) */ strcpy(basename, "Base"); int icelldim = 3; int iphysdim = 3; cg_base_write(index_file, basename, icelldim, iphysdim, &index_base); /* CREATION OF FILE STRUCTURE -- all processors write the same information. Only zone meta-data is written to the library at this stage */ int idxZone; for (idxZone = 0; idxZone != numZone; ++idxZone) { /* define zone name (user can give any name) */ sprintf(zonename, "Zone %d", idxZone + 1); /* create zone */ if (cg_zone_write(index_file, index_base, zonename, (cgsize_t*)zoneSize[idxZone], CGNS_ENUMV(Structured), &index_zone)) cg_error_exit(); if (cg_grid_write(index_file, index_base, index_zone, "GridCoordinates", &index_grid)) cg_error_exit(); /* construct the grid coordinates nodes (user must use SIDS-standard names here) */ if (cgp_coord_write(index_file, index_base, index_zone, CGNS_ENUMV(RealSingle), "CoordinateX", &index_coordx)) cgp_error_exit(); if (cgp_coord_write(index_file, index_base, index_zone, CGNS_ENUMV(RealSingle), "CoordinateY", &index_coordy)) cgp_error_exit(); if (cgp_coord_write(index_file, index_base, index_zone, CGNS_ENUMV(RealSingle), "CoordinateZ", &index_coordz)) cgp_error_exit(); } /* COLLECTIVE WRITING OF FILE DATA -- each processor writes to a separate zone */ /* partition the zones among the processes */ int maxLocalZone; /* the maximum number of zones on any process */ int idxGlobalZoneBeg; /* the global index of the first zone on this process */ int numLocalZone = numZone/comm_size; /* the number of zones local to this process */ { int numUnevenZone = numZone - numLocalZone*comm_size; maxLocalZone = numLocalZone + (numUnevenZone > 0); if (comm_rank < numUnevenZone) { ++numLocalZone; idxGlobalZoneBeg = comm_rank*numLocalZone; } else { idxGlobalZoneBeg = numUnevenZone*(numLocalZone + 1); idxGlobalZoneBeg += (comm_rank - numUnevenZone)*numLocalZone; } } int idxLocalZone; for (idxLocalZone = 0; idxLocalZone < maxLocalZone; ++idxLocalZone) { const int idxGlobalZone = idxGlobalZoneBeg + idxLocalZone; cgsize_t s_rmin[3], s_rmax[3], m_dimvals[3], m_rmin[3], m_rmax[3]; double *x = NULL; double *y = NULL; double *z = NULL; if (idxGlobalZone < numZone) { /* create gridpoints for simple example: */ const int ni = zoneSize[idxGlobalZone][0][0]; const int nj = zoneSize[idxGlobalZone][0][1]; const int nk = zoneSize[idxGlobalZone][0][2]; const int num_vertex = ni*nj*nk; const double xOffset = idxGlobalZone*zoneSize[0][1][0]; x = (double*)malloc(3*num_vertex*sizeof(double)); y = x + num_vertex; z = y + num_vertex; for (k = 0; k < nk; ++k) { for (j = 0; j < nj; ++j) { for (i = 0; i < ni; ++i) { int idx = (k*nj + j)*ni + i; x[idx] = i + xOffset; y[idx] = j; z[idx] = k; } } } /* shape in file space */ for (n = 0; n < 3; ++n) { s_rmin[n] = 1; s_rmax[n] = zoneSize[idxGlobalZone][0][n]; } /* shape in memory */ for (n = 0; n < 3; ++n) { m_dimvals[n] = zoneSize[idxGlobalZone][0][n]; m_rmin[n] = 1; m_rmax[n] = zoneSize[idxGlobalZone][0][n]; } } /* if there is nothing for this process to write, a valid zone index must be provided and data array = NULL */ index_zone = (idxGlobalZone < numZone) ? idxGlobalZone + 1 : 1; /* the data is defined as double but will be written as single */ if (cgp_coord_general_write_data(index_file, index_base, index_zone, 1, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, x)) cgp_error_exit(); if (cgp_coord_general_write_data(index_file, index_base, index_zone, 2, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, y)) cgp_error_exit(); if (cgp_coord_general_write_data(index_file, index_base, index_zone, 3, s_rmin, s_rmax, CGNS_ENUMV(RealDouble), 3, m_dimvals, m_rmin, m_rmax, z)) cgp_error_exit(); if (idxGlobalZone < numZone) { free(x); } } /* close CGNS file */ cgp_close(index_file); MPI_Finalize(); if (comm_rank == 0) { printf("\nSuccessfully wrote grid to file grid_poz_c.cgns\n"); } return 0; } CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/000077500000000000000000000000001474000356600211415ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/CMakeLists.txt000066400000000000000000000045211474000356600237030ustar00rootroot00000000000000######### # Tests # ######### # Link all the executables to cgns and hdf5 if(CGNS_BUILD_SHARED) set(Fortran_EXAMPLE_LK_LIBS cgns_shared) else() set(Fortran_EXAMPLE_LK_LIBS cgns_static) endif() if (CGNS_ENABLE_HDF5 AND HDF5_LIBRARY) list(APPEND Fortran_EXAMPLE_LK_LIBS ${HDF5_LIBRARY}) if(HDF5_NEED_ZLIB AND ZLIB_LIBRARY) list(APPEND Fortran_EXAMPLE_LK_LIBS ${ZLIB_LIBRARY}) endif() if(HDF5_NEED_SZIP AND SZIP_LIBRARY) list(APPEND Fortran_EXAMPLE_LK_LIBS ${SZIP_LIBRARY}) endif() if(HDF5_NEED_MPI AND MPI_LIBS) list(APPEND Fortran_EXAMPLE_LK_LIBS ${MPI_LIBS}) endif() endif () if (NOT WIN32) list(APPEND Fortran_EXAMPLE_LK_LIBS m) endif () # Add a prefix to differentiate from C example's executables set(PREFIX "Fortran_") # Set the files needed by each test set (examples write_grid_str write_bc_str write_bcpnts_str write_bcpnts_unst write_con2zn_str write_con2zn_genrl_str write_convergence write_descriptor write_dimensional write_flowcent_str write_flowcentrind_str write_floweqn_str write_flowvert_str write_flowvert_unst write_grid2zn_str write_grid_unst write_nondimensional write_timevert_str read_bc_str read_bcpnts_str read_bcpnts_unst read_con2zn_genrl_str read_con2zn_str read_convergence read_descriptor read_dimensional read_flowcent_str read_flowcentrind_str read_floweqn_str read_flowvert_str read_flowvert_unst read_grid2zn_str read_grid_str read_grid_unst read_nondimensional read_timevert_str ) # Build each test foreach (example ${examples}) add_executable (${PREFIX}${example} ${example}.F90) target_link_libraries(${PREFIX}${example} PRIVATE ${Fortran_EXAMPLE_LK_LIBS}) endforeach () # Add the tests so that ctest can find them #if (CGNS_ENABLE_TESTS) # foreach (example ${examples}) # add_test (${example} ${example}) # endforeach (example ${examples}) #endif (CGNS_ENABLE_TESTS) # write_grid_str # write_flowvert_str # write_nondimensional # write_descriptor # write_convergence # write_floweqn_str # write_bcpnts_str # write_grid_unst # write_flowvert_unst # write_dimensional # write_descriptor # write_convergence # write_bcpnts_unst # write_grid_str # write_timevert_str # write_grid_str # write_flowcent_str # write_bc_str # write_grid_str # write_flowcentrind_str # write_discreteface_str # write_grid2zn_str # write_con2zn_str # write_grid2zn_str # write_con2zn_genrl_str CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Makefile000066400000000000000000000012331474000356600226000ustar00rootroot00000000000000 DIRS = \ Test_Grid_Str \ Test_Grid_Unstr \ Test_Grid_Str_Timeacc \ Test_Grid_Str_FlowCent \ Test_Grid_Str_FlowCentRind \ Test_Grid_Str_2zn \ Test_Grid_Str_2zngenrl #---------- all : @status=0;for d in $(DIRS) ; do \ cd $$d && $(MAKE); \ status=`expr $$status + $$?`; \ cd ..; \ done;\ if [ $$status -ne 0 ]; then \ exit $$status; \ fi test : $(TESTS) @status=0;for d in $(DIRS) ; do \ cd $$d && $(MAKE); \ status=`expr $$status + $$?`; \ cd ..; \ done;\ if [ $$status -ne 0 ]; then \ exit $$status; \ fi;\ ./test.sh; \ exit $$?; clean : $(CLEAN) -@for d in $(DIRS) ; do \ cd $$d && $(MAKE) clean; \ cd ..; \ done; CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/README000066400000000000000000000021271474000356600220230ustar00rootroot00000000000000This contains a set of Fortran90 test cases from UserGuideCode. (modified for use with V3.3) If CGNS is compiled with --enable-64bit, then the created "grid.cgns" file will use 64-bit integers as appropriate Currently, the testing (make test) only compares output files of some of the variables written to and read from the grid.cgns file. It does not check whether the 64-bit integers were necessarily written as I8 or not. To check this, one could use "cgnsview" to look at the grid.cgns file(s) directly. For example, with 64-bit integers, in the cgns file under Test_Grid_Str, the PointList data type under the BC_t nodes (under ZoneBC_t) should be I8 rather than I4. ***** NOTE ***** You will first have to edit the Makefile include to set up your CGNS location and compiler and options Edit 'make.defs' for Linux/Unix Not checked for Windows yet. To just build the code, use make on linux/Unix To build and run the tests, use make test Note: executables, output files, and the resulting CGNS file are put in each Subdirectory/build/ directory To clean everything up, use make clean CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str/000077500000000000000000000000001474000356600236555ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str/Makefile000066400000000000000000000053461474000356600253250ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_str$(EXE) WRITE2 = write_flowvert_str$(EXE) WRITE3 = write_nondimensional$(EXE) WRITE4 = write_descriptor$(EXE) WRITE5 = write_convergence$(EXE) WRITE6 = write_floweqn_str$(EXE) WRITE7 = write_bcpnts_str$(EXE) READ1 = read_grid_str$(EXE) READ2 = read_flowvert_str$(EXE) READ3 = read_nondimensional$(EXE) READ4 = read_descriptor$(EXE) READ5 = read_convergence$(EXE) READ6 = read_floweqn_str$(EXE) READ7 = read_bcpnts_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) $(WRITE3) $(WRITE4) $(WRITE5) $(WRITE6) $(WRITE7) READ_PROGS = $(READ1) $(READ2) $(READ3) $(READ4) $(READ5) $(READ6) $(READ7) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(WRITE3) $(READ3) > $(OUTDIR)/output3 -$(DIFF) OUTPUT3 $(OUTDIR)/output3 $(WRITE4) $(READ4) > $(OUTDIR)/output4 -$(DIFF) OUTPUT4 $(OUTDIR)/output4 $(WRITE4) $(READ4) > $(OUTDIR)/output5 -$(DIFF) OUTPUT5 $(OUTDIR)/output5 $(WRITE6) $(READ6) > $(OUTDIR)/output6 -$(DIFF) OUTPUT6 $(OUTDIR)/output6 $(WRITE7) $(READ7) > $(OUTDIR)/output7 -$(DIFF) OUTPUT7 $(OUTDIR)/output7 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_grid_str.F90 $(LIBS) $(WRITE2) : ../write_flowvert_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_flowvert_str.F90 $(LIBS) $(WRITE3) : ../write_nondimensional.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_nondimensional.F90 $(LIBS) $(WRITE4) : ../write_descriptor.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_descriptor.F90 $(LIBS) $(WRITE5) : ../write_convergence.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_convergence.F90 $(LIBS) $(WRITE6) : ../write_floweqn_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_floweqn_str.F90 $(LIBS) $(WRITE7) : ../write_bcpnts_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_bcpnts_str.F90 $(LIBS) $(READ1) : ../read_grid_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_grid_str.F90 $(LIBS) $(READ2) : ../read_flowvert_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_flowvert_str.F90 $(LIBS) $(READ3) : ../read_nondimensional.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_nondimensional.F90 $(LIBS) $(READ4) : ../read_descriptor.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_descriptor.F90 $(LIBS) $(READ5) : ../read_convergence.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_convergence.F90 $(LIBS) $(READ6) : ../read_floweqn_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_floweqn_str.F90 $(LIBS) $(READ7) : ../read_bcpnts_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_bcpnts_str.F90 $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str/OUTPUT1000066400000000000000000000002221474000356600247150ustar00rootroot00000000000000 Successfully read grid from file grid.cgns For example, x,y,z(21,17,9)= 20.00000 16.00000 8.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str/OUTPUT2000066400000000000000000000002151474000356600247200ustar00rootroot00000000000000 Successfully read flow solution from file grid.cgns For example, r,p(21,17,9)= 20.00000 16.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str/OUTPUT3000066400000000000000000000023241474000356600247240ustar00rootroot00000000000000 DataClass = NormalizedByUnknownDimensional ReferenceState = ReferenceQuantities Variable=Mach data= 4.60000000 Variable=Reynolds data= 6000000.00000000 Variable=Mach_Velocity data= 4.60000000 Variable=Mach_VelocitySound data= 1.00000000 Variable=Reynolds_Velocity data= 4.60000000 Variable=Reynolds_Length data= 1.00000000 Variable=Reynolds_ViscosityKinematic data= 0.00000077 Variable=Density data= 1.00000000 Variable=Pressure data= 0.71428571 Variable=VelocitySound data= 1.00000000 Variable=ViscosityMolecular data= 0.00000077 Variable=LengthReference data= 1.00000000 Variable=VelocityX data= 4.60000000 Variable=VelocityY data= 0.00000000 Variable=VelocityZ data= 0.00000000 Successfully read nondimensional info from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str/OUTPUT4000066400000000000000000000002201474000356600247160ustar00rootroot00000000000000 The descriptor is: Supersonic vehicle with landing gear M=4.6, Re=6 million Successfully read descriptors from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str/OUTPUT5000066400000000000000000000003141474000356600247230ustar00rootroot00000000000000 Successfully read cl history from file grid.cgns values are: 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000 10.00000 CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str/OUTPUT6000066400000000000000000000006201474000356600247240ustar00rootroot00000000000000 Eqn dimension = 3 Gov eqn = NSTurbulent diffusion= 0 1 0 0 0 0 Gas model type = Ideal gamma= 1.40000 Turbulence closure type = EddyViscosity turb prandtl number = 0.90000 Turbulence model type = OneEquation_SpalartAllmaras Successfully read equation set info from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str/OUTPUT7000066400000000000000000000071241474000356600247330ustar00rootroot00000000000000 BC number: 1 name=Ilo type=BCTunnelInflow no of pts= 153 (these points read here, but only some printed out:) ipnts(1, 1), (2, 1), (3, 1)= 1 1 1 ipnts(1, 2), (2, 2), (3, 2)= 1 1 2 ipnts(1, 3), (2, 3), (3, 3)= 1 1 3 ipnts(1, 4), (2, 4), (3, 4)= 1 1 4 ipnts(1, 5), (2, 5), (3, 5)= 1 1 5 ipnts(1, 6), (2, 6), (3, 6)= 1 1 6 ipnts(1, 7), (2, 7), (3, 7)= 1 1 7 ipnts(1, 8), (2, 8), (3, 8)= 1 1 8 ipnts(1, 9), (2, 9), (3, 9)= 1 1 9 ipnts(1,10), (2,10), (3,10)= 1 2 1 BC number: 2 name=Ihi type=BCExtrapolate no of pts= 153 (these points read here, but only some printed out:) ipnts(1, 1), (2, 1), (3, 1)= 21 1 1 ipnts(1, 2), (2, 2), (3, 2)= 21 1 2 ipnts(1, 3), (2, 3), (3, 3)= 21 1 3 ipnts(1, 4), (2, 4), (3, 4)= 21 1 4 ipnts(1, 5), (2, 5), (3, 5)= 21 1 5 ipnts(1, 6), (2, 6), (3, 6)= 21 1 6 ipnts(1, 7), (2, 7), (3, 7)= 21 1 7 ipnts(1, 8), (2, 8), (3, 8)= 21 1 8 ipnts(1, 9), (2, 9), (3, 9)= 21 1 9 ipnts(1,10), (2,10), (3,10)= 21 2 1 BC number: 3 name=Jlo type=BCWallInviscid no of pts= 189 (these points read here, but only some printed out:) ipnts(1, 1), (2, 1), (3, 1)= 1 1 1 ipnts(1, 2), (2, 2), (3, 2)= 1 1 2 ipnts(1, 3), (2, 3), (3, 3)= 1 1 3 ipnts(1, 4), (2, 4), (3, 4)= 1 1 4 ipnts(1, 5), (2, 5), (3, 5)= 1 1 5 ipnts(1, 6), (2, 6), (3, 6)= 1 1 6 ipnts(1, 7), (2, 7), (3, 7)= 1 1 7 ipnts(1, 8), (2, 8), (3, 8)= 1 1 8 ipnts(1, 9), (2, 9), (3, 9)= 1 1 9 ipnts(1,10), (2,10), (3,10)= 2 1 1 BC number: 4 name=Jhi type=BCWallInviscid no of pts= 189 (these points read here, but only some printed out:) ipnts(1, 1), (2, 1), (3, 1)= 1 17 1 ipnts(1, 2), (2, 2), (3, 2)= 1 17 2 ipnts(1, 3), (2, 3), (3, 3)= 1 17 3 ipnts(1, 4), (2, 4), (3, 4)= 1 17 4 ipnts(1, 5), (2, 5), (3, 5)= 1 17 5 ipnts(1, 6), (2, 6), (3, 6)= 1 17 6 ipnts(1, 7), (2, 7), (3, 7)= 1 17 7 ipnts(1, 8), (2, 8), (3, 8)= 1 17 8 ipnts(1, 9), (2, 9), (3, 9)= 1 17 9 ipnts(1,10), (2,10), (3,10)= 2 17 1 BC number: 5 name=Klo type=BCWallInviscid no of pts= 357 (these points read here, but only some printed out:) ipnts(1, 1), (2, 1), (3, 1)= 1 1 1 ipnts(1, 2), (2, 2), (3, 2)= 1 2 1 ipnts(1, 3), (2, 3), (3, 3)= 1 3 1 ipnts(1, 4), (2, 4), (3, 4)= 1 4 1 ipnts(1, 5), (2, 5), (3, 5)= 1 5 1 ipnts(1, 6), (2, 6), (3, 6)= 1 6 1 ipnts(1, 7), (2, 7), (3, 7)= 1 7 1 ipnts(1, 8), (2, 8), (3, 8)= 1 8 1 ipnts(1, 9), (2, 9), (3, 9)= 1 9 1 ipnts(1,10), (2,10), (3,10)= 1 10 1 BC number: 6 name=Khi type=BCWallInviscid no of pts= 357 (these points read here, but only some printed out:) ipnts(1, 1), (2, 1), (3, 1)= 1 1 9 ipnts(1, 2), (2, 2), (3, 2)= 1 2 9 ipnts(1, 3), (2, 3), (3, 3)= 1 3 9 ipnts(1, 4), (2, 4), (3, 4)= 1 4 9 ipnts(1, 5), (2, 5), (3, 5)= 1 5 9 ipnts(1, 6), (2, 6), (3, 6)= 1 6 9 ipnts(1, 7), (2, 7), (3, 7)= 1 7 9 ipnts(1, 8), (2, 8), (3, 8)= 1 8 9 ipnts(1, 9), (2, 9), (3, 9)= 1 9 9 ipnts(1,10), (2,10), (3,10)= 1 10 9 Successfully read BCs (PointList format) from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_2zn/000077500000000000000000000000001474000356600244465ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_2zn/Makefile000066400000000000000000000017511474000356600261120ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid2zn_str$(EXE) WRITE2 = write_con2zn_str$(EXE) READ1 = read_grid2zn_str$(EXE) READ2 = read_con2zn_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) READ_PROGS = $(READ1) $(READ2) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid2zn_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_grid2zn_str.F90 $(LIBS) $(WRITE2) : ../write_con2zn_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_con2zn_str.F90 $(LIBS) $(READ1) : ../read_grid2zn_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_grid2zn_str.F90 $(LIBS) $(READ2) : ../read_con2zn_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_con2zn_str.F90 $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_2zn/OUTPUT1000066400000000000000000000003441474000356600255130ustar00rootroot00000000000000 Successfully read grid from file grid.cgns For example, zone 1 x,y,z(21,17,9)= 20.00000 16.00000 8.00000 zone 2 x,y,z(21,17,9)= 40.00000 16.00000 8.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_2zn/OUTPUT2000066400000000000000000000007241474000356600255160ustar00rootroot00000000000000 In zone 1: donor name=Zone 2 range (this zone)= 21 1 1 21 17 9 range (donor zone)= 1 1 1 1 17 9 transform= 1 2 3 In zone 2: donor name=Zone 1 range (this zone)= 1 1 1 1 17 9 range (donor zone)= 21 1 1 21 17 9 transform= 1 2 3 Successfully read 1-to-1 connectivity info from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_2zngenrl/000077500000000000000000000000001474000356600254765ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_2zngenrl/Makefile000066400000000000000000000020151474000356600271340ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid2zn_str$(EXE) WRITE2 = write_con2zn_genrl_str$(EXE) READ1 = read_grid2zn_str$(EXE) READ2 = read_con2zn_genrl_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) READ_PROGS = $(READ1) $(READ2) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid2zn_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_grid2zn_str.F90 $(LIBS) $(WRITE2) : ../write_con2zn_genrl_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_con2zn_genrl_str.F90 $(LIBS) $(READ1) : ../read_grid2zn_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_grid2zn_str.F90 $(LIBS) $(READ2) : ../read_con2zn_genrl_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_con2zn_genrl_str.F90 $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_2zngenrl/OUTPUT1000066400000000000000000000003441474000356600265430ustar00rootroot00000000000000 Successfully read grid from file grid.cgns For example, zone 1 x,y,z(21,17,9)= 20.00000 16.00000 8.00000 zone 2 x,y,z(21,17,9)= 40.00000 16.00000 8.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_2zngenrl/OUTPUT2000066400000000000000000000052641474000356600265520ustar00rootroot00000000000000 In zone 1: donor name=Zone 2 number of connectivity pts= 153 grid location=Vertex connectivity type=Abutting1to1 pointset type=PointList donor zonetype=Structured donor pointset type=PointListDonor ipnts and ipntsdonor arrays read, only some written out here: ipnts(1, 1), (2, 1), (3, 1)= 21 1 1 ipntsdonor(1, 1), (2, 1), (3, 1)= 1 1 1 ipnts(1, 2), (2, 2), (3, 2)= 21 1 2 ipntsdonor(1, 2), (2, 2), (3, 2)= 1 1 2 ipnts(1, 3), (2, 3), (3, 3)= 21 1 3 ipntsdonor(1, 3), (2, 3), (3, 3)= 1 1 3 ipnts(1, 4), (2, 4), (3, 4)= 21 1 4 ipntsdonor(1, 4), (2, 4), (3, 4)= 1 1 4 ipnts(1, 5), (2, 5), (3, 5)= 21 1 5 ipntsdonor(1, 5), (2, 5), (3, 5)= 1 1 5 ipnts(1, 6), (2, 6), (3, 6)= 21 1 6 ipntsdonor(1, 6), (2, 6), (3, 6)= 1 1 6 ipnts(1, 7), (2, 7), (3, 7)= 21 1 7 ipntsdonor(1, 7), (2, 7), (3, 7)= 1 1 7 ipnts(1, 8), (2, 8), (3, 8)= 21 1 8 ipntsdonor(1, 8), (2, 8), (3, 8)= 1 1 8 ipnts(1, 9), (2, 9), (3, 9)= 21 1 9 ipntsdonor(1, 9), (2, 9), (3, 9)= 1 1 9 ipnts(1,10), (2,10), (3,10)= 21 2 1 ipntsdonor(1,10), (2,10), (3,10)= 1 2 1 In zone 2: donor name=Zone 1 number of connectivity pts= 153 grid location=Vertex connectivity type=Abutting1to1 pointset type=PointList donor zonetype=Structured donor pointset type=PointListDonor ipnts and ipntsdonor arrays read, only some written out here: ipnts(1, 1), (2, 1), (3, 1)= 1 1 1 ipntsdonor(1, 1), (2, 1), (3, 1)= 21 1 1 ipnts(1, 2), (2, 2), (3, 2)= 1 1 2 ipntsdonor(1, 2), (2, 2), (3, 2)= 21 1 2 ipnts(1, 3), (2, 3), (3, 3)= 1 1 3 ipntsdonor(1, 3), (2, 3), (3, 3)= 21 1 3 ipnts(1, 4), (2, 4), (3, 4)= 1 1 4 ipntsdonor(1, 4), (2, 4), (3, 4)= 21 1 4 ipnts(1, 5), (2, 5), (3, 5)= 1 1 5 ipntsdonor(1, 5), (2, 5), (3, 5)= 21 1 5 ipnts(1, 6), (2, 6), (3, 6)= 1 1 6 ipntsdonor(1, 6), (2, 6), (3, 6)= 21 1 6 ipnts(1, 7), (2, 7), (3, 7)= 1 1 7 ipntsdonor(1, 7), (2, 7), (3, 7)= 21 1 7 ipnts(1, 8), (2, 8), (3, 8)= 1 1 8 ipntsdonor(1, 8), (2, 8), (3, 8)= 21 1 8 ipnts(1, 9), (2, 9), (3, 9)= 1 1 9 ipntsdonor(1, 9), (2, 9), (3, 9)= 21 1 9 ipnts(1,10), (2,10), (3,10)= 1 2 1 ipntsdonor(1,10), (2,10), (3,10)= 21 2 1 Successfully read general 1-to-1 connectivity info from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_FlowCent/000077500000000000000000000000001474000356600254565ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_FlowCent/Makefile000066400000000000000000000024521474000356600271210ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_str$(EXE) WRITE2 = write_flowcent_str$(EXE) WRITE3 = write_bc_str$(EXE) READ1 = read_grid_str$(EXE) READ2 = read_flowcent_str$(EXE) READ3 = read_bc_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) $(WRITE3) READ_PROGS = $(READ1) $(READ2) $(READ3) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(WRITE3) $(READ3) > $(OUTDIR)/output3 -$(DIFF) OUTPUT3 $(OUTDIR)/output3 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_grid_str.F90 $(LIBS) $(WRITE2) : ../write_flowcent_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_flowcent_str.F90 $(LIBS) $(WRITE3) : ../write_bc_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_bc_str.F90 $(LIBS) $(READ1) : ../read_grid_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_grid_str.F90 $(LIBS) $(READ2) : ../read_flowcent_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_flowcent_str.F90 $(LIBS) $(READ3) : ../read_bc_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_bc_str.F90 $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_FlowCent/OUTPUT1000066400000000000000000000002221474000356600265160ustar00rootroot00000000000000 Successfully read grid from file grid.cgns For example, x,y,z(21,17,9)= 20.00000 16.00000 8.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_FlowCent/OUTPUT2000066400000000000000000000002151474000356600265210ustar00rootroot00000000000000 Successfully read flow solution from file grid.cgns For example, r,p(20,16,8)= 19.00000 15.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_FlowCent/OUTPUT3000066400000000000000000000021011474000356600265160ustar00rootroot00000000000000 BC number: 1 name=Ilo type=BCTunnelInflow i-range= 1 1 j-range= 1 17 k-range= 1 9 BC number: 2 name=Ihi type=BCExtrapolate i-range= 21 21 j-range= 1 17 k-range= 1 9 BC number: 3 name=Jlo type=BCWallInviscid i-range= 1 21 j-range= 1 1 k-range= 1 9 BC number: 4 name=Jhi type=BCWallInviscid i-range= 1 21 j-range= 17 17 k-range= 1 9 BC number: 5 name=Klo type=BCWallInviscid i-range= 1 21 j-range= 1 17 k-range= 1 1 BC number: 6 name=Khi type=BCWallInviscid i-range= 1 21 j-range= 1 17 k-range= 9 9 Successfully read BCs (PointRange format) from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_FlowCentRind/000077500000000000000000000000001474000356600262735ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_FlowCentRind/Makefile000066400000000000000000000017721474000356600277420ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_str$(EXE) WRITE2 = write_flowcentrind_str$(EXE) READ1 = read_grid_str$(EXE) READ2 = read_flowcentrind_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) READ_PROGS = $(READ1) $(READ2) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_grid_str.F90 $(LIBS) $(WRITE2) : ../write_flowcentrind_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_flowcentrind_str.F90 $(LIBS) $(READ1) : ../read_grid_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_grid_str.F90 $(LIBS) $(READ2) : ../read_flowcentrind_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_flowcentrind_str.F90 $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_FlowCentRind/OUTPUT1000066400000000000000000000002221474000356600273330ustar00rootroot00000000000000 Successfully read grid from file grid.cgns For example, x,y,z(21,17,9)= 20.00000 16.00000 8.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_FlowCentRind/OUTPUT2000066400000000000000000000003701474000356600273400ustar00rootroot00000000000000 Successfully read flow solution from file grid.cgns For example, r,p(21,17,8)= 19.00000 15.00000 rind: r,p(1,17,8)= 1055.00000 1056.00000 rind: r,p(22,17,8)= -1055.00000 -1056.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_Timeacc/000077500000000000000000000000001474000356600253025ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_Timeacc/Makefile000066400000000000000000000017421474000356600267460ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_str$(EXE) WRITE2 = write_timevert_str$(EXE) READ1 = read_grid_str$(EXE) READ2 = read_timevert_str$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) READ_PROGS = $(READ1) $(READ2) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_grid_str.F90 $(LIBS) $(WRITE2) : ../write_timevert_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_timevert_str.F90 $(LIBS) $(READ1) : ../read_grid_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_grid_str.F90 $(LIBS) $(READ2) : ../read_timevert_str.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_timevert_str.F90 $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_Timeacc/OUTPUT1000066400000000000000000000002221474000356600263420ustar00rootroot00000000000000 Successfully read grid from file grid.cgns For example, x,y,z(21,17,9)= 20.00000 16.00000 8.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Str_Timeacc/OUTPUT2000066400000000000000000000013141474000356600263460ustar00rootroot00000000000000 number of time steps stored = 3 Times stored are: 10.000 20.000 50.000 Flow solution names corresponding to each are: FlowSolution1 FlowSolution2 FlowSolution3 Simulation type is: TimeAccurate Successfully read 3 flow solutions from file grid.cgns For example, r1,p1(1,1,1)= 0.00000 0.00000 r2,p2(1,1,1)= 1.00000 1.00000 r3,p3(1,1,1)= 2.00000 2.00000 For example, r1,p1(21,17,9)= 20.00000 16.00000 r2,p2(21,17,9)= 21.00000 17.00000 r3,p3(21,17,9)= 22.00000 18.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Unstr/000077500000000000000000000000001474000356600242205ustar00rootroot00000000000000CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Unstr/Makefile000066400000000000000000000046151474000356600256660ustar00rootroot00000000000000include ../make.defs WRITE1 = write_grid_unst$(EXE) WRITE2 = write_flowvert_unst$(EXE) WRITE3 = write_dimensional$(EXE) WRITE4 = write_descriptor$(EXE) WRITE5 = write_convergence$(EXE) WRITE6 = write_bcpnts_unst$(EXE) READ1 = read_grid_unst$(EXE) READ2 = read_flowvert_unst$(EXE) READ3 = read_dimensional$(EXE) READ4 = read_descriptor$(EXE) READ5 = read_convergence$(EXE) READ6 = read_bcpnts_unst$(EXE) WRITE_PROGS = $(WRITE1) $(WRITE2) $(WRITE3) $(WRITE4) $(WRITE5) $(WRITE6) READ_PROGS = $(READ1) $(READ2) $(READ3) $(READ4) $(READ5) $(READ6) all : write read write : $(OUTDIR) $(WRITE_PROGS) read : $(OUTDIR) $(READ_PROGS) test : write read -@$(RM) grid.cgns $(WRITE1) $(READ1) > $(OUTDIR)/output1 -$(DIFF) OUTPUT1 $(OUTDIR)/output1 $(WRITE2) $(READ2) > $(OUTDIR)/output2 -$(DIFF) OUTPUT2 $(OUTDIR)/output2 $(WRITE3) $(READ3) > $(OUTDIR)/output3 -$(DIFF) OUTPUT3 $(OUTDIR)/output3 $(WRITE4) $(READ4) > $(OUTDIR)/output4 -$(DIFF) OUTPUT4 $(OUTDIR)/output4 $(WRITE5) $(READ5) > $(OUTDIR)/output5 -$(DIFF) OUTPUT5 $(OUTDIR)/output5 $(WRITE6) $(READ6) > $(OUTDIR)/output6 -$(DIFF) OUTPUT6 $(OUTDIR)/output6 $(OUTDIR) : -@$(MKDIR) $(OUTDIR) $(WRITE1) : ../write_grid_unst.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_grid_unst.F90 $(LIBS) $(WRITE2) : ../write_flowvert_unst.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_flowvert_unst.F90 $(LIBS) $(WRITE3) : ../write_dimensional.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_dimensional.F90 $(LIBS) $(WRITE4) : ../write_descriptor.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_descriptor.F90 $(LIBS) $(WRITE5) : ../write_convergence.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_convergence.F90 $(LIBS) $(WRITE6) : ../write_bcpnts_unst.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../write_bcpnts_unst.F90 $(LIBS) $(READ1) : ../read_grid_unst.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_grid_unst.F90 $(LIBS) $(READ2) : ../read_flowvert_unst.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_flowvert_unst.F90 $(LIBS) $(READ3) : ../read_dimensional.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_dimensional.F90 $(LIBS) $(READ4) : ../read_descriptor.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_descriptor.F90 $(LIBS) $(READ5) : ../read_convergence.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_convergence.F90 $(LIBS) $(READ6) : ../read_bcpnts_unst.F90 $(F77) $(FOPTS) $(FEOUT) $@ ../read_bcpnts_unst.F90 $(LIBS) clean : -$(RM) grid.cgns $(WRITE_PROGS) $(READ_PROGS) -$(RMDIR) $(OUTDIR) CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Unstr/OUTPUT1000066400000000000000000000021051474000356600252620ustar00rootroot00000000000000 number of sections= 4 Reading section data... section name=Elem section type=HEXA_8 istart,iend= 1 2560 reading element data for this element Reading section data... section name=InflowElem section type=QUAD_4 istart,iend= 2561 2688 not reading element data for this element Reading section data... section name=OutflowElem section type=QUAD_4 istart,iend= 2689 2816 not reading element data for this element Reading section data... section name=SidewallElem section type=QUAD_4 istart,iend= 2817 3776 not reading element data for this element Successfully read unstructured grid from file grid.cgns for example, element 1 is made up of nodes: 1 2 23 22 358 359 380 379 x,y,z of node 358 are: 0.00000 0.00000 1.00000 x,y,z of node 1358 are: 13.00000 13.00000 3.00000 CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Unstr/OUTPUT2000066400000000000000000000002751474000356600252710ustar00rootroot00000000000000 Successfully read flow solution from file grid.cgns For example, r,p(380) = 1.00000 1.00000 r,p(3213)= 20.00000 16.00000 Program successful... ending now CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Unstr/OUTPUT3000066400000000000000000000015651474000356600252750ustar00rootroot00000000000000 DataClass = Dimensional Units= Kilogram Meter Second Kelvin Degree For Density , exponents are: 1.0 -3.0 0.0 0.0 0.0 For Pressure , exponents are: 1.0 -1.0 -2.0 0.0 0.0 For CoordinateX , exponents are: 0.0 1.0 0.0 0.0 0.0 For CoordinateY , exponents are: 0.0 1.0 0.0 0.0 0.0 For CoordinateZ , exponents are: 0.0 1.0 0.0 0.0 0.0 Successfully read dimensional data from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Unstr/OUTPUT4000066400000000000000000000002201474000356600252610ustar00rootroot00000000000000 The descriptor is: Supersonic vehicle with landing gear M=4.6, Re=6 million Successfully read descriptors from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Unstr/OUTPUT5000066400000000000000000000003141474000356600252660ustar00rootroot00000000000000 Successfully read cl history from file grid.cgns values are: 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000 10.00000 CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/Test_Grid_Unstr/OUTPUT6000066400000000000000000000024411474000356600252720ustar00rootroot00000000000000 GridLocation=FaceCenter means BC data refers to elements, not nodes BC number: 1 name=Ilo type=BCTunnelInflow no of elements= 128 (these elements read here, but only some printed out:) ipnts( 1)=2561 ipnts( 2)=2562 ipnts( 3)=2563 ipnts( 4)=2564 ipnts( 5)=2565 ipnts( 6)=2566 ipnts( 7)=2567 ipnts( 8)=2568 ipnts( 9)=2569 ipnts(10)=2570 GridLocation=FaceCenter means BC data refers to elements, not nodes BC number: 2 name=Ihi type=BCExtrapolate no of elements= 128 (these elements read here, but only some printed out:) ipnts( 1)=2689 ipnts( 2)=2690 ipnts( 3)=2691 ipnts( 4)=2692 ipnts( 5)=2693 ipnts( 6)=2694 ipnts( 7)=2695 ipnts( 8)=2696 ipnts( 9)=2697 ipnts(10)=2698 GridLocation=FaceCenter means BC data refers to elements, not nodes BC number: 3 name=Walls type=BCWallInviscid no of elements= 960 (these elements read here, but only some printed out:) ipnts( 1)=2817 ipnts( 2)=2818 ipnts( 3)=2819 ipnts( 4)=2820 ipnts( 5)=2821 ipnts( 6)=2822 ipnts( 7)=2823 ipnts( 8)=2824 ipnts( 9)=2825 ipnts(10)=2826 Successfully read BCs (PointList format) from file grid.cgns CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/make.defs000066400000000000000000000010241474000356600227160ustar00rootroot00000000000000# location for the CGNS includes and required libraries CGNSDIR = ../../.. include $(CGNSDIR)/make.defs include $(CGNSDIR)/cgnsBuild.defs CGNSLIB = $(CGNSDIR)/$(LIBCGNS) CGNSinclude = ../../../ CGNSlibs = $(CGNSLIB) $(HDF5LIB) # Fortran compiler and options FOPTS = -I$(CGNSinclude) $(FFLAGS) LIBS = $(CGNSlibs) $(SZIPLIB) $(ZLIBLIB) $(HDF5LIB_DEP) -lm $(FLIBS) # how to name output executable and extension FEOUT = -o EXE = # working directory for output OUTDIR = build # additional commands MKDIR = mkdir DIFF = diff -w CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_bc_str.F90000066400000000000000000000057331474000356600237000ustar00rootroot00000000000000 program read_bc_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid + BCs (in PointRange format), and reads the BCs ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f), and the BCs must also ! already have been written (using write_bc_str.f). Note: whether the ! existing CGNS file has a flow solution in it already or ! not is irrelevant. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_bc_str.F90 ! ifort -o read_bc_str read_bc_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer(cgsize_t) ipnts(3,2),npts,normallistflag integer normalindex(3) integer normallist,ndataset,normaldatatype,iptset,ibocotype,ib,nbocos integer index_zone,index_base,index_file,ier character boconame*32 ! ! READ BOUNDARY CONDITIONS FROM EXISTING CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! find out number of BCs that exist under this zone call cg_nbocos_f(index_file,index_base,index_zone,nbocos,ier) ! do loop over the total number of BCs do ib=1,nbocos ! get BC info call cg_boco_info_f(index_file,index_base,index_zone,ib, & boconame,ibocotype,iptset,npts,normalindex,normallistflag, & normaldatatype,ndataset,ier) if (iptset .ne. CGNS_ENUMV(PointRange)) then write(6,'('' Error. For this program, BCs must be set'', & '' up as PointRange type'',a32)') PointSetTypeName(iptset) stop end if write(6,'('' BC number: '',i5)') ib write(6,'('' name='',a32)') boconame write(6,'('' type='',a32)') BCTypeName(ibocotype) ! read point range in here call cg_boco_read_f(index_file,index_base,index_zone,ib, & ipnts,normallist,ier) write(6,'('' i-range='',2i5)') ipnts(1,1),ipnts(1,2) write(6,'('' j-range='',2i5)') ipnts(2,1),ipnts(2,2) write(6,'('' k-range='',2i5)') ipnts(3,1),ipnts(3,2) enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read BCs (PointRange format)'', & '' from file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_bcpnts_str.F90000066400000000000000000000065571474000356600246120ustar00rootroot00000000000000 program read_bcpnts_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid + BCs (in PointList format), and reads the BCs ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f), and the BCs must also ! already have been written (using write_bcpnts_str.f). Note: whether the ! existing CGNS file has a flow solution in it already or ! not is irrelevant. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_bcpnts_str.F90 ! ifort -o read_bcpnts_str read_bcpnts_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer, parameter :: maxpnts=400 integer(cgsize_t) ipnts(3,maxpnts),npts,normallistflag integer normalindex(3) integer i,normallist,ndataset,normaldatatype,iptset,ibocotype integer ib,nbocos integer index_zone,index_base,index_file,ier character boconame*32 ! ! READ BOUNDARY CONDITIONS FROM EXISTING CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! find out number of BCs that exist under this zone call cg_nbocos_f(index_file,index_base,index_zone,nbocos,ier) ! do loop over the total number of BCs do ib=1,nbocos ! get BC info call cg_boco_info_f(index_file,index_base,index_zone,ib, & boconame,ibocotype,iptset,npts,normalindex,normallistflag, & normaldatatype,ndataset,ier) if (iptset .ne. CGNS_ENUMV(PointList)) then write(6,'('' Error. For this program, BCs must be set'', & '' up as PointList type'',a32)') PointSetTypeName(iptset) stop end if write(6,'('' BC number: '',i5)') ib write(6,'('' name='',a32)') boconame write(6,'('' type='',a32)') BCTypeName(ibocotype) write(6,'('' no of pts='',i5)') npts if (npts .gt. maxpnts) then write(6,'('' Error. Must increase maxpnts to at least '',i5)') npts stop end if ! read point list in here (nothing done with them in this program) call cg_boco_read_f(index_file,index_base,index_zone,ib, & ipnts,normallist,ier) write(6,'('' (these points read here, but only some'', & '' printed out:)'')') do i=1,10 write(6,'('' ipnts(1,'',i2,''), (2,'',i2,''), (3,'',i2,'')='', & 3i4)') i,i,i,ipnts(1,i),ipnts(2,i),ipnts(3,i) enddo enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read BCs (PointList format)'', & '' from file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_bcpnts_unst.F90000066400000000000000000000074041474000356600247630ustar00rootroot00000000000000 program read_bcpnts_unst use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! unstructured grid + BCs (in PointList+GridLocation=FaceCenter ! format), and reads the BCs ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_unst.f), and the BCs must also ! already have been written (using write_bcpnts_unst.f). Note: whether the ! existing CGNS file has a flow solution in it already or ! not is irrelevant. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_bcpnts_unst.F90 ! ifort -o read_bcpnts_unst read_bcpnts_unst.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer, parameter :: maxpnts=960 integer(cgsize_t) ipnts(maxpnts),npts,normallistflag integer normalindex(3) integer i,normallist,ndataset,normaldatatype,iptset,ibocotype integer igr,ib,nbocos integer index_zone,index_base,index_file,ier character boconame*32 ! ! READ BOUNDARY CONDITIONS FROM EXISTING CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! find out number of BCs that exist under this zone call cg_nbocos_f(index_file,index_base,index_zone,nbocos,ier) ! do loop over the total number of BCs do ib=1,nbocos ! find out what BC grid location is (expecting FaceCenter) call cg_goto_f(index_file,index_base,ier,'Zone_t',1, & 'ZoneBC_t',1,'BC_t',ib,'end') call cg_gridlocation_read_f(igr,ier) if (igr .eq. CGNS_ENUMV(FaceCenter)) then write(6,'('' GridLocation=FaceCenter means BC data refers'', & '' to elements, not nodes'')') end if ! get BC info call cg_boco_info_f(index_file,index_base,index_zone,ib, & boconame,ibocotype,iptset,npts,normalindex,normallistflag, & normaldatatype,ndataset,ier) if (iptset .ne. CGNS_ENUMV(PointList)) then write(6,'('' Error. For this program, BCs must be set'', & '' up as PointList type'',a32)') PointSetTypeName(iptset) stop end if write(6,'('' BC number: '',i5)') ib write(6,'('' name='',a32)') boconame write(6,'('' type='',a32)') BCTypeName(ibocotype) write(6,'('' no of elements='',i5)') npts if (npts .gt. maxpnts) then write(6,'('' Error. Must increase maxpnts to at least '', & i5)') npts stop end if ! read point list in here (nothing done with them in this program) call cg_boco_read_f(index_file,index_base,index_zone,ib, & ipnts,normallist,ier) write(6,'('' (these elements read here, but only some'', & '' printed out:)'')') do i=1,10 write(6,'('' ipnts('',i2,'')='',i4)') i,ipnts(i) enddo enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read BCs (PointList format)'', & '' from file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_con2zn_genrl_str.F90000066400000000000000000000106571474000356600257150ustar00rootroot00000000000000 program read_con2zn_genrl_str use cgns implicit none ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid (2 zones) plus 1-to-1 connectivity ! information (written in GENERAL form), and reads the ! connectivity info. ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid2zn_str.f plus write_con2zn_genrl_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_con2zn_genrl_str.F90 ! ifort -o read_con2zn_genrl_str read_con2zn_genrl_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer, parameter :: maxpnts=400 integer(cgsize_t) npts,ndata_donor integer(cgsize_t) ipnts(3,maxpnts),ipntsdonor(3,maxpnts) integer i,idonor_datatype,idonor_ptset_type,idonor_zonetype,iptset_type integer iconnect_type,location,nconns,nzone integer index_conn,index_zone,index_base,index_file,ier character donorname*32,connectname*32 ! ! READ GENERAL CONNECTIVITY INFORMATION FROM EXISTING CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! get number of zones (should be 2 for our case) call cg_nzones_f(index_file,index_base,nzone,ier) if (nzone .ne. 2) then write(6,'('' Error. This program expects 2 zones. '',i5, & '' read'')') nzone stop end if ! loop over zones do index_zone=1,nzone ! find out how many general interfaces there are in this zone ! (for this program, there should only be one) call cg_nconns_f(index_file,index_base,index_zone,nconns,ier) if (nconns .ne. 1) then write(6,'('' Error. Expecting one general interface.'', & i6,'' read'')') nconns stop end if index_conn=nconns ! read general connectivity info call cg_conn_info_f(index_file,index_base,index_zone,index_conn, & connectname,location,iconnect_type,iptset_type,npts, & donorname,idonor_zonetype,idonor_ptset_type,idonor_datatype, & ndata_donor,ier) if (npts .gt. maxpnts) then write(6,'('' Error. Must increase maxpnts to at least '',i5)') npts stop end if call cg_conn_read_f(index_file,index_base,index_zone,index_conn, & ipnts,idonor_datatype,ipntsdonor,ier) write(6,'('' In zone '',i5,'':'')') index_zone write(6,'('' donor name='',a32)') donorname write(6,'('' number of connectivity pts='',i6)') npts write(6,'('' grid location='',a32)') & GridLocationName(location) write(6,'('' connectivity type='',a32)') & GridConnectivityTypeName(iconnect_type) write(6,'('' pointset type='',a32)') & PointSetTypeName(iptset_type) write(6,'('' donor zonetype='',a32)') & ZoneTypeName(idonor_zonetype) write(6,'('' donor pointset type='',a32)') & PointSetTypeName(idonor_ptset_type) ! write(6,'('' data type='',a32)') DataTypeName(idonor_datatype) write(6,'('' ipnts and ipntsdonor arrays read, only some'', & '' written out here:'')') do i=1,10 write(6,'('' ipnts(1,'',i2,''), (2,'',i2,''), (3,'',i2,'')='', & 3i4,'' ipntsdonor(1,'',i2,''), (2,'',i2,''), (3,'',i2, & '')='',3i4)') i,i,i,ipnts(1,i),ipnts(2,i),ipnts(3,i), & i,i,i,ipntsdonor(1,i),ipntsdonor(2,i),ipntsdonor(3,i) enddo enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read general 1-to-1 connectivity'', & '' info from file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_con2zn_str.F90000066400000000000000000000060411474000356600245160ustar00rootroot00000000000000 program read_con2zn_str use cgns implicit none ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid (2 zones) plus 1-to-1 connectivity ! information, and reads the connectivity info. ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid2zn_str.f plus write_con2zn_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_con2zn_str.F90 ! ifort -o read_con2zn_str read_con2zn_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer(cgsize_t) ipnts(3,2),ipntsdonor(3,2) integer itranfrm(3) integer nzone,n1to1 integer index_conn,index_zone,index_base,index_file,ier character donorname*32,connectname*32 ! ! READ 1-TO-1 CONNECTIVITY INFORMATION FROM EXISTING CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! get number of zones (should be 2 for our case) call cg_nzones_f(index_file,index_base,nzone,ier) if (nzone .ne. 2) then write(6,'('' Error. This program expects 2 zones. '',i5, & '' read'')') nzone stop end if ! loop over zones do index_zone=1,nzone ! find out how many 1-to-1 interfaces there are in this zone ! (for this program, there should only be one) call cg_n1to1_f(index_file,index_base,index_zone,n1to1,ier) if (n1to1 .ne. 1) then write(6,'('' Error. Expecting one 1-to-1 interface.'', & i6,'' read'')') n1to1 stop end if index_conn=n1to1 ! read 1-to-1 info call cg_1to1_read_f(index_file,index_base,index_zone,index_conn, & connectname,donorname,ipnts,ipntsdonor,itranfrm,ier) write(6,'('' In zone '',i5,'':'')') index_zone write(6,'('' donor name='',a32)') donorname write(6,'('' range (this zone)='',6i5)') ipnts(1,1), & ipnts(2,1),ipnts(3,1),ipnts(1,2),ipnts(2,2),ipnts(3,2) write(6,'('' range (donor zone)='',6i5)') ipntsdonor(1,1), & ipntsdonor(2,1),ipntsdonor(3,1),ipntsdonor(1,2), & ipntsdonor(2,2),ipntsdonor(3,2) write(6,'('' transform='',3i5)') itranfrm(1),itranfrm(2), & itranfrm(3) enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read 1-to-1 connectivity info from'', & '' file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_convergence.F90000066400000000000000000000053241474000356600247160ustar00rootroot00000000000000 program read_convergence use cgns implicit none #include "cgnstypes_f03.h" ! ! Reads convergence history from an existing CGNS file. ! ! The CGNS grid file 'grid.cgns' must already exist ! and a convergence history should be in it (using write_convergence.f). ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_convergence.F90 ! ifort -o read_convergence read_convergence.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer, parameter :: ntt=20 real*4 cl(ntt) integer(cgsize_t) idim(1) integer ndim,itype,index_array,narrays integer index_base,index_file,ier character arrayname*32 ! ! READ CONVERGENCE HISTORY INFORMATION FROM EXISTING CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! go to base node call cg_goto_f(index_file,index_base,ier,'end') ! go to history node (we assume it exists and that there is only one - ! real working code would check!) call cg_goto_f(index_file,index_base,ier,'ConvergenceHistory_t', & 1,'end') ! find out how many arrays are here (there should be only one!): call cg_narrays_f(narrays,ier) index_array=narrays ! some checks: if (narrays .ne. 1) then write(6,'('' Error! Expecting only one array, read'',i5)') narrays stop end if call cg_array_info_f(index_array,arrayname,itype,ndim,idim,ier) if (idim(1) .gt. ntt) then write(6,'('' Error! must increase ntt to at least '',i5)') idim(1) stop end if if (arrayname .ne. 'CoefLift') then write(6,'('' Error! expecting CoefLift, read'',a32)') arrayname stop end if ! read lift coefficient array call cg_array_read_as_f(index_array,CGNS_ENUMV(RealSingle),cl,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read cl history from file grid.cgns'')') write(6,'('' values are: '',5f12.5)') cl(1),cl(2),cl(3), & cl(4),cl(5) write(6,'('' '',5f12.5)') cl(6),cl(7),cl(8), & cl(9),cl(10) stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_descriptor.F90000066400000000000000000000040301474000356600245670ustar00rootroot00000000000000 program read_descriptor use cgns implicit none ! ! Reads descriptor node (under CGNSBase_t) from an existing CGNS file. ! ! The CGNS grid file 'grid.cgns' must already exist ! and a descriptor node should be in it (using write_descriptor.f). ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_descriptor.F90 ! ifort -o read_descriptor read_descriptor.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! maxsize should match the length of 'text': integer, parameter :: maxsize=70 integer isize,n,ndescriptors,index_base,index_file,ier character text*70,name*32 ! ! READ DESCRIPTOR FROM EXISTING CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! go to base node call cg_goto_f(index_file,index_base,ier,'end') ! find out how many descriptors are here: call cg_ndescriptors_f(ndescriptors,ier) do n=1,ndescriptors call cg_descriptor_size_f(n,isize,ier) if (isize .gt. maxsize) then write(6,'('' Error! must increase maxsize to at least '', & i5)') isize stop end if ! read descriptor call cg_descriptor_read_f(n,name,text,ier) write(6,'('' The descriptor is:'',/,/,a)') text enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'(/,'' Successfully read descriptors from file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_dimensional.F90000066400000000000000000000102401474000356600247130ustar00rootroot00000000000000 program read_dimensional use cgns implicit none ! ! Opens an existing CGNS file that contains a simple 3-D ! grid plus a flow solution WITH DIMENSIONALITY, and reads ! the dimensionality. ! ! The CGNS grid file 'grid.cgns' must already exist ! (for example, created using ! write_grid_str.f followed by write_flowcent_str.f or ! write_grid_str.f followed by write_flowvert_str.f or ! write_grid_str.f followed by write_flowcentrind_str.f or ! write_grid_unst.f followed by write_flowvert_unst.f ! followed by write_dimensional.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_dimensional.F90 ! ifort -o read_dimensional read_dimensional.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! real*4 exponents(5) integer ic,ncoords,idatatype,iff,nfields,ia,ix,it,il,im,id integer index_grid,index_flow,index_zone,index_base,index_file,ier character fieldname*32,coordname*32 ! ! READ DIMENSIONAL INFO FOR GRID AND FLOW SOLN ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! we know there is only one FlowSolution_t (real working code would check!) index_flow=1 ! we know there is only one GridCoordinates_t (real working code would check!) index_grid=1 ! read DataClass and DimensionalUnits under Base call cg_goto_f(index_file,index_base,ier,'end') call cg_dataclass_read_f(id,ier) write(6,'('' DataClass = '',a32)') DataClassName(id) if (DataClassName(id) .ne. 'Dimensional') then write(6,'('' Error! Expecting Dimensional'')') stop end if call cg_units_read_f(im,il,it,ix,ia,ier) write(6,'('' Units='',5(/,8x,a32))') MassUnitsName(im), & LengthUnitsName(il),TimeUnitsName(it), & TemperatureUnitsName(ix),AngleUnitsName(ia) ! read fields call cg_nfields_f(index_file,index_base,index_zone,index_flow, & nfields,ier) if (nfields .ne. 2) then write(6,'('' Error! expecting 2 fields, read '',i5)') nfields stop end if do iff=1,nfields ! read DimensionalExponents call cg_goto_f(index_file,index_base,ier,'Zone_t',1, & 'FlowSolution_t',1,'DataArray_t',iff,'end') call cg_exponents_read_f(exponents,ier) ! get field name call cg_field_info_f(index_file,index_base,index_zone, & index_flow,iff,idatatype,fieldname,ier) write(6,'('' For '',a32,'', exponents are:'',5(/,6x,f5.1))') & fieldname,exponents(1),exponents(2),exponents(3),exponents(4), & exponents(5) enddo ! read grid call cg_ncoords_f(index_file,index_base,index_zone,ncoords,ier) do ic=1,ncoords ! read DimensionalExponents call cg_goto_f(index_file,index_base,ier,'Zone_t',1, & 'GridCoordinates_t',1,'DataArray_t',ic,'end') call cg_exponents_read_f(exponents,ier) ! get coord name call cg_coord_info_f(index_file,index_base,index_zone, & ic,idatatype,coordname,ier) write(6,'('' For '',a32,'', exponents are:'',5(/,6x,f5.1))') & coordname,exponents(1),exponents(2),exponents(3),exponents(4), & exponents(5) enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read dimensional data from file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_flowcent_str.F90000066400000000000000000000065761474000356600251430ustar00rootroot00000000000000 program read_flowcent_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid plus a flow solution (at CELL CENTERS), ! and reads it. (Compare this program with read_flowvert_str) ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f followed by ! write_flowcent_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_flowcent_str.F90 ! ifort -o read_flowcent_str read_flowcent_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! r and p must be dimensioned exactly as (21-1,17-1,N-1) (N>=9) ! for this particular case or else they will be read from ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*8 r(20,16,8),p(20,16,8) integer(cgsize_t) isize(3,3),irmin(3),irmax(3) integer loc,index_flow,index_zone,index_base,index_file,ier character*32 zonename,solname ! ! READ FLOW SOLUTION FROM CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! we know there is only one FlowSolution_t (real working code would check!) index_flow=1 ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename,isize,ier) ! lower range index irmin(1)=1 irmin(2)=1 irmin(3)=1 ! upper range index - use cell dimensions ! checking GridLocation first (real working code would check ! to make sure there are no Rind cells also!): call cg_sol_info_f(index_file,index_base,index_zone,index_flow, & solname,loc,ier) if (loc .ne. CGNS_ENUMV(CellCenter)) then write(6,'('' Error, GridLocation must be CellCenter!'', & '' Currently:'',a32)') GridLocationName(loc) stop end if irmax(1)=isize(1,2) irmax(2)=isize(2,2) irmax(3)=isize(3,2) ! read flow solution call cg_field_read_f(index_file,index_base,index_zone,index_flow, & 'Density',CGNS_ENUMV(RealDouble),irmin,irmax,r,ier) call cg_field_read_f(index_file,index_base,index_zone,index_flow, & 'Pressure',CGNS_ENUMV(RealDouble),irmin,irmax,p,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read flow solution from file'', & '' grid.cgns'')') write(6,'('' For example, r,p(20,16,8)='',2f12.5)') & r(20,16,8),p(20,16,8) write(6,'('' Program successful... ending now'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_flowcentrind_str.F90000066400000000000000000000100101474000356600257720ustar00rootroot00000000000000 program read_flowcentrind_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid plus a flow solution (at CELL CENTERS PLUS ! RIND CELLS IN THE I AND J DIRECTIONS), and reads it. ! (Compare this program with read_flowcent_str) ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f followed by ! write_flowcentrind_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_flowcentrind_str.F90 ! ifort -o read_flowcentrind_str read_flowcentrind_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! r and p must be dimensioned exactly as (21-1+2,17-1+2,N-1) (N>=9) ! for this particular case or else they will be read from ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): ! Rind cells are stored in array locations (i,1,k), (i,18,k), (1,j,k), (22,j,k) real*4 r(22,18,8),p(22,18,8) integer(cgsize_t) isize(3,3),irmin(3),irmax(3) integer irinddata(6) integer loc,index_flow,index_zone,index_base,index_file,ier character*32 zonename,solname ! ! READ FLOW SOLUTION FROM CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! we know there is only one FlowSolution_t (real working code would check!) index_flow=1 ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename,isize,ier) ! go to position within tree at FlowSolution\_t node call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowSolution_t',index_flow,'end') ! read rind data call cg_rind_read_f(irinddata,ier) ! lower range index irmin(1)=1-irinddata(1) irmin(2)=1-irinddata(3) irmin(3)=1-irinddata(5) ! upper range index - use cell dimensions and rind info ! checking GridLocation first: call cg_sol_info_f(index_file,index_base,index_zone,index_flow, & solname,loc,ier) if (loc .ne. CGNS_ENUMV(CellCenter)) then write(6,'('' Error, GridLocation must be CellCenter!'', & '' Currently:'',a32)') GridLocationName(loc) stop end if irmax(1)=isize(1,2)+irinddata(2) irmax(2)=isize(2,2)+irinddata(4) irmax(3)=isize(3,2)+irinddata(6) ! read flow solution call cg_field_read_f(index_file,index_base,index_zone,index_flow, & 'Density',CGNS_ENUMV(RealSingle),irmin,irmax,r,ier) call cg_field_read_f(index_file,index_base,index_zone,index_flow, & 'Pressure',CGNS_ENUMV(RealSingle),irmin,irmax,p,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read flow solution from file'', & '' grid.cgns'')') write(6,'('' For example, r,p(21,17,8)='',2f12.5)') & r(21,17,8),p(21,17,8) write(6,'('' rind: r,p(1,17,8)='',2f12.5)') & r(1,17,8),p(1,17,8) write(6,'('' rind: r,p(22,17,8)='',2f12.5)') & r(22,17,8),p(22,17,8) write(6,'('' Program successful... ending now'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_floweqn_str.F90000066400000000000000000000102031474000356600247530ustar00rootroot00000000000000 program read_floweqn_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file and reads flow equation info ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f followed by write_floweqn_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_floweqn_str.F90 ! ifort -o read_floweqn_str read_floweqn_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! real*4 prandtl,gamma integer idata(6) integer itype,itm,itc,itcm,ivm,igm,ige,id integer index_zone,index_base,index_file,ier ! ! READ FLOW EQUATION SET INFO ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! existing file must be 3D structured (real working code would check!) ! Read info from 'FlowEquationSet' node under 'Zone_t' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone,'end') call cg_equationset_read_f(id,ige,igm,ivm,itcm,itc,itm,ier) if (ier .gt. 0) then write(6,'('' Error! FlowEquationSet node does not exist.'')') stop end if write(6,'('' Eqn dimension = '',i5)') id ! Read 'GoverningEquations' node if (ige .eq. 1) then call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'end') call cg_governing_read_f(itype,ier) write(6,'('' Gov eqn = '',a32)') GoverningEquationsTypeName(itype) ! Read 'DiffusionModel' node call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'GoverningEquations_t',1,'end') call cg_diffusion_read_f(idata,ier) write(6,'('' diffusion='',6i5)') idata(1),idata(2), & idata(3),idata(4),idata(5),idata(6) end if ! Read gas model if (igm .eq. 1) then call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'end') call cg_model_read_f('GasModel_t',itype,ier) write(6,'('' Gas model type = '',a32)') ModelTypeName(itype) call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'GasModel_t',1,'end') call cg_array_read_as_f(1,CGNS_ENUMV(RealSingle),gamma,ier) write(6,'('' gamma='',f12.5)') gamma end if ! Read turbulence closure if (itc .eq. 1) then call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'end') call cg_model_read_f('TurbulenceClosure_t',itype,ier) write(6,'('' Turbulence closure type = '',a32)') & ModelTypeName(itype) call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'TurbulenceClosure_t',1,'end') call cg_array_read_as_f(1,CGNS_ENUMV(RealSingle),prandtl,ier) write(6,'('' turb prandtl number = '',f12.5)') prandtl end if if (itm .eq. 1) then call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'end') call cg_model_read_f('TurbulenceModel_t',itype,ier) write(6,'('' Turbulence model type = '',a32)') & ModelTypeName(itype) end if ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read equation set info from file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_flowvert_str.F90000066400000000000000000000064621474000356600251640ustar00rootroot00000000000000 program read_flowvert_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid plus a flow solution (at VERTICES), ! and reads it. ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f followed by ! write_flowvert_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_flowvert_str.F90 ! ifort -o read_flowvert_str read_flowvert_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! r and p must be dimensioned exactly as (21,17,N) (N>=9) ! for this particular case or else they will be read from ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*4 r(21,17,9),p(21,17,9) integer(cgsize_t) isize(3,3),irmin(3),irmax(3) integer loc,index_flow,index_zone,index_base,index_file,ier character*32 zonename,solname ! ! READ FLOW SOLUTION FROM CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! we know there is only one FlowSolution_t (real working code would check!) index_flow=1 ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename,isize,ier) ! lower range index irmin(1)=1 irmin(2)=1 irmin(3)=1 ! upper range index - use vertex dimensions ! checking GridLocation first (real working code would check ! to make sure there are no Rind cells also!): call cg_sol_info_f(index_file,index_base,index_zone,index_flow, & solname,loc,ier) if (loc .ne. CGNS_ENUMV(Vertex)) then write(6,'('' Error, GridLocation must be Vertex! Currently:'', & a32)') GridLocationName(loc) stop end if irmax(1)=isize(1,1) irmax(2)=isize(2,1) irmax(3)=isize(3,1) ! read flow solution call cg_field_read_f(index_file,index_base,index_zone,index_flow, & 'Density',CGNS_ENUMV(RealSingle),irmin,irmax,r,ier) call cg_field_read_f(index_file,index_base,index_zone,index_flow, & 'Pressure',CGNS_ENUMV(RealSingle),irmin,irmax,p,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read flow solution from file'', & '' grid.cgns'')') write(6,'('' For example, r,p(21,17,9)='',2f12.5)') & r(21,17,9),p(21,17,9) write(6,'('' Program successful... ending now'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_flowvert_unst.F90000066400000000000000000000062341474000356600253420ustar00rootroot00000000000000 program read_flowvert_unst use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! unstructured grid plus a flow solution (at VERTICES), ! and reads it. ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_unst.f followed by ! write_flowvert_unst.f) ! Note that, other than the dimensions of the variables ! r and p, this program is very similar to that for ! reading flow solutions from a structured zone: ! read_flowvert_str.f ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_flowvert_unst.F90 ! ifort -o read_flowvert_unst read_flowvert_unst.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! real*4 r(21*17*9),p(21*17*9) integer(cgsize_t) isize(1,3),irmin,irmax integer loc,index_flow,index_zone,index_base,index_file,ier character*32 zonename,solname ! ! READ FLOW SOLUTION FROM CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! we know there is only one FlowSolution_t (real working code would check!) index_flow=1 ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename,isize,ier) ! lower range index irmin=1 ! upper range index - use vertex dimensions ! checking GridLocation first (real working code would check ! to make sure there are no Rind cells also!): call cg_sol_info_f(index_file,index_base,index_zone,index_flow, & solname,loc,ier) if (loc .ne. CGNS_ENUMV(Vertex)) then write(6,'('' Error, GridLocation must be Vertex! Currently:'', & a32)') GridLocationName(loc) stop end if irmax=isize(1,1) ! read flow solution call cg_field_read_f(index_file,index_base,index_zone,index_flow, & 'Density',CGNS_ENUMV(RealSingle),irmin,irmax,r,ier) call cg_field_read_f(index_file,index_base,index_zone,index_flow, & 'Pressure',CGNS_ENUMV(RealSingle),irmin,irmax,p,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read flow solution from file'', & '' grid.cgns'')') write(6,'('' For example, r,p(380) ='',2f12.5)') & r(380),p(380) write(6,'('' r,p(3213)='',2f12.5)') & r(3213),p(3213) write(6,'('' Program successful... ending now'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_grid2zn_str.F90000066400000000000000000000072211474000356600246650ustar00rootroot00000000000000 program read_grid2zn_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Reads simple 3-D structured 2-zone grid from CGNS file ! (companion program to write_grid2zn_str.f) ! ! The CGNS grid file 'grid.cgns' must already exist. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_grid2zn_str.F90 ! ifort -o read_grid2zn_str read_grid2zn_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! x,y,z must be dimensioned exactly as (21,17,N) (N>=9) ! for this particular case or else they will be read from ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*4 x(21,17,9),y(21,17,9),z(21,17,9) real*4 xsav(21,17,9,2),ysav(21,17,9,2),zsav(21,17,9,2) integer(cgsize_t) isize(3,3),irmin(3),irmax(3) integer nzone,i,j,k,index_zone,index_base,index_file,ier character zonename*32 ! ! READ X, Y, Z GRID POINTS FROM CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! get number of zones (should be 2 for our case) call cg_nzones_f(index_file,index_base,nzone,ier) if (nzone .ne. 2) then write(6,'('' Error. This program expects 2 zones. '',i5, & '' read'')') nzone stop end if ! do loop over the zones do index_zone=1,nzone ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone, & zonename,isize,ier) ! lower range index irmin(1)=1 irmin(2)=1 irmin(3)=1 ! upper range index of vertices irmax(1)=isize(1,1) irmax(2)=isize(2,1) irmax(3)=isize(3,1) ! read grid coordinates call cg_coord_read_f(index_file,index_base,index_zone, & 'CoordinateX',CGNS_ENUMV(RealSingle),irmin,irmax,x,ier) call cg_coord_read_f(index_file,index_base,index_zone, & 'CoordinateY',CGNS_ENUMV(RealSingle),irmin,irmax,y,ier) call cg_coord_read_f(index_file,index_base,index_zone, & 'CoordinateZ',CGNS_ENUMV(RealSingle),irmin,irmax,z,ier) ! store grid coordinates in xsav,ysav,zsav array: do i=1,isize(1,1) do j=1,isize(2,1) do k=1,isize(3,1) xsav(i,j,k,index_zone)=x(i,j,k) ysav(i,j,k,index_zone)=y(i,j,k) zsav(i,j,k,index_zone)=z(i,j,k) enddo enddo enddo enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read grid from file grid.cgns'')') write(6,'('' For example, zone 1 x,y,z(21,17,9)='',3f12.5)') & xsav(21,17,9,1),ysav(21,17,9,1),zsav(21,17,9,1) write(6,'('' zone 2 x,y,z(21,17,9)='',3f12.5)') & xsav(21,17,9,2),ysav(21,17,9,2),zsav(21,17,9,2) write(6,'('' Program successful... ending now'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_grid_str.F90000066400000000000000000000054771474000356600242460ustar00rootroot00000000000000 program read_grid_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Reads simple 3-D structured grid from CGNS file ! (companion program to write_grid_str.f) ! ! The CGNS grid file 'grid.cgns' must already exist. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_grid_str.F90 ! ifort -o read_grid_str read_grid_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! x,y,z must be dimensioned exactly as (21,17,N) (N>=9) ! for this particular case or else they will be read from ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*4 x(21,17,9),y(21,17,9),z(21,17,9) integer(cgsize_t) isize(3,3),irmin(3),irmax(3) integer index_zone,index_base,index_file,ier character zonename*32 ! ! READ X, Y, Z GRID POINTS FROM CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename, & isize,ier) ! lower range index irmin(1)=1 irmin(2)=1 irmin(3)=1 ! upper range index of vertices irmax(1)=isize(1,1) irmax(2)=isize(2,1) irmax(3)=isize(3,1) ! read grid coordinates call cg_coord_read_f(index_file,index_base,index_zone, & 'CoordinateX',CGNS_ENUMV(RealSingle),irmin,irmax,x,ier) call cg_coord_read_f(index_file,index_base,index_zone, & 'CoordinateY',CGNS_ENUMV(RealSingle),irmin,irmax,y,ier) call cg_coord_read_f(index_file,index_base,index_zone, & 'CoordinateZ',CGNS_ENUMV(RealSingle),irmin,irmax,z,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read grid from file grid.cgns'')') write(6,'('' For example, x,y,z(21,17,9)='',3f12.5)') & x(21,17,9),y(21,17,9),z(21,17,9) write(6,'('' Program successful... ending now'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_grid_unst.F90000066400000000000000000000074761474000356600244300ustar00rootroot00000000000000 program read_grid_unst use cgns implicit none #include "cgnstypes_f03.h" ! ! Reads simple 3-D unstructured grid from a CGNS file ! (created using write_grid_unst.f). ! ! The CGNS grid file 'grid.cgns' must already exist. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_grid_unst.F90 ! ifort -o read_grid_unst read_grid_unst.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! real*4 x(21*17*9),y(21*17*9),z(21*17*9) integer(cgsize_t) isize(1,3),ielem(8,20*16*8) integer(cgsize_t) irmin,irmax,istart,iend,iparentdata integer iparent_flag,nbndry,itype,index_sect,nsections integer index_zone,index_base,index_file,ier character zonename*32,sectionname*32 ! ! READ X, Y, Z GRID POINTS FROM CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename, & isize,ier) ! lower range index irmin=1 ! upper range index of vertices irmax=isize(1,1) ! read grid coordinates call cg_coord_read_f(index_file,index_base,index_zone, & 'CoordinateX',CGNS_ENUMV(RealSingle),irmin,irmax,x,ier) call cg_coord_read_f(index_file,index_base,index_zone, & 'CoordinateY',CGNS_ENUMV(RealSingle),irmin,irmax,y,ier) call cg_coord_read_f(index_file,index_base,index_zone, & 'CoordinateZ',CGNS_ENUMV(RealSingle),irmin,irmax,z,ier) ! find out how many sections call cg_nsections_f(index_file,index_base,index_zone,nsections,ier) write(6,'('' number of sections='',i7)') nsections ! read element connectivity do index_sect=1,nsections call cg_section_read_f(index_file,index_base,index_zone, & index_sect,sectionname,itype,istart,iend,nbndry, & iparent_flag,ier) write(6,'('' Reading section data...'')') write(6,'('' section name='',a32)') sectionname write(6,'('' section type='',a32)') ElementTypeName(itype) write(6,'('' istart,iend='',2i6)') istart,iend if (ElementTypeName(itype) .eq. 'HEXA_8') then write(6,'('' reading element data for this element'')') call cg_elements_read_f(index_file,index_base,index_zone, & index_sect,ielem,iparentdata,ier) else write(6,'('' not reading element data for this element'')') end if enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read unstructured grid from file'', & '' grid.cgns'')') write(6,'('' for example, element 1 is made up of nodes:'', & 8i5)') ielem(1,1),ielem(2,1),ielem(3,1),ielem(4,1), & ielem(5,1),ielem(6,1),ielem(7,1),ielem(8,1) write(6,'('' x,y,z of node 358 are:'',3f12.5)') & x(358),y(358),z(358) write(6,'('' x,y,z of node 1358 are:'',3f12.5)') & x(1358),y(1358),z(1358) stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_nondimensional.F90000066400000000000000000000052741474000356600254410ustar00rootroot00000000000000 program read_nondimensional use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file and reads the DataClass and ! ReferenceState appropriate for a completely ! NONDIMENSIONAL data set. ! ! The CGNS grid file 'grid.cgns' must already exist, ! processed further using write_nondimensional.f. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_nondimensional.F90 ! ifort -o read_nondimensional read_nondimensional.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! real*8 data integer(cgsize_t) idimvec(1) integer n,idim,idata,narrays,id,index_base,index_file,ier character state*32,arrayname*32 ! ! READ NONDIMENSIONAL INFO ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! read DataClass under Base call cg_goto_f(index_file,index_base,ier,'end') call cg_dataclass_read_f(id,ier) write(6,'('' DataClass = '',a32)') DataClassName(id) if (DataClassName(id) .ne. 'NormalizedByUnknownDimensional') then write(6,'('' Error! Expecting NormalizedByUnknownDimensional'')') stop end if ! read ReferenceState under Base call cg_state_read_f(state,ier) write(6,'('' ReferenceState = '',a32)') state ! Go to ReferenceState node, read Mach array and its dataclass call cg_goto_f(index_file,index_base,ier,'ReferenceState_t',1,'end') ! find out how many data arrays call cg_narrays_f(narrays,ier) do n=1,narrays call cg_array_info_f(n,arrayname,idata,idim,idimvec,ier) if (idim .ne. 1 .or. idimvec(1) .ne. 1) then write(6,'('' Error! expecting idim,idimvec=1,1'')') write(6,'('' they are idim,idimvec='',2i5)')idim,idimvec(1) stop end if call cg_array_read_as_f(n,CGNS_ENUMV(RealDouble),data,ier) write(6,'('' Variable='',a32)') arrayname write(6,'('' data='',f18.8)') data enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read nondimensional info from file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/read_timevert_str.F90000066400000000000000000000160721474000356600251510ustar00rootroot00000000000000 program read_timevert_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid plus 3 different flow solutions (at VERTICES), ! along with time-accurate info, and reads it. ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f followed by ! write_timevert_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c read_timevert_str.F90 ! ifort -o read_timevert_str read_timevert_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! r1, r2, r3 and p1, p2, p3 ! must be dimensioned exactly as (21,17,N) (N>=9) ! for this particular case or else they will be written to ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*4 r1(21,17,9),p1(21,17,9) real*4 r2(21,17,9),p2(21,17,9) real*4 r3(21,17,9),p3(21,17,9) real*4 time(3) integer(cgsize_t) isize(3,3),irmin(3),irmax(3) integer(cgsize_t) idims(2),id2(1) integer n,idatatype,id1,nsteps,narrays,isim,loc integer index_zone,index_base,index_file,ier character zonename*32,bitername*32,zitername*32 character arrayname*32 character solname(3)*32,solname2*32 ! ! READ FLOW SOLUTION FROM CGNS FILE ! open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename, & isize,ier) ! lower range index irmin(1)=1 irmin(2)=1 irmin(3)=1 ! upper range index - use vertex dimensions irmax(1)=isize(1,1) irmax(2)=isize(2,1) irmax(3)=isize(3,1) ! read BaseIterativeData call cg_biter_read_f(index_file,index_base,bitername,nsteps,ier) write(6,'('' number of time steps stored = '',i5)') nsteps if (nsteps .ne. 3) then write(6,'('' Error, expecting nsteps=3!'')') stop end if call cg_goto_f(index_file,index_base,ier,'BaseIterativeData_t',1,'end') call cg_narrays_f(narrays,ier) if (narrays .ne. 1) then write(6,'('' Error, expecting 1 array in BaseIterativeData'', & ''... there are '',i5)') narrays stop end if call cg_array_info_f(1,arrayname,idatatype,id1,id2,ier) if (id1 .ne. 1 .or. id2(1) .ne. 3) then write(6,'('' Error, expecting data dimension and vector to'', & '' be 1 and 3 in BaseIterativeData... read '',2i5)') id1,id2(1) stop end if call cg_array_read_as_f(1,CGNS_ENUMV(RealSingle),time,ier) write(6,'('' Times stored are:'')') do n=1,nsteps write(6,'(f12.3)') time(n) enddo ! read ZoneIterativeData call cg_ziter_read_f(index_file,index_base,index_zone,zitername,ier) call cg_goto_f(index_file,index_base,ier,'Zone_t', & index_zone,'ZoneIterativeData_t',1,'end') call cg_narrays_f(narrays,ier) if (narrays .ne. 1) then write(6,'('' Error, expecting 1 array in ZoneIterativeData'', & ''... there are '',i5)') narrays stop end if call cg_array_info_f(1,arrayname,idatatype,id1,idims,ier) if (id1 .ne. 2 .or. idims(1) .ne. 32) then write(6,'('' Error, expecting data dimension and vector to'', & '' be 2 and 32 in ZoneIterativeData... read '',2i5)') id1, & idims(1) stop end if call cg_array_read_as_f(1,CGNS_ENUMV(Character),solname,ier) write(6,'('' Flow solution names corresponding to each are:'')') do n=1,nsteps write(6,'(a32)') solname(n) enddo ! read SimulationType call cg_simulation_type_read_f(index_file,index_base,isim,ier) write(6,'('' Simulation type is: '',a32)') SimulationTypeName(isim) ! do loop to read flow solutions do n=1,nsteps ! check that soln names match, and also check GridLocation (real ! working code would check to make sure there are no Rind cells ! also!): call cg_sol_info_f(index_file,index_base,index_zone,n, & solname2,loc,ier) if (solname2 .ne. solname(n)) then write(6,'('' Error, soln names do not match'')') stop end if if (loc .ne. CGNS_ENUMV(Vertex)) then write(6,'('' Error, GridLocation must be Vertex! Currently:'', & a32)') GridLocationName(loc) stop end if if (n .eq. 1) then call cg_field_read_f(index_file,index_base,index_zone,n, & 'Density',CGNS_ENUMV(RealSingle),irmin,irmax,r1,ier) call cg_field_read_f(index_file,index_base,index_zone,n, & 'Pressure',CGNS_ENUMV(RealSingle),irmin,irmax,p1,ier) else if (n .eq. 2) then call cg_field_read_f(index_file,index_base,index_zone,n, & 'Density',CGNS_ENUMV(RealSingle),irmin,irmax,r2,ier) call cg_field_read_f(index_file,index_base,index_zone,n, & 'Pressure',CGNS_ENUMV(RealSingle),irmin,irmax,p2,ier) else call cg_field_read_f(index_file,index_base,index_zone,n, & 'Density',CGNS_ENUMV(RealSingle),irmin,irmax,r3,ier) call cg_field_read_f(index_file,index_base,index_zone,n, & 'Pressure',CGNS_ENUMV(RealSingle),irmin,irmax,p3,ier) end if enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully read 3 flow solutions from file'', & '' grid.cgns'')') write(6,'('' For example, r1,p1(1,1,1)='',2f12.5)') & r1(1,1,1),p1(1,1,1) write(6,'('' r2,p2(1,1,1)='',2f12.5)') & r2(1,1,1),p2(1,1,1) write(6,'('' r3,p3(1,1,1)='',2f12.5)') & r3(1,1,1),p3(1,1,1) write(6,'('' For example, r1,p1(21,17,9)='',2f12.5)') & r1(21,17,9),p1(21,17,9) write(6,'('' r2,p2(21,17,9)='',2f12.5)') & r2(21,17,9),p2(21,17,9) write(6,'('' r3,p3(21,17,9)='',2f12.5)') & r3(21,17,9),p3(21,17,9) ! write(6,'('' Program successful... ending now'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/test.sh000077500000000000000000000076021474000356600224640ustar00rootroot00000000000000#! /bin/bash NO_COLOR="\033[0m" OK_COLOR="\033[32;01m" ERROR_COLOR="\033[31;01m" echoresults() { padlimit=40 pad=$(printf '%*s' "$padlimit") pad=${pad// /.} padlength=40 printf ' %*.*s' 0 $((padlength - ${#x} )) "$pad" if test $status -ne 0 then printf " [${ERROR_COLOR}FAILED${NO_COLOR}]\n" status=1 else printf " [${OK_COLOR}PASSED${NO_COLOR}]" printf "%+12s\n" "$itime" fi } TIMING_AVAIL=$(/usr/bin/time -a -o CGNS_timing.txt -f "%e" pwd > /dev/null; echo $?) run_tests() { printf "%-40s \n" "Testing $dir..." cd "$dir" # loop through tests size_arr=${#w_arr[@]} #Number of elements in the array itime="" for i in $(seq 1 $size_arr);do x=" Program: ${w_arr[$i-1]}" printf "$x" if [ "$TIMING_AVAIL" = "0" ]; then /usr/bin/time -a -o ../CGNS_timing.txt -f "$dir.${w_arr[$i-1]} %e" "./${w_arr[$i-1]}" >/dev/null 2>&1 itime=$(tail -n1 ../CGNS_timing.txt | awk '{print $2}' | sed -e 's/$/ sec/') else "./${w_arr[$i-1]}" >/dev/null 2>&1 fi status=$? echoresults return_val=$((status + return_val)) x=" Program: ${r_arr[$i-1]}" printf "$x" if [ "$TIMING_AVAIL" = "0" ]; then /usr/bin/time -a -o ../CGNS_timing.txt -f "$dir.${r_arr[$i-1]} %e" "./${r_arr[$i-1]}" > "build/output$i" itime=$(tail -n1 ../CGNS_timing.txt | awk '{print $2}' | sed -e 's/$/ sec/') else "./${r_arr[$i-1]}" > "build/output$i" fi diff <( sed '/Library/ d' "build/output$i") <( sed '/Library/ d' "./OUTPUT$i") > "build/results$i.txt" status=$? echoresults return_val=$((status + return_val)) done cd .. } return_val=0 rm -f CGNS_timing.txt ############################### # Special cases ############################### ## declare an array of tests declare -a w_arr=("write_grid_str" "write_flowvert_str" "write_nondimensional" "write_descriptor" \ "write_convergence" "write_floweqn_str" "write_bcpnts_str") declare -a r_arr=("read_grid_str" "read_flowvert_str" "read_nondimensional" "read_descriptor" \ "read_convergence" "read_floweqn_str" "read_bcpnts_str") dir=Test_Grid_Str run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid_unst" "write_flowvert_unst" "write_dimensional" "write_descriptor" "write_convergence" "write_bcpnts_unst") declare -a r_arr=("read_grid_unst" "read_flowvert_unst" "read_dimensional" "read_descriptor" "read_convergence" "read_bcpnts_unst") dir=Test_Grid_Unstr run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid_str" "write_timevert_str") declare -a r_arr=("read_grid_str" "read_timevert_str") dir=Test_Grid_Str_Timeacc run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid_str" "write_flowcent_str" "write_bc_str") declare -a r_arr=("read_grid_str" "read_flowcent_str" "read_bc_str") dir=Test_Grid_Str_FlowCent run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid_str" "write_flowcentrind_str") declare -a r_arr=("read_grid_str" "read_flowcentrind_str") dir=Test_Grid_Str_FlowCentRind run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid2zn_str" "write_con2zn_str") declare -a r_arr=("read_grid2zn_str" "read_con2zn_str") dir=Test_Grid_Str_2zn run_tests ############################### ## declare an array of tests declare -a w_arr=("write_grid2zn_str" "write_con2zn_genrl_str") declare -a r_arr=("read_grid2zn_str" "read_con2zn_genrl_str") dir=Test_Grid_Str_2zngenrl run_tests ############################### echo "=== finished ===" if test $return_val != 0; then printf "$ERROR_COLOR" else printf "$OK_COLOR" fi printf "$return_val tests failed $NO_COLOR \n" exit $return_val CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_bc_str.F90000066400000000000000000000114131474000356600241070ustar00rootroot00000000000000 program write_bc_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid, and adds BC definitions (defined ! over a range of points = PointRange) ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f). Note: whether the ! existing CGNS file has a flow solution in it already or ! not is irrelevant. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_bc_str.F90 ! ifort -o write_bc_str write_bc_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer ilo,ihi,jlo,jhi,klo,khi integer index_zone,index_base,index_file,index_bc,ier integer(cgsize_t) isize(3,3),ipnts(3,2) character zonename*32 ! write(6,'('' Program write_bc_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! WRITE BOUNDARY CONDITIONS TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename, & isize,ier) write(6,'('' zonename='',a32)') zonename ilo=1 ihi=isize(1,1) jlo=1 jhi=isize(2,1) klo=1 khi=isize(3,1) ! write boundary conditions for ilo face, defining range first ! (user can give any name) ! lower point of range ipnts(1,1)=ilo ipnts(2,1)=jlo ipnts(3,1)=klo ! upper point of range ipnts(1,2)=ilo ipnts(2,2)=jhi ipnts(3,2)=khi call cg_boco_write_f(index_file,index_base,index_zone,'Ilo', & CGNS_ENUMV(BCTunnelInflow),CGNS_ENUMV(PointRange),2_cgsize_t,ipnts,index_bc,ier) ! write boundary conditions for ihi face, defining range first ! (user can give any name) ! lower point of range ipnts(1,1)=ihi ipnts(2,1)=jlo ipnts(3,1)=klo ! upper point of range ipnts(1,2)=ihi ipnts(2,2)=jhi ipnts(3,2)=khi call cg_boco_write_f(index_file,index_base,index_zone,'Ihi', & CGNS_ENUMV(BCExtrapolate),CGNS_ENUMV(PointRange),2_cgsize_t,ipnts,index_bc,ier) ! write boundary conditions for jlo face, defining range first ! (user can give any name) ! lower point of range ipnts(1,1)=ilo ipnts(2,1)=jlo ipnts(3,1)=klo ! upper point of range ipnts(1,2)=ihi ipnts(2,2)=jlo ipnts(3,2)=khi call cg_boco_write_f(index_file,index_base,index_zone,'Jlo', & CGNS_ENUMV(BCWallInviscid),CGNS_ENUMV(PointRange),2_cgsize_t,ipnts,index_bc,ier) ! write boundary conditions for jhi face, defining range first ! (user can give any name) ! lower point of range ipnts(1,1)=ilo ipnts(2,1)=jhi ipnts(3,1)=klo ! upper point of range ipnts(1,2)=ihi ipnts(2,2)=jhi ipnts(3,2)=khi call cg_boco_write_f(index_file,index_base,index_zone,'Jhi', & CGNS_ENUMV(BCWallInviscid),CGNS_ENUMV(PointRange),2_cgsize_t,ipnts,index_bc,ier) ! write boundary conditions for klo face, defining range first ! (user can give any name) ! lower point of range ipnts(1,1)=ilo ipnts(2,1)=jlo ipnts(3,1)=klo ! upper point of range ipnts(1,2)=ihi ipnts(2,2)=jhi ipnts(3,2)=klo call cg_boco_write_f(index_file,index_base,index_zone,'Klo', & CGNS_ENUMV(BCWallInviscid),CGNS_ENUMV(PointRange),2_cgsize_t,ipnts,index_bc,ier) ! write boundary conditions for khi face, defining range first ! (user can give any name) ! lower point of range ipnts(1,1)=ilo ipnts(2,1)=jlo ipnts(3,1)=khi ! upper point of range ipnts(1,2)=ihi ipnts(2,2)=jhi ipnts(3,2)=khi call cg_boco_write_f(index_file,index_base,index_zone,'Khi', & CGNS_ENUMV(BCWallInviscid),CGNS_ENUMV(PointRange),2_cgsize_t,ipnts,index_bc,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added BCs (PointRange) to file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_bcpnts_str.F90000066400000000000000000000140431474000356600250160ustar00rootroot00000000000000 program write_bcpnts_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid, and adds BC definitions (defined ! as individual points = PointList) ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f). Note: whether the ! existing CGNS file has a flow solution in it already or ! not is irrelevant. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_bcpnts_str.F90 ! ifort -o write_bcpnts_str write_bcpnts_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer, parameter :: maxcount=400 integer(cgsize_t) isize(3,3),ipnts(3,maxcount),icounts integer i,j,k,ilo,ihi,jlo,jhi,klo,khi,icount integer index_bc,index_zone,index_base,index_file,ier character zonename*32 ! write(6,'('' Program write_bcpnts_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! WRITE BOUNDARY CONDITIONS TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename,isize,ier) write(6,'('' zonename='',a32)') zonename ilo=1 ihi=isize(1,1) jlo=1 jhi=isize(2,1) klo=1 khi=isize(3,1) ! write boundary conditions for ilo face, defining pointlist first ! (user can give any name) icount=0 do j=jlo,jhi do k=klo,khi icount=icount+1 ipnts(1,icount)=ilo ipnts(2,icount)=j ipnts(3,icount)=k enddo enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if icounts=icount call cg_boco_write_f(index_file,index_base,index_zone,'Ilo', & CGNS_ENUMV(BCTunnelInflow),CGNS_ENUMV(PointList),icounts,ipnts,index_bc,ier) ! write boundary conditions for ihi face, defining pointlist first ! (user can give any name) icount=0 do j=jlo,jhi do k=klo,khi icount=icount+1 ipnts(1,icount)=ihi ipnts(2,icount)=j ipnts(3,icount)=k enddo enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if icounts=icount call cg_boco_write_f(index_file,index_base,index_zone,'Ihi', & CGNS_ENUMV(BCExtrapolate),CGNS_ENUMV(PointList),icounts,ipnts,index_bc,ier) ! write boundary conditions for jlo face, defining pointlist first ! (user can give any name) icount=0 do i=ilo,ihi do k=klo,khi icount=icount+1 ipnts(1,icount)=i ipnts(2,icount)=jlo ipnts(3,icount)=k enddo enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if icounts=icount call cg_boco_write_f(index_file,index_base,index_zone,'Jlo', & CGNS_ENUMV(BCWallInviscid),CGNS_ENUMV(PointList),icounts,ipnts,index_bc,ier) ! write boundary conditions for jhi face, defining pointlist first ! (user can give any name) icount=0 do i=ilo,ihi do k=klo,khi icount=icount+1 ipnts(1,icount)=i ipnts(2,icount)=jhi ipnts(3,icount)=k enddo enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if icounts=icount call cg_boco_write_f(index_file,index_base,index_zone,'Jhi', & CGNS_ENUMV(BCWallInviscid),CGNS_ENUMV(PointList),icounts,ipnts,index_bc,ier) ! write boundary conditions for klo face, defining pointlist first ! (user can give any name) icount=0 do i=ilo,ihi do j=jlo,jhi icount=icount+1 ipnts(1,icount)=i ipnts(2,icount)=j ipnts(3,icount)=klo enddo enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if icounts=icount call cg_boco_write_f(index_file,index_base,index_zone,'Klo', & CGNS_ENUMV(BCWallInviscid),CGNS_ENUMV(PointList),icounts,ipnts,index_bc,ier) ! write boundary conditions for khi face, defining pointlist first ! (user can give any name) icount=0 do i=ilo,ihi do j=jlo,jhi icount=icount+1 ipnts(1,icount)=i ipnts(2,icount)=j ipnts(3,icount)=khi enddo enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if icounts=icount call cg_boco_write_f(index_file,index_base,index_zone,'Khi', & CGNS_ENUMV(BCWallInviscid),CGNS_ENUMV(PointList),icounts,ipnts,index_bc,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added BCs (PointList) to file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_bcpnts_unst.F90000066400000000000000000000112771474000356600252050ustar00rootroot00000000000000 program write_bcpnts_unst use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! unstructured grid, and adds BC definitions (defined ! as individual FaceCenter "points" = PointList+GridLocation=FaceCenter) ! The BCs are added as FaceCenter points, associated with ! face elements (QUAD_4), rather than associated to nodes ! ! For the following, be sure you are using Version 2.0 or ! later release of the API ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_unst.f). Note: whether the ! existing CGNS file has a flow solution in it already or ! not is irrelevant. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_bcpnts_unst.F90 ! ifort -o write_bcpnts_unst write_bcpnts_unst.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer, parameter :: maxcount=960 integer n,ibc,icount,nelem_start,nelem_end integer index_zone,index_base,index_file,index_bc,ier integer(cgsize_t) ipnts(maxcount),icounts ! write(6,'('' Program write_bcpnts_unst'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! WRITE BOUNDARY CONDITIONS TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! we know that for the unstructured zone, the following face elements ! have been defined as inflow (real working code would check!): nelem_start=2561 nelem_end=2688 icount=0 do n=nelem_start,nelem_end icount=icount+1 ipnts(icount)=n enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if ! write boundary conditions for ilo face icounts=icount call cg_boco_write_f(index_file,index_base,index_zone,'Ilo', & CGNS_ENUMV(BCTunnelInflow),CGNS_ENUMV(PointList),icounts,ipnts,index_bc,ier) ! we know that for the unstructured zone, the following face elements ! have been defined as outflow (real working code would check!): nelem_start=2689 nelem_end=2816 icount=0 do n=nelem_start,nelem_end icount=icount+1 ipnts(icount)=n enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if ! write boundary conditions for ihi face icounts=icount call cg_boco_write_f(index_file,index_base,index_zone,'Ihi', & CGNS_ENUMV(BCExtrapolate),CGNS_ENUMV(PointList),icounts,ipnts,index_bc,ier) ! we know that for the unstructured zone, the following face elements ! have been defined as walls (real working code would check!): nelem_start=2817 nelem_end=3776 icount=0 do n=nelem_start,nelem_end icount=icount+1 ipnts(icount)=n enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if ! write boundary conditions for wall faces icounts=icount call cg_boco_write_f(index_file,index_base,index_zone,'Walls', & CGNS_ENUMV(BCWallInviscid),CGNS_ENUMV(PointList),icounts,ipnts,index_bc,ier) ! ! the above are all face-center locations for the BCs - must indicate this, ! otherwise Vertices will be assumed! do ibc=1,index_bc ! (the following call positions you in BC_t - it assumes there ! is only one Zone_t and one ZoneBC_t - real working code would check!) call cg_goto_f(index_file,index_base,ier,'Zone_t',1, & 'ZoneBC_t',1,'BC_t',ibc,'end') call cg_gridlocation_write_f(CGNS_ENUMV(FaceCenter),ier) enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added FaceCenter BCs (PointList) to'', & '' unstructured grid file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_con2zn_genrl_str.F90000066400000000000000000000120261474000356600261240ustar00rootroot00000000000000 program write_con2zn_genrl_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid (2 zones), and adds 1-to-1 ! connectivity information to it (using GENERAL ! method, as opposed to specific 1-to-1 method). ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid2zn_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_con2zn_genrl_str.F90 ! ifort -o write_con2zn_genrl_str write_con2zn_genrl_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer, parameter :: maxcount=400 integer ilo(2),ihi(2),jlo(2),jhi(2),klo(2),khi(2) integer(cgsize_t) isize(3,3),ipnts(3,maxcount) integer(cgsize_t) ipntsdonor(3,maxcount),icounts integer index_conn,index_zone,index_base,index_file,ier integer nconns,n1to1,icount,nzone,j,k character donorname*32,zonename(2)*32 ! write(6,'('' Program write_con2zn_genrl_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! WRITE GENERAL CONNECTIVITY INFORMATION TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! get number of zones (should be 2 for our case) call cg_nzones_f(index_file,index_base,nzone,ier) if (nzone .ne. 2) then write(6,'('' Error. This program expects 2 zones. '',i5, & '' read'')') nzone stop end if ! loop over zones to get zone sizes and names do index_zone=1,nzone call cg_zone_read_f(index_file,index_base,index_zone, & zonename(index_zone),isize,ier) ilo(index_zone)=1 ihi(index_zone)=isize(1,1) jlo(index_zone)=1 jhi(index_zone)=isize(2,1) klo(index_zone)=1 khi(index_zone)=isize(3,1) enddo ! loop over zones again do index_zone=1,nzone ! for this program, there should be no existing connectivity info: call cg_nconns_f(index_file,index_base,index_zone,nconns,ier) if (nconns .ne. 0) then write(6,'('' Error. This program expects no interfaces'', & '' yet.'',i5,'' read'')') nconns stop end if call cg_n1to1_f(index_file,index_base,index_zone,n1to1,ier) if (n1to1 .ne. 0) then write(6,'('' Error. This program expects no interfaces'', & '' yet.'',i5,'' read'')') n1to1 stop end if ! set up point lists if (index_zone .eq. 1) then icount=0 do j=jlo(index_zone),jhi(index_zone) do k=klo(index_zone),khi(index_zone) icount=icount+1 ipnts(1,icount)=ihi(1) ipnts(2,icount)=j ipnts(3,icount)=k ipntsdonor(1,icount)=ilo(2) ipntsdonor(2,icount)=j ipntsdonor(3,icount)=k enddo enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if donorname=zonename(2) else icount=0 do j=jlo(index_zone),jhi(index_zone) do k=klo(index_zone),khi(index_zone) icount=icount+1 ipnts(1,icount)=ilo(2) ipnts(2,icount)=j ipnts(3,icount)=k ipntsdonor(1,icount)=ihi(1) ipntsdonor(2,icount)=j ipntsdonor(3,icount)=k enddo enddo if (icount .gt. maxcount) then write(6,'('' Error. Need to increase maxcount to at least'', & i5)') icount stop end if donorname=zonename(1) end if ! write integer connectivity info (user can give any name) icounts=icount call cg_conn_write_f(index_file,index_base,index_zone, & 'GenInterface',CGNS_ENUMV(Vertex),CGNS_ENUMV(Abutting1to1),CGNS_ENUMV(PointList),icounts,ipnts, & donorname,CGNS_ENUMV(Structured),CGNS_ENUMV(PointListDonor),CGNS_ENUMV(Integer),icounts, & ipntsdonor,index_conn,ier) enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added 1-to-1 connectivity info to'', & '' file grid.cgns (using GENERAL method)'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_con2zn_str.F90000066400000000000000000000111001474000356600247250ustar00rootroot00000000000000 program write_con2zn_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid (2 zones), and adds 1-to-1 ! connectivity information to it. ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid2zn_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_con2zn_str.F90 ! ifort -o write_con2zn_str write_con2zn_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer ilo(2),ihi(2),jlo(2),jhi(2),klo(2),khi(2) integer itranfrm(3) integer index_conn,n1to1,nconns,nzone integer index_zone,index_base,index_file,ier integer(cgsize_t) isize(3,3),ipnts(3,2),ipntsdonor(3,2) character donorname*32,zonename(2)*32 ! write(6,'('' Program write_con2zn_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! WRITE 1-TO-1 CONNECTIVITY INFORMATION TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! get number of zones (should be 2 for our case) call cg_nzones_f(index_file,index_base,nzone,ier) if (nzone .ne. 2) then write(6,'('' Error. This program expects 2 zones. '',i5, & '' read'')') nzone stop end if ! loop over zones to get zone sizes and names do index_zone=1,nzone call cg_zone_read_f(index_file,index_base,index_zone, & zonename(index_zone),isize,ier) ilo(index_zone)=1 ihi(index_zone)=isize(1,1) jlo(index_zone)=1 jhi(index_zone)=isize(2,1) klo(index_zone)=1 khi(index_zone)=isize(3,1) enddo ! loop over zones again do index_zone=1,nzone ! for this program, there should be no existing connectivity info: call cg_nconns_f(index_file,index_base,index_zone,nconns,ier) if (nconns .ne. 0) then write(6,'('' Error. This program expects no interfaces'', & '' yet.'',i5,'' read'')') nconns stop end if call cg_n1to1_f(index_file,index_base,index_zone,n1to1,ier) if (n1to1 .ne. 0) then write(6,'('' Error. This program expects no interfaces'', & '' yet.'',i5,'' read'')') n1to1 stop end if ! set up index ranges if (index_zone .eq. 1) then donorname=zonename(2) ! lower point of receiver range ipnts(1,1)=ihi(1) ipnts(2,1)=jlo(1) ipnts(3,1)=klo(1) ! upper point of receiver range ipnts(1,2)=ihi(1) ipnts(2,2)=jhi(1) ipnts(3,2)=khi(1) ! lower point of donor range ipntsdonor(1,1)=ilo(2) ipntsdonor(2,1)=jlo(2) ipntsdonor(3,1)=klo(2) ! upper point of donor range ipntsdonor(1,2)=ilo(2) ipntsdonor(2,2)=jhi(2) ipntsdonor(3,2)=khi(2) else donorname=zonename(1) ! lower point of receiver range ipnts(1,1)=ilo(2) ipnts(2,1)=jlo(2) ipnts(3,1)=klo(2) ! upper point of receiver range ipnts(1,2)=ilo(2) ipnts(2,2)=jhi(2) ipnts(3,2)=khi(2) ! lower point of donor range ipntsdonor(1,1)=ihi(1) ipntsdonor(2,1)=jlo(1) ipntsdonor(3,1)=klo(1) ! upper point of donor range ipntsdonor(1,2)=ihi(1) ipntsdonor(2,2)=jhi(1) ipntsdonor(3,2)=khi(1) end if ! set up Transform itranfrm(1)=1 itranfrm(2)=2 itranfrm(3)=3 ! write 1-to-1 info (user can give any name) call cg_1to1_write_f(index_file,index_base,index_zone, & 'Interface',donorname,ipnts,ipntsdonor,itranfrm, & index_conn,ier) enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added 1-to-1 connectivity info to'', & '' file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_convergence.F90000066400000000000000000000042201474000356600251270ustar00rootroot00000000000000 program write_convergence use cgns implicit none #include "cgnstypes_f03.h" ! ! Adds convergence history to an existing CGNS file. ! ! The CGNS grid file 'grid.cgns' must already exist. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_convergence.F90 ! ifort -o write_convergence write_convergence.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer, parameter :: ntt=20 real*8 cl(ntt) integer index_base,index_file,ier,n integer(cgsize_t) nuse ! write(6,'('' Program write_convergence'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! create history array simple example: do n=1,ntt cl(n)=float(n) enddo write(6,'('' created simple cl history'')') ! ! WRITE CONVERGENCE HISTORY INFORMATION TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! go to base node call cg_goto_f(index_file,index_base,ier,'end') ! create history node (SIDS names it GlobalConvergenceHistory at base level) call cg_convergence_write_f(ntt,CHAR(0),ier) ! go to new history node call cg_goto_f(index_file,index_base,ier,'ConvergenceHistory_t',1,'end') ! write lift coefficient array (user must use SIDS-standard name here) nuse=ntt call cg_array_write_f('CoefLift',CGNS_ENUMV(RealDouble),1,[nuse],cl,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully wrote cl history to file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_descriptor.F90000066400000000000000000000035241474000356600250150ustar00rootroot00000000000000 program write_descriptor use cgns implicit none #include "cgnstypes_f03.h" ! ! Adds descriptor node to an existing CGNS file (under the ! CGNSBase_t node). ! ! The CGNS grid file 'grid.cgns' must already exist. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_descriptor.F90 ! ifort -o write_descriptor write_descriptor.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer index_base,index_file,ier character text1*36,text2*36,textstring*73 ! write(6,'('' Program write_descriptor'')') if (CG_BUILD_64BIT) then write(6,'('' ...compiled in 64-bit mode, but not needed'')') end if ! ! WRITE DESCRIPTOR NODE AT BASE LEVEL ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! go to base node call cg_goto_f(index_file,index_base,ier,'end') ! write descriptor node (user can give any name) text1='Supersonic vehicle with landing gear' text2='M=4.6, Re=6 million' textstring=text1//char(10)//text2 call cg_descriptor_write_f('Information',textstring,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully wrote descriptor node to file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_dimensional.F90000066400000000000000000000102231474000356600251330ustar00rootroot00000000000000 program write_dimensional use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! grid plus a flow solution and adds its dimensionality ! (dimensional data). ! ! The CGNS grid file 'grid.cgns' must already exist ! (for example, created using ! write_grid_str.f followed by write_flowcent_str.f or ! write_grid_str.f followed by write_flowvert_str.f or ! write_grid_str.f followed by write_flowcentrind_str.f or ! write_grid_unst.f followed by write_flowvert_unst.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_dimensional.F90 ! ifort -o write_dimensional write_dimensional.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! real*4 exponents(5) integer icc,iff,nfields,index_grid,index_flow,index_zone integer index_base,index_file,ier,ncoords,idatatype character fieldname*32 ! write(6,'('' Program write_dimensional'')') if (CG_BUILD_64BIT) then write(6,'('' ...compiled in 64-bit mode, but not needed'')') end if ! ! WRITE DIMENSIONAL INFO FOR GRID AND FLOW SOLN ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! we know there is only one FlowSolution_t (real working code would check!) index_flow=1 ! we know there is only one GridCoordinates_t (real working code would check!) index_grid=1 ! put DataClass and DimensionalUnits under Base call cg_goto_f(index_file,index_base,ier,'end') call cg_dataclass_write_f(CGNS_ENUMV(Dimensional),ier) call cg_units_write_f(CGNS_ENUMV(Kilogram),CGNS_ENUMV(Meter),CGNS_ENUMV(Second),CGNS_ENUMV(Kelvin),CGNS_ENUMV(Degree),ier) ! read fields call cg_nfields_f(index_file,index_base,index_zone,index_flow, & nfields,ier) if (nfields .ne. 2) then write(6,'('' Error! expecting 2 fields, read '',i5)') nfields stop end if do iff=1,nfields call cg_field_info_f(index_file,index_base,index_zone, & index_flow,iff,idatatype,fieldname,ier) write(6,'('' fieldname='',a32)') fieldname if (fieldname .eq. 'Density') then exponents(1)=1. exponents(2)=-3. exponents(3)=0. exponents(4)=0. exponents(5)=0. else if (fieldname .eq. 'Pressure') then exponents(1)=1. exponents(2)=-1. exponents(3)=-2. exponents(4)=0. exponents(5)=0. else write(6,'('' Error! this fieldname not expected: '',a32)') fieldname stop end if ! write DimensionalExponents call cg_goto_f(index_file,index_base,ier,'Zone_t',1, & 'FlowSolution_t',1,'DataArray_t',iff,'end') call cg_exponents_write_f(CGNS_ENUMV(RealSingle),exponents,ier) enddo ! read grid call cg_ncoords_f(index_file,index_base,index_zone,ncoords,ier) exponents(1)=0. exponents(2)=1. exponents(3)=0. exponents(4)=0. exponents(5)=0. do icc=1,ncoords ! write DimensionalExponents call cg_goto_f(index_file,index_base,ier,'Zone_t',1, & 'GridCoordinates_t',1,'DataArray_t',icc,'end') call cg_exponents_write_f(CGNS_ENUMV(RealSingle),exponents,ier) enddo ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully wrote dimensional data to file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_flowcent_str.F90000066400000000000000000000064651474000356600253570ustar00rootroot00000000000000 program write_flowcent_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid, and adds a flow solution (at CELL CENTERS) ! to it. (Compare this program with write_flowvert_str) ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_flowcent_str.F90 ! ifort -o write_flowcent_str write_flowcent_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! r and p must be dimensioned exactly as (21-1,17-1,N-1) (N>=9) ! for this particular case or else they will be written to ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*8 r(20,16,8),p(20,16,8) integer index_field,index_flow,index_zone,index_base,index_file,ier integer i,j,k,ni,nj,nk character solname*32 ! write(6,'('' Program write_flowcent_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...compiled in 64-bit mode, but not needed'')') end if ! ! create fake flow solution AT CELL CENTERS for simple example: ni=20 nj=16 nk=8 do k=1,nk do j=1,nj do i=1,ni r(i,j,k)=float(i-1) p(i,j,k)=float(j-1) enddo enddo enddo write(6,'('' created simple 3-D rho and p flow solution'')') ! ! WRITE FLOW SOLUTION TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! define flow solution node name (user can give any name) solname = 'FlowSolution' ! create flow solution node (NOTE USE OF CellCenter HERE) call cg_sol_write_f(index_file,index_base,index_zone,solname, & CGNS_ENUMV(CellCenter),index_flow,ier) ! write flow solution (user must use SIDS-standard names here) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Density',r,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Pressure',p,index_field,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added CellCenter flow solution data'', & '' to file grid.cgns'')') write(6,'('' Note: if the original CGNS file already had'', & '' a FlowSolution_t node,'')') write(6,'('' it has been overwritten'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_flowcentrind_str.F90000066400000000000000000000110151474000356600262170ustar00rootroot00000000000000 program write_flowcentrind_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid, and adds a flow solution (at CELL CENTERS ! PLUS RIND CELLS IN I AND J DIRECTIONS) to it. ! (Compare this program with write_flowcent_str) ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_flowcentrind_str.F90 ! ifort -o write_flowcentrind_str write_flowcentrind_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! r and p must be dimensioned exactly as (21-1+2,17-1+2,N-1) (N>=9) ! for this particular case or else they will be written to ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): ! Rind cells are stored in array locations (i,1,k), (i,18,k), (1,j,k), (22,j,k) real*8 r(22,18,8),p(22,18,8) integer index_file,index_base,index_zone,index_flow,index_field,ier integer i,j,k,ni,nj,nk integer irinddata(6) character solname*32 ! write(6,'('' Program write_flowcentrind_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...compiled in 64-bit mode, but not needed'')') end if ! ! create fake flow solution AT CELL CENTERS for simple example: ni=20 nj=16 nk=8 do k=1,nk do j=1,nj do i=1,ni r(i+1,j+1,k)=float(i-1) p(i+1,j+1,k)=float(j-1) enddo enddo enddo ! create rind cell data: do k=1,nk do j=0,nj+1 r(1,j+1,k)=999.d0+float(j)+5.d0*float(k) p(1,j+1,k)=999.d0+float(j)+5.d0*float(k)+1.d0 r(ni+2,j+1,k)=-999.d0-float(j)-5.d0*float(k) p(ni+2,j+1,k)=-999.d0-float(j)-5.d0*float(k)-1.d0 enddo enddo do k=1,nk do i=0,ni+1 r(i+1,1,k)=888.d0+float(i)+5.d0*float(k) p(i+1,1,k)=888.d0+float(i)+5.d0*float(k)+1.d0 r(i+1,nj+2,k)=-888.d0-float(i)-5.d0*float(k) p(i+1,nj+2,k)=-888.d0-float(i)-5.d0*float(k)-1.d0 enddo enddo write(6,'('' created simple 3-D rho and p flow solution'', & '' with rind data'')') ! ! WRITE FLOW SOLUTION TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! define flow solution node name (user can give any name) solname = 'FlowSolution' ! create flow solution node (NOTE USE OF CellCenter HERE) call cg_sol_write_f(index_file,index_base,index_zone,solname, & CGNS_ENUMV(CellCenter),index_flow,ier) ! go to position within tree at FlowSolution_t node call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowSolution_t',index_flow,'end') ! write rind information under FlowSolution_t node (ilo,ihi,jlo,jhi,klo,khi) irinddata(1)=1 irinddata(2)=1 irinddata(3)=1 irinddata(4)=1 irinddata(5)=0 irinddata(6)=0 call cg_rind_write_f(irinddata,ier) ! write flow solution (user must use SIDS-standard names here) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Density',r,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Pressure',p,index_field,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added flow solution data to file'', & '' grid.cgns'')') write(6,'('' Note: if the original CGNS file already had'', & '' a FlowSolution_t node,'')') write(6,'('' it has been overwritten'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_floweqn_str.F90000066400000000000000000000110221474000356600251720ustar00rootroot00000000000000 program write_floweqn_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file and writes flow eqn info ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_floweqn_str.F90 ! ifort -o write_floweqn_str write_floweqn_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! real*4 gamma,prandtl integer idata(6) integer ieq_dim,index_zone,index_base,index_file,ier integer(cgsize_t) nuse ! write(6,'('' Program write_floweqn_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! data for writing gamma=1.4 prandtl=0.90 ! WRITE FLOW EQUATION SET INFO ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! existing file must be 3D structured (real working code would check!) ! Create 'FlowEquationSet' node under 'Zone_t' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone,'end') ! equation dimension = 3 ieq_dim=3 call cg_equationset_write_f(ieq_dim,ier) ! ! Create 'GoverningEquations' node under 'FlowEquationSet' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'end') call cg_governing_write_f(CGNS_ENUMV(NSTurbulent),ier) ! Create 'DiffusionModel' node under 'GoverningEquations' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'GoverningEquations_t',1,'end') idata(1)=0 idata(2)=1 idata(3)=0 idata(4)=0 idata(5)=0 idata(6)=0 call cg_diffusion_write_f(idata,ier) ! nuse=1 ! Create 'GasModel' under 'FlowEquationSet' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'end') call cg_model_write_f('GasModel_t',CGNS_ENUMV(Ideal),ier) ! Create 'SpecificHeatRatio' under GasModel call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'GasModel_t',1,'end') call cg_array_write_f('SpecificHeatRatio',CGNS_ENUMV(RealSingle),1,[nuse],gamma,ier) ! Create 'DataClass' under 'SpecificHeatRatio' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'GasModel_t',1,'DataArray_t',1,'end') call cg_dataclass_write_f(CGNS_ENUMV(NondimensionalParameter),ier) ! ! Create 'TurbulenceClosure' under 'FlowEquationSet' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'end') call cg_model_write_f('TurbulenceClosure_t',CGNS_ENUMV(EddyViscosity),ier) ! Create 'PrandtlTurbulent' under 'TurbulenceClosure' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'TurbulenceClosure_t',1,'end') call cg_array_write_f('PrandtlTurbulent',CGNS_ENUMV(RealSingle),1,[nuse],prandtl,ier) ! Create 'DataClass' under 'PrandtlTurbulent' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'TurbulenceClosure_t',1, & 'DataArray_t',1,'end') call cg_dataclass_write_f(CGNS_ENUMV(NondimensionalParameter),ier) ! ! Create 'TurbulenceModel' under 'FlowEquationSet' call cg_goto_f(index_file,index_base,ier,'Zone_t',index_zone, & 'FlowEquationSet_t',1,'end') call cg_model_write_f('TurbulenceModel_t', & CGNS_ENUMV(OneEquation_SpalartAllmaras),ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully wrote equation set info to file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_flowvert_str.F90000066400000000000000000000064051474000356600254000ustar00rootroot00000000000000 program write_flowvert_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid, and adds a flow solution (at VERTICES) ! to it. (Compare this program with write_flowcent_str) ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_flowvert_str.F90 ! ifort -o write_flowvert_str write_flowvert_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! r and p must be dimensioned exactly as (21,17,N) (N>=9) ! for this particular case or else they will be written to ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*8 r(21,17,9),p(21,17,9) integer index_field,index_flow,index_zone,index_base,ier integer index_file,i,j,k,ni,nj,nk character solname*32 ! write(6,'('' Program write_flowvert_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...compiled in 64-bit mode, but not needed'')') end if ! ! create fake flow solution AT VERTICES for simple example: ni=21 nj=17 nk=9 do k=1,nk do j=1,nj do i=1,ni r(i,j,k)=float(i-1) p(i,j,k)=float(j-1) enddo enddo enddo write(6,'('' created simple 3-D rho and p flow solution'')') ! ! WRITE FLOW SOLUTION TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! define flow solution node name (user can give any name) solname = 'FlowSolution' ! create flow solution node call cg_sol_write_f(index_file,index_base,index_zone,solname, & CGNS_ENUMV(Vertex),index_flow,ier) ! write flow solution (user must use SIDS-standard names here) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Density',r,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Pressure',p,index_field,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added Vertex flow solution data'', & '' to file grid.cgns'')') write(6,'('' Note: if the original CGNS file already had'', & '' a FlowSolution_t node,'')') write(6,'('' it has been overwritten'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_flowvert_unst.F90000066400000000000000000000061671474000356600255660ustar00rootroot00000000000000 program write_flowvert_unst use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! unstructured grid, and adds a flow solution (at VERTICES) ! to it. ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_unst.f) ! Note that, other than the dimensions of the variables ! r and p, this program is essentially identical to that for ! writing flow solutions to a structured zone: ! write_flowvert_str.f ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_flowvert_unst.F90 ! ifort -o write_flowvert_unst write_flowvert_unst.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! real*8 r(21*17*9),p(21*17*9) integer index_field,index_flow,index_zone,index_base,ier integer index_file,i,j,k,ni,nj,nk,iset character solname*32 ! write(6,'('' Program write_flowvert_unst'')') if (CG_BUILD_64BIT) then write(6,'('' ...compiled in 64-bit mode, but not needed'')') end if ! ! create fake flow solution AT VERTICES for simple example: ni=21 nj=17 nk=9 iset=0 do k=1,nk do j=1,nj do i=1,ni iset=iset+1 r(iset)=float(i-1) p(iset)=float(j-1) enddo enddo enddo write(6,'('' created simple 3-D rho and p flow solution'')') ! ! WRITE FLOW SOLUTION TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! define flow solution node name (user can give any name) solname = 'FlowSolution' ! create flow solution node call cg_sol_write_f(index_file,index_base,index_zone,solname, & CGNS_ENUMV(Vertex),index_flow,ier) ! write flow solution (user must use SIDS-standard names here) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Density',r,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Pressure',p,index_field,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added flow solution data to file'', & '' grid.cgns (unstructured)'')') write(6,'('' Note: if the original CGNS file already had'', & '' a FlowSolution_t node,'')') write(6,'('' it has been overwritten'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_grid2zn_str.F90000066400000000000000000000102531474000356600251030ustar00rootroot00000000000000 program write_grid2zn_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Creates simple 3-D structured grid WITH 2 ZONES and writes ! it to a CGNS file. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_grid2zn_str.F90 ! ifort -o write_grid2zn_str write_grid2zn_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! x,y,z must be dimensioned exactly as (21,17,N) (N>=9) ! for this particular case or else they will be written to ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*8 x1(21,17,9),y1(21,17,9),z1(21,17,9) real*8 x2(21,17,9),y2(21,17,9),z2(21,17,9) integer index_coord,index_zone,index_base,ier integer iphysdim,icelldim,index_file integer i,j,k,ni,nj,nk integer(cgsize_t) isize(3,3) character basename*32,zonename*32 ! write(6,'('' Program write_grid2zn_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! create gridpoints for simple example: ni=21 nj=17 nk=9 do k=1,nk do j=1,nj do i=1,ni x1(i,j,k)=float(i-1) y1(i,j,k)=float(j-1) z1(i,j,k)=float(k-1) x2(i,j,k)=x1(i,j,k)+20.d0 y2(i,j,k)=y1(i,j,k) z2(i,j,k)=z1(i,j,k) enddo enddo enddo write(6,'('' created simple 3-D grid points (2 zones)'')') ! ! WRITE X, Y, Z GRID POINTS TO CGNS FILE ! open CGNS file for write call cg_open_f('grid.cgns',CG_MODE_WRITE,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! create base (user can give any name) basename='Base' icelldim=3 iphysdim=3 call cg_base_write_f(index_file,basename,icelldim,iphysdim,index_base,ier) ! vertex size isize(1,1)=21 isize(2,1)=17 isize(3,1)=9 ! cell size isize(1,2)=isize(1,1)-1 isize(2,2)=isize(2,1)-1 isize(3,2)=isize(3,1)-1 ! boundary vertex size (always zero for structured grids) isize(1,3)=0 isize(2,3)=0 isize(3,3)=0 ! define zone 1 name (user can give any name) zonename = 'Zone 1' ! create zone call cg_zone_write_f(index_file,index_base,zonename,isize, & CGNS_ENUMV(Structured),index_zone,ier) ! write grid coordinates (user must use SIDS-standard names here) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateX',x1,index_coord,ier) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateY',y1,index_coord,ier) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateZ',z1,index_coord,ier) ! define zone 2 name (user can give any name) zonename = 'Zone 2' ! create zone call cg_zone_write_f(index_file,index_base,zonename,isize, & CGNS_ENUMV(Structured),index_zone,ier) ! write grid coordinates (user must use SIDS-standard names here) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateX',x2,index_coord,ier) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateY',y2,index_coord,ier) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateZ',z2,index_coord,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully wrote grid to file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_grid_str.F90000066400000000000000000000064261474000356600244600ustar00rootroot00000000000000 program write_grid_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Creates simple 3-D structured grid and writes it to a ! CGNS file. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_grid_str.F90 ! ifort -o write_grid_str write_grid_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! ! dimension statements (note that tri-dimensional arrays ! x,y,z must be dimensioned exactly as (21,17,N) (N>=9) ! for this particular case or else they will be written to ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*8 x(21,17,9),y(21,17,9),z(21,17,9) integer ni,nj,nk,i,j,k integer icelldim,iphysdim integer index_coord,index_file,ier integer index_base,index_zone integer(cgsize_t) isize(3,3) character basename*32,zonename*32 ! write(6,'('' Program write_grid_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! create gridpoints for simple example: ni=21 nj=17 nk=9 do k=1,nk do j=1,nj do i=1,ni x(i,j,k)=float(i-1) y(i,j,k)=float(j-1) z(i,j,k)=float(k-1) enddo enddo enddo write(6,'('' created simple 3-D grid points'')') ! ! WRITE X, Y, Z GRID POINTS TO CGNS FILE ! open CGNS file for write call cg_open_f('grid.cgns',CG_MODE_WRITE,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! create base (user can give any name) basename='Base' icelldim=3 iphysdim=3 call cg_base_write_f(index_file,basename,icelldim,iphysdim, & index_base,ier) ! define zone name (user can give any name) zonename = 'Zone 1' ! vertex size isize(1,1)=21 isize(2,1)=17 isize(3,1)=9 ! cell size isize(1,2)=isize(1,1)-1 isize(2,2)=isize(2,1)-1 isize(3,2)=isize(3,1)-1 ! boundary vertex size (always zero for structured grids) isize(1,3)=0 isize(2,3)=0 isize(3,3)=0 ! create zone call cg_zone_write_f(index_file,index_base,zonename,isize, & CGNS_ENUMV(Structured),index_zone,ier) ! write grid coordinates (user must use SIDS-standard names here) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateX',x,index_coord,ier) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateY',y,index_coord,ier) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateZ',z,index_coord,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully wrote grid to file grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_grid_unst.F90000066400000000000000000000211621474000356600246330ustar00rootroot00000000000000 program write_grid_unst use cgns implicit none #include "cgnstypes_f03.h" ! ! Creates simple 3-D unstructured grid and writes it to a ! CGNS file. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_grid_unst.F90 ! ifort -o write_grid_unst write_grid_unst.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! integer, parameter :: maxelemi=20*16*8 integer, parameter :: maxelemj=1216 real*8 x(21*17*9),y(21*17*9),z(21*17*9) integer i,j,k,ifirstnode,nbdyelem,ni,nj,nk integer index_file,index_section,ielem_no integer index_base,index_zone,index_coord integer ier,iset,iphysdim,icelldim integer(cgsize_t) isize(1,3),ielem(8,maxelemi),jelem(4,maxelemj) integer(cgsize_t) nelem_start,nelem_end character basename*32,zonename*32 ! write(6,'('' Program write_grid_unst'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! create gridpoints for simple example: ni=21 nj=17 nk=9 iset=0 do k=1,nk do j=1,nj do i=1,ni iset=iset+1 x(iset)=float(i-1) y(iset)=float(j-1) z(iset)=float(k-1) enddo enddo enddo write(6,'('' created simple 3-D grid points'')') ! ! WRITE X, Y, Z GRID POINTS TO CGNS FILE ! open CGNS file for write call cg_open_f('grid.cgns',CG_MODE_WRITE,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! create base (user can give any name) basename='Base' icelldim=3 iphysdim=3 call cg_base_write_f(index_file,basename,icelldim,iphysdim,index_base,ier) ! define zone name (user can give any name) zonename = 'Zone 1' ! vertex size isize(1,1)=ni*nj*nk ! cell size isize(1,2)=(ni-1)*(nj-1)*(nk-1) ! boundary vertex size (zero if elements not sorted) isize(1,3)=0 ! create zone call cg_zone_write_f(index_file,index_base,zonename,isize, & CGNS_ENUMV(Unstructured),index_zone,ier) ! write grid coordinates (user must use SIDS-standard names here) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateX',x,index_coord,ier) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateY',y,index_coord,ier) call cg_coord_write_f(index_file,index_base,index_zone,CGNS_ENUMV(RealDouble), & 'CoordinateZ',z,index_coord,ier) ! set element connectivity: ! ---------------------------------------------------------- ! do all the HEXA_8 elements (this part is mandatory): ! maintain SIDS-standard ordering ielem_no=0 ! index no of first element nelem_start=1 do k=1,nk-1 do j=1,nj-1 do i=1,ni-1 ielem_no=ielem_no+1 ! in this example, due to the order in the node numbering, the ! hexahedral elements can be reconstructed using the following ! relationships: ifirstnode=i+(j-1)*ni+(k-1)*ni*nj ielem(1,ielem_no)=ifirstnode ielem(2,ielem_no)=ifirstnode+1 ielem(3,ielem_no)=ifirstnode+1+ni ielem(4,ielem_no)=ifirstnode+ni ielem(5,ielem_no)=ifirstnode+ni*nj ielem(6,ielem_no)=ifirstnode+ni*nj+1 ielem(7,ielem_no)=ifirstnode+ni*nj+1+ni ielem(8,ielem_no)=ifirstnode+ni*nj+ni enddo enddo enddo ! index no of last element (=2560) nelem_end=ielem_no if (nelem_end .gt. maxelemi) then write(6,'('' Error, must increase maxelemi to at least '', & i7)') nelem_end stop end if ! unsorted boundary elements nbdyelem=0 ! write HEXA_8 element connectivity (user can give any name) call cg_section_write_f(index_file,index_base,index_zone, & 'Elem',CGNS_ENUMV(HEXA_8),nelem_start,nelem_end,nbdyelem,ielem, & index_section,ier) ! ---------------------------------------------------------- ! do boundary (QUAD) elements (this part is optional, ! but you must do it if you eventually want to define BCs ! at element faces rather than at nodes): ! maintain SIDS-standard ordering ! INFLOW: ielem_no=0 ! index no of first element nelem_start=nelem_end+1 i=1 do k=1,nk-1 do j=1,nj-1 ielem_no=ielem_no+1 ifirstnode=i+(j-1)*ni+(k-1)*ni*nj jelem(1,ielem_no)=ifirstnode jelem(2,ielem_no)=ifirstnode+ni*nj jelem(3,ielem_no)=ifirstnode+ni*nj+ni jelem(4,ielem_no)=ifirstnode+ni enddo enddo ! index no of last element nelem_end=nelem_start+ielem_no-1 if (ielem_no .gt. maxelemj) then write(6,'('' Error, must increase maxelemj to at least '', & i7)') ielem_no stop end if ! write QUAD element connectivity for inflow face (user can give any name) call cg_section_write_f(index_file,index_base,index_zone, & 'InflowElem',CGNS_ENUMV(QUAD_4),nelem_start,nelem_end,nbdyelem, & jelem,index_section,ier) ! OUTFLOW: ielem_no=0 ! index no of first element nelem_start=nelem_end+1 i=ni-1 do k=1,nk-1 do j=1,nj-1 ielem_no=ielem_no+1 ifirstnode=i+(j-1)*ni+(k-1)*ni*nj jelem(1,ielem_no)=ifirstnode+1 jelem(2,ielem_no)=ifirstnode+1+ni jelem(3,ielem_no)=ifirstnode+ni*nj+1+ni jelem(4,ielem_no)=ifirstnode+ni*nj+1 enddo enddo ! index no of last element nelem_end=nelem_start+ielem_no-1 if (ielem_no .gt. maxelemj) then write(6,'('' Error, must increase maxelemj to at least '', & i7)') ielem_no stop end if ! write QUAD element connectivity for outflow face (user can give any name) call cg_section_write_f(index_file,index_base,index_zone, & 'OutflowElem',CGNS_ENUMV(QUAD_4),nelem_start,nelem_end,nbdyelem, & jelem,index_section,ier) ! SIDEWALLS: ielem_no=0 ! index no of first element nelem_start=nelem_end+1 j=1 do k=1,nk-1 do i=1,ni-1 ielem_no=ielem_no+1 ifirstnode=i+(j-1)*ni+(k-1)*ni*nj jelem(1,ielem_no)=ifirstnode jelem(2,ielem_no)=ifirstnode+ni*nj jelem(3,ielem_no)=ifirstnode+ni*nj+1 jelem(4,ielem_no)=ifirstnode+1 enddo enddo j=nj-1 do k=1,nk-1 do i=1,ni-1 ielem_no=ielem_no+1 ifirstnode=i+(j-1)*ni+(k-1)*ni*nj jelem(1,ielem_no)=ifirstnode+1+ni jelem(2,ielem_no)=ifirstnode+ni jelem(3,ielem_no)=ifirstnode+ni*nj+ni jelem(4,ielem_no)=ifirstnode+ni*nj+1+ni enddo enddo k=1 do j=1,nj-1 do i=1,ni-1 ielem_no=ielem_no+1 ifirstnode=i+(j-1)*ni+(k-1)*ni*nj jelem(1,ielem_no)=ifirstnode jelem(2,ielem_no)=ifirstnode+1 jelem(3,ielem_no)=ifirstnode+1+ni jelem(4,ielem_no)=ifirstnode+ni enddo enddo k=nk-1 do j=1,nj-1 do i=1,ni-1 ielem_no=ielem_no+1 ifirstnode=i+(j-1)*ni+(k-1)*ni*nj jelem(1,ielem_no)=ifirstnode+ni*nj jelem(2,ielem_no)=ifirstnode+ni*nj+ni jelem(3,ielem_no)=ifirstnode+ni*nj+1+ni jelem(4,ielem_no)=ifirstnode+ni*nj+1 enddo enddo ! index no of last element nelem_end=nelem_start+ielem_no-1 if (ielem_no .gt. maxelemj) then write(6,'('' Error, must increase maxelemj to at least '', & i7)') ielem_no stop end if ! write QUAD element connectivity for sidewall face (user can give any name) call cg_section_write_f(index_file,index_base,index_zone, & 'SidewallElem',CGNS_ENUMV(QUAD_4),nelem_start,nelem_end,nbdyelem, & jelem,index_section,ier) ! ---------------------------------------------------------- ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully wrote unstructured grid to file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_nondimensional.F90000066400000000000000000000121711474000356600256520ustar00rootroot00000000000000 program write_nondimensional use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file and adds the DataClass and ! ReferenceState appropriate for a completely ! NONDIMENSIONAL data set. ! ! The CGNS grid file 'grid.cgns' must already exist ! (for example, created using write_grid_str.f or ! write_grid_unst.f). In this case, the flow solution does ! not need to be present. ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_nondimensional.F90 ! ifort -o write_nondimensional write_nondimensional.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! real*8 xmach,reue,xmv,xmc,rev,rel,renu,rho0,gamma,p0,c0,vm0 real*8 xlength0,vx,vy,vz integer index_file,ier,index_base,idata integer(cgsize_t) nuse ! write(6,'('' Program write_nondimensional'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! define nondimensional parameters xmach=4.6d0 reue=6000000.d0 xmv=xmach xmc=1.d0 rev=xmach rel=1.d0 renu=xmach/reue rho0=1.d0 gamma=1.4d0 p0=1.d0/gamma c0=1.d0 vm0=xmach/reue xlength0=1.d0 vx=xmach vy=0.d0 vz=0.d0 nuse=1 ! WRITE NONDIMENSIONAL INFO ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! put DataClass under Base call cg_goto_f(index_file,index_base,ier,'end') ! check first if a dataclass has already been written call cg_dataclass_read_f(idata,ier) if (ier .eq. 0) then write(6,'('' Error! DataClass already exists!'')') write(6,'('' Re-make CGNS file without it and related info,'', & '' then try again'')') stop else ier=0 end if call cg_dataclass_write_f(CGNS_ENUMV(NormalizedByUnknownDimensional),ier) ! put ReferenceState under Base call cg_state_write_f('ReferenceQuantities',ier) ! Go to ReferenceState node, write Mach array and its dataclass call cg_goto_f(index_file,index_base,ier,'ReferenceState_t',1,'end') call cg_array_write_f('Mach',CGNS_ENUMV(RealDouble),1,[nuse],xmach,ier) call cg_goto_f(index_file,index_base,ier,'ReferenceState_t',1, & 'DataArray_t',1,'end') call cg_dataclass_write_f(CGNS_ENUMV(NondimensionalParameter),ier) ! Go to ReferenceState node, write Reynolds array and its dataclass call cg_goto_f(index_file,index_base,ier,'ReferenceState_t',1,'end') call cg_array_write_f('Reynolds',CGNS_ENUMV(RealDouble),1,[nuse],reue,ier) call cg_goto_f(index_file,index_base,ier,'ReferenceState_t',1, & 'DataArray_t',2,'end') call cg_dataclass_write_f(CGNS_ENUMV(NondimensionalParameter),ier) ! Go to ReferenceState node to write reference quantities: call cg_goto_f(index_file,index_base,ier,'ReferenceState_t',1,'end') ! First, write reference quantities that make up Mach and Reynolds: ! Mach_Velocity call cg_array_write_f('Mach_Velocity',CGNS_ENUMV(RealDouble),1,[nuse],xmv,ier) ! Mach_VelocitySound call cg_array_write_f('Mach_VelocitySound',CGNS_ENUMV(RealDouble),1,[nuse],xmc,ier) ! Reynolds_Velocity call cg_array_write_f('Reynolds_Velocity',CGNS_ENUMV(RealDouble),1,[nuse],rev,ier) ! Reynolds_Length call cg_array_write_f('Reynolds_Length',CGNS_ENUMV(RealDouble),1,[nuse],rel,ier) ! Reynolds_ViscosityKinematic call cg_array_write_f('Reynolds_ViscosityKinematic',CGNS_ENUMV(RealDouble), & 1,[nuse],renu,ier) ! ! Next, write flow field reference quantities: ! Density call cg_array_write_f('Density',CGNS_ENUMV(RealDouble),1,[nuse],rho0,ier) ! Pressure call cg_array_write_f('Pressure',CGNS_ENUMV(RealDouble),1,[nuse],p0,ier) ! VelocitySound call cg_array_write_f('VelocitySound',CGNS_ENUMV(RealDouble),1,[nuse],c0,ier) ! ViscosityMolecular call cg_array_write_f('ViscosityMolecular',CGNS_ENUMV(RealDouble),1,[nuse],vm0,ier) ! LengthReference call cg_array_write_f('LengthReference',CGNS_ENUMV(RealDouble),1,[nuse],xlength0,ier) ! VelocityX call cg_array_write_f('VelocityX',CGNS_ENUMV(RealDouble),1,[nuse],vx,ier) ! VelocityY call cg_array_write_f('VelocityY',CGNS_ENUMV(RealDouble),1,[nuse],vy,ier) ! VelocityZ call cg_array_write_f('VelocityZ',CGNS_ENUMV(RealDouble),1,[nuse],vz,ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully wrote nondimensional info to file'', & '' grid.cgns'')') stop end CGNS-4.5.0/src/Test_UserGuideCode/Fortran_code/write_timevert_str.F90000066400000000000000000000135001474000356600253610ustar00rootroot00000000000000 program write_timevert_str use cgns implicit none #include "cgnstypes_f03.h" ! ! Opens an existing CGNS file that contains a simple 3-D ! structured grid, and adds 3 different flow solutions ! (at VERTICES) to it, along with time-accurate info. ! In this example, r1 & p1, r2 & p2, r3 & p3 correspond ! with solutions at 3 different time steps. ! ! The CGNS grid file 'grid.cgns' must already exist ! (created using write_grid_str.f) ! ! Example compilation for this program is (change paths if needed!): ! Note: when using the cgns module file, you must use the SAME fortran compiler ! used to compile CGNS (see make.defs file) ! ...or change, for example, via environment "setenv FC ifort" ! ! ifort -I ../.. -c write_timevert_str.F90 ! ifort -o write_timevert_str write_timevert_str.o -L ../../lib -lcgns ! ! (../../lib is the location where the compiled ! library libcgns.a is located) ! ! The following is no longer supported; now superseded by "use cgns": ! include 'cgnslib_f.h' ! Note Windows machines need to include cgnswin_f.h ! ! dimension statements (note that tri-dimensional arrays ! r1, r2, r3 and p1, p2, p3 ! must be dimensioned exactly as (21,17,N) (N>=9) ! for this particular case or else they will be written to ! the CGNS file incorrectly! Other options are to use 1-D ! arrays, use dynamic memory, or pass index values to a ! subroutine and dimension exactly there): real*8 r1(21,17,9),p1(21,17,9) real*8 r2(21,17,9),p2(21,17,9) real*8 r3(21,17,9),p3(21,17,9) real*8 time(3) integer nsteps,index_field,n,index_zone,ier,index_file integer i,j,k,ni,nj,nk,index_base,index_flow integer(cgsize_t) idata(2),nuse character solname(3)*32 ! write(6,'('' Program write_timevert_str'')') if (CG_BUILD_64BIT) then write(6,'('' ...using 64-bit mode for particular integers'')') end if ! ! set up the times corresponding to the 3 solutions to be ! stored: time(1)=10.d0 time(2)=20.d0 time(3)=50.d0 ! create fake flow solution AT VERTICES for simple example: ni=21 nj=17 nk=9 do k=1,nk do j=1,nj do i=1,ni ! soln at time 1: r1(i,j,k)=float(i-1) p1(i,j,k)=float(j-1) ! soln at time 2: r2(i,j,k)=r1(i,j,k)+1.d0 p2(i,j,k)=p1(i,j,k)+1.d0 ! soln at time 3: r3(i,j,k)=r2(i,j,k)+1.d0 p3(i,j,k)=p2(i,j,k)+1.d0 enddo enddo enddo write(6,'('' created simple 3-D rho and p flow solution'')') ! ! WRITE FLOW SOLUTION TO EXISTING CGNS FILE ! open CGNS file for modify call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f ! we know there is only one base (real working code would check!) index_base=1 ! we know there is only one zone (real working code would check!) index_zone=1 ! define 3 different solution names (user can give any names) solname(1) = 'FlowSolution1' solname(2) = 'FlowSolution2' solname(3) = 'FlowSolution3' ! do loop for the 3 solutions: do n=1,3 ! create flow solution node call cg_sol_write_f(index_file,index_base,index_zone,solname(n), & CGNS_ENUMV(Vertex),index_flow,ier) write(6,'('' ... writing solution number '',i5)') index_flow ! write flow solution (user must use SIDS-standard names here) if (n .eq. 1) then call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Density',r1,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Pressure',p1,index_field,ier) else if (n .eq. 2) then call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Density',r2,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Pressure',p2,index_field,ier) else call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Density',r3,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow, & CGNS_ENUMV(RealDouble),'Pressure',p3,index_field,ier) end if enddo ! create BaseIterativeData nsteps=3 call cg_biter_write_f(index_file,index_base,'TimeIterValues',nsteps,ier) ! go to BaseIterativeData level and write time values call cg_goto_f(index_file,index_base,ier,'BaseIterativeData_t',1,'end') nuse=3 call cg_array_write_f('TimeValues',CGNS_ENUMV(RealDouble),1,[nuse],time,ier) ! create ZoneIterativeData call cg_ziter_write_f(index_file,index_base,index_zone, & 'ZoneIterativeData',ier) ! go to ZoneIterativeData level and give info telling which ! flow solution corresponds with which time (solname(1) corresponds ! with time(1), solname(2) with time(2), and solname(3) with time(3)) call cg_goto_f(index_file,index_base,ier,'Zone_t', & index_zone,'ZoneIterativeData_t',1,'end') idata(1)=32 idata(2)=3 call cg_array_write_f('FlowSolutionPointers',CGNS_ENUMV(Character),2,idata, & solname,ier) ! add SimulationType call cg_simulation_type_write_f(index_file,index_base,CGNS_ENUMV(TimeAccurate),ier) ! close CGNS file call cg_close_f(index_file,ier) write(6,'('' Successfully added 3 times of flow solution data'', & '' and time info to file grid.cgns'')') write(6,'('' Note: if the original CGNS file already had'', & '' a FlowSolution_t node,'')') write(6,'('' it has been overwritten'')') stop end CGNS-4.5.0/src/adf/000077500000000000000000000000001474000356600136005ustar00rootroot00000000000000CGNS-4.5.0/src/adf/ADF.h000066400000000000000000000256111474000356600143500ustar00rootroot00000000000000/* ------------------------------------------------------------------------- * * CGNS - CFD General Notation System (http://www.cgns.org) * * CGNS/MLL - Mid-Level Library header file * * Please see cgnsconfig.h file for this local installation configuration * * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- * This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. * ------------------------------------------------------------------------- */ /** File: ADF.h ---------------------------------------------------------------------- BOEING ---------------------------------------------------------------------- Project: CGNS Author: Tom Dickens 865-6122 tpd6908@yak.ca.boeing.com Date: 3/2/1995 Purpose: Provide prototype declarations for the ADF-Core routines. ---------------------------------------------------------------------- ---------------------------------------------------------------------- **/ #ifndef ADF_INCLUDE #define ADF_INCLUDE #include "cgnstypes.h" #if defined(_WIN32) && defined(BUILD_DLL) # define EXTERN extern __declspec(dllexport) #else # define EXTERN extern #endif /*********************************************************************** Defines: These defines are used within the ADF core routines to specify the size in bytes of various items. Caution: Simply changing a define here may not correctly adjust the ADF core code. These sizes are provided for reference only! ***********************************************************************/ #define ADF_DATA_TYPE_LENGTH 32 #define ADF_CGIO_DATA_TYPE_LENGTH 2 #define ADF_DATE_LENGTH 32 #define ADF_FILENAME_LENGTH 1024 #define ADF_FORMAT_LENGTH 20 #define ADF_LABEL_LENGTH 32 #define ADF_MAXIMUM_LINK_DEPTH 100 #define ADF_MAX_DIMENSIONS 12 #define ADF_MAX_ERROR_STR_LENGTH 80 #define ADF_MAX_LINK_DATA_SIZE 4096 #define ADF_NAME_LENGTH 32 #define ADF_STATUS_LENGTH 32 #define ADF_VERSION_LENGTH 32 /*********************************************************************** Prototypes for Interface Routines ***********************************************************************/ #if defined (__cplusplus) extern "C" { #endif EXTERN void ADF_Children_Names( const double PID, const int istart, const int ilen, const int name_length, int *ilen_ret, char *names, int *error_return ) ; EXTERN void ADF_Children_IDs( const double PID, const int istart, const int ilen, int *ilen_ret, double *IDs, int *error_return ) ; EXTERN void ADF_Create( const double PID, const char *name, double *ID, int *error_return ) ; EXTERN void ADF_Database_Close( const double ID, int *error_return ) ; EXTERN void ADF_Database_Delete( const char *filename, int *error_return ) ; EXTERN void ADF_Database_Garbage_Collection( const double ID, int *error_return ) ; EXTERN void ADF_Database_Get_Format( const double Root_ID, char *format, int *error_return ) ; EXTERN void ADF_Database_Open( const char *filename, const char *status, const char *format, double *root_ID, int *error_return ) ; EXTERN void ADF_Database_Valid( const char *filename, int *error_return ) ; EXTERN void ADF_Database_Set_Format( const double Root_ID, const char *format, int *error_return ) ; EXTERN void ADF_Database_Version( const double Root_ID, char *version, char *creation_date, char *modification_date, int *error_return ) ; EXTERN void ADF_Delete( const double PID, const double ID, int *error_return ) ; EXTERN void ADF_Error_Message( const int error_return_input, char *error_string ) ; EXTERN void ADF_Flush_to_Disk( const double ID, int *error_return ) ; EXTERN void ADF_Get_Data_Type( const double ID, char *data_type, int *error_return ) ; EXTERN void ADF_Get_Dimension_Values( const double ID, cgsize_t dim_vals[], int *error_return ) ; EXTERN void ADF_Get_Error_State( int *error_state, int *error_return ) ; EXTERN void ADF_Get_Label( const double ID, char *label, int *error_return ) ; EXTERN void ADF_Get_Link_Path( const double ID, char *filename, char *link_path, int *error_return ) ; EXTERN void ADF_Get_Name( const double ID, char *name, int *error_return ) ; EXTERN void ADF_Get_Node_ID( const double PID, const char *name, double *ID, int *error_return ) ; EXTERN void ADF_Get_Number_of_Dimensions( const double ID, int *num_dims, int *error_return ) ; EXTERN void ADF_Get_Root_ID( const double ID, double *Root_ID, int *error_return ) ; EXTERN void ADF_Is_Link( const double ID, int *link_path_length, int *error_return ) ; EXTERN void ADF_Library_Version( char *version, int *error_return ) ; EXTERN void ADF_Link( const double PID, const char *name, const char *file, const char *name_in_file, double *ID, int *error_return ) ; EXTERN void ADF_Link_Size( const double ID, int *len_file, int *len_name, int *error_return ) ; EXTERN void ADF_Move_Child( const double PID, const double ID, const double NPID, int *error_return ) ; EXTERN void ADF_Number_of_Children( const double ID, int *num_children, int *error_return ) ; EXTERN void ADF_Put_Dimension_Information( const double ID, const char *data_type, const int dims, const cgsize_t dim_vals[], int *error_return ) ; EXTERN void ADF_Put_Name( const double PID, const double ID, const char *name, int *error_return ) ; EXTERN void ADF_Read_All_Data( const double ID, const char *m_data_type, char *data, int *error_return ) ; EXTERN void ADF_Read_Block_Data( const double ID, const cgsize_t b_start, const cgsize_t b_end, char *data, int *error_return ) ; EXTERN void ADF_Read_Data( const double ID, const cgsize_t s_start[], const cgsize_t s_end[], const cgsize_t s_stride[], const int m_num_dims, const cgsize_t m_dims[], const cgsize_t m_start[], const cgsize_t m_end[], const cgsize_t m_stride[], const char *m_data_type, char *data, int *error_return ) ; EXTERN void ADF_Set_Error_State( const int error_state, int *error_return ) ; EXTERN void ADF_Set_Label( const double ID, const char *label, int *error_return ) ; EXTERN void ADF_Write_All_Data( const double ID, const char *data, int *error_return ) ; EXTERN void ADF_Write_Block_Data( const double ID, const cgsize_t b_start, const cgsize_t b_end, char *data, int *error_return ) ; EXTERN void ADF_Write_Data( const double ID, const cgsize_t s_start[], const cgsize_t s_end[], const cgsize_t s_stride[], const int m_num_dims, const cgsize_t m_dims[], const cgsize_t m_start[], const cgsize_t m_end[], const cgsize_t m_stride[], const char *data, int *error_return ) ; #if defined (__cplusplus) } #endif #undef EXTERN /*********************************************************************** Error-return values These values need to be kept in sync with the error strings in file ADF_interface.c ***********************************************************************/ /** Don't use zero since you can assign zero to a pointer **/ #define NO_ERROR -1 #define NUMBER_LESS_THAN_MINIMUM 1 #define NUMBER_GREATER_THAN_MAXIMUM 2 #define STRING_LENGTH_ZERO 3 #define STRING_LENGTH_TOO_BIG 4 #define STRING_NOT_A_HEX_STRING 5 #define TOO_MANY_ADF_FILES_OPENED 6 #define ADF_FILE_STATUS_NOT_RECOGNIZED 7 #define FILE_OPEN_ERROR 8 #define ADF_FILE_NOT_OPENED 9 #define FILE_INDEX_OUT_OF_RANGE 10 #define BLOCK_OFFSET_OUT_OF_RANGE 11 #define NULL_STRING_POINTER 12 #define FSEEK_ERROR 13 #define FWRITE_ERROR 14 #define FREAD_ERROR 15 #define ADF_MEMORY_TAG_ERROR 16 #define ADF_DISK_TAG_ERROR 17 #define REQUESTED_NEW_FILE_EXISTS 18 #define ADF_FILE_FORMAT_NOT_RECOGNIZED 19 #define FREE_OF_ROOT_NODE 20 #define FREE_OF_FREE_CHUNK_TABLE 21 #define REQUESTED_OLD_FILE_NOT_FOUND 22 #define UNIMPLEMENTED_CODE 23 #define SUB_NODE_TABLE_ENTRIES_BAD 24 #define MEMORY_ALLOCATION_FAILED 25 #define DUPLICATE_CHILD_NAME 26 #define ZERO_DIMENSIONS 27 #define BAD_NUMBER_OF_DIMENSIONS 28 #define CHILD_NOT_OF_GIVEN_PARENT 29 #define DATA_TYPE_TOO_LONG 30 #define INVALID_DATA_TYPE 31 #define NULL_POINTER 32 #define NO_DATA 33 #define ERROR_ZEROING_OUT_MEMORY 34 #define REQUESTED_DATA_TOO_LONG 35 #define END_OUT_OF_DEFINED_RANGE 36 #define BAD_STRIDE_VALUE 37 #define MINIMUM_GT_MAXIMUM 38 #define MACHINE_FORMAT_NOT_RECOGNIZED 39 #define CANNOT_CONVERT_NATIVE_FORMAT 40 #define CONVERSION_FORMATS_EQUAL 41 #define DATA_TYPE_NOT_SUPPORTED 42 #define FILE_CLOSE_ERROR 43 #define NUMERIC_OVERFLOW 44 #define START_OUT_OF_DEFINED_RANGE 45 #define ZERO_LENGTH_VALUE 46 #define BAD_DIMENSION_VALUE 47 #define BAD_ERROR_STATE 48 #define UNEQUAL_MEMORY_AND_DISK_DIMS 49 #define LINKS_TOO_DEEP 50 #define NODE_IS_NOT_A_LINK 51 #define LINK_TARGET_NOT_THERE 52 #define LINKED_TO_FILE_NOT_THERE 53 #define NODE_ID_ZERO 54 #define INCOMPLETE_DATA 55 #define INVALID_NODE_NAME 56 #define INVALID_VERSION 57 #define NODES_NOT_IN_SAME_FILE 58 #define PRISTK_NOT_FOUND 59 #define MACHINE_FILE_INCOMPATABLE 60 #define FFLUSH_ERROR 61 #define NULL_NODEID_POINTER 62 #define MAX_FILE_SIZE_EXCEEDED 63 #define MAX_INT32_SIZE_EXCEEDED 64 #endif CGNS-4.5.0/src/adf/ADF.inc000066400000000000000000000205051474000356600146670ustar00rootroot00000000000000C C File: ADF.inc C ---------------------------------------------------------------------- C BOEING C ---------------------------------------------------------------------- C Project: CGNS C Authors: Tom Dickens 865-6122 tpd6908@yak.ca.boeing.com C Chuck Keagle 234-0990 keagle@cfdd38.cfd.ca.boeing.com C Date: 2/7/96 C Purpose: Provide FORTRAN definitions for the ADF-Core routines. C ---------------------------------------------------------------------- C ---------------------------------------------------------------------- implicit none C*********************************************************************** C Defines: These defines are used within the ADF core routines C to specify the size in bytes of various items. C Caution: Simply changing a define here may not correctly adjust the C ADF core code. These sizes are provided for reference only! C***********************************************************************/ integer ADF_DATA_TYPE_LENGTH integer ADF_DATE_LENGTH integer ADF_FILENAME_LENGTH integer ADF_FORMAT_LENGTH integer ADF_LABEL_LENGTH integer ADF_MAXIMUM_LINK_DEPTH integer ADF_MAX_DIMENSIONS integer ADF_MAX_ERROR_STR_LENGTH integer ADF_MAX_LINK_DATA_SIZE integer ADF_NAME_LENGTH integer ADF_STATUS_LENGTH integer ADF_VERSION_LENGTH parameter (ADF_DATA_TYPE_LENGTH = 32) parameter (ADF_DATE_LENGTH = 32 ) parameter (ADF_FILENAME_LENGTH = 1024) parameter (ADF_FORMAT_LENGTH = 20) parameter (ADF_LABEL_LENGTH = 32) parameter (ADF_MAXIMUM_LINK_DEPTH = 100) parameter (ADF_MAX_DIMENSIONS = 12) parameter (ADF_MAX_ERROR_STR_LENGTH = 80) parameter (ADF_MAX_LINK_DATA_SIZE = 4096) parameter (ADF_NAME_LENGTH = 32) parameter (ADF_STATUS_LENGTH = 32) parameter (ADF_VERSION_LENGTH = 32 ) !*********************************************************************** ! Error-return values ! These values need to be kept in sync with the error strings in ! file ADF_interface.c !*********************************************************************** ! Don't use zero since you can assign zero to a pointer integer NO_ERROR integer NUMBER_LESS_THAN_MINIMUM integer NUMBER_GREATER_THAN_MAXIMUM integer STRING_LENGTH_ZERO integer STRING_LENGTH_TOO_BIG integer STRING_NOT_A_HEX_STRING integer TOO_MANY_ADF_FILES_OPENED integer ADF_FILE_STATUS_NOT_RECOGNIZED integer FILE_OPEN_ERROR integer ADF_FILE_NOT_OPENED integer FILE_INDEX_OUT_OF_RANGE integer BLOCK_OFFSET_OUT_OF_RANGE integer NULL_STRING_POINTER integer FSEEK_ERROR integer FWRITE_ERROR integer FREAD_ERROR integer ADF_MEMORY_TAG_ERROR integer ADF_DISK_TAG_ERROR integer REQUESTED_NEW_FILE_EXISTS integer ADF_FILE_FORMAT_NOT_RECOGNIZED integer FREE_OF_ROOT_NODE integer FREE_OF_FREE_CHUNK_TABLE integer REQUESTED_OLD_FILE_NOT_FOUND integer UNIMPLEMENTED_CODE integer SUB_NODE_TABLE_ENTRIES_BAD integer MEMORY_ALLOCATION_FAILED integer DUPLICATE_CHILD_NAME integer ZERO_DIMENSIONS integer BAD_NUMBER_OF_DIMENSIONS integer CHILD_NOT_OF_GIVEN_PARENT integer DATA_TYPE_TOO_LONG integer INVALID_DATA_TYPE integer NULL_POINTER integer NO_DATA integer ERROR_ZEROING_OUT_MEMORY integer REQUESTED_DATA_TOO_LONG integer END_OUT_OF_DEFINED_RANGE integer BAD_STRIDE_VALUE integer MINIMUM_GT_MAXIMUM integer MACHINE_FORMAT_NOT_RECOGNIZED integer CANNOT_CONVERT_NATIVE_FORMAT integer CONVERSION_FORMATS_EQUAL integer DATA_TYPE_NOT_SUPPORTED integer FILE_CLOSE_ERROR integer NUMERIC_OVERFLOW integer START_OUT_OF_DEFINED_RANGE integer ZERO_LENGTH_VALUE integer BAD_DIMENSION_VALUE integer BAD_ERROR_STATE integer UNEQUAL_MEMORY_AND_DISK_DIMS integer LINKS_TOO_DEEP integer NODE_IS_NOT_A_LINK integer LINK_TARGET_NOT_THERE integer LINKED_TO_FILE_NOT_THERE integer NODE_ID_ZERO integer INCOMPLETE_DATA integer INVALID_NODE_NAME integer INVALID_VERSION integer NODES_NOT_IN_SAME_FILE integer PRISTK_NOT_FOUND integer MACHINE_FILE_INCOMPATABLE integer FFLUSH_ERROR integer NULL_NODEID_POINTER integer MAX_FILE_SIZE_EXCEEDED parameter (NO_ERROR = -1) parameter (NUMBER_LESS_THAN_MINIMUM = 1) parameter (NUMBER_GREATER_THAN_MAXIMUM = 2) parameter (STRING_LENGTH_ZERO = 3) parameter (STRING_LENGTH_TOO_BIG = 4) parameter (STRING_NOT_A_HEX_STRING = 5) parameter (TOO_MANY_ADF_FILES_OPENED = 6) parameter (ADF_FILE_STATUS_NOT_RECOGNIZED= 7) parameter (FILE_OPEN_ERROR = 8) parameter (ADF_FILE_NOT_OPENED = 9) parameter (FILE_INDEX_OUT_OF_RANGE = 10) parameter (BLOCK_OFFSET_OUT_OF_RANGE = 11) parameter (NULL_STRING_POINTER = 12) parameter (FSEEK_ERROR = 13) parameter (FWRITE_ERROR = 14) parameter (FREAD_ERROR = 15) parameter (ADF_MEMORY_TAG_ERROR = 16) parameter (ADF_DISK_TAG_ERROR = 17) parameter (REQUESTED_NEW_FILE_EXISTS = 18) parameter (ADF_FILE_FORMAT_NOT_RECOGNIZED= 19) parameter (FREE_OF_ROOT_NODE = 20) parameter (FREE_OF_FREE_CHUNK_TABLE = 21) parameter (REQUESTED_OLD_FILE_NOT_FOUND = 22) parameter (UNIMPLEMENTED_CODE = 23) parameter (SUB_NODE_TABLE_ENTRIES_BAD = 24) parameter (MEMORY_ALLOCATION_FAILED = 25) parameter (DUPLICATE_CHILD_NAME = 26) parameter (ZERO_DIMENSIONS = 27) parameter (BAD_NUMBER_OF_DIMENSIONS = 28) parameter (CHILD_NOT_OF_GIVEN_PARENT = 29) parameter (DATA_TYPE_TOO_LONG = 30) parameter (INVALID_DATA_TYPE = 31) parameter (NULL_POINTER = 32) parameter (NO_DATA = 33) parameter (ERROR_ZEROING_OUT_MEMORY = 34) parameter (REQUESTED_DATA_TOO_LONG = 35) parameter (END_OUT_OF_DEFINED_RANGE = 36) parameter (BAD_STRIDE_VALUE = 37) parameter (MINIMUM_GT_MAXIMUM = 38) parameter (MACHINE_FORMAT_NOT_RECOGNIZED = 39) parameter (CANNOT_CONVERT_NATIVE_FORMAT = 40) parameter (CONVERSION_FORMATS_EQUAL = 41) parameter (DATA_TYPE_NOT_SUPPORTED = 42) parameter (FILE_CLOSE_ERROR = 43) parameter (NUMERIC_OVERFLOW = 44) parameter (START_OUT_OF_DEFINED_RANGE = 45) parameter (ZERO_LENGTH_VALUE = 46) parameter (BAD_DIMENSION_VALUE = 47) parameter (BAD_ERROR_STATE = 48) parameter (UNEQUAL_MEMORY_AND_DISK_DIMS = 49) parameter (LINKS_TOO_DEEP = 50) parameter (NODE_IS_NOT_A_LINK = 51) parameter (LINK_TARGET_NOT_THERE = 52) parameter (LINKED_TO_FILE_NOT_THERE = 53) parameter (NODE_ID_ZERO = 54) parameter (INCOMPLETE_DATA = 55) parameter (INVALID_NODE_NAME = 56) parameter (INVALID_VERSION = 57) parameter (NODES_NOT_IN_SAME_FILE = 58) parameter (PRISTK_NOT_FOUND = 59) parameter (MACHINE_FILE_INCOMPATABLE = 60) parameter (FFLUSH_ERROR = 61) parameter (NULL_NODEID_POINTER = 62) parameter (MAX_FILE_SIZE_EXCEEDED = 63) CGNS-4.5.0/src/adf/ADF_fbind.h000066400000000000000000000075701474000356600155160ustar00rootroot00000000000000/*****************************************************************************/ /* McDonnell Douglas Corporation */ /*****************************************************************************/ /* */ /*****************************************************************************/ /* 'typedefs' and macro definitions for interfacing FORTRAN and C */ /*****************************************************************************/ #if defined(SYSTYPE) #undef SYSTYPE #endif #ifndef USE_ADF_MACROS /* use the CGNS Fortran macros */ #include "fortran_macros.h" #define SYSTYPE typedef VINTEGER Fint; typedef VFLOAT Freal; typedef VREAL Fdouble; typedef VCHARACTER *Fchar; #define F2CP(FCHAR) STR_PTR(FCHAR) #define FNAME(A,B) FMNAME(A,B) #else #if defined(__convexc__) /* Convex */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A ## _ #elif defined(cray) /* Cray */ #define SYSTYPE #include typedef int Fint; typedef float Freal; typedef double Fdouble; typedef _fcd Fchar; #define F2CP(FCHAR) (_fcdtocp(FCHAR)) #define FNAME(A,B) B #elif defined(__hpux) /* Hewlett Packard HP-UX */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A #elif defined(_AIX) /* IBM RS/6000 */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A #elif defined(__PARAGON__) /* Intel Paragon */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A ## _ #elif defined(sgi) /* Silicon Graphics */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A ## _ #elif defined(VMS) /* DEC VAX/VMS */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef struct dsc$descriptor_s *Fchar; #define F2CP(FCHAR) ((FCHAR)->dsc$a_pointer) #define FNAME(A,B) A #include #elif defined(__alpha) /* DEC ALPHA OSF/1 */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A ## _ #elif defined(PPRO) /* Pentium Pro (P6) using the Intel Reference Compiler */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A #elif defined(sun) /* Sun */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A ## _ #elif defined(_WIN32) /* WIN32 */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) B #elif defined(_CX_UX) /* Harris Nighthawk */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A ## _ #elif defined(m88k) #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A/**/_ #elif defined(__linux__) /* LINUX on Intel */ #define SYSTYPE typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A ## _ #else typedef int Fint; typedef float Freal; typedef double Fdouble; typedef char *Fchar; #define F2CP(FCHAR) (FCHAR) #define FNAME(A,B) A #endif #endif CGNS-4.5.0/src/adf/ADF_fortran.f000066400000000000000000000637231474000356600161070ustar00rootroot00000000000000c c*********************************************************************** c R1: Get Children names of a Node. Return the name of children nodes c directly associated with a parent node. The names of the children c are NOT guaranteed to be returned in any particular order. If a c new child is added, it is NOT guaranteed to be returned as the last c child. Note: To start with the first child, use an istart value of 1. c c f77: ADFCNAM( ID, istart, inum, inamlen, inumret, names, ierr ) c input: real*8 ID. The ID of the Node to use. c input: integer istart. The Nth child's name to start with (first=1). c input: integer inum. Maximum number of names to return. c input: integer inamlen. Length of names. c output: integer inumret. The number of names returned. c output: character*(*) names Array of names. c output: integer ierr. c*********************************************************************** subroutine ADFCNAM( ID, istart, inum, inamlen, inumret, names, 1 ierr ) IMPLICIT NONE real*8 ID integer istart integer inum integer inamlen integer inumret character*(*) names integer ierr call ADFCNA2( ID, istart, inum, inamlen, len(names), inumret, 1 names, ierr ) return end c*********************************************************************** c R1: Create a Node. Create a new node (not a link-node) as a child c of a given parent. Default values in this new node are: label=blank, c number of sub-nodes = 0, data-type = "MT", number of dimensions c = 0, data = NULL. c c f77: ADFCRE( PID, name, ID, ierr ) c input: real*8 PID. The ID of the parent node, to whom we are c creating a new child node. c input: character*(*) name. c output: real*8 ID. The ID of the newly created node. c output: integer ierr. c*********************************************************************** subroutine ADFCRE( PID, name, ID, ierr ) IMPLICIT NONE real*8 PID character*(*) name real*8 ID integer ierr call ADFCRE2( PID, name, LEN( name ), ID, ierr ) return end c*********************************************************************** c R1: Close an opened database. If the ADF database spans multiple c files then all files used will also be closed. If an ADF file which c is linked to by this database is also opened through another c database, only the opened file stream associated with this database c will be closed. c c f77: ADFDCLO( RootID, ierr ) c input: real*8 RootID Root ID of the database. c output: integer ierr. c*********************************************************************** subroutine ADFDCLO( RootID, ierr ) IMPLICIT NONE real*8 RootID integer ierr call ADFDCL2( RootID, ierr ) return end c*********************************************************************** c Rn: Delete an existing database. This will delete one or more ADF c files which are linked together under file top ADF file named c "filename". c c f77: ADFDDEL( filename, ierr ) c input: character*(*) filename c output: integer ierr. c*********************************************************************** subroutine ADFDDEL( filename, ierr ) IMPLICIT NONE character*(*) filename integer ierr call ADFDDE2( filename, LEN( filename ), ierr ) return end c*********************************************************************** c R2: Delete a Node. If the node is NOT a link, then the specified c node and all c sub-nodes anywhere under it are also deleted. For a link, and also c for links farther down in the tree, the link-node will be deleted, c but the node which the link is linked to is not affected. When a c node is deleted, other link-nodes which point to it are left c dangling. For example, if N13 is deleted, then L1 and L2 point to a c non-existing node. This is OK until L1 and L2 are used. c c f77: ADFDEL( PID, ID, ierr ) c input: real*8 PID. The ID of the node's parent. c input: real*8 ID. The ID of the node to use. c output: integer ierr. c*********************************************************************** subroutine ADFDEL( PID, ID, ierr ) IMPLICIT NONE real*8 PID real*8 ID integer ierr call ADFDEL2( PID, ID, ierr ) return end c*********************************************************************** c Rn: Garbage Collection. Redistribute data in the file to use free- c space which is not located at the end of the file. Neighboring free c spaces will be merged. Note: For better file compaction a utility c could be written to copy an ADF file, creating a new ADF file c without any wasted space. c c f77: ADFDGC( ID, ierr ) c input: real*8 ID. The ID of a node in the ADF file in which to do c garbage collection. c output: integer ierr. c*********************************************************************** subroutine ADFDGC( ID, ierr ) IMPLICIT NONE real*8 ID integer ierr call ADFDGC2( ID, ierr ) return end c*********************************************************************** c R1: Get the data format used in an existing database. c c f77: ADFDGF( RootID, format, ierr ) c input: real*8 RootID The rootID of the ADF file. c output: character*20 format. See format for ADFDOPN. c output: integer ierr. c*********************************************************************** subroutine ADFDGF( RootID, format, ierr ) IMPLICIT NONE real*8 RootID character*(*) format integer ierr call ADFDGF2( RootID, format, LEN( format ), ierr ) return end c*********************************************************************** c R1: Open a database. Open either a new or an existing ADF file. c If links to other ADF files are used, these additional files will be c opened automatically as required. c c f77: ADFDOPN( filename, status, format, rootID, ierr) c input: character*(*) filename. Not used if status SCRATCH is c used. Filename must be a legal name and may c include a relative or absolute path. It must be c directly usable by the C fopen() system c routine (no environment expansion is done). c input: character*(*) status. Like FORTRAN OPEN() status. c This field is required. Allowable values are: c READ_ONLY - File must exist. Writing NOT allowed. c OLD - File must exist. Reading and writing allowed. c NEW - File must not exist. c SCRATCH - New file. Filename is ignored. c UNKNOWN - OLD if file exists, else NEW is used. c input: character*(*) format. Specifies the numeric format for c the file. If blank, the machine's native c format is used. This field is only used when a c file is created. c NATIVE - Determine the format on the machine. If the c native format is not one of the formats c supported, the created file cannot be used on c other machines. c IEEE_BIG - Use the IEEE big ENDIAN format. c IEEE_LITTLE - Use the IEEE little ENDIAN format. c CRAY - Use the native Cray format. c output: real*8 rootID c output: integer ierr. c*********************************************************************** subroutine ADFDOPN( filename, status, format, rootID, ierr) IMPLICIT NONE character*(*) filename character*(*) status character*(*) format real*8 rootID integer ierr call ADFDOP2( filename, len( filename ), status, len( status ), 1 format, len( format ), rootID, ierr ) return end c*********************************************************************** c R1: Set the data format used in an existing database. c Note: Use with extreme caution. Needed only c for data conversion utilities and NOT intended c for the general user!!! c c f77: ADFDSF( RootID, format, ierr ) c input: real*8 RootID The rootID if the ADF file. c input: character*(*) format. See format for ADFDOPN. c output: integer ierr. c*********************************************************************** subroutine ADFDSF( RootID, format, ierr ) IMPLICIT NONE real*8 RootID character*(*) format integer ierr call ADFDSF2( RootID, format, len( format ), ierr ) return end c*********************************************************************** c R1: Get ADF File Version ID. This is the version number of the ADF c library routines which created an ADF database. Modified ADF databases c will take on the version ID of the current ADF library version if c it is higher than the version indicated in the file. c The format of the version ID is: "ADF Database Version 000.01" c c f77: ADFDVER( RootID, version, cdate, mdate, ierr ) c input: real*8 RootID. The ID of the root node in the ADF file. c output: character(32) version. A 32-byte character string c containing the version ID. c output: character(32) cdate. A 32-byte character string c containing the creation date of the file. c output: character(32) mdate. A 32-byte character c string containing the last modification date of the file. c output: integer ierr. c*********************************************************************** subroutine ADFDVER( RootID, version, cdate, mdate, ierr ) IMPLICIT NONE real*8 RootID character*(*) version character*(*) cdate character*(*) mdate integer ierr call ADFDVE2( RootID, version, cdate, mdate, 1 len( version ), len( cdate ), len( mdate ), ierr ) return end c*********************************************************************** c R1: Return Error Message. Given an ierr from an ADF routine, c get a textual description of the error. c c f77: ADFERR( ierr, errstr ) c input: integer ierr. c output: character(80) errstr. An 80-byte description of c the specified error. If the number is bad, the c string "Unknown error #nnn" is returned. c*********************************************************************** subroutine ADFERR( ierr, errstr ) IMPLICIT NONE integer ierr character*(*) errstr call ADFERR2( ierr, errstr, len( errstr ) ) return end c*********************************************************************** c R1: Flush data to disk. This routine is used to force any modified c information to be flushed to the physical disk. This ensures that c data will not be lost if a program aborts. This control of when to c flush all data to disk is provided to the user rather than to flush c the data every time it is modified, which would result in reduced c performance. c c f77: ADFFTD( ID, ierr ) c input: real*8 ID. The ID of a node in the ADF file in which to flush. c output: integer ierr. c*********************************************************************** subroutine ADFFTD( ID, ierr ) IMPLICIT NONE real*8 ID integer ierr call ADFFTD2( ID, ierr ) return end c*********************************************************************** c R1: Get Data Type. Return the 32 character string in a node's data- c type field. In C, the data-type will be null terminated after the last c non-blank character. A maximum of 33 characters may be used c (32 for the data-type plus 1 for the null). c c f77: ADFGDT( ID, dtype, ierr ) c input: real*8 ID. The ID of the node to use. c output: character*(*) dtype. The 32-character data-type of the node. c output: integer ierr. c*********************************************************************** subroutine ADFGDT( ID, dtype, ierr ) IMPLICIT NONE real*8 ID character*(*) dtype integer ierr call ADFGDT2( ID, dtype, len( dtype ), ierr ) return end c*********************************************************************** c R1: Get Dimension Values. Return the dimension values for a node. c Values will only be returned for the number of dimensions defined in c the node. If the number of dimensions for the node is zero, an c error is returned. c c f77: ADFGDV( ID, dvals, ierr ) c input: real*8 ID. The ID of the node to use. c output: integer dvals(12). c output: integer ierr. c*********************************************************************** subroutine ADFGDV( ID, dvals, ierr ) IMPLICIT NONE real*8 ID integer dvals(12) integer ierr call ADFGDV2( ID, dvals, ierr ) return end c*********************************************************************** c R1 Get Error State. Return the active error state. c c f77: ADFGES( estate, ierr ) c output: integer estate. Flag for ABORT on error (1) or return c error status (0). Set on a per database basis. c output: integer ierr. c*********************************************************************** subroutine ADFGES( estate, ierr ) IMPLICIT NONE integer estate integer ierr call ADFGES2( estate, ierr ) return end c*********************************************************************** c R1: Get Label. Return the 32 character string in a node's label field. c In C, the label will be null terminated after the last non-blank c character. A maximum of 33 characters may be used (32 for the c label plus 1 for the null). c c f77: ADFGLB( ID, label, ierr ) c input: real*8 ID. The ID of the node to use. c output: character*(*) label. The 32-character label of the node. c output: integer ierr. c*********************************************************************** subroutine ADFGLB( ID, label, ierr ) IMPLICIT NONE real*8 ID character*(*) label integer ierr call ADFGLB2( ID, label, len( label ), ierr ) return end c*********************************************************************** c R1: Get path information from a link. If the node is a link-node, c return the path information. Else, return an error. c If the link is in the same file, then a blank filename is returned. c c f77: ADFGLKP( ID, file, name, ierr ) c input: real*8 ID. The ID of the node to use. c output: character*(*) file. The filename. c output: character*(*) name. The name of node. c output: integer ierr. c*********************************************************************** subroutine ADFGLKP( ID, file, name, ierr ) IMPLICIT NONE real*8 ID character*(*) file character*(*) name integer ierr call ADFGLK2( ID, file, len( file ), name, len( name ), ierr ) return end c*********************************************************************** c R1: Get Name of a Node. Given a node's ID, return the 32 character c name of that node. In C, the name will be null terminated after the c last non-blank character. A maximum of 33 characters may be used c (32 for the name plus 1 for the null). c c f77: ADFGNAM( ID, name, ierr ) c input: real*8 ID. The ID of the node to use. c output: character*(*) name. The simple name of the node. c output: integer ierr. c*********************************************************************** subroutine ADFGNAM( ID, name, ierr ) IMPLICIT NONE real*8 ID character*(*) name integer ierr call ADFGNA2( ID, name, len( name ), ierr ) return end c*********************************************************************** c R1: Get Number of Dimensions. Return the number of data dimensions c used in a node. Valid values are from 0 to 12. c c f77: ADFGND( ID, ndims, ierr ) c input: real*8 ID. The ID of the node to use. c output: integer ndims. c output: integer ierr. c*********************************************************************** subroutine ADFGND( ID, ndims, ierr ) IMPLICIT NONE real*8 ID integer ndims integer ierr call ADFGND2( ID, ndims, ierr ) return end c*********************************************************************** c R1: Get Unique-Identifier of a Node. Given a parent node ID and a c a name of child node, return the ID of the child. To return the ID c of the root-node in an ADF file, use any known ID in the ADF file c and a name of "/". c c f77: ADFGNID( PID, name, ID, ierr ) c input: real*8 PID. The ID of the Node's parent. c input: character*(*) name. The name of the node. Compound c names including path information use a slash c "/" notation between node names. If a c leading slash is used, then PID can be any c valid node ID in the ADF database. c output: real*8 ID. The ID of the named node. c output: integer ierr. c*********************************************************************** subroutine ADFGNID( PID, name, ID, ierr ) IMPLICIT NONE real*8 PID character*(*) name real*8 ID integer ierr call ADFGNI2( PID, name, len( name ), ID, ierr ) return end c*********************************************************************** c R1: Get root-ID for an ADF system from any ID in the system. c c f77: ADFGRID( ID, RootID, ierr ) c input: real*8 ID. The ID of the node to use. c output: real*8 RootID. The ID of the root node. c output: integer ierr. c*********************************************************************** subroutine ADFGRID( ID, RootID, ierr ) IMPLICIT NONE real*8 ID real*8 RootID integer ierr call ADFGRI2( ID, RootID, ierr ) return end c*********************************************************************** c R1: Test if a Node is a link. If the actual data-type of the node c is "LK" (created with ADF_Link), return the link path length. c Otherwise, return 0. c c f77: ADFISLK( ID, lplen, ierr ) c input: real*8 ID. The ID of the node to use. c input: integer lplen. 0 if the node is NOT a link. If c the node is a link, the length of the path string is returned. c output: integer ierr. c*********************************************************************** subroutine ADFISLK( ID, lplen, ierr ) IMPLICIT NONE real*8 ID integer lplen integer ierr call ADFISL2( ID, lplen, ierr ) return end c*********************************************************************** c R1: Create a link. Note: The Node linked to does not have to exist c when the link is created (but it may exist and that is OK). However, c when the link is used, an error will occur if the linked to node does c not exist. c c f77: ADFLINK( PID, name, file, nfile, ID, ierr ) c input: real*8 PID. The ID of the Node's parent. c input: character*(*) name. The name of the link node. c input: character*(*) file. The filename to use for the link c (directly usable by a C open() routine). If c blank (null), the link will be within the same file. c input: character*(*) nfile. The name of the node which c the link will point to. This can be a simple or c compound name. c output: real*8 ID. The ID of the link-node. c output: integer ierr. c*********************************************************************** subroutine ADFLINK( PID, name, file, nfile, ID, ierr ) IMPLICIT NONE real*8 PID character*(*) name character*(*) file character*(*) nfile real*8 ID integer ierr call ADFLIN2( PID, name, file, nfile, len( name ), 1 len( file ), len( nfile ), ID, ierr ) return end c*********************************************************************** c R1: Get ADF Library Version ID. This is the version number of the c ADF library routines which your program is currently using. c The format of the version ID is: "ADF Library Version 000.01" c Note: There is a double space between Library and Version. This c lines up the number with the Database Version string. c c f77: ADFLVER( version, ierr ) c output: character(32) version. A 32-byte character string c containing the ADF Library version ID information. c output: integer ierr. c*********************************************************************** subroutine ADFLVER( version, ierr ) IMPLICIT NONE character*(*) version integer ierr call ADFLVE2( version, len( version ), ierr ) return end c*********************************************************************** c R2: Change Parent (move a Child Node). The node and the 2 parents c must all exist within a single ADF file. If the node is pointed to c by a link-node, changing the node's parent will break the link. c c f77: ADFMOVE( PID, ID, NPID, ierr ) c input: real*8 PID. The ID of the Node's parent. c input: real*8 ID. The ID of the node to use. c input: real*8 NPID. The ID of the Node's New Parent c output: integer ierr. c*********************************************************************** subroutine ADFMOVE( PID, ID, NPID, ierr ) IMPLICIT NONE real*8 PID real*8 ID real*8 NPID integer ierr call ADFMOV2( PID, ID, NPID, ierr ) return end c*********************************************************************** c R1: Get Number of Children of a Node. Return the number of children c nodes directly associated with a parent node. c c f77: ADFNCLD( ID, numcld, ierr ) c input: real*8 ID. The ID of the node to use. c output: integer numcld. The number of children directly c associated with this node. c output: integer ierr. c*********************************************************************** subroutine ADFNCLD( ID, numcld, ierr ) IMPLICIT NONE real*8 ID integer numcld integer ierr call ADFNCL2( ID, numcld, ierr ) return end c*********************************************************************** c R1: Set/change the data-type and Dimension Information of a Node. c Valid user-definable data-types are: c c No data MT c Integer 32 I4 c Integer 64 I8 c Unsigned Int 32 U4 c Unsigned Int 64 U8 c Real 32 R4 c Real 64 R8 c Complex 64 X4 c Complex 128 X8 c Character (unsigned byte) C1 c Byte (unsigned byte) B1 c Compound data-types can be used which combine types c ("I4,I4,R8"), define an array ("I4[25]"), or a combination of these c ("I4,C1[20],R8[3]"). c dims can be a number from 0 to 12. c dim_vals is an array of integers. The number of integers used is c determined by the dims argument. If dims is zero, the dim_values c are not used. Valid range for dim_values are from 1 to c 2,147,483,648. The total data size, calculated by the data-type-size c times the dimension value(s), cannot exceed 2,147,483,648. c Note: When this routine is called and the data-type or the c number of dimensions changes, any data currently associated c with the node is lost!! The dimension values can be changed and c the data space will be extended as needed. c- c f77: ADFPDIM( ID, dtype, dims, dvals, ierr) c input: real*8 ID. The ID of the node. c input: character*(*) dtype. c input: integer dims. The number of dimensions this node has. c input: integer dvals(12). The dimension values for this node. c output: integer ierr. c*********************************************************************** subroutine ADFPDIM( ID, dtype, dims, dvals, ierr) IMPLICIT NONE real*8 ID character*(*) dtype integer dims integer dvals(12) integer ierr call ADFPDI2( ID, dtype, len( dtype ), dims, dvals, ierr) return end c*********************************************************************** c R2: Put (change) Name of a Node. Warning: If the node is pointed c to by a link-node, changing the node's name will break the link. c c f77: ADFPNAM( PID, ID, name, ierr ) c input: real*8 PID. The ID of the Node's parent. c input: real*8 ID. The ID of the node to use. c input: character*(*) name. The new name of the node. c output: integer ierr. c*********************************************************************** subroutine ADFPNAM( PID, ID, name, ierr ) IMPLICIT NONE real*8 PID real*8 ID character*(*) name integer ierr call ADFPNA2( PID, ID, name, len( name ), ierr ) return end c*********************************************************************** c R1 Set Error State. For all ADF calls, set the error handling c convention; either return error codes, or abort the program on an error. c The default state for the ADF interface is to return error codes and NOT c abort. c c f77: ADFSES( estate, ierr ) c input: integer estate. Flag for ABORT on error (1) or return c error status (0). Set on a per database basis. c output: integer ierr. c*********************************************************************** subroutine ADFSES( estate, ierr ) IMPLICIT NONE integer estate integer ierr call ADFSES2( estate, ierr ) return end c*********************************************************************** c R1: Set Label. Set the 32 character string in a node's label field. c c f77: ADFSLB( ID, label, ierr ) c input: real*8 ID. The ID of the node to use. c input: character*(*) label. The 32-character label of the node. c output: integer ierr. c*********************************************************************** subroutine ADFSLB( ID, label, ierr ) IMPLICIT NONE real*8 ID character*(*) label integer ierr call ADFSLB2( ID, label, len( label ), ierr ) return end CGNS-4.5.0/src/adf/ADF_fortran_2_c.c000066400000000000000000001104331474000356600166160ustar00rootroot00000000000000/* created by combine 2.0 */ /* file ADFAAA2.c */ /*********************************************************************** ADF Core: Glue routines between the FORTRAN interface and the C interface. ***********************************************************************/ #include #include #include #include "ADF.h" #include "ADF_internals.h" #ifdef MEM_DEBUG #include "cg_malloc.h" #endif /* end of file ADFAAA2.c */ /* file ADFCNA2.c */ /*********************************************************************** ADFCNAM ADF_Children_Names: ***********************************************************************/ void FNAME(adfcna2,ADFCNA2)( const Fdouble *PID, const Fint *istart, const Fint *imaxnum, const Fint *idim, const Fint *name_length, Fint *inum_ret, Fchar names, Fint *error_return ) { int i; char *pstr, *tmp_names; if( *idim != *name_length ) { /** inconsistency **/ *error_return = BAD_DIMENSION_VALUE ; /** not really what this error code was meant for but it might do **/ return ; } /* end if */ pstr = F2CP(names); tmp_names = (char *) malloc( (*imaxnum) * (*name_length + 1) * (sizeof(char)) ) ; if( tmp_names == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; return ; } /* end if */ ADF_Children_Names( *PID, *istart, *imaxnum, *name_length, inum_ret, tmp_names, error_return ) ; if( *error_return != NO_ERROR ) { free( tmp_names ) ; return ; } /* end if */ for( i=0; i<*inum_ret; i++ ) { /* Blank-fill the names */ if( strlen( &tmp_names[ i * (*name_length+1) ]) == *name_length ) { /** string is maximum length, do not null terminate or blank fill **/ strncpy( &pstr[ i * (*name_length) ], &tmp_names[ i * (*name_length+1) ], *name_length ) ; } else { /** string is short enough, blank fill remainder **/ strcpy( &pstr[ i * (*name_length) ], &tmp_names[ i * (*name_length+1) ] ) ; ADFI_blank_fill_string( &pstr[ i * (*name_length) ], *name_length ) ; } /* end if */ } /* end for */ free( tmp_names ) ; } /* end of file ADFCNA2.c */ /* file ADFCID2.c */ /*********************************************************************** ADFCNAM ADF_Children_IDs: ***********************************************************************/ void FNAME(adfcid2,ADFCID2)( const Fdouble *PID, const Fint *istart, const Fint *imaxnum, Fint *inum_ret, Fdouble *CIDs, Fint *error_return ) { ADF_Children_IDs( *PID, *istart, *imaxnum, inum_ret, CIDs, error_return ) ; } /* end of file ADFCID2.c */ /* file ADFCRE2.c */ /*********************************************************************** ADFCRE ADF_Create: ***********************************************************************/ void FNAME(adfcre2,ADFCRE2)( const Fdouble *PID, const Fchar name, const Fint *name_length, Fdouble *ID, Fint *error_return ) { char c_name[ ADF_NAME_LENGTH + 1 ] ; ADFI_string_2_C_string( F2CP(name), MIN(ADF_NAME_LENGTH, *name_length), c_name, error_return ) ; if( *error_return != NO_ERROR ) return ; ADF_Create( *PID, c_name, ID, error_return ) ; } /* end of file ADFCRE2.c */ /* file ADFDCL2.c */ /*********************************************************************** ADFDCLO ADF_Database_Close: ***********************************************************************/ void FNAME(adfdcl2,ADFDCL2)( const Fdouble *Root_ID, Fint *error_return ) { ADF_Database_Close( *Root_ID, error_return ) ; } /* end of file ADFDCL2.c */ /* file ADFDDE2.c */ /*********************************************************************** ADFDDEL ADF_Database_Delete: ***********************************************************************/ void FNAME(adfdde2,ADFDDE2)( const Fchar filename, const Fint *name_length, Fint *error_return ) { char c_name[ ADF_FILENAME_LENGTH + 1 ] ; ADFI_string_2_C_string( F2CP(filename), MIN(ADF_FILENAME_LENGTH, *name_length), c_name, error_return ) ; if( *error_return != NO_ERROR ) return ; ADF_Database_Delete( c_name, error_return ) ; } /* end of file ADFDDE2.c */ /* file ADFDEL2.c */ /*********************************************************************** ADFDEL ADF_Delete: ***********************************************************************/ void FNAME(adfdel2,ADFDEL2)( const Fdouble *PID, const Fdouble *ID, Fint *error_return ) { ADF_Delete( *PID, *ID, error_return ) ; } /* end of file ADFDEL2.c */ /* file ADFDGC2.c */ /*********************************************************************** ADFDGC ADF_Database_Garbage_Collection: ***********************************************************************/ void FNAME(adfdgc2,ADFDGC2)( const Fdouble *ID, Fint *error_return ) { ADF_Database_Garbage_Collection( *ID, error_return ) ; } /* end of file ADFDGC2.c */ /* file ADFDGF2.c */ /*********************************************************************** ADFDGF ADF_Database_Get_Format: ***********************************************************************/ void FNAME(adfdgf2,ADFDGF2)( const Fdouble *Root_ID, Fchar format, const Fint *format_length, Fint *error_return ) { ADF_Database_Get_Format( *Root_ID, F2CP(format), error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_blank_fill_string( F2CP(format), *format_length ) ; } /* end of file ADFDGF2.c */ /* file ADFDOP2.c */ /*********************************************************************** ADFDOPN ADF_Database_Open: ***********************************************************************/ void FNAME(adfdop2,ADFDOP2)( const Fchar filename, const Fint *filename_length, Fchar status_in, const Fint *status_length, const Fchar format, const Fint *format_length, Fdouble *Root_ID, Fint *error_return ) { char c_filename[ ADF_FILENAME_LENGTH + 1 ], c_status[ ADF_NAME_LENGTH+1 ], c_format[ ADF_NAME_LENGTH+1 ] ; ADFI_string_2_C_string( F2CP(filename), MIN(ADF_FILENAME_LENGTH, *filename_length), c_filename, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_string_2_C_string( F2CP(status_in), MIN(ADF_NAME_LENGTH, *status_length), c_status, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_string_2_C_string( F2CP(format), MIN(ADF_NAME_LENGTH, *format_length), c_format, error_return ) ; if( *error_return != NO_ERROR ) return ; ADF_Database_Open( c_filename, c_status, c_format, Root_ID, error_return ) ; } /* end of file ADFDOP2.c */ /* file ADFDSF2.c */ /*********************************************************************** ADFDSF ADF_Database_Set_Format: ***********************************************************************/ void FNAME(adfdsf2,ADFDSF2)( const Fdouble *Root_ID, const Fchar format, const Fint *format_length, Fint *error_return ) { char c_format[ ADF_NAME_LENGTH + 1 ] ; ADFI_string_2_C_string( F2CP(format), MIN(ADF_NAME_LENGTH, *format_length), c_format, error_return ) ; if( *error_return != NO_ERROR ) return ; ADF_Database_Set_Format( *Root_ID, c_format, error_return ) ; } /* end of file ADFDSF2.c */ /* file ADFDVE2.c */ /*********************************************************************** ADVDVER ADF_Database_Version: ***********************************************************************/ void FNAME(adfdve2,ADFDVE2)( const Fdouble *Root_ID, Fchar version, Fchar creation_date, Fchar modification_date, const Fint *v_length, const Fint *c_length, const Fint *m_length, Fint *error_return ) { ADF_Database_Version( *Root_ID, F2CP(version), F2CP(creation_date), F2CP(modification_date), error_return ) ; ADFI_blank_fill_string( F2CP(version), *v_length ) ; ADFI_blank_fill_string( F2CP(creation_date), *c_length ) ; ADFI_blank_fill_string( F2CP(modification_date), *m_length ) ; } /* end of file ADFDVE2.c */ /* file ADFERR2.c */ /*********************************************************************** ADFERR ADF_Error_Message: ***********************************************************************/ void FNAME(adferr2,ADFERR2)( const Fint *error_return_input, Fchar error_string, const Fint *str_length ) { char msg_buf[ADF_MAX_ERROR_STR_LENGTH+1] ; ADF_Error_Message( *error_return_input, msg_buf ) ; strncpy( F2CP(error_string), msg_buf, *str_length ) ; ADFI_blank_fill_string( F2CP(error_string), *str_length ) ; } /* end of file ADFERR2.c */ /* file ADFFTD2.c */ /*********************************************************************** ADFFTD ADF_Flush_to_Disk: ***********************************************************************/ void FNAME(adfftd2,ADFFTD2)( const Fdouble *ID, Fint *error_return ) { ADF_Flush_to_Disk( *ID, error_return ) ; } /* end of file ADFFTD2.c */ /* file ADFGDT2.c */ /*********************************************************************** ADFGDT ADF_Get_Data_Type: ***********************************************************************/ void FNAME(adfgdt2,ADFGDT2)( const Fdouble *ID, Fchar data_type, const Fint *data_type_length, Fint *error_return ) { char ctype[ ADF_DATA_TYPE_LENGTH + 1 ] ; ADF_Get_Data_Type( *ID, ctype, error_return ) ; if( *error_return == NO_ERROR ) { if( strlen( ctype ) < *data_type_length ) { strcpy( F2CP(data_type), ctype ) ; ADFI_blank_fill_string( F2CP(data_type), *data_type_length ) ; } else { strncpy( F2CP(data_type), ctype, *data_type_length ) ; } /* end if */ } /* end if */ } /* end of file ADFGDT2.c */ /* file ADFGDV2.c */ /*********************************************************************** ADFGDV ADF_Get_Dimension_Values: ***********************************************************************/ void FNAME(adfgdv2,ADFGDV2)( const Fdouble *ID, Fint dim_vals[], Fint *error_return ) { ADF_Get_Dimension_Values( *ID, dim_vals, error_return ) ; } /* end of file ADFGDV2.c */ /* file ADFGES2.c */ /*********************************************************************** ADFGES ADF_Get_Error_State: ***********************************************************************/ void FNAME(adfges2,ADFGES2)( Fint *error_state, Fint *error_return ) { ADF_Get_Error_State( error_state, error_return ) ; } /* end of file ADFGES2.c */ /* file ADFGLB2.c */ /*********************************************************************** ADFGLB ADF_Get_Label: ***********************************************************************/ void FNAME(adfglb2,ADFGLB2)( const Fdouble *ID, Fchar label, const Fint *label_length, Fint *error_return ) { char clabel[ ADF_LABEL_LENGTH + 1 ] ; ADF_Get_Label( *ID, clabel, error_return ) ; if( *error_return == NO_ERROR ) { if( strlen( clabel ) < *label_length ) { strcpy( F2CP(label), clabel ) ; ADFI_blank_fill_string( F2CP(label), *label_length ) ; } else { strncpy( F2CP(label), clabel, *label_length ) ; } /* end if */ } /* end if */ } /* end of file ADFGLB2.c */ /* file ADFGLK2.c */ /*********************************************************************** ADFGLKP ADF_Get_Link_Path: ***********************************************************************/ void FNAME(adfglk2,ADFGLK2)( const Fdouble *ID, Fchar filename, const Fint *filename_length, Fchar link_path, const Fint *link_path_length, Fint *error_return ) { char cpath[ ADF_MAX_LINK_DATA_SIZE + 1 ], cfilename[ ADF_FILENAME_LENGTH + 1 ] ; ADF_Get_Link_Path( *ID, cfilename, cpath, error_return ) ; if( *error_return == NO_ERROR ) { if( strlen(cfilename) < *filename_length ) { strcpy( F2CP(filename), cfilename ) ; ADFI_blank_fill_string( F2CP(filename), *filename_length ) ; } else { strncpy( F2CP(filename), cfilename, *filename_length ) ; } /* end if */ if( strlen(cpath) < *link_path_length ) { strcpy( F2CP(link_path), cpath ) ; ADFI_blank_fill_string( F2CP(link_path), *link_path_length ) ; } else { strncpy( F2CP(link_path), cpath, *link_path_length ) ; } /* end if */ } /* end if */ } /* end of file ADFGLK2.c */ /* file ADFGNA2.c */ /*********************************************************************** ADFGNAM ADF_Get_Name: ***********************************************************************/ void FNAME(adfgna2,ADFGNA2)( const Fdouble *ID, Fchar name, const Fint *name_length, Fint *error_return ) { char cname[ ADF_NAME_LENGTH + 1 ] ; ADF_Get_Name( *ID, cname, error_return ) ; if( *error_return == NO_ERROR ) { if( strlen( cname ) < *name_length ) { strcpy( F2CP(name), cname ) ; ADFI_blank_fill_string( F2CP(name), *name_length ) ; } else { strncpy( F2CP(name), cname, *name_length ) ; } /* end if */ } /* end if */ } /* end of file ADFGNA2.c */ /* file ADFGND2.c */ /*********************************************************************** ADFGND ADF_Get_Number_of_Dimensions: ***********************************************************************/ void FNAME(adfgnd2,ADFGND2)( const Fdouble *ID, Fint *num_dims, Fint *error_return ) { ADF_Get_Number_of_Dimensions( *ID, num_dims, error_return ) ; } /* end of file ADFGND2.c */ /* file ADFGNI2.c */ /*********************************************************************** ADFGNID ADF_Get_Node_ID: ***********************************************************************/ void FNAME(adfgni2,ADFGNI2)( const Fdouble *PID, const Fchar name, const Fint *name_length, Fdouble *ID, Fint *error_return ) { char c_name[ ADF_FILENAME_LENGTH + 1 ] ; ADFI_string_2_C_string( F2CP(name), MIN(ADF_FILENAME_LENGTH, *name_length), c_name, error_return ) ; if( *error_return != NO_ERROR ) return ; ADF_Get_Node_ID( *PID, c_name, ID, error_return ) ; } /* end of file ADFGNI2.c */ /* file ADFGRI2.c */ /*********************************************************************** ADFGRID ADF_Get_Root_ID: ***********************************************************************/ void FNAME(adfgri2,ADFGRI2)( const Fdouble *ID, Fdouble *Root_ID, Fint *error_return ) { ADF_Get_Root_ID( *ID, Root_ID, error_return ) ; } /* end of file ADFGRI2.c */ /* file ADFISL2.c */ /*********************************************************************** ADFISLK ADF_Is_Link: ***********************************************************************/ void FNAME(adfisl2,ADFISL2)( const Fdouble *ID, Fint *link_path_length, Fint *error_return ) { ADF_Is_Link( *ID, link_path_length, error_return ) ; } /* end of file ADFISL2.c */ /* file ADFLIN2.c */ /*********************************************************************** ADFLINK ADF_Link: ***********************************************************************/ void FNAME(adflin2,ADFLIN2)( const Fdouble *PID, const Fchar name, const Fchar file, const Fchar name_in_file, const Fint *name_length, const Fint *file_length, const Fint *nfile_length, Fdouble *ID, Fint *error_return ) { char c_name[ ADF_FILENAME_LENGTH + 1 ], c_file[ ADF_FILENAME_LENGTH + 1 ], c_nfile[ ADF_MAX_LINK_DATA_SIZE + 1 ] ; ADFI_string_2_C_string( F2CP(name), MIN(ADF_FILENAME_LENGTH, *name_length), c_name, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_string_2_C_string( F2CP(file), MIN(ADF_FILENAME_LENGTH, *file_length), c_file, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_string_2_C_string( F2CP(name_in_file), MIN(ADF_MAX_LINK_DATA_SIZE, *nfile_length), c_nfile, error_return ) ; if( *error_return != NO_ERROR ) return ; ADF_Link( *PID, c_name, c_file, c_nfile, ID, error_return ) ; } /* end of file ADFLIN2.c */ /* file ADFLVE2.c */ /*********************************************************************** ADFLVER ADF_Library_Version: ***********************************************************************/ void FNAME(adflve2,ADFLVE2)( Fchar version, const Fint *version_length, Fint *error_return ) { ADF_Library_Version( F2CP(version), error_return ) ; ADFI_blank_fill_string ( F2CP(version), *version_length ); } /* end of file ADFLVE2.c */ /* file ADFMOV2.c */ /*********************************************************************** ADFMOVE ADF_Move_Child: ***********************************************************************/ void FNAME(adfmov2,ADFMOV2)( const Fdouble *PID, const Fdouble *ID, const Fdouble *NPID, Fint *error_return ) { ADF_Move_Child( *PID, *ID, *NPID, error_return ) ; } /* end of file ADFMOV2.c */ /* file ADFNCL2.c */ /*********************************************************************** ADFNCLD ADF_Number_of_Children: ***********************************************************************/ void FNAME(adfncl2,ADFNCL2)( const Fdouble *ID, Fint *num_children, Fint *error_return ) { ADF_Number_of_Children( *ID, num_children, error_return ) ; } /* end of file ADFNCL2.c */ /* file ADFPDI2.c */ /*********************************************************************** ADFPDIM ADF_Put_Dimension_Information: ***********************************************************************/ void FNAME(adfpdi2,ADFPDI2)( const Fdouble *ID, const Fchar data_type, const Fint *data_type_length, const Fint *dims, const Fint dim_vals[], Fint *error_return ) { char c_data_type[ ADF_DATA_TYPE_LENGTH + 1 ] ; /* CMLU */ int i; for (i=0;i= 0 ) { /** expecting character data type **/ ADF_Read_All_Data( *ID, F2CP(data), error_return ) ; } else { /** expecting non-character data type **/ ADF_Read_All_Data( *ID, data.c_pointer, (int *)data.fcd_len ) ; } #else ADF_Read_All_Data( *ID, F2CP(data), error_return ) ; #endif } /* end of file ADFRALL.c */ /* file ADFRBLK.c */ /*********************************************************************** ADFRBLK ADF_Read_Block_Data: Read block of data from a Node. Reads a block of the node's data and returns it into a contiguous memory space. input: real*8 ID The ID of the node to use. input: const int b_start The starting point in block in token space input: const int b_end The ending point in block in token space output: character *(*) data The start of the data in memory. output: integer error_return Error flag. ***********************************************************************/ void FNAME(adfrblk,ADFRBLK)( const Fdouble *ID, const Fint *b_start, const Fint *b_end, Fchar data, Fint *error_return ) { #if defined(cray) && defined(_ADDR64) int local_error ; char data_type[ ADF_DATA_TYPE_LENGTH + 1 ] ; char errmsg[ ADF_MAX_ERROR_STR_LENGTH + 1 ] ; /** see ADFWALL() for more details **/ ADF_Get_Data_Type( *ID, data_type, &local_error ) ; if( local_error != NO_ERROR ) { ADF_Error_Message( local_error, errmsg ) ; fprintf(stderr,"%s\n", errmsg ) ; fprintf(stderr,"Unrecoverable ADF error. ADFRBLK\n" ) ; fprintf(stderr,"Cannot determine data type, so cannot determine function\n" ) ; fprintf(stderr,"argument list (character arrays are different than other\n" ) ; fprintf(stderr,"types in this environment), so cannot set error_return.\n" ) ; abort () ; } /* end if */ if ( ADFI_stridx_c( data_type, "C1" ) >= 0 ) { /** expecting character data type **/ ADF_Read_Block_Data( *ID, (long) *b_start, (long) *b_end, F2CP(data), error_return ) ; } else { /** expecting non-character data type **/ ADF_Read_Block_Data( *ID, (long) *b_start, (long) *b_end, data.c_pointer, (int *)data.fcd_len ) ; } #else ADF_Read_Block_Data( *ID, (long) *b_start, (long) *b_end, F2CP(data), error_return ) ; #endif } /* end of file ADFRBLK.c */ /* file ADFREA2.c */ /* end of file ADFREA2.c */ /* file ADFREAD.c */ /*********************************************************************** ADFREAD ADF_Read_Data: A 1-based system is used with all index values (the first element has an index of 1, not 0). R1: Read data from a node, with partial capabilities. The partial capabilities are both in the node's data and also in memory. Vectors of integers are used to indicate the data to be accessed from the node, and another set of integer vectors is used to describe the memory location for the data. Note: If the data-type of the node is a compound data-type ("I4[3],R8") for example, the partial capabilities will access one or more of these 20-byte data entities. You cannot access a subset of an occurrence of the data-type. f77: ADFREAD( ID, sstart[], send[], sstrid[], mnumd, mdims[], mstart[], mend[], mstrid[], data, ierr ) input: real*8 ID The ID of the node to use. input: integer sstart(12) The starting dimension values to use in the database (node). input: integer send(12) The ending dimension values to use in the database (node). input: integer sstrid(12) The stride values to use in the database (node). input: integer mnumd The number of dimensions to use in memory. input: integer mdims(mnumd) The dimensionality to use in memory. input: integer mstart(mnumd) The starting dimension values to use in memory. input: integer mend(mnumd) The ending dimension values to use in memory. input: integer mstrid(mnumd) The stride values to use in memory. output: character*(*) data The start of the data in memory. output: integer ierr ***********************************************************************/ void FNAME(adfread,ADFREAD)( const Fdouble *ID, const Fint s_start[], const Fint s_end[], const Fint s_stride[], const Fint *m_num_dims, const Fint m_dims[], const Fint m_start[], const Fint m_end[], const Fint m_stride[], Fchar data, Fint *error_return ) { #if defined(cray) && defined(_ADDR64) int local_error ; char data_type[ ADF_DATA_TYPE_LENGTH + 1 ] ; char errmsg[ ADF_MAX_ERROR_STR_LENGTH + 1 ] ; /** see ADFWALL() for more details **/ ADF_Get_Data_Type( *ID, data_type, &local_error ) ; if( local_error != NO_ERROR ) { ADF_Error_Message( local_error, errmsg ) ; fprintf(stderr,"%s\n", errmsg ) ; fprintf(stderr,"Unrecoverable ADF error. ADFREAD\n" ) ; fprintf(stderr,"Cannot determine data type, so cannot determine function\n" ) ; fprintf(stderr,"argument list (character arrays are different than other\n" ) ; fprintf(stderr,"types in this environment), so cannot set error_return.\n" ) ; abort () ; } /* end if */ if ( ADFI_stridx_c( data_type, "C1" ) >= 0 ) { /** expecting character data type **/ ADF_Read_Data( *ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, F2CP(data), error_return ) ; } else { /** expecting non-character data type **/ ADF_Read_Data( *ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, data.c_pointer, (int *)data.fcd_len ) ; } #else ADF_Read_Data( *ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, F2CP(data), error_return ) ; #endif } /* end of file ADFREAD.c */ /* file ADFSES2.c */ /*********************************************************************** ADFSES ADF_Set_Error_State: ***********************************************************************/ void FNAME(adfses2,ADFSES2)( const Fint *error_state, Fint *error_return ) { ADF_Set_Error_State( *error_state, error_return ) ; } /* end of file ADFSES2.c */ /* file ADFSLB2.c */ /*********************************************************************** ADFSLB ADF_Set_Label: ***********************************************************************/ void FNAME(adfslb2,ADFSLB2)( const Fdouble *ID, const Fchar label, const Fint *label_length, Fint *error_return ) { char c_label[ ADF_LABEL_LENGTH + 1 ] ; ADFI_string_2_C_string( F2CP(label), MIN(ADF_LABEL_LENGTH, *label_length), c_label, error_return ) ; if( *error_return != NO_ERROR ) return ; ADF_Set_Label( *ID, c_label, error_return ) ; } /* end of file ADFSLB2.c */ /* file ADFWAL2.c */ /* end of file ADFWAL2.c */ /* file ADFWALL.c */ /*********************************************************************** ADFWALL ADF_Write_All_Data: Write all data to a Node. Writes all the node's data from a contiguous memory space. input: real*8 ID The node's id. input: character *(*) data The start of data in memory. output: integer error_return Error flag. ***********************************************************************/ void FNAME(adfwall,ADFWALL)( const Fdouble *ID, const Fchar data, Fint *error_return ) { #if defined(cray) && defined(_ADDR64) int local_error ; char data_type[ ADF_DATA_TYPE_LENGTH + 1 ] ; char errmsg[ ADF_MAX_ERROR_STR_LENGTH + 1 ] ; /** On Crays with 64 bit addresses (like Tritons), Fortran character arrays occupy two 64 bit words on argument stacks (see ). Other data (INTEGER, REAL, etc) occupy one word. To accommodate both situations with one function, some tricks need to be employed... **/ /** First, find the data type that ADF is expecting and assume the function is being called with that kind of argument. This function is defined with character data in mind and deviates from that if necessary. **/ ADF_Get_Data_Type( *ID, data_type, &local_error ) ; if( local_error != NO_ERROR ) { ADF_Error_Message( local_error, errmsg ) ; fprintf(stderr,"%s\n", errmsg ) ; fprintf(stderr,"Unrecoverable ADF error. ADFWALL\n" ) ; fprintf(stderr,"Cannot determine data type, so cannot determine function\n" ) ; fprintf(stderr,"argument list (character arrays are different than other\n" ) ; fprintf(stderr,"types in this environment), so cannot set error_return.\n" ) ; abort () ; } /* end if */ if ( ADFI_stridx_c( data_type, "C1" ) >= 0 ) { /** expecting character data type **/ ADF_Write_All_Data( *ID, F2CP(data), error_return ) ; } else { /** expecting data type other than character - the stack is not as long as is with character data and so "error_return" does not correspond to anything valid. Since "data" is declared Fchar but the actual argument is not, the second half of "data" contains the error flag argument (the stack is assumed to be contiguous). **/ ADF_Write_All_Data( *ID, data.c_pointer, (int *)data.fcd_len ) ; } #else /** In other CRAY environments the declared length is encoded in unused portions of pointers and the F2CP macro handles its conversion. In other environments, the character array declared length mystery argument is assumed to be on the end of the stack and is ignored here (F2CP macro does nothing). **/ ADF_Write_All_Data( *ID, F2CP(data), error_return ) ; #endif } /* end of file ADFWALL.c */ /* file ADFWBLK.c */ /*********************************************************************** ADFWBLK ADF_Write_Block_Data: Write block of data from a Node. Writes a block of the node's data and returns it into a contiguous memory space. input: real*8 ID The ID of the node to use. input: const int b_start The starting point in block in token space input: const int b_end The ending point in block in token space output: character *(*) data The start of the data in memory. output: integer error_return Error flag. ***********************************************************************/ void FNAME(adfwblk,ADFWBLK)( const Fdouble *ID, const Fint *b_start, const Fint *b_end, Fchar data, Fint *error_return ) { #if defined(cray) && defined(_ADDR64) int local_error ; char data_type[ ADF_DATA_TYPE_LENGTH + 1 ] ; char errmsg[ ADF_MAX_ERROR_STR_LENGTH + 1 ] ; /** see ADFWALL() for more details **/ ADF_Get_Data_Type( *ID, data_type, &local_error ) ; if( local_error != NO_ERROR ) { ADF_Error_Message( local_error, errmsg ) ; fprintf(stderr,"%s\n", errmsg ) ; fprintf(stderr,"Unrecoverable ADF error. ADFWBLK\n" ) ; fprintf(stderr,"Cannot determine data type, so cannot determine function\n" ) ; fprintf(stderr,"argument list (character arrays are different than other\n" ) ; fprintf(stderr,"types in this environment), so cannot set error_return.\n" ) ; abort () ; } /* end if */ if ( ADFI_stridx_c( data_type, "C1" ) >= 0 ) { /** expecting character data type **/ ADF_Write_Block_Data( *ID, (long) *b_start, (long) *b_end, F2CP(data), error_return ) ; } else { /** expecting non-character data type **/ ADF_Write_Block_Data( *ID, (long) *b_start, (long) *b_end, data.c_pointer, (int *)data.fcd_len ) ; } #else ADF_Write_Block_Data( *ID, (long) *b_start, (long) *b_end, F2CP(data), error_return ) ; #endif } /* end of file ADFWBLK.c */ /* file ADFWRI2.c */ /* end of file ADFWRI2.c */ /* file ADFWRIT.c */ /*********************************************************************** ADFWRIT ADF_Write_Data: Write data to a Node, with partial capabilities. See ADF_Read_Data for description. f77: ADFWRIT( ID, sstart[], send[], sstrid[], mnumd, mdims[], mstart[], mend[], mstrid[], data, ierr ) input: real*8 ID The ID of the node to use. input: integer sstart(12) The starting dimension values to use in the database (node). input: integer send(12) The ending dimension values to use in the database (node). input: integer sstrid(12) The stride values to use in the database (node). input: integer mnumd The number of dimensions to use in memory. input: integer mdims(mnumd) The dimensionality to use in memory. input: integer mstart(mnumd) The starting dimension values to use in memory. input: integer mend(mnumd) The ending dimension values to use in memory. input: integer mstrid(mnumd) The stride values to use in memory. input: character*(*) data The start of the data in memory. output: integer ierr ***********************************************************************/ void FNAME(adfwrit,ADFWRIT)( const Fdouble *ID, const Fint s_start[], const Fint s_end[], const Fint s_stride[], const Fint *m_num_dims, const Fint m_dims[], const Fint m_start[], const Fint m_end[], const Fint m_stride[], const Fchar data, Fint *error_return ) { #if defined(cray) && defined(_ADDR64) int local_error ; char data_type[ ADF_DATA_TYPE_LENGTH + 1 ] ; char errmsg[ ADF_MAX_ERROR_STR_LENGTH + 1 ] ; /** see ADFWALL() for more details **/ ADF_Get_Data_Type( *ID, data_type, &local_error ) ; if( local_error != NO_ERROR ) { ADF_Error_Message( local_error, errmsg ) ; fprintf(stderr,"%s\n", errmsg ) ; fprintf(stderr,"Unrecoverable ADF error. ADFWRIT\n" ) ; fprintf(stderr,"Cannot determine data type, so cannot determine function\n" ) ; fprintf(stderr,"argument list (character arrays are different than other\n" ) ; fprintf(stderr,"types in this environment), so cannot set error_return.\n" ) ; abort () ; } /* end if */ if ( ADFI_stridx_c( data_type, "C1" ) >= 0 ) { /** expecting character data type **/ ADF_Write_Data( *ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, F2CP(data), error_return ) ; } else { /** expecting non-character data type **/ ADF_Write_Data( *ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, data.c_pointer, (int *)data.fcd_len ) ; } #else ADF_Write_Data( *ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, F2CP(data), error_return ) ; #endif } /* end of file ADFWRIT.c */ /* end of combine 2.0 */ CGNS-4.5.0/src/adf/ADF_interface.c000066400000000000000000004750621474000356600163740ustar00rootroot00000000000000/* created by combine 2.0 */ /* file ADF_AAA_var.c */ /* file ADF_AAA_var.c */ /*** File: ADF_interface.c ---------------------------------------------------------------------- BOEING ---------------------------------------------------------------------- Project: CGNS Author: Tom Dickens 234-1024 tpd6908@yak.ca.boeing.com Date: 3/2/1995 Purpose: The code which implements the ADF-Core capabilities. ---------------------------------------------------------------------- ---------------------------------------------------------------------- ***/ /*********************************************************************** Library and Database "what" strings. ***********************************************************************/ /** Change the major revision letter in the Library Version for changes to the API (new public functions, changes to public header files, changes to existings functions or their defined behavior) and/or changes to the internal file format resulting in incompatibilites with previous library versions. Change the internal revision number for internal changes and bug fixes; reset to zero for major revision letter changes. **/ static char ADF_L_identification[] = "@(#)ADF Library Version F01>" ; /* 01234567890123456789012345678901 = 32 */ /** Change version database version number every time the library version changes according to the following philosophy. The format: AXXxxx where: A Major revision number. Major internal structure changes. This number is not expected to change very often if at all because backward compatibility is only available by explicit policy decision. One alphabetic character. Range of values: A-Za-z In unlikely event of reaching z, then can use any other unused printable ASCII character except blank or symbols used by "what" command: @, (, #, ), ~, >, \. XX Minor revision number. New features and minor changes and bug fixes. Files are backward but NOT forward compatible. Two digit hexadecimal number (uppercase letters). Range of values: 00 - FF Reset to 00 with changes in major revision number. xxx Incremental number. Incremented with every new version of library (even if no changes are made to file format). Files are forward AND backward compatible. Three digit hexadecimal number (lowercase letters) Range of values: 000 to fff Does not reset. Definitions: forward compatible Older versions of libraries can read and write to files created by newer versions of libraries. backward compatible Newer versions of libraries can read and write to files created by older versions of libraries. **/ /** change suggested by Kevin Mack of Adapco With the original ADF library, there is no binary data for at least the first 560 bytes, which causes a lot of programs (mailers, WinZip) to think that the file is text and try to do a \n -> \n\r conversion. Since this string is only used for the 'what' command, I am deciding that we don't need this functionality and am putting binary characters here. Specifically, I am putting control characters, because while some programs (Evolution/gnome-vfs) look for unprintable characters, some look for a ratio (Mozilla). **/ /** modification by Bruce Wedan I'm modifying the 1st 4 bytes of the header, @(#), by turning on the high bit. This makes these bytes non-ASCII and should not effect the check/reporting of version number **/ /* AXXxxx */ static char ADF_D_identification[] = "\300\250\243\251ADF Database Version B02012>" ; /* 0 1 2 3 4567890123456789012345678901 = 32 */ static char ADF_A_identification[] = "\300\250\243\251ADF Database Version A02011>" ; /*********************************************************************** Includes ***********************************************************************/ #ifndef _WIN32 #define _POSIX_C_SOURCE 200112L #endif #include #include #include #include #include #if defined(_WIN32) && !defined(__NUTC__) # include # ifndef F_OK # define R_OK 004 /* Test for Read permission */ # define W_OK 002 /* Test for Write permission */ # define X_OK 001 /* Test for eXecute permission */ # define F_OK 000 /* Test for existence of File */ # endif # define ACCESS _access #else # include # define ACCESS access #endif #include "ADF.h" #include "ADF_internals.h" #include "cgnstypes.h" #ifdef MEM_DEBUG #include "cg_malloc.h" #endif /*********************************************************************** Error strings These strings must be kept in sync with the error defines in ADF.h. ***********************************************************************/ const char *ADF_error_string[] = { "ADF -1: No Error.", "ADF 1: Integer number is less than given minimum value.", "ADF 2: Integer number is greater than given maximum value.", "ADF 3: String length of zero or blank string detected.", "ADF 4: String length longer than maximum allowable length.", "ADF 5: String is not an ASCII-HEX string.", "ADF 6: Too many ADF files opened.", "ADF 7: ADF file status was not recognized.", "ADF 8: ADF file-open error.", "ADF 9: ADF file not currently opened.", "ADF 10: ADF file index out of legal range.", "ADF 11: Block/offset out of legal range.", "ADF 12: A string pointer is NULL.", "ADF 13: FSEEK error.", "ADF 14: FWRITE error.", "ADF 15: FREAD error.", "ADF 16: Internal error: Memory boundary tag bad.", "ADF 17: Internal error: Disk boundary tag bad.", "ADF 18: File Open Error: NEW - File already exists.", "ADF 19: ADF file format was not recognized.", "ADF 20: Attempt to free the RootNode disk information.", "ADF 21: Attempt to free the FreeChunkTable disk information.", "ADF 22: File Open Error: OLD - File does not exist.", "ADF 23: Entered area of Unimplemented Code...", "ADF 24: Sub-Node.entries is bad.", "ADF 25: Memory allocation failed.", "ADF 26: Duplicate child name under a parent node.", "ADF 27: Node has no dimensions.", "ADF 28: Node's number-of-dimensions is not in legal range.", "ADF 29: Specified child is NOT a child of the specified parent.", "ADF 30: Data-Type is too long.", "ADF 31: Invalid Data-Type.", "ADF 32: A pointer is NULL.", "ADF 33: Node has no data associated with it.", "ADF 34: Error zeroing out memory.", "ADF 35: Requested data exceeds actual data available.", "ADF 36: Bad end value.", "ADF 37: Bad stride value.", "ADF 38: Minimum values is greater than the maximum value.", "ADF 39: The format of this machine does not match a known signature.", "ADF 40: Cannot convert to or from an unknown Native format.", "ADF 41: The two conversion formats are equal, no conversion done.", "ADF 42: The data format is not support on a particular machine.", "ADF 43: File Close error.", "ADF 44: Numeric overflow/underflow in data conversion.", "ADF 45: Bad start value.", "ADF 46: A value of zero is not allowable.", "ADF 47: Bad dimension value.", "ADF 48: Error state must be either a 0 (zero) or a 1 (one).", "ADF 49: Dimensional specifications for disk and memory are unequal.", "ADF 50: Too many link level used. May be caused by a recursive link.", "ADF 51: The node is not a link. It was expected to be a link.", "ADF 52: The linked-to node does not exist.", "ADF 53: The ADF file of a linked-node is not accessible.", "ADF 54: A node-id of 0.0 is not valid.", "ADF 55: Incomplete Data when reading multiple data blocks.", "ADF 56: Node name contains invalid characters.", "ADF 57: ADF file version incompatible with this library version.", "ADF 58: Nodes are not from the same file.", "ADF 59: Priority Stack Error.", "ADF 60: Machine format and file format are incompatible.", "ADF 61: FFLUSH error", "ADF 62: The node ID pointer is NULL.", "ADF 63: The maximum size for a file exceeded.", "ADF 64: Dimensions exceed that for a 32-bit integer.", "ADF x: Last error message" } ; /*********************************************************************** Global Variables: ***********************************************************************/ int ADF_sys_err = 0; static int ADF_abort_on_error = FALSE ; extern char data_chunk_start_tag[]; #define CHECK_ADF_ABORT( error_flag ) if( error_flag != NO_ERROR ) { \ if( ADF_abort_on_error == TRUE ) { \ ADF_Error_Message( error_flag, 0L );\ ADFI_Abort( error_flag) ; } \ else { return ; } } /* Added to remove memory leaks in ADF_Get_Node_ID */ #define CHECK_ADF_ABORT1( error_flag ) if( error_flag != NO_ERROR ) { \ free (name_tmp); \ if( ADF_abort_on_error == TRUE ) { \ ADF_Error_Message( error_flag, 0L );\ ADFI_Abort( error_flag) ; } \ else { return ; } } /*********************************************************************** Data Query: Note: If the node is a link, the data query will occur on the linked-to node, not the node which is the link. Internal Implementation: A linked node will have a data-type of "LK", dimension of 1 and a dimension value of the length of a data string containing the file-path and the node-path within the file. The routines ADF_Is_Link and ADF_Get_Link_Path allow viewing of a link's data-type and data. ***********************************************************************/ /*********************************************************************** Data I/O: A 1-based system is used with all index values (the first element has an index of 1, not 0). ***********************************************************************/ /* end of file ADF_AAA_var.c */ /* end of file ADF_AAA_var.c */ /* file ADF_Children_Names.c */ /*********************************************************************** ADF Children names: Get Children names of a Node. Return the name of children nodes directly associated with a parent node. The names of the children are NOT guaranteed to be returned in any particular order. If a new child is added, it is NOT guaranteed to be returned as the last child. Null-terminated names will be written into the names array and thus there needs to be room for the null character. As an example, the array can be defined as: char names[IMAX_NUM][IMAX_NAME_LENGTH+1]; where IMAX_NUM and IMAX_NAME_LENGTH are defined by the using application and correspond to this function's "imax_num" and "imax_name_len" parameters respectively. "imax_name_len" is the maximum length of a name to be copied into the names array. This value can be equal to ADF_NAME_LENGTH but does not have to be. However, the name dimension of the array MUST be declared to be "imax_name_len" + 1. The name will be returned truncated (but still null-terminated) if the actual name is longer than "imax_name_len" and if "imax_name_len" is less than ADF_NAME_LENGTH. Note that the names array parameter is declared as a single dimension character array inside this function. Therefore, use a (char *) cast to cast a two dimensional array argument. ADF_Children_Names( PID, istart, imax_num, imax_name_len, inum_ret, names, error_return ) input: const double PID The ID of the Node to use. input: const int istart The Nth child's name to start with (first is 1). input: const int imax_num Maximum number of names to return. input: const int imax_name_len Maximum Length of a name to return. output: int *inum_ret The number of names returned. output: char *names The returned names (cast with (char *)). output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER NUMBER_LESS_THAN_MINIMUM ***********************************************************************/ void ADF_Children_Names( const double PID, const int istart, const int imax_num, const int imax_name_len, int *inum_ret, char *names, int *error_return ) { int i ; unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; struct SUB_NODE_TABLE_ENTRY sub_node_table_entry ; double LID ; *error_return = NO_ERROR ; if( inum_ret == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *inum_ret = 0 ; if( names == NULL ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( (istart <=0) || (imax_num <= 0) || (imax_name_len <= 0) ) { *error_return = NUMBER_LESS_THAN_MINIMUM ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ ADFI_chase_link( PID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Check for zero children, return if 0 **/ if( node.num_sub_nodes == 0 ) { return ; } /* end if */ /** point to the first child wanted **/ block_offset.block = node.sub_node_table.block ; block_offset.offset = node.sub_node_table.offset + (TAG_SIZE + DISK_POINTER_SIZE + (ADF_NAME_LENGTH + DISK_POINTER_SIZE) * (istart-1)) ; /** Return the data for the requested children **/ for( i=(istart-1); i< MIN(istart-1+imax_num, (int) node.num_sub_nodes); i++ ) { ADFI_adjust_disk_pointer( &block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Read the sun-node entry table **/ ADFI_read_sub_node_table_entry( file_index, &block_offset, &sub_node_table_entry, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Convert the child's name from blank-filled into a C string **/ ADFI_string_2_C_string( sub_node_table_entry.child_name, MIN(imax_name_len,ADF_NAME_LENGTH), &names[(i-(istart-1))*(imax_name_len+1)], error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Increment the disk-pointer and the number of names returned **/ block_offset.offset += (ADF_NAME_LENGTH + DISK_POINTER_SIZE) ; *inum_ret = *inum_ret + 1 ; } /* end for */ } /* end of ADF_Children_Names */ /* end of file ADF_Children_Names.c */ /* file ADF_Children_IDs.c */ /*********************************************************************** ADF Children IDs: Get Children node IDs of a Node. Return the node IDs of children nodes directly associated with a parent node. ADF_Children_IDs( PID, istart, imax_num, inum_ret, IDs, error_return) input: const double PID The ID of the Node to use. input: const int istart The Nth child's name to start with (first is 1). input: const int imax_num Maximum number of names to return. output: int *inum_ret The number of names returned. output: double *IDs The returned node IDs output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER NUMBER_LESS_THAN_MINIMUM ***********************************************************************/ void ADF_Children_IDs ( const double PID, const int istart, const int imax_num, int *inum_ret, double *IDs, int *error_return ) { int i ; unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; struct SUB_NODE_TABLE_ENTRY sub_node_table_entry ; double LID ; *error_return = NO_ERROR ; if( inum_ret == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *inum_ret = 0 ; if( IDs == NULL ) { *error_return = NULL_NODEID_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( (istart <=0) || (imax_num <= 0) ) { *error_return = NUMBER_LESS_THAN_MINIMUM ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ ADFI_chase_link( PID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Check for zero children, return if 0 **/ if( node.num_sub_nodes == 0 ) { return ; } /* end if */ /** point to the first child wanted **/ block_offset.block = node.sub_node_table.block ; block_offset.offset = node.sub_node_table.offset + (TAG_SIZE + DISK_POINTER_SIZE + (ADF_NAME_LENGTH + DISK_POINTER_SIZE) * (istart-1)) ; /** Return the data for the requested children **/ for( i=(istart-1); i< MIN(istart-1+imax_num, (int) node.num_sub_nodes); i++ ) { ADFI_adjust_disk_pointer( &block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Read the sub-node entry table **/ ADFI_read_sub_node_table_entry( file_index, &block_offset, &sub_node_table_entry, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get the ID from the sub-node table **/ ADFI_file_block_offset_2_ID( file_index, sub_node_table_entry.child_location.block, sub_node_table_entry.child_location.offset, &IDs[i-(istart-1)], error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Increment the disk-pointer and the number of IDs returned **/ block_offset.offset += (ADF_NAME_LENGTH + DISK_POINTER_SIZE) ; *inum_ret = *inum_ret + 1 ; } /* end for */ } /* end of ADF_Children_IDs */ /* end of file ADF_Children_IDs.c */ /* file ADF_Create.c */ /*********************************************************************** ADF Create: Create a Node. Create a new node (not a link-node) as a child of a given parent. Default values in this new node are: label=blank, number of sub-nodes = 0, data-type = "MT", number of dimensions = 0, data = NULL. ADF_Create( PID, name, ID, error_return ) input: const double PID The ID of the parent node, to whom we are creating a new child node. input: const char *name The name of the new child. output: double *ID The ID of the newly created node. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADF_Create( const double PID, const char *name, double *ID, int *error_return ) { unsigned int file_index ; struct DISK_POINTER parent_block_offset, child_block_offset ; struct DISK_POINTER sub_node_entry_location ; struct NODE_HEADER parent_node, child_node ; struct SUB_NODE_TABLE_ENTRY sub_node_entry ; int i, name_length, name_start, found ; double LID ; ADFI_check_string_length( name, ADF_NAME_LENGTH, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( ID == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( PID, &LID, &file_index, &parent_block_offset, &parent_node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Initialize node header **/ ADFI_fill_initial_node_header( &child_node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Skip any leading blanks in the name **/ name_start = 0 ; while( name[ name_start ] == ' ' ) { name_start++ ; } /* end while */ name_length = (int)strlen( &name[ name_start ] ) ; if( name_length > ADF_NAME_LENGTH ) { *error_return = STRING_LENGTH_TOO_BIG ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Check for uniqueness and legality of the name **/ ADFI_check_4_child_name( file_index, &parent_block_offset, &name[ name_start ], &found, &sub_node_entry_location, &sub_node_entry, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( found == 1 ) { *error_return = DUPLICATE_CHILD_NAME ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ for ( i=0; i < name_length; i++ ) { if ( ! isprint ( name[ name_start + i ] ) || name[ name_start + i ] == '/' ) { *error_return = INVALID_NODE_NAME; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ } /* end for */ /** Assign the name to the new node **/ strncpy( child_node.name, &name[ name_start ], name_length ) ; /** Allocate disk space for the new node **/ ADFI_file_malloc( file_index, NODE_HEADER_SIZE, &child_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Write out the new node header **/ ADFI_write_node_header( file_index, &child_block_offset, &child_node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** OK, new node is on disk. Now, update the list of children for the parent... **/ ADFI_add_2_sub_node_table( file_index, &parent_block_offset, &child_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Return the ID of the new child **/ ADFI_file_block_offset_2_ID( file_index, child_block_offset.block, child_block_offset.offset, ID, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Finally, update modification date **/ ADFI_write_modification_date( file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Create */ /* end of file ADF_Create.c */ /* file ADF_Database_Close.c */ /*********************************************************************** ADF Database Close: Close an opened database. If the ADF database spans multiple files, then all files used will also be closed. If an ADF file which is linked to by this database is also opened through another database, only the opened file stream associated with this database will be closed. ADF_Database_Close( Root_ID, error_return ) input: const double Root_ID Root-ID of the ADF database. output: int *error_return Error return. ***********************************************************************/ void ADF_Database_Close( const double Root_ID, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; *error_return = NO_ERROR ; /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( Root_ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Close the ADF file (which may close other sub-files) **/ ADFI_close_file( file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Database_Close */ /* end of file ADF_Database_Close.c */ /* file ADF_Database_Delete.c */ /*********************************************************************** ADF Database Delete: Delete an existing database. This will delete one or more ADF files which are linked together under file top ADF file named "filename". ADF_Database_Delete( filename, error_return ) input: char *filename Filename of the ADF database to delete. output: int *error_return Error return. ***********************************************************************/ void ADF_Database_Delete( const char *filename, int *error_return ) { ADFI_check_string_length( filename, ADF_FILENAME_LENGTH, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; fprintf(stderr,"Subroutine ADF_Database_Delete is not yet implemented...\n" ) ; *error_return = UNIMPLEMENTED_CODE ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Database_Delete */ /* end of file ADF_Database_Delete.c */ /* file ADF_Database_Garbage_Collection.c */ /*********************************************************************** ADF Database Garbage Collection: Garbage Collection. This capability will most likely be implemented internally and will not be user-callable. ADF_Database_Garbage_Collection( ID, error_return ) input: const double ID The ID of a node in the ADF file in which to do garbage collection. output: int *error_return Error return. ***********************************************************************/ void ADF_Database_Garbage_Collection( const double ID, int *error_return ) { fprintf(stderr, "Subroutine ADF_Database_Garbage_Collection is not yet implemented...\n" ) ; *error_return = UNIMPLEMENTED_CODE ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Database_Garbage_Collection */ /* end of file ADF_Database_Garbage_Collection.c */ /* file ADF_Database_Get_Format.c */ /*********************************************************************** ADF Database Get Format: Get the data format used in an existing database. ADF_Database_Get_Format( Root_ID, format, error_return ) input: const double Root_ID The root_ID of the ADF file. output: char *format See format for ADFDOPN. Maximum of 20 characters returned. output: int *error_return Error return. ***********************************************************************/ void ADF_Database_Get_Format( const double Root_ID, char *format, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct FILE_HEADER file_header ; if( format == NULL ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( Root_ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get node_header for the node **/ ADFI_read_file_header( file_index, &file_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; #define EVAL_2_BYTES( C0, C1 ) (((C0)<<8)+((C1))) switch( EVAL_2_BYTES( file_header.numeric_format, file_header.os_size ) ) { case EVAL_2_BYTES( 'B', 'L' ) : strcpy( format, IEEE_BIG_32_FORMAT_STRING ) ; break ; case EVAL_2_BYTES( 'L', 'L' ) : strcpy( format, IEEE_LITTLE_32_FORMAT_STRING ) ; break ; case EVAL_2_BYTES( 'B', 'B' ) : strcpy( format, IEEE_BIG_64_FORMAT_STRING ) ; break ; case EVAL_2_BYTES( 'L', 'B' ) : strcpy( format, IEEE_LITTLE_64_FORMAT_STRING ) ; break ; case EVAL_2_BYTES( 'C', 'B' ) : strcpy( format, CRAY_FORMAT_STRING ) ; break ; case EVAL_2_BYTES( 'N', 'L' ) : case EVAL_2_BYTES( 'N', 'B' ) : strcpy( format, NATIVE_FORMAT_STRING ) ; break ; default: *error_return = ADF_FILE_FORMAT_NOT_RECOGNIZED ; return ; } /* end switch */ } /* end of ADF_Database_Get_Format */ /* end of file ADF_Database_Get_Format.c */ /* file ADF_Database_Open.c */ /*********************************************************************** ADF Database Open: Open a database. Open either a new or an existing ADF file. If links to other ADF files are used, these additional file will be opened automatically as required. ADF_Database_Open( filename, status, format, root_ID, error_return) input: const char *filename Not used if status SCRATCH is used. Filename must be a legal name and may include a relative or absolute path. It must be directly usable by the C fopen() system routine. input: const char *status_in Like FORTRAN OPEN() status. Allowable values are: READ_ONLY - File must exist. Writing NOT allowed. OLD - File must exist. Reading and writing allowed. NEW - File must not exist. SCRATCH - New file. Filename is ignored. UNKNOWN - OLD if file exists, else NEW is used. input: const char *format Specifies the numeric format for the file. If blank or NULL, the machine's native format is used. This field is only used when a file is created. NATIVE - Determine the format on the machine. If the native format is not one of the formats supported, the created file cannot be used on other machines. IEEE_BIG - Use the IEEE big ENDIAN format. IEEE_LITTLE - Use the IEEE little ENDIAN format. CRAY - Use the native Cray format. output: double *root_ID Root-ID of the opened ADF database. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER ADF_FILE_STATUS_NOT_RECOGNIZED REQUESTED_NEW_FILE_EXISTS FILE_OPEN_ERROR ***********************************************************************/ void ADF_Database_Open( const char *filename, const char *status_in, const char *format, double *Root_ID, int *error_return ) { int iret, legacy = 0 ; int error_dummy ; char machine_format, format_to_use, os_to_use ; char *status ; int formats_compare ; unsigned int file_index ; unsigned int file_minor_version, lib_minor_version ; struct FILE_HEADER file_header ; struct NODE_HEADER node_header ; struct FREE_CHUNK_TABLE free_chunk_table ; file_header.tag0[0] = '\0' ; status = (char *)status_in ; if( status == NULL ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( Root_ID == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** DO NOT Check filename for NULL here, it may NOT be used... **/ *error_return = NO_ERROR ; /** Get this machine's numeric format **/ ADFI_figure_machine_format( format, &machine_format, &format_to_use, &os_to_use, error_return ) ; if( ADFI_stridx_c( status, "SCRATCH" ) != 0 ) { ADFI_check_string_length( filename, ADF_FILENAME_LENGTH, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ ADFI_check_string_length( status, ADF_STATUS_LENGTH, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Determine the requested STATUS **/ if( ADFI_stridx_c( status, "UNKNOWN" ) == 0 ) { /** Determine the assessability of the filename **/ iret = ACCESS( filename, F_OK ) ; if( iret != 0 ) /* File does not exist, set status to NEW */ status = "NEW" ; else status = "OLD" ; } /* end else if */ if( (ADFI_stridx_c( status, "READ_ONLY" ) == 0) || (ADFI_stridx_c( status, "OLD" ) == 0) ) { /** Determine the assessability of the filename **/ iret = ACCESS( filename, F_OK ) ; if( iret != 0 ) { /* File does not exist, this is BAD for OLD */ *error_return = REQUESTED_OLD_FILE_NOT_FOUND ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** open the file **/ ADFI_open_file( filename, status, &file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else if */ else if( (ADFI_stridx_c( status, "NEW" ) == 0) || (ADFI_stridx_c( status, "SCRATCH" ) == 0) ) { /** Determine the assessability of the filename **/ if( ADFI_stridx_c( status, "NEW" ) == 0 ) { iret = ACCESS( filename, F_OK ) ; if( iret == 0 ) { /* File exists, this is BAD for NEW */ *error_return = REQUESTED_NEW_FILE_EXISTS ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( errno != ENOENT ) { *error_return = FILE_OPEN_ERROR ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ } /* end if */ if (ADFI_stridx_c(format, "LEGACY") == 0) legacy = 1; /** Compose the file header **/ ADFI_fill_initial_file_header( format_to_use, os_to_use, legacy ? ADF_A_identification : ADF_D_identification, &file_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Open the new file **/ ADFI_open_file( filename, status, &file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /* need this to write header */ ADF_file[file_index].old_version = (char)legacy; ADF_file[file_index].format = format_to_use; ADF_file[file_index].os_size = os_to_use; /** write out the file header **/ ADFI_write_file_header( file_index, &file_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Compose Initial root-node header **/ ADFI_fill_initial_node_header( &node_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; strncpy( node_header.name, ROOT_NODE_NAME, strlen( ROOT_NODE_NAME )) ; strncpy( node_header.label, ROOT_NODE_LABEL, strlen( ROOT_NODE_LABEL ) ) ; /** Write out the root-node header **/ ADFI_write_node_header( file_index, &file_header.root_node, &node_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Compose Initial Free-Chunk Table **/ ADFI_fill_initial_free_chunk_table( &free_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Write out Free-Chunk Table **/ ADFI_write_free_chunk_table( file_index, &free_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else if */ else { *error_return = ADF_FILE_STATUS_NOT_RECOGNIZED ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ /** Read the header of the ADF file **/ if( file_header.tag0[0] == '\0' ) { ADFI_read_file_header( file_index, &file_header, error_return ) ; if ( *error_return != NO_ERROR ) goto Open_Error ; /** Check Database version numbers for compatibility **/ if( file_header.what[25] != ADF_D_identification[25] ) { /* Look at major revision letter: version in file must equal what this library would write unless there is a policy decision to support both versions. */ if (file_header.what[25] == 'A') ADF_file[file_index].old_version = 1 ; else { *error_return = INVALID_VERSION ; goto Open_Error ; } } /* end if */ if( file_header.what[28] == '>' ) { /* we have an old file created before this version numbering scheme was instituted - probably will not work */ *error_return = INVALID_VERSION ; if ( *error_return != NO_ERROR ) goto Open_Error ; } else /* check version number for file format compatibility */ { /* Look at minor revision number: version in file must be less than or equal to what this library would write. */ ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &file_header.what[26], &file_minor_version, error_return) ; if ( *error_return != NO_ERROR ) goto Open_Error ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &ADF_D_identification[26], &lib_minor_version, error_return) ; if ( *error_return != NO_ERROR ) goto Open_Error ; if( file_minor_version > lib_minor_version ) { *error_return = INVALID_VERSION ; if ( *error_return != NO_ERROR ) goto Open_Error ; } /* end if */ if( file_minor_version < lib_minor_version ) { /** If a new feature is added which requires that the file version be changed then it is done here. Care must be take not to break forward compatibility by changing the file version. Thus new features may not be available for older file versions. For instance version A1 files cannot be upgraded to version A2 and above since a change was made to how links were store and the file version is used to decide how to treat links. **/ if ( ADF_D_identification[25] == 'A' && file_minor_version > 1 ) { ADFI_remember_version_update( file_index, ADF_D_identification, error_return ) ; if ( *error_return != NO_ERROR ) goto Open_Error ; } /* end if */ /** The link separator was changed from " " to ">" in order to support blanks in filenames under Windows. This change is for version A02 and higher **/ if ( ADF_D_identification[25] == 'A' && file_minor_version < 2 ) { ADF_file[file_index].link_separator = ' ' ; } /* end if */ } /* end if */ } /* end if */ } /* end if */ /** get the root ID for the user **/ ADFI_file_block_offset_2_ID( file_index, file_header.root_node.block, file_header.root_node.offset, Root_ID, error_return ) ; if ( *error_return != NO_ERROR ) goto Open_Error ; /** Remember the file's data format **/ ADFI_remember_file_format( file_index, file_header.numeric_format, file_header.os_size, error_return ) ; if ( *error_return != NO_ERROR ) goto Open_Error ; /** check machine modes, if machine is native the file must be !! **/ ADFI_file_and_machine_compare( file_index, NULL, &formats_compare, error_return ) ; if ( *error_return != NO_ERROR ) goto Open_Error ; return ; Open_Error: /** Close the ADF file and free its index **/ ADFI_close_file( file_index, &error_dummy ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Database_Open */ /* end of file ADF_Database_Open.c */ /*********************************************************************** ADF Database Valid: Checks if a file is a valid ADF file. If status if given, then check if the file can be opened in that mode. ADF_Database_Valid( filename, status, error_return) input: const char *filename Filename must be a legal name and may include a relative or absolute path. It must be directly usable by the C fopen() system routine. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER FILE_OPEN_ERROR ADF_FILE_FORMAT_NOT_RECOGNIZED ***********************************************************************/ void ADF_Database_Valid( const char *filename, int *error_return ) { FILE *fp; char header[33]; if (NULL == filename || 0 == *filename) { *error_return = NULL_STRING_POINTER; return; } if (ACCESS(filename, F_OK)) { *error_return = REQUESTED_OLD_FILE_NOT_FOUND; return; } if ((fp = fopen(filename, "rb")) == NULL) { if (errno == EMFILE) *error_return = TOO_MANY_ADF_FILES_OPENED; else *error_return = FILE_OPEN_ERROR; return; } if (32 != fread (header, sizeof(char), 32, fp)) { *error_return = FREAD_ERROR; fclose (fp); return; } fclose (fp); header[32] = 0; if (strncmp (&header[4], "ADF Database Version", 20)) *error_return = ADF_FILE_FORMAT_NOT_RECOGNIZED; else *error_return = NO_ERROR; } /* file ADF_Database_Set_Format.c */ /*********************************************************************** ADF Database Set Format: Set the data format used in an existing database. Note: Use with extreme caution. Needed only for data conversion utilities and NOT intended for the general user!!! ADF_Database_Set_Format( Root_ID, format, error_return ) input: const double Root_ID The root_ID if the ADF file. input: const char *format See format for ADFDOPN. output: int *error_return Error return. ***********************************************************************/ void ADF_Database_Set_Format( const double Root_ID, const char *format, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct FILE_HEADER file_header ; char machine_format, format_to_use, os_to_use ; ADFI_check_string_length( format, ADF_FORMAT_LENGTH, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( Root_ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get node_header for the node **/ ADFI_read_file_header( file_index, &file_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_figure_machine_format( format, &machine_format, &format_to_use, &os_to_use, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; file_header.numeric_format = format_to_use ; file_header.os_size = os_to_use ; /** Get modification date to be updated with the header **/ ADFI_get_current_date ( file_header.modification_date ); /** Now write the disk header out... **/ ADFI_write_file_header( file_index, &file_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_remember_file_format( file_index, format_to_use, os_to_use, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Database_Set_Format */ /* end of file ADF_Database_Set_Format.c */ /* file ADF_Database_Version.c */ /*********************************************************************** ADF Database Version: Get ADF File Version ID. This is the version number of the ADF library routines which created an ADF database. Modified ADF databases will take on the version ID of the current ADF library version if it is higher than the version indicated in the file. The format of the version ID is: "ADF Database Version 000.01" ADF_Database_Version( Root_ID, version, creation_date, modification_date, error_return ) input: const double Root_ID The ID of the root node in the ADF file. output: char *version A 32-byte character string containing the version ID. output: char *creation_date A 32-byte character string containing the creation date of the file. output: char *modification_date A 32-byte character string containing the last modification date of the file. output: int *error_return Error return. ***********************************************************************/ void ADF_Database_Version( const double Root_ID, char *version, char *creation_date, char *modification_date, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct FILE_HEADER file_header ; if( (version == NULL) || (creation_date == NULL) || (modification_date == NULL) ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( Root_ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get node_header for the node **/ ADFI_read_file_header( file_index, &file_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; *error_return = NO_ERROR ; /** Convert the "what" string into a C string **/ ADFI_string_2_C_string( &file_header.what[4], (int)strcspn ( file_header.what, ">" ) - 4, version, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Convert the creation date string into a C string **/ ADFI_string_2_C_string( file_header.creation_date, 28, creation_date, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Convert the modification date string into a C string **/ ADFI_string_2_C_string( file_header.modification_date, 28, modification_date, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Database_Version */ /* end of file ADF_Database_Version.c */ /* file ADF_Delete.c */ /*********************************************************************** ADF Delete: Delete a Node. If the node is NOT a link, then the specified node and all sub-nodes anywhere under it are also deleted. For a link, and also for links farther down in the tree, the link-node will be deleted, but the node which the link is linked to is not affected. When a node is deleted, other link-nodes which point to it are left dangling. For example, if N13 is deleted, then L1 and L2 point to a non-existing node. This is OK until L1 and L2 are used. ADF_Delete( PID, ID, error_return ) input: const double PID The ID of the node's parent. input: const double ID The ID of the node to use. output: int *error_return Error return. ***********************************************************************/ void ADF_Delete( const double PID, const double ID, int *error_return ) { int num_ids , i, link_path_length ; double *ids ; unsigned int file_index ; struct DISK_POINTER parent ; struct DISK_POINTER child ; struct NODE_HEADER node_header ; /** Don't use ADFI_chase_link() - delete link nodes but NOT the nodes they are linked too **/ ADFI_ID_2_file_block_offset( ID, &file_index, &child.block, &child.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADF_Is_Link( ID, &link_path_length, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_read_node_header( file_index, &child, &node_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Delete node data **/ if( link_path_length > 0 ) { /** this node IS a link **/ /** Delete the link path data for this node **/ ADFI_delete_data( file_index, &node_header, error_return ) ; } else { /** this node is NOT a link **/ /** Recursively delete all sub-nodes (children) of this node **/ ADFI_get_direct_children_ids( file_index, &child, &num_ids, &ids, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; for( i=0; i 0 ) { free( ids ) ; } /* end if */ /** Delete all data for this node **/ ADF_Put_Dimension_Information( ID, "MT", 0, (cgsize_t *)0, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if-else */ /** Disassociate node from parent **/ ADFI_ID_2_file_block_offset( PID, &file_index, &parent.block, &parent.offset, error_return ) ; /* file_index should be same as before since parent and child should be in the same file */ CHECK_ADF_ABORT( *error_return ) ; ADFI_delete_from_sub_node_table( file_index, &parent, &child, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Delete this node's sub node table **/ if( node_header.entries_for_sub_nodes > 0 ) { ADFI_delete_sub_node_table( file_index, &node_header.sub_node_table, node_header.entries_for_sub_nodes, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Delete node header from disk **/ ADFI_file_free( file_index, &child, 0, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Finally, update modification date **/ ADFI_write_modification_date( file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Delete */ /* end of file ADF_Delete.c */ /* file ADF_Error_Message.c */ /*********************************************************************** ADF Error message: Return Error Message. Given an error_return from an ADF routine, get a textual description of the error. ADF_Error_Message( error_return, error_string ) input: const int error_return An ADF-generated error code. output: char *error_string An 80-byte description of the specified error. If the number is NULL, then print out error message. ***********************************************************************/ void ADF_Error_Message( const int error_return_input, char *error_string ) { char err_msg_str[ADF_MAX_ERROR_STR_LENGTH+1] ; /** If return pointer is NULL, print message to stdout **/ if( error_string == NULL ) { ADF_Error_Message( error_return_input, err_msg_str ) ; fprintf(stderr,"%s\n", err_msg_str ) ; return ; } /* end if */ /** NO_ERROR is NOT zero for pointer-assignment checking **/ if( error_return_input == NO_ERROR ) { strcpy( error_string, ADF_error_string[ 0 ] ) ; } /* end if */ /** Check range of error code **/ else if( (error_return_input <= 0) || (error_return_input >= sizeof( ADF_error_string )/sizeof(char *) - 1 ) ) { sprintf( error_string, "ADF: Unrecognized error number %d.", error_return_input ) ; } /* end else if */ /** Error-code good, copy it for the user **/ else if (ADF_sys_err && (FILE_OPEN_ERROR == error_return_input || FILE_CLOSE_ERROR == error_return_input || FSEEK_ERROR == error_return_input || FREAD_ERROR == error_return_input || FWRITE_ERROR == error_return_input || FFLUSH_ERROR == error_return_input)) { char *p; strncpy (err_msg_str, strerror(ADF_sys_err), ADF_MAX_ERROR_STR_LENGTH-8); err_msg_str[ADF_MAX_ERROR_STR_LENGTH-8] = 0; p = err_msg_str + strlen(err_msg_str) - 1; if (*p == '\n') *p = 0; sprintf (error_string, "ADF %d: %s", error_return_input, err_msg_str); } else { strcpy( error_string, ADF_error_string[error_return_input] ) ; } /* end else */ } /* end of ADF_Error_Message */ /* end of file ADF_Error_Message.c */ /* file ADF_Flush_to_Disk.c */ /*********************************************************************** ADF Flush to Disk: Flush data to disk. This routine is used force any modified information to be flushed to the physical disk. This ensures that data will not be lost if a program aborts. This control of when to flush all data to disk is provided to the user rather than to flush the data every time it is modified, which would result in reduced performance. ADF_Flush_to_Disk( ID, error_return ) input: const double ID The ID of a node in the ADF file to flush. output: int *error_return Error return. ***********************************************************************/ void ADF_Flush_to_Disk( const double ID, int *error_return ) { double LID ; unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_fflush_file( file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Flush_to_Disk */ /* end of file ADF_Flush_to_Disk.c */ /* file ADF_Get_Data_Type.c */ /*********************************************************************** ADF Get Data Type: Get Data Type. Return the 32 character string in a node's data-type field. In C, the name will be null terminated after the last non-blank character. A maximum of 33 characters may be used (32 for the name plus 1 for the null). ADF_Get_Data_Type( ID, data_type, error_return ) input: const double ID The ID of the node to use. output: char *data_type The 32-character data-type of the node. output: int *error_return Error return. ***********************************************************************/ void ADF_Get_Data_Type( const double ID, char *data_type, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; double LID ; if( data_type == NULL ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Copy the blank-filled data-type into a C string **/ ADFI_string_2_C_string( node.data_type, ADF_CGIO_DATA_TYPE_LENGTH, data_type, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Get_Data_Type */ /* end of file ADF_Get_Data_Type.c */ /* file ADF_Get_Dimension_Values.c */ /*********************************************************************** ADF Get Dimension Values: Get Dimension Values. Return the dimension values for a node. Values will be in the range of 1 to 100,000. Values will only be returned for the number of dimensions defined in the node. If the number of dimensions for the node is zero, an error is returned. ADF_Get_Dimension_Values( ID, dim_vals, error_return ) input: const double ID The ID of the node to use. output: int dim_vals[] Array for returned dimension values. output: int *error_return Error return. Possible errors: NO_ERROR ZERO_DIMENSIONS BAD_NUMBER_OF_DIMENSIONS BAD_DIMENSION_VALUE NULL_POINTER FILE_INDEX_OUT_OF_RANGE BLOCK_OFFSET_OUT_OF_RANGE ***********************************************************************/ void ADF_Get_Dimension_Values( const double ID, cgsize_t dim_vals[], int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; int i ; double LID ; if( dim_vals == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Check for zero dimensions **/ if( node.number_of_dimensions == 0 ) { *error_return = ZERO_DIMENSIONS ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Check for too-large-of dimensions **/ if( node.number_of_dimensions > ADF_MAX_DIMENSIONS ) { *error_return = BAD_NUMBER_OF_DIMENSIONS ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Copy the dimension information **/ for( i=0; i<(int)node.number_of_dimensions; i++ ) { #if CG_SIZEOF_SIZE == 32 if (node.dimension_values[i] > CG_MAX_INT32) { *error_return = MAX_INT32_SIZE_EXCEEDED; CHECK_ADF_ABORT( *error_return ) ; } #endif dim_vals[i] = (cgsize_t)node.dimension_values[i] ; } } /* end of ADF_Get_Dimension_Values */ /* end of file ADF_Get_Dimension_Values.c */ /* file ADF_Get_Error_State.c */ /*********************************************************************** ADF Get Error State: Get Error State. Return the current error state. ADF_Get_Error_State( error_state, error_return ) output: int *error_state Flag for ABORT on error (1) or return error status (0). output: int *error_return Error return. ***********************************************************************/ void ADF_Get_Error_State( int *error_state, int *error_return ) { if( error_state == 0L ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; if( ADF_abort_on_error == TRUE ) *error_state = 1 ; else *error_state = 0 ; } /* end of ADF_Get_Error_State */ /* end of file ADF_Get_Error_State.c */ /* file ADF_Get_Label.c */ /*********************************************************************** ADF Get Label: Return the 32 character string in a node's label field. ADF_Get_Label( ID, label, error_return ) input: const double ID The ID of the node to use. output: char *label The 32-character label of the node. output: int *error_return Error return. ***********************************************************************/ void ADF_Get_Label( const double ID, char *label, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; double LID ; if( label == NULL ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Copy the blank-filled label type into a C string **/ ADFI_string_2_C_string( node.label, ADF_LABEL_LENGTH, label, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Get_Label */ /* end of file ADF_Get_Label.c */ /* file ADF_Get_Link_Path.c */ /*********************************************************************** ADF Get Link path: Get path information from a link. If the node is a link-node, return the path information. Else, return an error. If the link is in the same file, then the filename returned is zero length. ADF_Get_Link_Path( ID, file, name_in_file, error_return ) input: const double ID The ID of the node to use. output: char *file The returned filename output: char *name_in_file The returned name of node. output: int *error_return Error return. ***********************************************************************/ void ADF_Get_Link_Path( const double ID, char *file, char *name_in_file, int *error_return ) { unsigned int file_index ; int file_bytes, machine_bytes, total_bytes ; char file_format, machine_format ; struct DISK_POINTER block_offset ; struct NODE_HEADER node_header ; struct TOKENIZED_DATA_TYPE tokenized_data_type[ 2 ] ; char link_data[ADF_FILENAME_LENGTH + ADF_MAX_LINK_DATA_SIZE + 1 + 1] ; size_t lenfilename ; char *separator; if( file == NULL ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( name_in_file == NULL ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get node_header for the node **/ ADFI_read_node_header( file_index, &block_offset, &node_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( (node_header.data_type[0] != 'L') || (node_header.data_type[1] != 'K')) { *error_return = NODE_IS_NOT_A_LINK ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Get tokenized datatype **/ ADFI_evaluate_datatype( file_index, node_header.data_type, &file_bytes, &machine_bytes, tokenized_data_type, &file_format, &machine_format, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; total_bytes = file_bytes * (int)node_header.dimension_values[0] ; ADFI_read_data_chunk( file_index, &node_header.data_chunks, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, link_data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /* NULL terminate the string */ link_data[ node_header.dimension_values[0] ] = '\0' ; file[0] = '\0' ; name_in_file[0] = '\0' ; /** look for file/link delimiter **/ separator = strchr (link_data, ADF_file[file_index].link_separator); if (separator == NULL) { lenfilename = 0; } else { lenfilename = (size_t)(separator - link_data); } if ( lenfilename == 0 ) /** no filename **/ { strcpy( name_in_file, &link_data[1] ); } else if ( lenfilename == strlen( link_data ) ) { strcpy( file, link_data) ; /** no link ? **/ } else { strncpy( file, link_data, lenfilename) ; file[lenfilename] = '\0'; strcpy( name_in_file, &link_data[lenfilename+1] ); } /* end if */ } /* end of ADF_Get_Link_Path */ /* end of file ADF_Get_Link_Path.c */ /*********************************************************************** ADF Get size of Link path: Get path information from a link. If the node is a link-node, return the path information. Else, return an error. If the link is in the same file, then the filename returned is zero length. ADF_Link_Size( ID, len_name, len_file, error_return ) input: const double ID The ID of the node to use. output: int *len_file The length of the filename output: int *len_name The length of the node path output: int *error_return Error return. ***********************************************************************/ void ADF_Link_Size( const double ID, int *len_file, int *len_name, int *error_return ) { unsigned int file_index ; int file_bytes, machine_bytes, total_bytes ; char file_format, machine_format ; struct DISK_POINTER block_offset ; struct NODE_HEADER node_header ; struct TOKENIZED_DATA_TYPE tokenized_data_type[ 2 ] ; char link_data[ADF_FILENAME_LENGTH + ADF_MAX_LINK_DATA_SIZE + 1 + 1] ; size_t lenfilename ; char *separator; if( len_name == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( len_file == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get node_header for the node **/ ADFI_read_node_header( file_index, &block_offset, &node_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; *len_name = *len_file = 0; if( (node_header.data_type[0] != 'L') || (node_header.data_type[1] != 'K')) { return ; } /* end if */ /** Get tokenized datatype **/ ADFI_evaluate_datatype( file_index, node_header.data_type, &file_bytes, &machine_bytes, tokenized_data_type, &file_format, &machine_format, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; total_bytes = file_bytes * (int)node_header.dimension_values[0] ; ADFI_read_data_chunk( file_index, &node_header.data_chunks, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, link_data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /* NULL terminate the string */ link_data[ node_header.dimension_values[0] ] = '\0' ; /** look for file/link delimiter **/ separator = strchr (link_data, ADF_file[file_index].link_separator); if (separator == NULL) { lenfilename = 0; } else { lenfilename = (size_t)(separator - link_data); } if ( lenfilename == 0 ) /** no filename **/ { *len_name = (int)strlen(link_data) - 1; } else if ( lenfilename == strlen( link_data ) ) { *len_file = (int)lenfilename; } else { *len_file = (int)lenfilename; *len_name = (int)(strlen(link_data) - lenfilename - 1); } /* end if */ } /* end of ADF_Get_Link_Path */ /* file ADF_Get_Name.c */ /*********************************************************************** ADF get name: Get Name of a Node. Given a node's ID, return the 32 character name of that node. ADF_Get_Name( ID, name, error_return ) input: const double ID The ID of the node to use. output: char *name The simple name of the node (no path info). output: int *error_return Error return. ***********************************************************************/ void ADF_Get_Name( const double ID, char *name, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; if( name == NULL ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get node_header for the node **/ ADFI_read_node_header( file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Copy the blank-filled name into a C string **/ ADFI_string_2_C_string( node.name, ADF_NAME_LENGTH, name, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Get_Name */ /* end of file ADF_Get_Name.c */ /* file ADF_Get_Node_ID.c */ /*********************************************************************** ADF get Node ID: Get Unique-Identifier of a Node. Given a parent node ID and a name of a child node, this routine returns the ID of the child. If the child node is a link, the ID of the link node is returned (not the ID of the linked-to node) - otherwise there would be no way to obtain the ID of a link node. The child name may be a simple name or a compound path name. If the name is a compound path name and it begins with a '/', then the parent node ID may be any valid ID in the same database as the first node in the path. If the name is only "/" and the parent ID is any valid ID in the database, the root ID is returned. If the name is a compound path name and does not begin with a '/', then the parent node ID is the ID of the parent of the first node in the path. If the path name contains a link node (except for the ending leaf node), then the link is followed. ADF_Get_Node_ID( PID, name, ID, error_return ) input: const double PID The ID of name's parent. input: const char *name The name of the node. Compound names including path information use a slash "/" notation between node names. If a leading slash is used, then PID can be any valid node ID in the ADF database of the first name in the path. output: double *ID The ID of the named node. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADF_Get_Node_ID( const double PID, const char *name, double *ID, int *error_return ) { double LID ; int found ; int name_length ; unsigned int file_index ; struct DISK_POINTER parent_block_offset, sub_node_entry_location ; struct SUB_NODE_TABLE_ENTRY sub_node_entry ; struct NODE_HEADER node_header ; char *name_tmp, *name_ptr, *name_pos ; if( name == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ name_length = (int)strlen( name ) ; if( name_length == 0 ) { *error_return = STRING_LENGTH_ZERO ; return ; } /* end if */ if( ID == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; *ID = PID ; /** initialize the ID variable to use in intermediate steps **/ if( name[0] == '/' ) { /** start at the root node **/ /** according to user documentation, PID can be any valid node in the database, but we need to use it to get the root ID in order to start at the top **/ ADF_Get_Root_ID( PID, ID, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** This is the root-node, return the Root-ID **/ if( name[ 1 ] == '\0' ) { return ; /** NOT an error, just done and need to get out **/ } /* end if */ } /* end if */ name_tmp = (char *) malloc( (name_length + 1) * sizeof( char ) ) ; if( name_tmp == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ strcpy( name_tmp, name ) ; /** start search for tokens (names separated by '/') **/ name_pos = name_tmp ; name_ptr = ADFI_strtok( name_tmp, &name_pos, "/" ) ; if( name_ptr == NULL ) { /** this should never happen but check anyway **/ *error_return = INVALID_NODE_NAME ; CHECK_ADF_ABORT1( *error_return ) ; } /* end if */ /** Get file-index, etc. to start. Note: Parent ID may be a link **/ ADFI_chase_link( *ID, &LID, &file_index, &parent_block_offset, &node_header, error_return ) ; CHECK_ADF_ABORT1( *error_return ) ; *ID = LID ; /** Track through the possible compound name string **/ while( name_ptr ) { /** Find this child under the current parent **/ ADFI_check_4_child_name( file_index, &parent_block_offset, name_ptr, &found, &sub_node_entry_location, &sub_node_entry, error_return ) ; CHECK_ADF_ABORT1( *error_return ) ; if( found == 0 ) { /** Child NOT found **/ *error_return = CHILD_NOT_OF_GIVEN_PARENT ; CHECK_ADF_ABORT1( *error_return ) ; } /* end if */ /** create the child ID **/ ADFI_file_block_offset_2_ID( file_index, sub_node_entry.child_location.block, sub_node_entry.child_location.offset, ID, error_return ) ; /** Get the next node-name token (NULL if no more). This is needed for the while-loop check and normally would be done at the end of the loop, but it is useful in the next step to see if there are any more branches in the path. **/ name_ptr = ADFI_strtok( name_tmp, &name_pos, "/" ) ; /** If this node is the last in the path it may be a link, but there needs to be a mechanism by which a link's ID can be determined and so we cannot follow the link at this time. **/ if( name_ptr != NULL ) { /* Make sure we have a real ID so we can continue the search */ ADFI_chase_link( *ID, &LID, &file_index, &parent_block_offset, &node_header, error_return ) ; CHECK_ADF_ABORT1( *error_return ) ; *ID = LID ; /** This child now becomes the parent. Do it again... **/ ADFI_ID_2_file_block_offset( *ID, &file_index, &parent_block_offset.block, &parent_block_offset.offset, error_return ) ; CHECK_ADF_ABORT1( *error_return ) ; } /* end if */ } /* end while */ free( name_tmp ) ; } /* end of ADF_Get_Node_ID */ /* end of file ADF_Get_Node_ID.c */ /* file ADF_Get_Number_of_Dimensions.c */ /*********************************************************************** ADF Get Number of Dimensions: Get Number of Dimensions. Return the number of data dimensions used in a node. Valid values are from 0 to 12. ADF_Get_Number_of_Dimensions( ID, num_dims, error_return) input: const double ID The ID of the node to use. output: int *num_dims The returned number of dimensions. output: int *error_return Error return. ***********************************************************************/ void ADF_Get_Number_of_Dimensions( const double ID, int *num_dims, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; double LID ; if( num_dims == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Return the number of dimensions **/ *num_dims = node.number_of_dimensions ; } /* end of ADF_Get_Number_of_Dimensions */ /* end of file ADF_Get_Number_of_Dimensions.c */ /* file ADF_Get_Root_ID.c */ /*********************************************************************** ADF_Get_Root_ID: Get root-ID for an ADF system from any ID in the system. input: const double ID The ID of the node to use. output: *double Root_ID The returned ID of the root node. output: int *error_return Error return. ***********************************************************************/ void ADF_Get_Root_ID( const double ID, double *Root_ID, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct FILE_HEADER file_header ; if( Root_ID == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; /** Get the file ID **/ ADFI_ID_2_file_block_offset( ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Use the file header to find the root ID **/ ADFI_read_file_header( file_index, &file_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Format the root ID **/ ADFI_file_block_offset_2_ID( file_index, file_header.root_node.block, file_header.root_node.offset, Root_ID, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Get_Root_ID */ /* end of file ADF_Get_Root_ID.c */ /* file ADF_Is_Link.c */ /*********************************************************************** ADF Is Link: Test if a Node is a link. If the actual data-type of the node is "LK" (created with ADF_Link), return the link path length. Otherwise, return 0. ADF_Is_Link( ID, link_path_length, error_return ) input: const double ID The ID of the node to use. output: int *link_path_length 0 if the node is NOT a link. If the node is a link, the length of the path string is returned. output: int *error_return Error return. ***********************************************************************/ void ADF_Is_Link( const double ID, int *link_path_length, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node_header ; if( link_path_length == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get node_header for the node **/ ADFI_read_node_header( file_index, &block_offset, &node_header, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( (node_header.data_type[0] == 'L') && (node_header.data_type[1] == 'K')) *link_path_length = (int)node_header.dimension_values[0] ; else *link_path_length = 0 ; } /* end of ADF_Is_Link */ /* end of file ADF_Is_Link.c */ /* file ADF_Library_Version.c */ /*********************************************************************** ADF Library Version: Get ADF Library Version ID. This is the version number of the ADF library routines which your program is currently using. The format of the version ID is: "ADF Library Version 000.01" ADF_Library_Version( version, error_return ) output: char *version A 32-byte character string containing the ADF Library version ID information. output: int *error_return Error return. ***********************************************************************/ void ADF_Library_Version( char *version, int *error_return ) { int lversion; if( version == NULL ) { *error_return = NULL_STRING_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; /** Copy the proper portion of the "what" string **/ strcpy ( version, &ADF_L_identification[4] ) ; lversion = (int)strlen ( version ) ; version[lversion-1] = '\0' ; /** remove trailing "what" delimiter ('>') **/ } /* end of ADF_Library_Version */ /* end of file ADF_Library_Version.c */ /* file ADF_Link.c */ /*********************************************************************** ADF Link: Create a link. Note: The Node linked to does not have to exist when the link is created (but it may exist and that is OK). However, when the link is used, an error will occur if the linked to node does not exist. ADF_Link( PID, name, file, name_in_file, ID, error_return ) input: const double PID The ID of the Node's parent. input: const char *name The name of the link node. input: const char *file The filename to use for the link (directly usable by a C open() routine). If blank (null), the link will be within the same file. input: const char *name_in_file The name of the node which the link will point to. This can be a simple or compound name. output: double ID The returned ID of the link-node. output: int *error_return Error return. ***********************************************************************/ void ADF_Link( const double PID, const char *name, const char *file_name, const char *name_in_file, double *ID, int *error_return ) { char link_data[ADF_FILENAME_LENGTH + ADF_MAX_LINK_DATA_SIZE + 2] ; int null_filename = FALSE ; int filename_length, linked_to_length, data_length ; cgsize_t dim_vals[1] ; unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node_header ; /** Don't check file since it can be a NULL pointer **/ ADFI_check_string_length( name, ADF_NAME_LENGTH, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_check_string_length( name_in_file, ADF_MAX_LINK_DATA_SIZE, error_return ); CHECK_ADF_ABORT( *error_return ) ; ADF_Is_Link( PID, &linked_to_length, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if ( linked_to_length > 0 ) { *error_return = LINKS_TOO_DEEP ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Create the node in the normal way **/ ADF_Create( PID, name, ID, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( *ID, &file_index, &block_offset.block, &block_offset.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Add the file and linked-to name as data in the child **/ ADFI_check_string_length( file_name, ADF_FILENAME_LENGTH, error_return ) ; if( *error_return != NO_ERROR ) { null_filename = TRUE ; filename_length = 0 ; } /* end if */ else { filename_length = (int)strlen( file_name) ; } /* end else */ linked_to_length = (int)strlen( name_in_file ) ; data_length = filename_length + linked_to_length + 1 ; if( data_length > ADF_FILENAME_LENGTH + ADF_MAX_LINK_DATA_SIZE + 1 ) { *error_return = STRING_LENGTH_TOO_BIG ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( null_filename == TRUE ) { sprintf( link_data, "%c%s", ADF_file[file_index].link_separator, name_in_file ) ; } /* end if */ else { sprintf( link_data, "%s%c%s", file_name, ADF_file[file_index].link_separator, name_in_file ) ; } /* end else */ /** We must use a datatype of "C1" to put the data into this node. With a datatype of "Lk" (a link), the written data will go into the linked-to node (that's the whole point). To set this up we must be careful... **/ dim_vals[0] = data_length ; ADF_Put_Dimension_Information( *ID, "C1", 1, dim_vals, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADF_Write_All_Data( *ID, link_data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Change the datatype to be LK, without deleting the data. We can't use ADF_Put_Dimension_Information since the change of datatype will delete the data. We must do this manually. **/ ADFI_read_node_header( file_index, &block_offset, &node_header, error_return ); CHECK_ADF_ABORT( *error_return ) ; if( (node_header.data_type[0] != 'C') || (node_header.data_type[1] != '1') || (node_header.data_type[2] != ' ') ) { *error_return = INVALID_DATA_TYPE ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ node_header.data_type[0] = 'L' ; node_header.data_type[1] = 'K' ; ADFI_write_node_header( file_index, &block_offset, &node_header, error_return ); CHECK_ADF_ABORT( *error_return ) ; /** Finally, update modification date **/ ADFI_write_modification_date( file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Link */ /* end of file ADF_Link.c */ /* file ADF_Move_Child.c */ /*********************************************************************** ADF Move Child: Change Parent (move a Child Node). The node and the 2 parents must all exist within a single ADF file. If the node is pointed to by a link-node, changing the node's parent will break the link. ADF_Move_Child( PID, ID, NPID, error_return ) input: double PID The ID of the Node's parent. input: double ID The ID of the node to use. input: double NPID The ID of the Node's New Parent output: int *error_return Error return. ***********************************************************************/ void ADF_Move_Child( const double PID, const double ID, const double NPID, int *error_return ) { unsigned int parent_file_index, child_file_index, new_parent_file_index, file_index ; char child_name[ ADF_NAME_LENGTH ] ; int found ; struct DISK_POINTER parent, child, new_parent, sub_node_entry_location ; struct SUB_NODE_TABLE_ENTRY sub_node_entry ; *error_return = NO_ERROR ; ADFI_ID_2_file_block_offset( PID, &parent_file_index, &parent.block, &parent.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_ID_2_file_block_offset( ID, &child_file_index, &child.block, &child.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( child_file_index != parent_file_index ) { *error_return = NODES_NOT_IN_SAME_FILE ; CHECK_ADF_ABORT( *error_return ) ; } ADFI_ID_2_file_block_offset( NPID, &new_parent_file_index, &new_parent.block, &new_parent.offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( new_parent_file_index != parent_file_index ) { *error_return = NODES_NOT_IN_SAME_FILE ; CHECK_ADF_ABORT( *error_return ) ; } file_index = parent_file_index ; /* use a shorter, more generic name - file indices should now be the same for all 3 nodes */ /** check that child is really a child of parent **/ ADF_Get_Name( ID, child_name, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_check_4_child_name( file_index, &parent, child_name, &found, &sub_node_entry_location, &sub_node_entry, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( found == 0 ) { /* child not found */ *error_return = CHILD_NOT_OF_GIVEN_PARENT ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** add child to its new parent's sub node table **/ ADFI_add_2_sub_node_table( file_index, &new_parent, &child, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** remove child from its old parent's sub node table **/ ADFI_delete_from_sub_node_table( file_index, &parent, &child, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Move_Child */ /* end of file ADF_Move_Child.c */ /* file ADF_Number_of_Children.c */ /*********************************************************************** ADF Number of Children; Get Number of Children of a Node. Return the number of children nodes directly associated with a parent node. ADF_Number_of_Children( ID, num_children, error_return ) input: const double ID The ID of the node to use. output: int *num_children The number of children directly associated with this node. output: int *error_return Error return. ***********************************************************************/ void ADF_Number_of_Children( const double ID, int *num_children, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; double LID ; if( num_children == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Return the number of children **/ *num_children = node.num_sub_nodes ; } /* end of ADF_Number_of_Children */ /* end of file ADF_Number_of_Children.c */ /* file ADF_Put_Dimension_Information.c */ /*********************************************************************** ADF Put Dimension Information: Set/change the data-type and Dimension Information of a Node. Valid user-definable data-types are: No data MT Integer 32 I4 Integer 64 I8 Unsigned Int 32 U4 Unsigned Int 64 U8 Real 32 R4 Real 64 R8 Complex 64 X4 Complex 128 X8 Character (unsigned byte) C1 Byte (unsigned byte) B1 Compound data-types can be used which combine types ("I4,I4,R8"), define an array ("I4[25]"), or a combination of these ("I4,C1[20],R8[3]"). dims can be a number from 0 to 12. dim_vals is an array of integers. The number of integers used is determined by the dims argument. If dims is zero, the dim_values are not used. Valid range for dim_values are from 1 to 2,147,483,648. The total data size, calculated by the data-type-size times the dimension value(s), cannot exceed 2,147,483,648. Note: When this routine is called and the data-type or the number of dimensions changes, any data currently associated with the node is lost!! The dimension values can be changed and the data space will be extended as needed. ADF_Put_Dimension_Information( ID, data_type, dims, dim_vals, error_return ) input: const double ID The ID of the node. input: const char *data-type The data-type to use. input: const int dims The number of dimensions this node has. input: const int dim_vals[] The dimension values for this node. output: int *error_return Error return. ***********************************************************************/ void ADF_Put_Dimension_Information( const double ID, const char *data_type, const int dims, const cgsize_t dim_vals[], int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; struct TOKENIZED_DATA_TYPE tokenized_data_type[ 1 + (ADF_DATA_TYPE_LENGTH + 1)/3 ] ; char file_format, machine_format ; int file_bytes[2], machine_bytes[2] ; cgulong_t data_bytes, old_data_bytes ; int i, datatype_length ; int preserve_data = FALSE ; double LID ; ADFI_check_string_length( data_type, ADF_DATA_TYPE_LENGTH, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( dim_vals == NULL && dims > 0 ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Check new datatype **/ ADFI_evaluate_datatype( file_index, data_type, &file_bytes[0], &machine_bytes[0], tokenized_data_type, &file_format, &machine_format, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Look at old datatype **/ ADFI_evaluate_datatype( file_index, node.data_type, &file_bytes[1], &machine_bytes[1], tokenized_data_type, &file_format, &machine_format, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Calculate new data-size **/ if( dims < 0 ) { *error_return = NUMBER_LESS_THAN_MINIMUM ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( dims > ADF_MAX_DIMENSIONS) { *error_return = BAD_NUMBER_OF_DIMENSIONS ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** If the number of dimensions is zero, set data-bytes to zero **/ if( dims == 0 ) data_bytes = 0 ; else { /** Calculate the total number of bytes in the data **/ for( data_bytes=file_bytes[0], i=0; i ADF_NAME_LENGTH ) { *error_return = STRING_LENGTH_TOO_BIG ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( name_length == 0 ) { *error_return = STRING_LENGTH_ZERO ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Need to check for uniqueness and legality of the name **/ ADFI_check_4_child_name( file_index, &parent_block_offset, &name[ name_start ], &found, &sub_node_entry_location, &sub_node_entry, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( found == 1 ) { *error_return = DUPLICATE_CHILD_NAME ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ for ( i=0; i < name_length; i++ ) { if ( ! isprint ( name[ name_start + i ] ) || name[ name_start + i ] == '/' ) { *error_return = INVALID_NODE_NAME; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ } /* end for */ /** Confirm that child is from the parent **/ ADFI_check_4_child_name( file_index, &parent_block_offset, child_node.name, &found, &sub_node_entry_location, &sub_node_entry, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( found == 0 ) { *error_return = CHILD_NOT_OF_GIVEN_PARENT ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( (child_block_offset.block != sub_node_entry.child_location.block) || (child_block_offset.offset != sub_node_entry.child_location.offset) ) { *error_return = CHILD_NOT_OF_GIVEN_PARENT ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Copy the name **/ name_length = (int)strlen( name ) ; for( i=0; i total_bytes ) { bytes_to_read = total_bytes - bytes_read ; } /* end if */ if( bytes_to_read == 0 ) break ; ADFI_read_data_chunk( file_index, &data_chunk_table[i].start, tokenized_data_type, file_bytes, bytes_to_read, 0, bytes_to_read, data_pointer, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** note: memory_bytes and file_bytes might be different (e.g., if machine is "IEEE_BIG" and file is "CRAY") in which case data pointer advances at a different rate from file pointer. **/ data_pointer += (bytes_to_read * memory_bytes) / file_bytes ; bytes_read += bytes_to_read ; } /* end for */ free( data_chunk_table ) ; if( bytes_read < total_bytes ) { *error_return = INCOMPLETE_DATA ; memset( data_pointer, 0, (size_t)(total_bytes - bytes_read) ) ; } /* end if */ } /* end else */ } /* end of ADF_Read_All_Data */ /* end of file ADF_Read_All_Data.c */ /* file ADF_Read_Block_Data.c */ /*********************************************************************** ADF Read Block Data: Read a continuous block of data from a Node. Reads a block the node's data and returns it into a contiguous memory space. ADF_Read_Block_Data( ID, data, error_return ) input: const double ID The ID of the node to use. input: const long b_start The starting point in block in token space input: const long b_end The ending point in block in token space output: char *data The start of the data in memory. output: int *error_return Error return. ***********************************************************************/ void ADF_Read_Block_Data( const double ID, const cgsize_t b_start, const cgsize_t b_end, char *data, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; struct TOKENIZED_DATA_TYPE tokenized_data_type[ 1 + (ADF_DATA_TYPE_LENGTH + 1)/3 ] ; struct DATA_CHUNK_TABLE_ENTRY *data_chunk_table ; char *data_pointer ; char file_format, machine_format ; int file_bytes, memory_bytes ; cglong_t bytes_to_read ; cglong_t total_bytes, bytes_read, start_offset ; cglong_t chunk_size, chunk_end_byte ; cglong_t start_byte, end_byte, block_bytes ; int i, j ; double LID ; if( data == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get datatype size **/ ADFI_evaluate_datatype( file_index, node.data_type, &file_bytes, &memory_bytes, tokenized_data_type, &file_format, &machine_format, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( (file_bytes == 0) || (node.number_of_dimensions == 0) ) { *error_return = NO_DATA ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Calculate total number of bytes in the data **/ total_bytes = file_bytes ; for( j=0; j<(int)node.number_of_dimensions; j++ ) total_bytes *= node.dimension_values[j] ; if( total_bytes == 0 ) { *error_return = ZERO_DIMENSIONS ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Calculate the starting and ending range in the file **/ start_byte = file_bytes * (b_start-1) ; end_byte = file_bytes * b_end ; if ( start_byte < 0 || start_byte > end_byte || end_byte > total_bytes ) { *error_return = START_OUT_OF_DEFINED_RANGE ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ block_bytes = end_byte - start_byte ; /** If there is NO DATA, fill data space with zeros, return error **/ if( node.number_of_data_chunks == 0 ) { memset( data, 0, (size_t)(block_bytes*memory_bytes/file_bytes) ) ; *error_return = NO_DATA ; return ; /** NO_DATA is really a warning, so don't check & abort... **/ } /* end if */ /** Read the data from disk **/ else if( node.number_of_data_chunks == 1 ) { ADFI_read_data_chunk( file_index, &node.data_chunks, tokenized_data_type, file_bytes, total_bytes, start_byte, block_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else if */ else { /** Allocate memory for the required table space in memory **/ data_chunk_table = (struct DATA_CHUNK_TABLE_ENTRY *) malloc( node.number_of_data_chunks * sizeof( *data_chunk_table ) ) ; if( data_chunk_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Read in the table **/ ADFI_read_data_chunk_table( file_index, &node.data_chunks, data_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Read data from each entry in the table **/ bytes_read = 0 ; chunk_end_byte = 0 ; data_pointer = data ; for( i=0; i<(int)node.number_of_data_chunks; i++ ) { chunk_size = (data_chunk_table[i].end.block - data_chunk_table[i].start.block) * DISK_BLOCK_SIZE + (data_chunk_table[i].end.offset - data_chunk_table[i].start.offset) - (TAG_SIZE + DISK_POINTER_SIZE) ; /** Check to be sure we don't think the chunk is bigger than it is (shrinking a data block can cause this) **/ if( chunk_end_byte + chunk_size > total_bytes ) { chunk_size = total_bytes - chunk_end_byte ; } /* end if */ if( chunk_size == 0 ) break ; chunk_end_byte += chunk_size ; /** If start of block not in this chunk then continue **/ if ( start_byte >= chunk_end_byte ) continue ; /** Set offset into the current chunk **/ if ( start_byte > (chunk_end_byte - chunk_size) ) /** The start of the block is inside the current chunk so adjust the offset to the beginning of the block **/ start_offset = ( start_byte - (chunk_end_byte-chunk_size) ) ; else start_offset = 0 ; /** Calculate the number of bytes needed in this chunk **/ bytes_to_read = chunk_size - start_offset ; if( bytes_read + bytes_to_read > block_bytes ) { bytes_to_read = block_bytes - bytes_read ; } /* end if */ if( bytes_to_read == 0 || (chunk_end_byte-chunk_size) > end_byte ) break ; ADFI_read_data_chunk( file_index, &data_chunk_table[i].start, tokenized_data_type, file_bytes, chunk_size, start_offset, bytes_to_read, data_pointer, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** note: memory_bytes and file_bytes might be different (e.g., if machine is "IEEE_BIG" and file is "CRAY") in which case data pointer advances at a different rate from file pointer. **/ data_pointer += (bytes_to_read * memory_bytes) / file_bytes ; bytes_read += bytes_to_read ; } /* end for */ free( data_chunk_table ) ; if( bytes_read < block_bytes ) { *error_return = INCOMPLETE_DATA ; memset( data_pointer, 0, (size_t)(total_bytes - bytes_read) ) ; } /* end if */ } /* end else */ } /* end of ADF_Read_Block_Data */ /* end of file ADF_Read_Block_Data.c */ /* file ADF_Read_Data.c */ /*********************************************************************** ADF Read Data: Read data from a node, with partial capabilities. The partial capabilities are both in the node's data and also in memory. Vectors of integers are used to indicate the data to be accessed from the node, and another set of integer vectors is used to describe the memory location for the data. Note: If the data-type of the node is a compound data-type ("I4[3],R8") for example, the partial capabilities will access one or more of these 20-byte data entities. You cannot access a subset of an occurrence of the data-type. ADF_Read_Data( ID, s_start[], s_end[], s_stride[], m_num_dims, m_dims[], m_start[], m_end[], m_stride[], data, error_return ) input: const double ID The ID of the node to use. input: const int s_start[] The starting dimension values to use in the database (node). input: const int s_end[] The ending dimension values to use in the database (node). input: const int s_stride[] The stride values to use in the database (node). input: const int m_num_dims The number of dimensions to use in memory. input: const int m_dims[] The dimensionality to use in memory. input: const int m_start[] The starting dimension values to use in memory. input: const int m_end[] The ending dimension values to use in memory. input: const int m_stride[] The stride values to use in memory. output: char *data The start of the data in memory. output: int *error_return Error return. ***********************************************************************/ void ADF_Read_Data( const double ID, const cgsize_t s_start[], const cgsize_t s_end[], const cgsize_t s_stride[], const int m_num_dims, const cgsize_t m_dims[], const cgsize_t m_start[], const cgsize_t m_end[], const cgsize_t m_stride[], const char *m_data_type, char *data, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset, relative_block ; struct NODE_HEADER node ; struct TOKENIZED_DATA_TYPE tokenized_data_type[ 1 + (ADF_DATA_TYPE_LENGTH + 1)/3 ] ; cglong_t current_disk[ADF_MAX_DIMENSIONS] ; cglong_t current_memory[ADF_MAX_DIMENSIONS] ; cgulong_t total_disk_elements, total_memory_elements ; cgulong_t disk_offset, memory_offset ; cgulong_t memory_dims[ADF_MAX_DIMENSIONS] ; char disk_format, machine_format ; int formats_compare ; int i ; int file_bytes = 0 ; int memory_bytes = 0 ; int no_data = FALSE ; double LID ; cgulong_t relative_offset = 0, current_chunk_size = 0, past_chunk_sizes = 0, current_chunk = 0, disk_elem ; struct DATA_CHUNK_TABLE_ENTRY *data_chunk_table = NULL; if( (s_start == NULL) || (s_end == NULL) || (s_stride == NULL) || (m_dims == NULL) || (m_start == NULL) || (m_end == NULL) || (m_stride == NULL) || (data == NULL) ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /* if it was provided, check to make sure the data types match */ if( m_data_type != NULL ) { if(strncmp(m_data_type, node.data_type, 2) != 0){ *error_return = INVALID_DATA_TYPE; CHECK_ADF_ABORT( *error_return ); } } /** Get datatype length **/ ADFI_evaluate_datatype( file_index, node.data_type, &file_bytes, &memory_bytes, tokenized_data_type, &disk_format, &machine_format, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( (file_bytes == 0) || (node.number_of_dimensions == 0) ) { *error_return = NO_DATA ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ ADFI_count_total_array_points( node.number_of_dimensions, node.dimension_values, s_start, s_end, s_stride, &total_disk_elements, &disk_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; for (i = 0; i < m_num_dims; i++) memory_dims[i] = m_dims[i]; ADFI_count_total_array_points( (unsigned int)m_num_dims, memory_dims, m_start, m_end, m_stride, &total_memory_elements, &memory_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( total_disk_elements != total_memory_elements ) { *error_return = UNEQUAL_MEMORY_AND_DISK_DIMS ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ ADFI_file_and_machine_compare( file_index, tokenized_data_type, &formats_compare, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Check to see if there is actual data to use **/ if( node.number_of_data_chunks == 0 ) { no_data = TRUE ; } /* end if */ /** Check for multiple data-chunks **/ else if( node.number_of_data_chunks == 1 ) { /** A single data chunk **/ /** Point to the start of the data **/ block_offset.block = node.data_chunks.block ; block_offset.offset = node.data_chunks.offset + TAG_SIZE + DISK_POINTER_SIZE + disk_offset * file_bytes ; ADFI_adjust_disk_pointer( &block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else if */ else if( node.number_of_data_chunks > 1 ) { /** Multiple data chunks **/ current_chunk = 0 ; past_chunk_sizes = 0 ; relative_offset = disk_offset * file_bytes ; /** Allocate memory for the required table space in memory **/ data_chunk_table = (struct DATA_CHUNK_TABLE_ENTRY *) malloc( node.number_of_data_chunks * sizeof( *data_chunk_table ) ) ; if( data_chunk_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Read in the table **/ ADFI_read_data_chunk_table( file_index, &node.data_chunks, data_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; current_chunk_size = (data_chunk_table[ current_chunk ].end.block - data_chunk_table[ current_chunk ].start.block) * DISK_BLOCK_SIZE + (data_chunk_table[ current_chunk ].end.offset - data_chunk_table[ current_chunk ].start.offset) - (TAG_SIZE + DISK_POINTER_SIZE) ; } /* end else if */ /** Setup initial indexing **/ for( i=0; i<(int)node.number_of_dimensions; i++ ) current_disk[i] = s_start[i] ; for( i=0; i DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ if( formats_compare ) { /** Read the data off of disk directly **/ ADFI_read_file( file_index, block_offset.block, block_offset.offset, file_bytes, (char *)data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { /** Read and translate data **/ ADFI_read_data_translated( file_index, block_offset.block, block_offset.offset, tokenized_data_type, file_bytes, file_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ /** Increment disk pointers, for the special case of one dimensional data we will a simple increment to maximize the throughput. Thus for block reads you can temporarily change to 1D for the read to improve efficiency. Note total size shouldn't change!! **/ if( disk_elem < total_disk_elements - 1 ) { if ( node.number_of_dimensions == 1 ) { disk_offset = s_stride[0]; current_disk[0] += disk_offset; if ( current_disk[0] > s_end[0] ) current_disk[0] = s_end[0] ; } /* end if */ else { ADFI_increment_array( node.number_of_dimensions, node.dimension_values, s_start, s_end, s_stride, current_disk, &disk_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ block_offset.offset += disk_offset * file_bytes ; if ( block_offset.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ } /* end if */ } /* end else if */ else if( node.number_of_data_chunks > 1 ) { /** Multiple data chunks **/ while( relative_offset >= past_chunk_sizes + current_chunk_size ) { if( ++current_chunk >= node.number_of_data_chunks ) { *error_return = INCOMPLETE_DATA ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { past_chunk_sizes += current_chunk_size ; current_chunk_size = (data_chunk_table[ current_chunk ].end.block - data_chunk_table[ current_chunk ].start.block) * DISK_BLOCK_SIZE + (data_chunk_table[ current_chunk ].end.offset - data_chunk_table[ current_chunk ].start.offset) - (TAG_SIZE + DISK_POINTER_SIZE) ; } /* end else */ } /* end while */ /** Get the data off of disk **/ relative_block.block = data_chunk_table[ current_chunk ].start.block ; relative_block.offset = data_chunk_table[ current_chunk ].start.offset + (TAG_SIZE + DISK_POINTER_SIZE) + (relative_offset - past_chunk_sizes) ; if ( relative_block.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &relative_block, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } if( formats_compare ) { /** Read the data off of disk directly **/ ADFI_read_file( file_index, relative_block.block, relative_block.offset, file_bytes, (char *)data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { /** Read and translate data **/ ADFI_read_data_translated( file_index, relative_block.block, relative_block.offset, tokenized_data_type, file_bytes, file_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ /** Increment disk pointers **/ if( disk_elem < total_disk_elements - 1 ) { if ( node.number_of_dimensions == 1 ) { disk_offset = s_stride[0]; current_disk[0] += disk_offset; if ( current_disk[0] > s_end[0] ) current_disk[0] = s_end[0] ; } /* end if */ else { ADFI_increment_array( node.number_of_dimensions, node.dimension_values, s_start, s_end, s_stride, current_disk, &disk_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ relative_offset += disk_offset * file_bytes ; } /* end if */ } /* end else if */ if( disk_elem < total_disk_elements - 1 ) { /** Increment memory pointers **/ if ( m_num_dims == 1 ) { memory_offset = m_stride[0]; current_memory[0] += disk_offset; if ( current_memory[0] > m_end[0] ) current_memory[0] = m_end[0] ; } /* end if */ else { ADFI_increment_array( (unsigned int)m_num_dims, memory_dims, m_start, m_end, m_stride, current_memory, &memory_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ /** Adjust data pointer **/ data += memory_offset * memory_bytes ; } /* end if */ } /* end for */ if( node.number_of_data_chunks > 1 ) /** Multiple data chunks **/ free( data_chunk_table ) ; } /* end of ADF_Read_Data */ /* end of file ADF_Read_Data.c */ /* file ADF_Set_Error_State.c */ /*********************************************************************** ADF Set Error State: Set Error State. For all ADF calls, set the error handling convention; either return error codes, or abort the program on an error. The default state for the ADF interface is to return error codes and NOT abort. ADF_Set_Error_State( error_state, error_return ) input: const int error_state Flag for ABORT on error (1) or return error status (0). output: int *error_return Error return. ***********************************************************************/ void ADF_Set_Error_State( const int error_state, int *error_return ) { *error_return = NO_ERROR ; if( error_state == 0 ) ADF_abort_on_error = FALSE ; else if( error_state == 1 ) ADF_abort_on_error = TRUE ; else { *error_return = BAD_ERROR_STATE ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ } /* end of ADF_Set_Error_State */ /* end of file ADF_Set_Error_State.c */ /* file ADF_Set_Label.c */ /*********************************************************************** ADF Set Label: Set Label. Set the 32 character string in a node's label field. ADF_Set_Label( ID, label, error_return ) input: const double ID The ID of the node to use. input: const char *label The 32-character label of the node. output: int *error_return Error return. ***********************************************************************/ void ADF_Set_Label( const double ID, const char *label, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset ; struct NODE_HEADER node ; int i, label_length ; double LID ; /** Don't check for NULL or BLANK label, these are OK **/ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Copy the label **/ if( label == NULL ) label_length = 0 ; /* copy none, then blank fill */ else label_length = (int)strlen( label ) ; if( label_length > ADF_LABEL_LENGTH ) { *error_return = STRING_LENGTH_TOO_BIG ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ for( i=0; i chunk_total_bytes ) { /** Write the part of the new data to existing data-chunk **/ ADFI_write_data_chunk( file_index, &node.data_chunks, tokenized_data_type, file_bytes, chunk_total_bytes, 0, chunk_total_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Allocate a second data chunk **/ total_bytes -= chunk_total_bytes ; ADFI_file_malloc( file_index, total_bytes + TAG_SIZE + TAG_SIZE + DISK_POINTER_SIZE, &new_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Write the rest of the data **/ /** note: memory_bytes and file_bytes might be different (e.g., if machine is "IEEE_BIG" and file is "CRAY") in which case data pointer advances at a different rate from file pointer. **/ data += (chunk_total_bytes * memory_bytes ) / file_bytes ; ADFI_write_data_chunk( file_index, &new_block_offset, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Allocate a data-chunk-table for two entries **/ ADFI_file_malloc( file_index, 2 * TAG_SIZE + 5 * DISK_POINTER_SIZE, &dct_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Write data-chunk-table to disk **/ data_chunk_entry_table[0].start.block = node.data_chunks.block ; data_chunk_entry_table[0].start.offset = node.data_chunks.offset ; chunk_start.block = node.data_chunks.block ; chunk_start.offset = node.data_chunks.offset + TAG_SIZE ; ADFI_adjust_disk_pointer( &chunk_start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** get the size of the data_chunk for the table end pointer **/ ADFI_read_disk_pointer_from_disk( file_index, chunk_start.block, chunk_start.offset, &data_chunk_entry_table[0].end, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; data_chunk_entry_table[1].start.block = new_block_offset.block ; data_chunk_entry_table[1].start.offset = new_block_offset.offset ; chunk_start.block = new_block_offset.block ; chunk_start.offset = new_block_offset.offset + TAG_SIZE ; ADFI_adjust_disk_pointer( &chunk_start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** get the size of the data_chunk for the table end pointer **/ ADFI_read_disk_pointer_from_disk( file_index, chunk_start.block, chunk_start.offset, &data_chunk_entry_table[1].end, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_write_data_chunk_table( file_index, &dct_block_offset, 2, data_chunk_entry_table, error_return ) ; /** Update node header with number of data-chunks = 2 and the pointer to the data-chunk-table **/ node.data_chunks.block = dct_block_offset.block ; node.data_chunks.offset = dct_block_offset.offset ; node.number_of_data_chunks = 2 ; ADFI_write_node_header( file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { /** Write the new data to existing data-chunk **/ ADFI_write_data_chunk( file_index, &node.data_chunks, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ } /* end else if */ else { /** Multiple data chunks **/ /** Allocate memory for the data-chunk-table, with an additional entry in case we need to grow it **/ data_chunk_table = (struct DATA_CHUNK_TABLE_ENTRY *) malloc( (node.number_of_data_chunks + 1 ) * sizeof( *data_chunk_table ) ) ; if( data_chunk_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Read in the table **/ ADFI_read_data_chunk_table( file_index, &node.data_chunks, data_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** looping on the data-chunks, write the size of the current chunk **/ for( i=0; i<(int)node.number_of_data_chunks; i++ ) { current_bytes = (data_chunk_table[i].end.block - data_chunk_table[i].start.block) * DISK_BLOCK_SIZE + (data_chunk_table[i].end.offset - data_chunk_table[i].start.offset) - (TAG_SIZE + DISK_POINTER_SIZE) ; /** Limit the number of bytes written by what's left to write. **/ current_bytes = MIN( current_bytes, total_bytes ) ; ADFI_write_data_chunk( file_index, &data_chunk_table[i].start, tokenized_data_type, file_bytes, current_bytes, 0, current_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** note: memory_bytes and file_bytes might be different (e.g., if machine is "IEEE_BIG" and file is "CRAY") in which case data pointer advances at a different rate from file pointer. **/ data += (current_bytes * memory_bytes ) / file_bytes ; total_bytes -= current_bytes ; if( total_bytes <= 0 ) break ; } /* end for */ /** If we are out of data-chunks and have data left, allocate a new data-chunk in the file. **/ if( total_bytes > 0 ) { /** Write data-chunk-table to disk **/ /** allocate data space in the file **/ ADFI_file_malloc( file_index, 2 * TAG_SIZE + DISK_POINTER_SIZE + total_bytes, &data_chunk_table[ node.number_of_data_chunks ].start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; data_chunk_table[ node.number_of_data_chunks ].end.block = data_chunk_table[ node.number_of_data_chunks ].start.block ; data_chunk_table[ node.number_of_data_chunks ].end.offset = data_chunk_table[ node.number_of_data_chunks ].start.offset + TAG_SIZE + DISK_POINTER_SIZE + total_bytes ; ADFI_adjust_disk_pointer( &data_chunk_table[ node.number_of_data_chunks ].end, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** allocate space for the new data-chunk-entry-table **/ ADFI_file_malloc( file_index, 2 * TAG_SIZE + (2 * (node.number_of_data_chunks + 1) + 1) * DISK_POINTER_SIZE, &dct_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_write_data_chunk_table( file_index, &dct_block_offset, node.number_of_data_chunks+1, data_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_write_data_chunk( file_index, &data_chunk_table[node.number_of_data_chunks ].start, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Free the old data-chunk-table **/ ADFI_file_free( file_index, &node.data_chunks, 0, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Update node header with number of data-chunks++ and the pointer to the data-chunk-table **/ node.number_of_data_chunks++ ; node.data_chunks.block = dct_block_offset.block ; node.data_chunks.offset = dct_block_offset.offset ; ADFI_write_node_header( file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ free( data_chunk_table ) ; } /* end else */ /** Finally, update modification date **/ ADFI_write_modification_date( file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Write_All_Data */ /* end of file ADF_Write_All_Data.c */ /* end of file ADF_Write_All_Data.c */ /* file ADF_Write_Block_Data.c */ /*********************************************************************** ADF Write Block Data: Write all data to a Node. Writes all the node's data from a contiguous memory space. ADF_Write_All_Data( ID, data, error_return ) input: const double ID The ID of the node to use. input: const long b_start The starting point in block in token space input: const long b_end The ending point in block in token space input: const char *data The start of the data in memory. output: int *error_return Error return. ***********************************************************************/ void ADF_Write_Block_Data( const double ID, const cgsize_t b_start, const cgsize_t b_end, char *data, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset, new_block_offset, dct_block_offset ; struct NODE_HEADER node ; struct TOKENIZED_DATA_TYPE tokenized_data_type[ 1 + (ADF_DATA_TYPE_LENGTH + 1)/3 ] ; struct DATA_CHUNK_TABLE_ENTRY data_chunk_entry_table[2], *data_chunk_table ; char file_format, machine_format ; int file_bytes, memory_bytes ; cglong_t total_bytes, bytes_written, bytes_to_write = 0; int i, j ; char tag[TAG_SIZE+1] ; struct DISK_POINTER data_start, chunk_start, end_of_chunk_tag ; cglong_t start_offset ; cglong_t chunk_size, chunk_end_byte ; cglong_t start_byte, end_byte, block_bytes ; double LID ; if( data == NULL ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get the datatype length **/ ADFI_evaluate_datatype( file_index, node.data_type, &file_bytes, &memory_bytes, tokenized_data_type, &file_format, &machine_format, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Calculate the total number of data bytes **/ total_bytes = file_bytes ; for( j=0; j<(int)node.number_of_dimensions; j++ ) total_bytes *= node.dimension_values[j] ; if( total_bytes == 0 ) { *error_return = ZERO_DIMENSIONS ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Calculate the starting and ending range in the file **/ start_byte = file_bytes * (b_start-1) ; end_byte = file_bytes * b_end ; if ( start_byte < 0 || start_byte > end_byte || end_byte > total_bytes ) { *error_return = START_OUT_OF_DEFINED_RANGE ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ block_bytes = end_byte - start_byte ; /** If there currently is NO data, allocate disk space for it **/ if( node.number_of_data_chunks == 0 ) { ADFI_file_malloc( file_index, total_bytes + TAG_SIZE + TAG_SIZE + DISK_POINTER_SIZE, &node.data_chunks, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Write the new data **/ ADFI_write_data_chunk( file_index, &node.data_chunks, tokenized_data_type, file_bytes, total_bytes, start_byte, block_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Record the modified the node-header **/ node.number_of_data_chunks = 1 ; ADFI_write_node_header( file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else if( node.number_of_data_chunks == 1 ) { /** Get the data length **/ ADFI_read_chunk_length( file_index, &node.data_chunks, tag, &end_of_chunk_tag, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; tag[TAG_SIZE] = '\0' ; /** Check start-of-chunk tag **/ if( ADFI_stridx_c( tag, data_chunk_start_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Point to the start of the data **/ data_start.block = node.data_chunks.block ; data_start.offset = node.data_chunks.offset + TAG_SIZE + DISK_POINTER_SIZE ; ADFI_adjust_disk_pointer( &data_start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** See if the new data exceedes the existing data space **/ chunk_size = end_of_chunk_tag.offset - data_start.offset + (end_of_chunk_tag.block - data_start.block) * DISK_BLOCK_SIZE ; /** If Data grew: Write old size, then allocate more data-space and write the rest **/ if( total_bytes > chunk_size ) { /** Write the part of the new data to existing data-chunk **/ bytes_written = 0 ; if ( start_byte <= chunk_size ) { bytes_to_write = MIN ( block_bytes, (chunk_size-start_byte) ) ; ADFI_write_data_chunk( file_index, &node.data_chunks, tokenized_data_type, file_bytes, chunk_size, start_byte, bytes_to_write, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; bytes_written += bytes_to_write ; } /* end if */ /** Allocate a second data chunk **/ total_bytes -= chunk_size ; ADFI_file_malloc( file_index, total_bytes + TAG_SIZE + TAG_SIZE + DISK_POINTER_SIZE, &new_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Write the rest of the data **/ /** note: memory_bytes and file_bytes might be different (e.g., if machine is "IEEE_BIG" and file is "CRAY") in which case data pointer advances at a different rate from file pointer. **/ data += (bytes_to_write * memory_bytes ) / file_bytes ; if ( bytes_written < block_bytes ) { bytes_to_write = block_bytes - bytes_written ; start_offset = MAX ( 0L, (start_byte - chunk_size) ) ; ADFI_write_data_chunk( file_index, &new_block_offset, tokenized_data_type, file_bytes, total_bytes, start_offset, bytes_to_write, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { ADFI_write_data_chunk( file_index, &new_block_offset, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, NULL, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ /** Allocate a data-chunk-table for two entries **/ ADFI_file_malloc( file_index, 2 * TAG_SIZE + 5 * DISK_POINTER_SIZE, &dct_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Write data-chunk-table to disk **/ data_chunk_entry_table[0].start.block = node.data_chunks.block ; data_chunk_entry_table[0].start.offset = node.data_chunks.offset ; /** get the size of the data_chunk for the table end pointer **/ chunk_start.block = node.data_chunks.block ; chunk_start.offset = node.data_chunks.offset + TAG_SIZE ; ADFI_adjust_disk_pointer( &chunk_start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_read_disk_pointer_from_disk( file_index, chunk_start.block, chunk_start.offset, &data_chunk_entry_table[0].end, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; data_chunk_entry_table[1].start.block = new_block_offset.block ; data_chunk_entry_table[1].start.offset = new_block_offset.offset ; chunk_start.block = new_block_offset.block ; chunk_start.offset = new_block_offset.offset + TAG_SIZE ; ADFI_adjust_disk_pointer( &chunk_start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** get the size of the data_chunk for the table end pointer **/ ADFI_read_disk_pointer_from_disk( file_index, chunk_start.block, chunk_start.offset, &data_chunk_entry_table[1].end, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_write_data_chunk_table( file_index, &dct_block_offset, 2, data_chunk_entry_table, error_return ) ; /** Update node header with number of data-chunks = 2 and the pointer to the data-chunk-table **/ node.data_chunks.block = dct_block_offset.block ; node.data_chunks.offset = dct_block_offset.offset ; node.number_of_data_chunks = 2 ; ADFI_write_node_header( file_index, &block_offset, &node, error_return ); CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { /** Write the new data to existing data-chunk **/ ADFI_write_data_chunk( file_index, &node.data_chunks, tokenized_data_type, file_bytes, chunk_size, start_byte, block_bytes, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ } /* end else if */ else { /** Multiple data chunks **/ /** Allocate memory for the data-chunk-table, with an additional entry in case we need to grow it **/ data_chunk_table = (struct DATA_CHUNK_TABLE_ENTRY *) malloc( (node.number_of_data_chunks + 1 ) * sizeof( *data_chunk_table ) ) ; if( data_chunk_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Read in the table **/ ADFI_read_data_chunk_table( file_index, &node.data_chunks, data_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** looping on the data-chunks, write the size of the current chunk **/ chunk_end_byte = 0 ; bytes_written = 0 ; for( i=0; i<(int)node.number_of_data_chunks; i++ ) { chunk_size = (data_chunk_table[i].end.block - data_chunk_table[i].start.block) * DISK_BLOCK_SIZE + (data_chunk_table[i].end.offset - data_chunk_table[i].start.offset) - (TAG_SIZE + DISK_POINTER_SIZE) ; chunk_end_byte += chunk_size ; /** If start of block not in this chunk then continue **/ if ( start_byte > chunk_end_byte ) continue ; /** Set offset into the current chunk **/ if ( start_byte > (chunk_end_byte - chunk_size) ) /** The start of the block is inside the current chunk so adjust the offset to the beginning of the block **/ start_offset = ( start_byte - (chunk_end_byte-chunk_size) ) ; else start_offset = 0 ; /** Check to be sure we aren't writing too much data **/ bytes_to_write = chunk_size - start_offset ; if( bytes_written + bytes_to_write > block_bytes ) { bytes_to_write = block_bytes - bytes_written ; } /* end if */ if( bytes_to_write == 0 || (chunk_end_byte-chunk_size) > end_byte ) continue ; /** Write the chunk **/ ADFI_write_data_chunk( file_index, &data_chunk_table[i].start, tokenized_data_type, file_bytes, chunk_size, start_offset, bytes_to_write, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** note: memory_bytes and file_bytes might be different (e.g., if machine is "IEEE_BIG" and file is "CRAY") in which case data pointer advances at a different rate from file pointer. **/ data += (bytes_to_write * memory_bytes ) / file_bytes ; bytes_written += bytes_to_write ; } /* end for */ /** If we are out of data-chunks and have data left, allocate a new data-chunk in the file. **/ total_bytes -= chunk_end_byte ; if( total_bytes > 0 ) { /** Write data-chunk-table to disk **/ /** allocate data space in the file **/ ADFI_file_malloc( file_index, 2 * TAG_SIZE + DISK_POINTER_SIZE + total_bytes, &data_chunk_table[ node.number_of_data_chunks ].start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; data_chunk_table[ node.number_of_data_chunks ].end.block = data_chunk_table[ node.number_of_data_chunks ].start.block ; data_chunk_table[ node.number_of_data_chunks ].end.offset = data_chunk_table[ node.number_of_data_chunks ].start.offset + TAG_SIZE + DISK_POINTER_SIZE + total_bytes ; ADFI_adjust_disk_pointer( &data_chunk_table[ node.number_of_data_chunks ].end, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** allocate space for the new data-chunk-entry-table **/ ADFI_file_malloc( file_index, 2 * TAG_SIZE + (2 * (node.number_of_data_chunks + 1) + 1) * DISK_POINTER_SIZE, &dct_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_write_data_chunk_table( file_index, &dct_block_offset, node.number_of_data_chunks+1, data_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if ( bytes_written < block_bytes ) { bytes_to_write = block_bytes - bytes_written ; start_offset = MAX ( 0L, (start_byte - total_bytes) ) ; ADFI_write_data_chunk( file_index, &data_chunk_table[node.number_of_data_chunks ].start, tokenized_data_type, file_bytes, total_bytes, start_offset, bytes_to_write, data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { ADFI_write_data_chunk( file_index, &data_chunk_table[node.number_of_data_chunks ].start, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, NULL, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ /** Free the old data-chunk-table **/ ADFI_file_free( file_index, &node.data_chunks, 0, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Update node header with number of data-chunks++ and the pointer to the data-chunk-table **/ node.number_of_data_chunks++ ; node.data_chunks.block = dct_block_offset.block ; node.data_chunks.offset = dct_block_offset.offset ; ADFI_write_node_header( file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ free( data_chunk_table ) ; } /* end else */ /** Finally, update modification date **/ ADFI_write_modification_date( file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Write_Block_Data */ /* end of file ADF_Write_Block_Data.c */ /* file ADF_Write_Data.c */ /*********************************************************************** ADF Write Data: Write data to a Node, with partial capabilities. See ADF_Read_Data for description. ADF_Write_Data( ID, s_start[], s_end[], s_stride[], m_num_dims, m_dims[], m_start[], m_end[], m_stride[], data, error_return ) input: const double ID The ID of the node to use. input: const int s_start[] The starting dimension values to use in the database (node). input: const int s_end[] The ending dimension values to use in the database (node). input: const int s_stride[] The stride values to use in the database (node). input: const int m_num_dims The number of dimensions to use in memory. input: const int m_dims[] The dimensionality to use in memory. input: const int m_start[] The starting dimension values to use in memory. input: const int m_end[] The ending dimension values to use in memory. input: const int m_stride[] The stride values to use in memory. input: const char *data The start of the data in memory. output: int *error_return Error return. ***********************************************************************/ void ADF_Write_Data( const double ID, const cgsize_t s_start[], const cgsize_t s_end[], const cgsize_t s_stride[], const int m_num_dims, const cgsize_t m_dims[], const cgsize_t m_start[], const cgsize_t m_end[], const cgsize_t m_stride[], const char *data, int *error_return ) { unsigned int file_index ; struct DISK_POINTER block_offset, dct_block_offset, relative_block ; struct DISK_POINTER data_start, new_block_offset ; struct DISK_POINTER chunk_start, end_of_chunk_tag ; struct NODE_HEADER node ; struct DATA_CHUNK_TABLE_ENTRY *data_chunk_table ; struct TOKENIZED_DATA_TYPE tokenized_data_type[ 1 + (ADF_DATA_TYPE_LENGTH + 1)/3 ] ; cglong_t current_disk[ADF_MAX_DIMENSIONS] ; cglong_t current_memory[ADF_MAX_DIMENSIONS] ; cgulong_t total_disk_elements, total_memory_elements ; cgulong_t disk_offset, memory_offset ; cgulong_t memory_dims[ADF_MAX_DIMENSIONS]; int formats_compare ; char disk_format, machine_format ; int i ; int file_bytes = 0 ; int memory_bytes = 0 ; char tag[TAG_SIZE+1] ; cgulong_t total_bytes, disk_elem ; cglong_t current_bytes, chunk_total_bytes ; double LID ; cgulong_t relative_offset, current_chunk, current_chunk_size, past_chunk_sizes ; if( (s_start == NULL) || (s_end == NULL) || (s_stride == NULL) || (m_dims == NULL) || (m_start == NULL) || (m_end == NULL) || (m_stride == NULL) || (data == NULL) ) { *error_return = NULL_POINTER ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ *error_return = NO_ERROR ; data_chunk_table = 0L ; ADFI_chase_link( ID, &LID, &file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Get datatype length **/ ADFI_evaluate_datatype( file_index, node.data_type, &file_bytes, &memory_bytes, tokenized_data_type, &disk_format, &machine_format, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( (file_bytes == 0) || (node.number_of_dimensions == 0) ) { *error_return = NO_DATA ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ ADFI_count_total_array_points( node.number_of_dimensions, node.dimension_values, s_start, s_end, s_stride, &total_disk_elements, &disk_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; for (i = 0; i < m_num_dims; i++) memory_dims[i] = m_dims[i]; ADFI_count_total_array_points( (unsigned int)m_num_dims, memory_dims, m_start, m_end, m_stride, &total_memory_elements, &memory_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; if( total_disk_elements != total_memory_elements ) { *error_return = UNEQUAL_MEMORY_AND_DISK_DIMS ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Calculate the total number of data bytes **/ total_bytes = file_bytes ; for( i=0; i<(int)node.number_of_dimensions; i++ ) total_bytes *= node.dimension_values[i] ; if( total_bytes == 0 ) { *error_return = ZERO_DIMENSIONS ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** check for need of data translation **/ ADFI_file_and_machine_compare( file_index, tokenized_data_type, &formats_compare, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** If there currently is NO data, allocate disk space for it **/ if( node.number_of_data_chunks == 0 ) { ADFI_file_malloc( file_index, total_bytes + TAG_SIZE + TAG_SIZE + DISK_POINTER_SIZE, &node.data_chunks, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** initialize the new disk_space with zero's, then we'll write the partial data **/ ADFI_write_data_chunk( file_index, &node.data_chunks, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, 0L, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Record the modified the node-header **/ node.number_of_data_chunks = 1 ; ADFI_write_node_header( file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** If one data chunk, check to see if we need to add a second **/ else if( node.number_of_data_chunks == 1 ) { /** Get the data length **/ ADFI_read_chunk_length( file_index, &node.data_chunks, tag, &end_of_chunk_tag, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; tag[TAG_SIZE] = '\0' ; /** Check start-of-chunk tag **/ if( ADFI_stridx_c( tag, data_chunk_start_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Point to the start of the data **/ data_start.block = node.data_chunks.block ; data_start.offset = node.data_chunks.offset + TAG_SIZE + DISK_POINTER_SIZE ; ADFI_adjust_disk_pointer( &data_start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** See if the new data exceedes the existing data space **/ chunk_total_bytes = end_of_chunk_tag.offset - data_start.offset + (end_of_chunk_tag.block - data_start.block) * DISK_BLOCK_SIZE ; /** If Data grew: Allocate more data-space and initialize to zero**/ if( (cglong_t) total_bytes > chunk_total_bytes ) { /** Allocate memory for the data-chunk-table, with an additional entry in case we need to grow it **/ data_chunk_table = (struct DATA_CHUNK_TABLE_ENTRY *) malloc( (node.number_of_data_chunks + 1 ) * sizeof( *data_chunk_table ) ) ; if( data_chunk_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Allocate a second data chunk **/ total_bytes -= chunk_total_bytes ; ADFI_file_malloc( file_index, total_bytes + TAG_SIZE + TAG_SIZE + DISK_POINTER_SIZE, &new_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Initialize the new data with zeros **/ ADFI_write_data_chunk( file_index, &new_block_offset, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, 0L, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Allocate a data-chunk-table for two entries **/ ADFI_file_malloc( file_index, 2 * TAG_SIZE + 5 * DISK_POINTER_SIZE, &dct_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Write data-chunk-table to disk **/ data_chunk_table[0].start.block = node.data_chunks.block ; data_chunk_table[0].start.offset = node.data_chunks.offset ; chunk_start.block = node.data_chunks.block ; chunk_start.offset = node.data_chunks.offset + TAG_SIZE ; ADFI_adjust_disk_pointer( &chunk_start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** get the size of the data_chunk for the table end pointer **/ ADFI_read_disk_pointer_from_disk( file_index, chunk_start.block, chunk_start.offset, &data_chunk_table[0].end, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; data_chunk_table[1].start.block = new_block_offset.block ; data_chunk_table[1].start.offset = new_block_offset.offset ; chunk_start.block = new_block_offset.block ; chunk_start.offset = new_block_offset.offset + TAG_SIZE ; ADFI_adjust_disk_pointer( &chunk_start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** get the size of the data_chunk for the table end pointer **/ ADFI_read_disk_pointer_from_disk( file_index, chunk_start.block, chunk_start.offset, &data_chunk_table[1].end, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_write_data_chunk_table( file_index, &dct_block_offset, 2, data_chunk_table, error_return ) ; /** Update node header with number of data-chunks = 2 and the pointer to the data-chunk-table **/ node.data_chunks.block = dct_block_offset.block ; node.data_chunks.offset = dct_block_offset.offset ; node.number_of_data_chunks = 2 ; ADFI_write_node_header( file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ } /* end else if */ else { /** Multiple data chunks, check to see if we need to add one mode **/ /** Allocate memory for the data-chunk-table, with an additional entry in case we need to grow it **/ data_chunk_table = (struct DATA_CHUNK_TABLE_ENTRY *) malloc( (node.number_of_data_chunks + 1 ) * sizeof( *data_chunk_table ) ) ; if( data_chunk_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Read in the table **/ ADFI_read_data_chunk_table( file_index, &node.data_chunks, data_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** looping on the data-chunks, look at the size of the chunks **/ for( i=0; i<(int)node.number_of_data_chunks; i++ ) { current_bytes = (data_chunk_table[i].end.block - data_chunk_table[i].start.block) * DISK_BLOCK_SIZE + (data_chunk_table[i].end.offset - data_chunk_table[i].start.offset) - (TAG_SIZE + DISK_POINTER_SIZE) ; total_bytes -= current_bytes ; if( total_bytes <= 0 ) break ; } /* end for */ /** If we are out of data-chunks and have data left, allocate a new data-chunk in the file. **/ if( total_bytes > 0 ) { /** Write data-chunk-table to disk **/ /** allocate data space in the file **/ ADFI_file_malloc( file_index, 2 * TAG_SIZE + DISK_POINTER_SIZE + total_bytes, &data_chunk_table[ node.number_of_data_chunks ].start, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; data_chunk_table[ node.number_of_data_chunks ].end.block = data_chunk_table[ node.number_of_data_chunks ].start.block ; data_chunk_table[ node.number_of_data_chunks ].end.offset = data_chunk_table[ node.number_of_data_chunks ].start.offset + TAG_SIZE + DISK_POINTER_SIZE + total_bytes ; ADFI_adjust_disk_pointer( &data_chunk_table[ node.number_of_data_chunks ].end, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** allocate space for the new data-chunk-entry-table **/ ADFI_file_malloc( file_index, 2 * TAG_SIZE + (2 * (node.number_of_data_chunks + 1) + 1) * DISK_POINTER_SIZE, &dct_block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; ADFI_write_data_chunk_table( file_index, &dct_block_offset, node.number_of_data_chunks+1, data_chunk_table, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Initialize the new data chunk to zeros **/ ADFI_write_data_chunk( file_index, &data_chunk_table[node.number_of_data_chunks ].start, tokenized_data_type, file_bytes, total_bytes, 0, total_bytes, 0L, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Free the old data-chunk-table **/ ADFI_file_free( file_index, &node.data_chunks, 0, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Update node header with number of data-chunks++ and the pointer to the data-chunk-table **/ node.number_of_data_chunks++ ; node.data_chunks.block = dct_block_offset.block ; node.data_chunks.offset = dct_block_offset.offset ; ADFI_write_node_header( file_index, &block_offset, &node, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ } /* end else */ /** Do single data-chunks here... **/ if( node.number_of_data_chunks == 1 ) { /** Point to the start of the data **/ block_offset.block = node.data_chunks.block ; block_offset.offset = node.data_chunks.offset + TAG_SIZE + DISK_POINTER_SIZE + disk_offset * file_bytes ; ADFI_adjust_disk_pointer( &block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; /** Setup initial indexing **/ for( i=0; i<(int)node.number_of_dimensions; i++ ) current_disk[i] = s_start[i] ; for( i=0; i DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /** Here is where we need to check for spanning multiple data-chunks **/ /** Put the data out to disk **/ if( formats_compare ) { /* directly */ ADFI_write_file( file_index, block_offset.block, block_offset.offset, file_bytes, (char *)data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { /* translated */ ADFI_write_data_translated( file_index, block_offset.block, block_offset.offset, tokenized_data_type, file_bytes, file_bytes, (char *)data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ /** Increment disk/memory pointers, for the special case of one dimensional data we will a simple increment to maximize the throughput. Thus for block writes you can temporarily change to 1D for the read to improve efficiency. Note total size shouldn't change!! **/ if( disk_elem < total_disk_elements - 1 ) { if ( node.number_of_dimensions == 1 ) { disk_offset = s_stride[0]; current_disk[0] += disk_offset; if ( current_disk[0] > s_end[0] ) current_disk[0] = s_end[0] ; } /* end if */ else { ADFI_increment_array( node.number_of_dimensions, node.dimension_values, s_start, s_end, s_stride, current_disk, &disk_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ if ( m_num_dims == 1 ) { memory_offset = m_stride[0]; current_memory[0] += disk_offset; if ( current_memory[0] > m_end[0] ) current_memory[0] = m_end[0] ; } /* end if */ else { ADFI_increment_array( (unsigned int)m_num_dims, memory_dims, m_start, m_end, m_stride, current_memory, &memory_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ block_offset.offset += disk_offset * file_bytes ; if ( block_offset.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &block_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Adjust data pointer **/ data += memory_offset * memory_bytes ; } /* end if */ } /* end for */ } /* end if */ else { /** Point to the start of the data **/ current_chunk = 0 ; past_chunk_sizes = 0 ; relative_offset = disk_offset * file_bytes ; current_chunk_size = (data_chunk_table[ current_chunk ].end.block - data_chunk_table[ current_chunk ].start.block) * DISK_BLOCK_SIZE + (data_chunk_table[ current_chunk ].end.offset - data_chunk_table[ current_chunk ].start.offset) - (TAG_SIZE + DISK_POINTER_SIZE) ; /** Setup initial indexing **/ for( i=0; i<(int)node.number_of_dimensions; i++ ) current_disk[i] = s_start[i] ; for( i=0; i= past_chunk_sizes + current_chunk_size ) { if( ++current_chunk >= node.number_of_data_chunks ) { *error_return = INCOMPLETE_DATA ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { past_chunk_sizes += current_chunk_size ; current_chunk_size = (data_chunk_table[ current_chunk ].end.block - data_chunk_table[ current_chunk ].start.block) * DISK_BLOCK_SIZE + (data_chunk_table[ current_chunk ].end.offset - data_chunk_table[ current_chunk ].start.offset) - (TAG_SIZE + DISK_POINTER_SIZE) ; } /* end else */ } /* end while */ /** Put the data to disk **/ relative_block.block = data_chunk_table[ current_chunk ].start.block ; relative_block.offset = data_chunk_table[ current_chunk ].start.offset + (TAG_SIZE + DISK_POINTER_SIZE) + (relative_offset - past_chunk_sizes) ; if ( relative_block.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &relative_block, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Put the data out to disk **/ if( formats_compare ) { /* directly */ ADFI_write_file( file_index, relative_block.block, relative_block.offset, file_bytes, (char *)data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ else { /* translated */ ADFI_write_data_translated( file_index, relative_block.block, relative_block.offset, tokenized_data_type, file_bytes, file_bytes, (char *)data, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end if */ /** Increment disk and memory pointers **/ if( disk_elem < total_disk_elements - 1 ) { if ( node.number_of_dimensions == 1 ) { disk_offset = s_stride[0]; current_disk[0] += disk_offset; if ( current_disk[0] > s_end[0] ) current_disk[0] = s_end[0] ; } /* end if */ else { ADFI_increment_array( node.number_of_dimensions, node.dimension_values, s_start, s_end, s_stride, current_disk, &disk_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ relative_offset += disk_offset * file_bytes ; if ( m_num_dims == 1 ) { memory_offset = m_stride[0]; current_memory[0] += disk_offset; if ( current_memory[0] > m_end[0] ) current_memory[0] = m_end[0] ; } /* end if */ else { ADFI_increment_array( (unsigned int)m_num_dims, memory_dims, m_start, m_end, m_stride, current_memory, &memory_offset, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end else */ /** Adjust data pointer **/ data += memory_offset * memory_bytes ; } /* end if */ } /* end for */ } /* end else */ if( data_chunk_table != 0L ) free( data_chunk_table ) ; /** Finally, update modification date **/ ADFI_write_modification_date( file_index, error_return ) ; CHECK_ADF_ABORT( *error_return ) ; } /* end of ADF_Write_Data */ /* end of file ADF_Write_Data.c */ /* end of combine 2.0 */ CGNS-4.5.0/src/adf/ADF_internals.c000066400000000000000000011321101474000356600164140ustar00rootroot00000000000000/* created by combine 2.0 */ /* file ADFI_AAA_var.c */ /*** File: ADF_internals.c ---------------------------------------------------------------------- BOEING ---------------------------------------------------------------------- Project: CGNS Author: Tom Dickens 234-1024 tpd6908@yak.ca.boeing.com Date: 3/2/1995 Purpose: Provide the underlying support for the ADF-Core. ---------------------------------------------------------------------- ---------------------------------------------------------------------- Notes: Integer numbers are stored on disk as ASCII-hex numbers. 2 bytes gives a number from 0 to 255, 4 bytes 0 to 65,535, 8 bytes 0 to 4,294,967,295, and 12 bytes from 0 to 281,474,976,710,655. Pointers are 12 bytes. 8 bytes pointing to a 4096-byte chunk on disk, and 4 bytes is an offset into that chunk. This gives a maximum file size of 17,592,186,048,512 bytes (17.5 Tera bytes). ---------------------------------------------------------------------- The tables below detail the format of the information which makes up the ADF file. There are 7 different, unique types of data "chunks" used. Three of these are of fixed length, and the other four are variable in length. With the exception of numeric data (user's data), all information in an ADF file is written in ASCII. Uniquely-defined boundary-tags are used to surround all "chunks" of information. These tags are checked to confirm "chunk" type and also to ensure data integrity. ---------------------------------------------------------------------- 186 Physical disk-First block bytes start end description range / format 32 0 31 "what" description "@(#)ADF Database Version AXXxxx>" 4 32 35 "AdF0" boundary tag Tag 28 36 63 Creation date/time "Wed Apr 19 09:33:25 1995 " 4 64 67 "AdF1" boundary tag Tag 28 68 95 Modification date/time "Wed Apr 19 09:33:29 1995 " 4 96 99 "AdF2" boundary tag Tag 1 100 100 Numeric format ['B', 'L', 'C', 'N'] 1 101 101 Duplicate of numeric format ['B', 'L', 'C', 'N'] 4 102 105 "AdF3" boundary tag Tag 2 106 107 sizeof( char ) 0 to 255 2 108 109 sizeof( short ) 0 to 255 2 110 111 sizeof( int ) 0 to 255 2 112 113 sizeof( long ) 0 to 255 2 114 115 sizeof( float ) 0 to 255 2 116 117 sizeof( double ) 0 to 255 2 118 119 sizeof( char * ) 0 to 255 2 120 121 sizeof( short * ) 0 to 255 2 122 123 sizeof( int *) 0 to 255 2 124 125 sizeof( long * ) 0 to 255 2 126 127 sizeof( float *) 0 to 255 2 128 129 sizeof( double *) 0 to 255 4 130 133 "AdF4" boundary tag Tag 12 134 145 Root-node header pointer Disk chunk, chunk offset. 12 146 157 End-of-File pointer Disk chunk, chunk offset. 12 158 169 Free-Chunk table pointer Disk chunk, chunk offset. 12 170 181 Extra pointer Disk chunk, chunk offset. 4 182 185 "AdF5" boundary tag Tag 80 Free-Chunk table bytes start end description range / format 4 0 3 "fCbt" boundary tag Tag 12 4 15 First small block pointer Disk chunk, chunk offset. 12 16 27 Last small block pointer Disk chunk, chunk offset. 12 28 39 First medium block pointer Disk chunk, chunk offset. 12 40 51 Last medium block pointer Disk chunk, chunk offset. 12 52 63 First large block pointer Disk chunk, chunk offset. 12 64 75 Last large block pointer Disk chunk, chunk offset. 4 76 79 "fcte" boundarg tag Tag Variable: min 32 Free Chunk bytes start end description range / format 4 0 3 "FreE" boundary tag Tag 12 4 15 Pointer to End-of-Chunk-Tag 12 16 27 Pointer to Next-Chunk in list 0 28 - more free space 4 28 31 "EndC" boundarg tag Tag Note: There can occur other free space "gas" in the file which are smaller than the 32-bytes needed to have tags and pointers. The convention in these cases is to just fill the entire free space with the letter z, lower-case. 246 Node header bytes start end description range / format 4 0 3 "NoDe" boundary tag Tag 32 4 35 Name Text: Blank filled 32 36 67 Label Text: Blank filled 8 68 75 Number of sub-nodes 0 to 4,294,967,295 8 76 83 Entries for sub-nodes 0 to 4,294,967,295 12 84 95 Pointer to sub-node table Disk chunk, chunk offset. 32 96 127 Data-type Text: Blank filled 2 128 129 Number of dimensions 0 to 12 8 130 137 Dimension value 0 0 to 4,294,967,295 8 138 145 Dimension value 1 0 to 4,294,967,295 8 146 153 Dimension value 2 0 to 4,294,967,295 8 154 161 Dimension value 3 0 to 4,294,967,295 8 162 169 Dimension value 4 0 to 4,294,967,295 8 170 177 Dimension value 5 0 to 4,294,967,295 8 178 185 Dimension value 6 0 to 4,294,967,295 8 186 193 Dimension value 7 0 to 4,294,967,295 8 194 201 Dimension value 8 0 to 4,294,967,295 8 202 209 Dimension value 9 0 to 4,294,967,295 8 210 217 Dimension value 10 0 to 4,294,967,295 8 218 225 Dimension value 11 0 to 4,294,967,295 4 226 229 Number of data chunks 0 to 65,535 12 230 241 Pointer to data chunk (or table) Disk chunk, chunk offset. 4 242 245 "TaiL" boundary tag Tag Variable: min 64 Sub-node table bytes start end description range / format 4 0 3 "SNTb" boundary tag Tag 12 4 15 Pointer to End-of-Table-Tag 32 16 47 Child's name Text: Blank filled 12 48 59 Pointer to child Disk chunk, chunk offset. 32 - - Child's name Text: Blank filled 12 - - Pointer to child Disk chunk, chunk offset. 32 - - Child's name Text: Blank filled 12 - - Pointer to child Disk chunk, chunk offset. 32 - - Child's name Text: Blank filled 12 - - Pointer to child Disk chunk, chunk offset. 32 - - Child's name Text: Blank filled 12 - - Pointer to child Disk chunk, chunk offset. 32 - - Child's name Text: Blank filled 12 - - Pointer to child Disk chunk, chunk offset. 4 60 63 "snTE" boundary tag Tag Variable: min 44 Data-chunk table bytes start end description range / format 4 0 3 "DCtb" boundary tag Tag 12 4 15 Pointer to End-of-Table-Tag 12 16 27 Pointer to data start Disk chunk, chunk offset. 12 28 39 Pointer to data end Disk chunk, chunk offset. 12 - - Pointer to data start Disk chunk, chunk offset. 12 - - Pointer to data end Disk chunk, chunk offset. 12 - - Pointer to data start Disk chunk, chunk offset. 12 - - Pointer to data end Disk chunk, chunk offset. 12 - - Pointer to data start Disk chunk, chunk offset. 12 - - Pointer to data end Disk chunk, chunk offset. 4 40 43 "dcTE" boundarg tag Tag Variable: min 32 Data-chunks (Minimum is 32 bytes, which corresponds to the size required for a free-chunk) bytes start end description range / format 4 0 3 "DaTa" boundary tag Tag 12 4 15 Pointer to End-of-Data-Tag 16 16 27 The data 4 28 31 "dEnD" boundarg tag Tag **/ /*********************************************************************** Includes ***********************************************************************/ #ifndef _WIN32 #define _POSIX_C_SOURCE 200112L #endif #include #include #include #include #include #include #include #include #if defined(_WIN32) && !defined(__NUTC__) # include # define ACCESS _access # define OPEN _open # define CLOSE _close # define FILENO _fileno # define READ _read # define WRITE _write # define LSEEK _lseek #else # include # include # include # define ACCESS access # define OPEN open # define CLOSE close # define FILENO fileno # define READ read # define WRITE write # define LSEEK lseek #endif #include "ADF.h" #include "ADF_internals.h" #ifdef MEM_DEBUG #include "cg_malloc.h" #endif #include "cgns_io.h" /* for cgio_find_file */ #if 0 #define CHECK_ABORT(E) if(E!=NO_ERROR){int a=0;int b=1/a;} #else #define CHECK_ABORT(E) if(E!=NO_ERROR)return; #endif /*********************************************************************** Large File Support - files > 2Gb on 32-bit machines ***********************************************************************/ #ifdef HAVE_OPEN64 # define file_open open64 #else # define file_open OPEN #endif #ifdef HAVE_LSEEK64 # ifdef _WIN32 typedef __int64 file_offset_t; # define file_seek _lseeki64 # else typedef off64_t file_offset_t; # define file_seek lseek64 # endif #else typedef off_t file_offset_t; # define file_seek LSEEK #endif extern int ADF_sys_err; /* how many file data structures to add when increasing */ #define ADF_FILE_INC 5 /* open file data structure */ ADF_FILE *ADF_file; int maximum_files = 0; /** Track the format of this machine as well as the format of eack of the files. This is used for reading and writing numeric data associated with the nodes, which may include numeric-format translations. **/ static char ADF_this_machine_format = UNDEFINED_FORMAT_CHAR ; static char ADF_this_machine_os_size = UNDEFINED_FORMAT_CHAR ; /** we need a block of "zz"-bytes for dead-space **/ static char block_of_ZZ[ SMALLEST_CHUNK_SIZE ] ; static int block_of_ZZ_initialized = FALSE ; /** we need a block of "xx"-bytes for free-blocks **/ static char block_of_XX[ DISK_BLOCK_SIZE ] ; static int block_of_XX_initialized = FALSE ; /** we need a block of null-bytes for disk conditioning **/ static char block_of_00[ DISK_BLOCK_SIZE ] ; static int block_of_00_initialized = FALSE ; /** read/write conversion buffer **/ #define CONVERSION_BUFF_SIZE 100000 static unsigned char from_to_data[ CONVERSION_BUFF_SIZE ] ; /** read/write buffering variables **/ static char rd_block_buffer[DISK_BLOCK_SIZE] ; static cglong_t last_rd_block = -1 ; static int last_rd_file = -1 ; static int num_in_rd_block = -1 ; static char wr_block_buffer[DISK_BLOCK_SIZE] ; static cglong_t last_wr_block = -2 ; static int last_wr_file = -2 ; static int flush_wr_block = -2 ; static double last_link_ID = 0.0; static double last_link_LID = 0.0; enum { FLUSH, FLUSH_CLOSE }; /** Assumed machine variable sizes for the currently supported machines. For ordering of data see the Figure_Machine_Format function. Note that when opening a new file not in the machine format these are the sizes used!! **/ enum { TO_FILE_FORMAT, FROM_FILE_FORMAT } ; #define NUMBER_KNOWN_MACHINES 5 static size_t machine_sizes[NUMBER_KNOWN_MACHINES][16] = { /* IEEE BIG 32 */ { 1, 1, 1, 2, 2, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4 }, /* IEEE SML 32 */ { 1, 1, 1, 2, 2, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4 }, /* IEEE BIG 64 */ { 1, 1, 1, 2, 2, 4, 4, 8, 8, 4, 8, 8, 8, 8, 8, 8 }, /* IEEE SML 64 */ { 1, 1, 1, 2, 2, 4, 4, 8, 8, 4, 8, 8, 8, 8, 8, 8 }, /* CRAY 64 */ { 1, 1, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 } } ; /*********************************************************************** pows: Powers of 16, from 16^0 to 16^7 ASCII_Hex: Hex numbers from 0 to 15. ***********************************************************************/ static const unsigned int pows[8] = { /** Powers of 16 **/ 1, 16, 256, 4096, 65536, 1048576, 16777216, 268435456 } ; static const char ASCII_Hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' } ; /*********************************************************************** Character string defining the data tags: ***********************************************************************/ static char *file_header_tags[] = { "AdF0", "AdF1", "AdF2", "AdF3", "AdF4", "AdF5" } ; static char node_start_tag[] = "NoDe" ; static char node_end_tag[] = "TaiL" ; static char free_chunk_table_start_tag[] = "fCbt" ; static char free_chunk_table_end_tag[] = "Fcte" ; static char free_chunk_start_tag[] = "FreE" ; static char free_chunk_end_tag[] = "EndC" ; static char sub_node_start_tag[] = "SNTb" ; static char sub_node_end_tag[] = "snTE" ; static char data_chunk_table_start_tag[] = "DCtb" ; static char data_chunk_table_end_tag[] = "dcTE" ; char data_chunk_start_tag[] = "DaTa" ; /* needed in ADF_interface.c */ static char data_chunk_end_tag[] = "dEnD" ; /*********************************************************************** Priority Stack Buffer is used to buffer some of the overhead of reading small blocks of file control information like the node header by saving the data into a memory buffer. The buffer has a priority value associated with it and is used to determine which entry to replace when the stack is full!! Each stack entry could be as large as 274 bytes since the stack data could be for a node where NODE_HEADER_SIZE = 246. ***********************************************************************/ #define MAX_STACK 50 static struct { int file_index; cgulong_t file_block; unsigned int block_offset; int stack_type; char *stack_data; int priority_level; } PRISTK[MAX_STACK] ; /* Define stack types */ enum { FILE_STK=1, NODE_STK, DISK_PTR_STK, FREE_CHUNK_STK, SUBNODE_STK }; /* Define stack control modes */ enum { INIT_STK, CLEAR_STK, CLEAR_STK_TYPE, DEL_STK_ENTRY, GET_STK, SET_STK }; /*********************************************************************** Defined macros ***********************************************************************/ #define EVAL_2_BYTES( C0, C1 ) (((C0)<<8)+((C1))) #define EVAL_4_BYTES( C0, C1, C2, C3 ) (((C0)<<24)+((C1)<<16)+((C2)<<8)+((C3))) /* end of file ADFI_AAA_var.c */ /* file ADFI_ASCII_Hex_2_unsigned_int.c */ /*********************************************************************** ADFI ASCII Hex to unsigned int: Convert a number of ASCII-HEX into an unsigned integer. input: const unsigned int minimum Expected minimum number. input: const unsigned int maximum Expected maximum number. input: const unsigned int string_length Length (bytes) of the input string. input: const char string[] The input string. output: unsigned int *number The resulting number. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER NULL_STRING_POINTER STRING_LENGTH_ZERO STRING_LENGTH_TOO_BIG STRING_NOT_A_HEX_STRING NUMBER_LESS_THAN_MINIMUM NUMBER_GREATER_THAN_MAXIMUM ***********************************************************************/ void ADFI_ASCII_Hex_2_unsigned_int( const unsigned int minimum, const unsigned int maximum, const unsigned int string_length, const char string[], unsigned int *number, int *error_return ) { unsigned int i, /** Index from 0 to string_length - 1 **/ ir, /** Index from string_length - 1 to 0 **/ j, /** Temoprary integer variable **/ num ; /** Working value of the number **/ if( string == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( string_length == 0 ) { *error_return = STRING_LENGTH_ZERO ; return ; } /* end if */ if( number == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( string_length > 8 ) { *error_return = STRING_LENGTH_TOO_BIG ; return ; } /* end if */ if( minimum > maximum ) { *error_return = MINIMUM_GT_MAXIMUM ; return ; } /* end if */ *error_return = NO_ERROR ; /** Convert the ASCII-Hex string into decimal **/ num = 0 ; ir = (string_length - 1) << 2; for( i=0; i= '0' && string[i] <= '9') j = string[i] - 48; else if (string[i] >= 'A' && string[i] <= 'F') j = string[i] - 55; else if (string[i] >= 'a' && string[i] <= 'f') j = string[i] - 87; else { *error_return = STRING_NOT_A_HEX_STRING ; return ; } num += (j << ir); ir -= 4; } if( num < minimum ) { *error_return = NUMBER_LESS_THAN_MINIMUM ; return ; } /* end if */ if( num > maximum ) { *error_return = NUMBER_GREATER_THAN_MAXIMUM ; return ; } /* end if */ /** Return the number **/ *number = num ; } /* end of ADFI_ASCII_Hex_2_unsigned_int */ /* end of file ADFI_ASCII_Hex_2_unsigned_int.c */ /*------------------------------------------------------------------------------------*/ static void ADFI_convert_integers( const int size, const int count, const char from_format, const char to_format, const char *from_data, char *to_data, int *error_return) { int do_swap = 0; if (from_format == 'N' || to_format == 'N') { *error_return = CANNOT_CONVERT_NATIVE_FORMAT; return; } if (from_format != to_format) { switch (EVAL_2_BYTES(from_format, to_format)) { case EVAL_2_BYTES('L', 'B'): case EVAL_2_BYTES('B', 'L'): case EVAL_2_BYTES('L', 'C'): case EVAL_2_BYTES('C', 'L'): do_swap = 1; break; case EVAL_2_BYTES('B', 'C'): case EVAL_2_BYTES('C', 'B'): break; default: *error_return = ADF_FILE_FORMAT_NOT_RECOGNIZED; return; } } *error_return = NO_ERROR; if (do_swap) { int n, i; for (n = 0; n < count; n++) { for (i = 0; i < size; i++) { to_data[i] = from_data[size-i-1]; } to_data += size; from_data += size; } } else { memcpy(to_data, from_data, (size_t)size * (size_t)count); } } /*------------------------------------------------------------------------------------*/ /* file ADFI_Abort.c */ /*********************************************************************** ADFI Abort: Do any cleanup and then shut the application down. input: const int error_code Error which caused the Abort. output: -none- Hey, we ain't coming back... ***********************************************************************/ void ADFI_Abort( const int error_code ) { fprintf(stderr,"ADF Aborted: Exiting\n" ) ; exit( error_code ) ; } /* end of ADFI_Abort */ /* end of file ADFI_Abort.c */ /* file ADFI_ID_2_file_block_offset.c */ /*********************************************************************** ADFI ID to file block and offset: The ID is a combination of the file-index, the block within the file, and an offset within the block. the file index is an unsigned 16-bit int. block pointer is a 32-bit unsigned int. block offset is a 16-bit unsigned int. input: const double ID Given ADF ID. output: unsigned int *file_index File index from the ID. output: unsigned long *file_block File block from the ID. output: unsigned long *block_offset Block offset from the ID. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER FILE_INDEX_OUT_OF_RANGE BLOCK_OFFSET_OUT_OF_RANGE ***********************************************************************/ void ADFI_ID_2_file_block_offset( const double ID, unsigned int *file_index, cgulong_t *file_block, cgulong_t *block_offset, int *error_return ) { unsigned char * cc; if( (file_index == NULL) || (file_block == NULL) || (block_offset == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( ID == 0.0 ) { *error_return = NODE_ID_ZERO ; return ; } /* end if */ *error_return = NO_ERROR ; cc = (unsigned char *) &ID; #ifdef PRINT_STUFF printf("In ADFI_ID_2_file_block_offset: ID=%lf\n",ID); printf("cc[0-7] = %02X %02X %02X %02X %02X %02X %02X %02X \n", cc[0], cc[1], cc[2], cc[3], cc[4], cc[5], cc[6], cc[7] ) ; #endif /** Unmap the bytes from the character **/ #ifdef NEW_ID_MAPPING if (ADF_this_machine_format == IEEE_LITTLE_FORMAT_CHAR) { *file_index = (((unsigned int)(cc[7] & 0x3F)) << 6) + (((unsigned int)(cc[6] & 0xFC)) >> 2); *file_block = (((cgulong_t)(cc[6] & 0x03)) << 36) + (((cgulong_t)(cc[5] & 0xFF)) << 28) + (((cgulong_t)(cc[4] & 0xFF)) << 20) + (((cgulong_t)(cc[3] & 0xFF)) << 12) + (((cgulong_t)(cc[2] & 0xFF)) << 4) + (((cgulong_t)(cc[1] & 0xF0)) >> 4); *block_offset = (((unsigned int)(cc[1] & 0x0F)) << 8) + (((unsigned int)(cc[0] & 0xFF))); } else { *file_index = (((unsigned int)(cc[0] & 0x3F)) << 6) + (((unsigned int)(cc[1] & 0xFC)) >> 2); *file_block = (((cgulong_t)(cc[1] & 0x03)) << 36) + (((cgulong_t)(cc[2] & 0xFF)) << 28) + (((cgulong_t)(cc[3] & 0xFF)) << 20) + (((cgulong_t)(cc[4] & 0xFF)) << 12) + (((cgulong_t)(cc[5] & 0xFF)) << 4) + (((cgulong_t)(cc[6] & 0xF0)) >> 4); *block_offset = (((unsigned int)(cc[6] & 0x0F)) << 8) + (((unsigned int)(cc[7] & 0xFF))); } #if 0 assert(*file_index <= 0xfff); assert(*file_block <= 0x3fffffffff); assert(*block_offset <= 0xfff); #endif #else if ( ADF_this_machine_format == IEEE_BIG_FORMAT_CHAR ) { *file_index = cc[1] + ((cc[0] & 0x3f) << 8) ; *file_block = cc[2] + (cc[3]<<8) + (cc[4]<<16) + (cc[5]<<24) ; *block_offset = cc[6] + (cc[7]<<8) ; } /* end if */ else if ( ADF_this_machine_format == IEEE_LITTLE_FORMAT_CHAR ) { *file_index = cc[6] + ((cc[7] & 0x3f) << 8) ; *file_block = cc[2] + (cc[3]<<8) + (cc[4]<<16) + (cc[5]<<24) ; *block_offset = cc[0] + (cc[1]<<8) ; } /* end else if */ else { *file_index = cc[0] + (cc[1]<<8) ; *file_block = cc[2] + (cc[3]<<8) + (cc[4]<<16) + (cc[5]<<24) ; *block_offset = cc[6] + (cc[7]<<8) ; } /* end else */ #endif #ifdef PRINT_STUFF printf("*file_index=%d, *file_block=%d, *block_offset=%d\n", *file_index, *file_block, *block_offset); #endif if( (int)(*file_index) >= maximum_files ) { *error_return = FILE_INDEX_OUT_OF_RANGE ; return ; } /* end if */ if( *block_offset >= DISK_BLOCK_SIZE ) { *error_return = BLOCK_OFFSET_OUT_OF_RANGE ; return ; } /* end if */ } /* end of ADFI_ID_2_file_block_offset */ /* end of file ADFI_ID_2_file_block_offset.c */ /* file ADFI_add_2_sub_node_table.c */ /*********************************************************************** ADFI add 2 sub node table: Add a child to a parent's sub-node table. input: const int file_index Index of ADF file. input: const struct DISK_POINTER *parent Location of the parent input: const struct DISK_POINTER *child Location of the child. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED SUB_NODE_TABLE_ENTRIES_BAD MEMORY_ALLOCATION_FAILED ***********************************************************************/ void ADFI_add_2_sub_node_table( const int file_index, const struct DISK_POINTER *parent, const struct DISK_POINTER *child, int *error_return ) { struct NODE_HEADER parent_node, child_node ; struct SUB_NODE_TABLE_ENTRY *sub_node_table ; struct DISK_POINTER tmp_disk_ptr ; unsigned int old_num_entries ; int i ; if( (parent == NULL) || (child == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Get node_header for the node (parent) **/ ADFI_read_node_header( file_index, parent, &parent_node, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Get node_header for the node (child) **/ ADFI_read_node_header( file_index, child, &child_node, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check current length of sub-node_table, add space if needed **/ if( parent_node.entries_for_sub_nodes <= parent_node.num_sub_nodes ) { old_num_entries = parent_node.entries_for_sub_nodes ; /** Increase the table space (double it) **/ if( parent_node.entries_for_sub_nodes == 0 ) parent_node.entries_for_sub_nodes = LIST_CHUNK ; else parent_node.entries_for_sub_nodes = (unsigned int) ( (float) parent_node.entries_for_sub_nodes * LIST_CHUNK_GROW_FACTOR ) ; if( parent_node.entries_for_sub_nodes <= parent_node.num_sub_nodes ) { *error_return = SUB_NODE_TABLE_ENTRIES_BAD ; return ; } /* end if */ /** Allocate memory for the required table space in memory **/ sub_node_table = (struct SUB_NODE_TABLE_ENTRY *) malloc( parent_node.entries_for_sub_nodes * sizeof( *sub_node_table ) ) ; if( sub_node_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; return ; } /* end if */ /** If sub-node table exists, get it **/ if( old_num_entries > 0 ) { ADFI_read_sub_node_table( file_index, &parent_node.sub_node_table, sub_node_table, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ /** Blank out the new part of the sub-node_table **/ for( i=parent_node.num_sub_nodes; i<(int) parent_node.entries_for_sub_nodes; i++ ) { strncpy( sub_node_table[i].child_name, /* " ", ADF_NAME_LENGTH ) ; */ "unused entry in sub-node-table ", ADF_NAME_LENGTH ) ; sub_node_table[i].child_location.block = 0 ; sub_node_table[i].child_location.offset = DISK_BLOCK_SIZE ; } /* end for */ /** Allocate memory for the required table space on disk **/ if( parent_node.num_sub_nodes > 0 ) { /* delete old table from file */ ADFI_delete_sub_node_table( file_index, &parent_node.sub_node_table, old_num_entries, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ ADFI_file_malloc( file_index, TAG_SIZE + DISK_POINTER_SIZE + TAG_SIZE + parent_node.entries_for_sub_nodes * (ADF_NAME_LENGTH + DISK_POINTER_SIZE), &tmp_disk_ptr, error_return ) ; if( *error_return != NO_ERROR ) return ; parent_node.sub_node_table.block = tmp_disk_ptr.block ; parent_node.sub_node_table.offset = tmp_disk_ptr.offset ; /** Write out modified sub_node_table **/ ADFI_write_sub_node_table( file_index, &parent_node.sub_node_table, parent_node.entries_for_sub_nodes, (struct SUB_NODE_TABLE_ENTRY *)sub_node_table, error_return ) ; free( sub_node_table ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ /** Insert new entry in sub-node table **/ tmp_disk_ptr.block = parent_node.sub_node_table.block ; tmp_disk_ptr.offset = parent_node.sub_node_table.offset + TAG_SIZE + DISK_POINTER_SIZE + parent_node.num_sub_nodes * (ADF_NAME_LENGTH + DISK_POINTER_SIZE) ; ADFI_adjust_disk_pointer( &tmp_disk_ptr, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Write the child's name **/ ADFI_write_file( file_index, tmp_disk_ptr.block, tmp_disk_ptr.offset, ADF_NAME_LENGTH, child_node.name, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Write out new sub_node_table entry **/ tmp_disk_ptr.offset += ADF_NAME_LENGTH ; ADFI_adjust_disk_pointer( &tmp_disk_ptr, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_write_disk_pointer_2_disk( file_index, tmp_disk_ptr.block, tmp_disk_ptr.offset, child, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Write out modified parent node-header **/ parent_node.num_sub_nodes++ ; ADFI_write_node_header( file_index, parent, &parent_node, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end of ADFI_add_2_sub_node_table */ /* end of file ADFI_add_2_sub_node_table.c */ /* file ADFI_adjust_disk_pointer.c */ /*********************************************************************** ADFI adjust disk pointer: Adjust the disk pointer so that the offset is in a legal range; from 0 and < DISK_BLOCK_SIZE. input: const struct DISK_POINTER *block_offset output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER BLOCK_OFFSET_OUT_OF_RANGE ***********************************************************************/ void ADFI_adjust_disk_pointer( struct DISK_POINTER *block_offset, int *error_return ) { cgulong_t oblock ; cgulong_t nblock ; if( block_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ *error_return = NO_ERROR ; if ( block_offset->offset < DISK_BLOCK_SIZE ) return ; /** Calculate the number of blocks in the current offset **/ nblock = (cgulong_t) (block_offset->offset / DISK_BLOCK_SIZE) ; /** Adjust block/offset checking for block roll-over **/ oblock = block_offset->block ; block_offset->block += nblock ; block_offset->offset -= nblock * DISK_BLOCK_SIZE ; if ( block_offset->block < oblock ) { *error_return = BLOCK_OFFSET_OUT_OF_RANGE ; return ; } /* end if */ } /* end of ADFI_adjust_disk_pointer */ /* end of file ADFI_adjust_disk_pointer.c */ /* file ADFI_big_endian_32_swap_64.c */ /*********************************************************************** ADFI big endian 32 swap 64: input: const char from_format Format to convert from. 'B','L','C','N' input: const char from_os_size Format to convert from. 'B','L' input: const char to_format Format to convert to. input: const char to_os_size Format to convert to. 'B','L' input: const char data_type[2] The type of data to convert. MT I4 I8 U4 U8 R4 R8 X4 X8 C1 B1 input: const unsigned long delta_from_bytes Number of from_bytes used. input: const unsigned long delta_to_bytes Number of to_bytes used. input: const char *from_data The data to convert from. output: char *to_data The resulting data. output: int *error_return Error return. Recognized data types: Machine representations Type Notation IEEE_BIG IEEE_LITTLE Cray 32 64 32 64 No data MT Integer 32 I4 I4 I4 I4 I4 I8 Integer 64 I8 -- I8 -- I8 I8 Unsigned 32 U4 I4 I4 I4 I4 I8 Unsigned 64 U8 -- I8 -- I8 I8 Real 32 R4 R4 R4 R4 R4 R8 Real 64 R8 R8 R8 R8 R8 R8 Complex 64 X4 R4R4 R4R4 R4R4 R4R4 R8R8 Complex 128 X8 R8R8 R8R8 R8R8 R8R8 R8R8 Character (unsigned byte) C1 C1 C1 C1 C1 C1 Byte (unsigned byte) B1 C1 C1 C1 C1 C1 Machine Numeric Formats: ***IEEE_BIG (SGI-Iris Assembly Language Programmer's Guide, pages 1-2, 6-3) I4: Byte0 Byte1 Byte2 Byte3 MSB---------------------LSB R4: Byte0 Byte1 Byte2 Byte3 Bits: sign-bit, 8-bit exponent, 23-bit mantissa The sign of the exponent is: 1=positive, 0=negative (NOT 2's complement) The interpretation of the floating-point number is: >>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, 11-bit exponent, 52-bit mantissa Machine Numeric Formats: ***IEEE_LITTLE ( The backwards Big Endian ) I4: Byte0 Byte1 Byte2 Byte3 LSB---------------------MSB R4: Byte0 Byte1 Byte2 Byte3 Bits: 23-bit mantissa, 8-bit exponent, sign-bit The sign of the exponent is: 1=positive, 0=negative (NOT 2's complement) The interpretation of the floating-point number is: >>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: 52-bit mantissa, 11-bit exponent, sign-bit Note: To convert between these two formats the order of the bytes is reversed since by definition the Big endian starts at the LSB and goes to the MSB where the little goes form the MSB to the LSB of the word. *** Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADFI_big_endian_32_swap_64( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ) { if( (from_data == NULL) || (to_data == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (delta_from_bytes == 0) || (delta_to_bytes == 0) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (from_format == 'N') || (to_format == 'N') ) { *error_return = CANNOT_CONVERT_NATIVE_FORMAT ; return ; } /* end if */ *error_return = NO_ERROR ; if ( delta_to_bytes == delta_from_bytes ) { memcpy( to_data, from_data, (size_t)delta_from_bytes ) ; } /* end if */ else if ( delta_from_bytes < delta_to_bytes ) { switch( EVAL_2_BYTES( data_type[0], data_type[1] ) ) { case EVAL_2_BYTES( 'I', '8' ): if( (from_data[0] & 0x80) == 0x80 ) { /* Negative number */ to_data[0] = 0xff ; to_data[1] = 0xff ; to_data[2] = 0xff ; to_data[3] = 0xff ; } /* end if */ else { to_data[0] = 0x00 ; to_data[1] = 0x00 ; to_data[2] = 0x00 ; to_data[3] = 0x00 ; } /* end else */ to_data[4] = from_data[0] ; to_data[5] = from_data[1] ; to_data[6] = from_data[2] ; to_data[7] = from_data[3] ; break ; default: *error_return = INVALID_DATA_TYPE ; return ; } /* end switch */ } /* end else if */ else { switch( EVAL_2_BYTES( data_type[0], data_type[1] ) ) { case EVAL_2_BYTES( 'I', '8' ): to_data[0] = from_data[4] ; to_data[1] = from_data[5] ; to_data[2] = from_data[6] ; to_data[3] = from_data[7] ; break ; default: *error_return = INVALID_DATA_TYPE ; return ; } /* end switch */ } /* end else */ } /* end of ADFI_big_endian_32_swap_64 */ /* end of file ADFI_big_endian_32_swap_64.c */ /* file ADFI_big_endian_to_cray.c */ /*********************************************************************** ADFI big endian to cray: input: const char from_format Format to convert from. 'B','L','C','N' input: const char from_os_size Format to convert from. 'B','L' input: const char to_format Format to convert to. input: const char to_os_size Format to convert to. 'B','L' input: const char data_type[2] The type of data to convert. MT I4 I8 U4 U8 R4 R8 X4 X8 C1 B1 input: const unsigned long delta_from_bytes Number of from_bytes used. input: const unsigned long delta_to_bytes Number of to_bytes used. input: const char *from_data The data to convert from. output: char *to_data The resulting data. output: int *error_return Error return. Recognized data types: Machine representations Type Notation IEEE_BIG IEEE_LITTLE Cray 32 64 32 64 No data MT Integer 32 I4 I4 I4 I4 I4 I8 Integer 64 I8 -- I8 -- I8 I8 Unsigned 32 U4 I4 I4 I4 I4 I8 Unsigned 64 U8 -- I8 -- I8 I8 Real 32 R4 R4 R4 R4 R4 R8 Real 64 R8 R8 R8 R8 R8 R8 Complex 64 X4 R4R4 R4R4 R4R4 R4R4 R8R8 Complex 128 X8 R8R8 R8R8 R8R8 R8R8 R8R8 Character (unsigned byte) C1 C1 C1 C1 C1 C1 Byte (unsigned byte) B1 C1 C1 C1 C1 C1 Machine Numeric Formats: ***IEEE_BIG (SGI-Iris Assembly Language Programmer's Guide, pages 1-2, 6-3) I4: Byte0 Byte1 Byte2 Byte3 MSB---------------------LSB R4: Byte0 Byte1 Byte2 Byte3 Bits: sign-bit, 8-bit exponent, 23-bit mantissa The sign of the exponent is: 1=positive, 0=negative (NOT 2's complement) The interpretation of the floating-point number is: >>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, 11-bit exponent, 52-bit mantissa ***Cray (Cray CFT77 Reference Manual, pages G-1 G-2) I8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 MSB-----------------------------------------------------LSB R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, exponent-sign, 14-bit exponent, 48-bit mantissa Note: Exponent sign: 1 in this bits indicates a positive exponent sign, thus bit 62 is the inverse of bit 61 (the sign in the exponent). The exception to this is a zero, in which all 64 bits are zero! The interpretation of the floating-point number is: >>> .mantissia(fraction) X 2^exponent. <<< The mantissia is left justified (the leftmost bit is a 1). This MUST be done! *** Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADFI_big_endian_to_cray( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ) { int i, exp ; if( (from_data == NULL) || (to_data == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (delta_from_bytes == 0) || (delta_to_bytes == 0) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (from_format == 'N') || (to_format == 'N') ) { *error_return = CANNOT_CONVERT_NATIVE_FORMAT ; return ; } /* end if */ *error_return = NO_ERROR ; switch( EVAL_2_BYTES( data_type[0], data_type[1] ) ) { case EVAL_2_BYTES( 'M', 'T' ): *error_return = NO_DATA ; return ; case EVAL_2_BYTES( 'C', '1' ): case EVAL_2_BYTES( 'B', '1' ): to_data[0] = from_data[0] ; break ; case EVAL_2_BYTES( 'I', '4' ): if( (from_data[0] & 0x80) == 0x80 ) { /* Negative number */ to_data[0] = 0xff ; to_data[1] = 0xff ; to_data[2] = 0xff ; to_data[3] = 0xff ; } /* end if */ else { to_data[0] = 0x00 ; to_data[1] = 0x00 ; to_data[2] = 0x00 ; to_data[3] = 0x00 ; } /* end else */ to_data[4] = from_data[0] ; to_data[5] = from_data[1] ; to_data[6] = from_data[2] ; to_data[7] = from_data[3] ; break ; case EVAL_2_BYTES( 'U', '4' ): to_data[0] = 0x00 ; to_data[1] = 0x00 ; to_data[2] = 0x00 ; to_data[3] = 0x00 ; to_data[4] = from_data[0] ; to_data[5] = from_data[1] ; to_data[6] = from_data[2] ; to_data[7] = from_data[3] ; break ; case EVAL_2_BYTES( 'I', '8' ): if( (from_data[0] & 0x80) == 0x80 ) { /* Negative number */ to_data[0] = 0xff ; to_data[1] = 0xff ; to_data[2] = 0xff ; to_data[3] = 0xff ; } /* end if */ else { to_data[0] = 0x00 ; to_data[1] = 0x00 ; to_data[2] = 0x00 ; to_data[3] = 0x00 ; } /* end else */ for( i=0; i<(int)delta_from_bytes; i++ ) to_data[8-delta_from_bytes+i] = from_data[i] ; break ; case EVAL_2_BYTES( 'U', '8' ): to_data[0] = 0x00 ; to_data[1] = 0x00 ; to_data[2] = 0x00 ; to_data[3] = 0x00 ; for( i=0; i<(int)delta_from_bytes; i++ ) to_data[8-delta_from_bytes+i] = from_data[i] ; break ; case EVAL_2_BYTES( 'R', '4' ): for( i=0; i<8; i++ ) to_data[i] = 0x00 ; /** Check for zero: a special case on the Cray (exponent sign) **/ if( (from_data[0] == 0x00) && (from_data[1] == 0x00) && (from_data[2] == 0x00) && (from_data[3] == 0x00) ) break ; /** Convert the sign **/ to_data[0] = from_data[0] & 0x80 ; /** Convert the exponent **/ /** 8 bits to 14 bits. Sign extent from 8 to 14 **/ /** Cray exponent is 2 greater than the Iris **/ exp = (from_data[0] & 0x3f) << 1 ; if( (from_data[1] & 0x80) == 0x80 ) exp += 1 ; if( (from_data[0] & 0x40) == 0x00 ) /* set sign */ exp -= 128 ; exp += 2 ; to_data[1] = exp & 0xff ; if( exp < 0 ) to_data[0] |= 0x3f ; /* exponent sign 0, sign extend exponent */ else to_data[0] |= 0x40 ; /* exponent sign 1 */ /** Convert the mantissia **/ /** 23 bits to 48 bits. Left shift 25 bits, zero fill **/ to_data[2] = from_data[1] | 0x80 ; to_data[3] = from_data[2] ; to_data[4] = from_data[3] ; break ; case EVAL_2_BYTES( 'R', '8' ): for( i=0; i<8; i++ ) to_data[i] = 0x00 ; /** Check for zero: a special case on the Cray (exponent sign) **/ if( (from_data[0] == 0x00) && (from_data[1] == 0x00) && (from_data[2] == 0x00) && (from_data[3] == 0x00) ) break ; /** Convert the sign **/ to_data[0] = from_data[0] & 0x80 ; /** Convert the exponent **/ /** 11 bits to 14 bits. Sign extent from 11 to 14 **/ /** Cray exponent is 2 greater than the Iris **/ exp = ((from_data[0] & 0x3f) << 4) + ((from_data[1]>>4)&0x0f) ; if( (from_data[0] & 0x40) == 0x00 ) /* set sign */ exp -= 1024 ; exp += 2 ; to_data[1] = (unsigned int)(exp & 0xff) ; to_data[0] |= ((exp>>8) & 0x03) ; if( exp < 0 ) to_data[0] |= 0x3c ; /* exponent sign 0, sign extend exponent */ else to_data[0] |= 0x40 ; /* exponent sign 1 */ /** Convert the mantissia **/ /** 52 bits to 48 bits. Use 48, drop last 4 bits **/ to_data[2] = 0x80 | ((from_data[1]<<3)&0x78) | ((from_data[2]>>5)&0x07) ; for( i=3; i<8; i++ ) to_data[i] = ((from_data[i-1]<<3)&0xF8) | ((from_data[i]>>5)&0x07) ; #ifdef PRINT_STUFF printf("from:" ) ; for( i=0; i<8; i++ ) printf("%02x ", from_data[i] ) ; printf("to:" ) ; for( i=0; i<8; i++ ) printf("%02x ", to_data[i] ) ; printf("\n" ) ; #endif break ; case EVAL_2_BYTES( 'X', '4' ): ADFI_big_endian_to_cray( from_format, from_os_size, to_format, to_os_size, "R4", delta_from_bytes, delta_to_bytes, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_big_endian_to_cray( from_format, from_os_size, to_format, to_os_size, "R4", delta_from_bytes, delta_to_bytes, &from_data[4], &to_data[8], error_return ) ; if( *error_return != NO_ERROR ) return ; break ; case EVAL_2_BYTES( 'X', '8' ): ADFI_big_endian_to_cray( from_format, from_os_size, to_format, to_os_size, "R8", delta_from_bytes, delta_to_bytes, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_big_endian_to_cray( from_format, from_os_size, to_format, to_os_size, "R8", delta_from_bytes, delta_to_bytes, &from_data[8], &to_data[8], error_return ) ; if( *error_return != NO_ERROR ) return ; break ; default: *error_return = INVALID_DATA_TYPE ; return ; } /* end switch */ } /* end of ADFI_big_endian_to_cray */ /* end of file ADFI_big_endian_to_cray.c */ /* file ADFI_big_little_endian_swap.c */ /*********************************************************************** ADFI big little endian swap: input: const char from_format Format to convert from. 'B','L','C','N' input: const char from_os_size Format to convert from. 'B','L' input: const char to_format Format to convert to. input: const char to_os_size Format to convert to. 'B','L' input: const char data_type[2] The type of data to convert. MT I4 I8 U4 U8 R4 R8 X4 X8 C1 B1 input: const unsigned long delta_from_bytes Number of from_bytes used. input: const unsigned long delta_to_bytes Number of to_bytes used. input: const char *from_data The data to convert from. output: char *to_data The resulting data. output: int *error_return Error return. Recognized data types: Machine representations Type Notation IEEE_BIG IEEE_LITTLE Cray 32 64 32 64 No data MT Integer 32 I4 I4 I4 I4 I4 I8 Integer 64 I8 -- I8 -- I8 I8 Unsigned 32 U4 I4 I4 I4 I4 I8 Unsigned 64 U8 -- I8 -- I8 I8 Real 32 R4 R4 R4 R4 R4 R8 Real 64 R8 R8 R8 R8 R8 R8 Complex 64 X4 R4R4 R4R4 R4R4 R4R4 R8R8 Complex 128 X8 R8R8 R8R8 R8R8 R8R8 R8R8 Character (unsigned byte) C1 C1 C1 C1 C1 C1 Byte (unsigned byte) B1 C1 C1 C1 C1 C1 Machine Numeric Formats: ***IEEE_BIG (SGI-Iris Assembly Language Programmer's Guide, pages 1-2, 6-3) I4: Byte0 Byte1 Byte2 Byte3 MSB---------------------LSB R4: Byte0 Byte1 Byte2 Byte3 Bits: sign-bit, 8-bit exponent, 23-bit mantissa The sign of the exponent is: 1=positive, 0=negative (NOT 2's complement) The interpretation of the floating-point number is: >>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, 11-bit exponent, 52-bit mantissa Machine Numeric Formats: ***IEEE_LITTLE ( The backwards Big Endian ) I4: Byte0 Byte1 Byte2 Byte3 LSB---------------------MSB R4: Byte0 Byte1 Byte2 Byte3 Bits: 23-bit mantissa, 8-bit exponent, sign-bit The sign of the exponent is: 1=positive, 0=negative (NOT 2's complement) The interpretation of the floating-point number is: >>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: 52-bit mantissa, 11-bit exponent, sign-bit Note: To convert between these two formats the order of the bytes is reversed since by definition the Big endian starts at the LSB and goes to the MSB where the little goes form the MSB to the LSB of the word. *** Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADFI_big_little_endian_swap( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ) { int i ; if( (from_data == NULL) || (to_data == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (delta_from_bytes == 0) || (delta_to_bytes == 0) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (from_format == 'N') || (to_format == 'N') ) { *error_return = CANNOT_CONVERT_NATIVE_FORMAT ; return ; } /* end if */ if ( from_os_size != to_os_size || delta_to_bytes != delta_from_bytes ) { *error_return = DATA_TYPE_NOT_SUPPORTED ; return ; } /** end if **/ *error_return = NO_ERROR ; for ( i=0; i<(int)delta_from_bytes; i++ ) to_data[i] = from_data[delta_from_bytes-1-i] ; } /* end of ADFI_big_little_endian_swap */ /* end of file ADFI_big_little_endian_swap.c */ /* file ADFI_blank_fill_string.c */ /*********************************************************************** ADFI blank fill string: input/output: char *str The string to fill with blanks. input: const int length The total length of the string to fill. ***********************************************************************/ void ADFI_blank_fill_string( char *str, const int length ) { int i ; for( i=(int)strlen( str ); iblock, &block_offset->offset, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_read_node_header( *file_index, block_offset, node_header, error_return ) ; return ; } Link_ID = ID ; while( done == FALSE ) { /** Get the file, block, and offset numbers from the ID **/ ADFI_ID_2_file_block_offset( Link_ID, file_index, &block_offset->block, &block_offset->offset, error_return ) ; CHECK_ABORT(*error_return); /** Get node_header for the node **/ ADFI_read_node_header( *file_index, block_offset, node_header, error_return ) ; CHECK_ABORT(*error_return); if( (node_header->data_type[0] == 'L') && (node_header->data_type[1] == 'K')) { /** node is a link get file and path data **/ ADF_Get_Link_Path( Link_ID, link_file, link_path, error_return ) ; CHECK_ABORT(*error_return); if( link_file[0] != '\0' ) { /* A filename is specified, open it. **/ /* locate the file */ ADFI_find_file(ADF_file[*file_index].file_name, link_file, error_return); CHECK_ABORT(*error_return); /** Link_ID = root-node of the new file. note: the file could already be opened, and may be the current file! **/ ADFI_get_file_index_from_name( link_file, &found, &link_file_index, &Link_ID, error_return ) ; if( ! found ) { /** Not found; try to open it **/ if (ACCESS(link_file,2)) /* check for read-only mode */ strcpy (status, "READ_ONLY"); else /* open in same mode as current file */ strcpy (status, ADF_file[*file_index].open_mode) ; if ( ADFI_stridx_c(status, "READ_ONLY" ) != 0 ) strcpy (status, "OLD") ; ADFI_link_open( link_file, status, &Link_ID, &link_file_index, error_return ); CHECK_ABORT(*error_return); } /* end else */ ADFI_link_add( *file_index, link_file_index, found ); } /* end if */ else { /* filename NOT specified, file must be root of link */ ADF_Get_Node_ID( Link_ID, "/", &temp_ID, error_return ) ; CHECK_ABORT(*error_return); Link_ID = temp_ID ; } /* end else */ /** Get the node ID of the link to node (may be other links) **/ ADF_Get_Node_ID( Link_ID, link_path, &temp_ID, error_return ) ; if( *error_return == CHILD_NOT_OF_GIVEN_PARENT ) *error_return = LINK_TARGET_NOT_THERE ; /* A better error message */ CHECK_ABORT(*error_return); Link_ID = temp_ID ; if( ++link_depth > ADF_MAXIMUM_LINK_DEPTH ) { *error_return = LINKS_TOO_DEEP ; return ; } /* end if */ } /* end if */ else { /** node is NOT a link **/ done = TRUE ; } /* end else */ } /* end while */ *LID = Link_ID ; if (Link_ID != ID) { last_link_ID = ID; last_link_LID = Link_ID; } } /* end of ADFI_chase_link */ /* end of file ADFI_chase_link.c */ /* file ADFI_check_4_child_name.c */ /*********************************************************************** ADFI check 4 child name: input: const int file_index Index of ADF file. input: const struct DISK_POINTER *parent Location of the parent input: const char *name The name of the new child. output: int *found 0 if NOT found, else 1. output: struct DISK_POINTER *sub_node_entry_location output: struct SUB_NODE_TABLE_ENTRY *sub_node_entry output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER NULL_STRING_POINTER ADF_FILE_NOT_OPENED MEMORY_ALLOCATION_FAILED ***********************************************************************/ void ADFI_check_4_child_name( const int file_index, const struct DISK_POINTER *parent, const char *name, int *found, struct DISK_POINTER *sub_node_entry_location, struct SUB_NODE_TABLE_ENTRY *sub_node_entry, int *error_return ) { struct NODE_HEADER parent_node ; struct SUB_NODE_TABLE_ENTRY *sub_node_table ; int i ; if( (parent == NULL) || (found == NULL) || (sub_node_entry_location == NULL) || (sub_node_entry == NULL ) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( name == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; *found = 0 ; /* default to NOT found */ /** Get node_header for the node **/ ADFI_read_node_header( file_index, parent, &parent_node, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check for valid node name **/ /** If parent has no children, the new name MUST be NOT found **/ if( parent_node.num_sub_nodes == 0 ) { *found = 0 ; return ; } /* end if */ /** Allocate memory for the required table space in memory **/ sub_node_table = (struct SUB_NODE_TABLE_ENTRY *) malloc( parent_node.entries_for_sub_nodes * sizeof( *sub_node_table ) ) ; if( sub_node_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; return ; } /* end if */ if( parent_node.entries_for_sub_nodes > 0 ) { ADFI_read_sub_node_table( file_index, &parent_node.sub_node_table, sub_node_table, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ /** Check all names for our new name **/ for( i=0; i<(int)parent_node.num_sub_nodes; i++ ) { ADFI_compare_node_names( sub_node_table[i].child_name, name, found, error_return ) ; if( *error_return != NO_ERROR ) break ; if( *found == 1 ) { /* name was found, save off addresses */ sub_node_entry_location->block = parent_node.sub_node_table.block ; sub_node_entry_location->offset = parent_node.sub_node_table.offset + TAG_SIZE + DISK_POINTER_SIZE + (ADF_NAME_LENGTH + DISK_POINTER_SIZE) * i ; ADFI_adjust_disk_pointer( sub_node_entry_location, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Also save off the child's name **/ strncpy( sub_node_entry->child_name, sub_node_table[i].child_name, ADF_NAME_LENGTH ) ; sub_node_entry->child_location.block = sub_node_table[i].child_location.block ; sub_node_entry->child_location.offset = sub_node_table[i].child_location.offset ; /** Get out of the for loop **/ break ; } /* end if */ } /* end for */ free( sub_node_table ) ; } /* end of ADFI_check_4_child_name */ /* end of file ADFI_check_4_child_name.c */ /* file ADFI_check_string_length.c */ /*********************************************************************** ADFI check string length: Check a character string for: being a NULL pointer, being too long, being zero length. input: const char *str The input string. input: const int max_length Maximum allowable length of the string. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER STRING_LENGTH_ZERO STRING_LENGTH_TOO_BIG ***********************************************************************/ void ADFI_check_string_length( const char *str, const int max_length, int *error_return ) { int str_length, i ; if( str == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ str_length = (int)strlen( str ) ; if( str_length == 0 ) { *error_return = STRING_LENGTH_ZERO ; return ; } /* end if */ if( (int) strlen( str ) > max_length ) { *error_return = STRING_LENGTH_TOO_BIG ; return ; } /* end if */ /** Check for blank string **/ *error_return = STRING_LENGTH_ZERO ; for( i=0; i= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /* close files that his file links to */ for (index = 0; index < ADF_file[file_index].nlinks; index++) { ADFI_close_file( ADF_file[file_index].links[index], error_return); } /* don't close until in_use is 0 */ index = ADF_file[file_index].in_use - 1; if ( index == 0) { ADF_sys_err = 0; if( ADF_file[file_index].file >= 0 ) { ADFI_flush_buffers( file_index, FLUSH_CLOSE, error_return ); if( CLOSE( ADF_file[file_index].file ) < 0 ) { ADF_sys_err = errno; *error_return = FILE_CLOSE_ERROR ; } } /* end if */ ADF_file[file_index].file = -1 ; /** Clear this file's entry **/ ADFI_stack_control(file_index,0,0,CLEAR_STK,0,0,NULL); if (ADF_file[file_index].nlinks) { free (ADF_file[file_index].links); ADF_file[file_index].nlinks = 0; } if (ADF_file[file_index].file_name != NULL) { free (ADF_file[file_index].file_name); ADF_file[file_index].file_name = NULL; } } ADF_file[file_index].in_use = index; /* if no more files open, free data structure */ for (index = 0; index < maximum_files; index++) { if (ADF_file[index].in_use) return; } free (ADF_file); maximum_files = 0; } /* end of ADFI_close_file */ /* end of file ADFI_close_file.c */ /* file ADFI_compare_node_names.c */ /*********************************************************************** ADFI compare node names: input: const char *name Existing node name. input: const char *new_name New node name. output: int *names_match 0 if name do NOT match, else 1. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADFI_compare_node_names( const char *name, const char *new_name, int *names_match, int *error_return ) { int i, new_length ; if( (name == NULL) || (new_name == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( names_match == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ *error_return = NO_ERROR ; *names_match = 0 ; /* Default to NO match */ new_length = (int)strlen( new_name ) ; for( i=0; i>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, 11-bit exponent, 52-bit mantissa Machine Numeric Formats: ***IEEE_LITTLE ( The backwards Big Endian ) I4: Byte0 Byte1 Byte2 Byte3 LSB---------------------MSB R4: Byte0 Byte1 Byte2 Byte3 Bits: 23-bit mantissa, 8-bit exponent, sign-bit The sign of the exponent is: 1=positive, 0=negative (NOT 2's complement) The interpretation of the floating-point number is: >>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: 52-bit mantissa, 11-bit exponent, sign-bit ***Cray (Cray CFT77 Reference Manual, pages G-1 G-2) I8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 MSB-----------------------------------------------------LSB R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, exponent-sign, 14-bit exponent, 48-bit mantissa Note: Exponent sign: 1 in this bits indicates a positive exponent sign, thus bit 62 is the inverse of bit 61 (the sign in the exponent). The exception to this is a zero, in which all 64 bits are zero! The interpretation of the floating-point number is: >>> .mantissia(fraction) X 2^exponent. <<< The mantissia is left justified (the leftmost bit is a 1). This MUST be done! *** Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADFI_convert_number_format( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const int convert_dir, const struct TOKENIZED_DATA_TYPE *tokenized_data_type, const unsigned int length, unsigned char *from_data, unsigned char *to_data, int *error_return ) { unsigned char temp_data[16] ; char data_type[2] ; int current_token ; int array_size ; int l, s ; cgulong_t delta_from_bytes, delta_to_bytes ; if( (from_data == NULL) || (to_data == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( length == 0 ) { *error_return = NUMBER_LESS_THAN_MINIMUM ; return ; } /* end if */ if( (from_format == 'N') || (to_format == 'N') ) { *error_return = CANNOT_CONVERT_NATIVE_FORMAT ; return ; } /* end if */ switch( EVAL_4_BYTES( from_format, to_format, from_os_size, to_os_size ) ) { case EVAL_4_BYTES( 'B', 'B', 'B', 'B' ): case EVAL_4_BYTES( 'C', 'C', 'B', 'B' ): case EVAL_4_BYTES( 'L', 'L', 'B', 'B' ): case EVAL_4_BYTES( 'B', 'B', 'L', 'L' ): case EVAL_4_BYTES( 'C', 'C', 'L', 'L' ): case EVAL_4_BYTES( 'L', 'L', 'L', 'L' ): *error_return = CONVERSION_FORMATS_EQUAL ; return ; } /* end switch */ *error_return = NO_ERROR ; /** loop over each element **/ for ( l=0; l<(int)length; l++ ) { current_token = -1 ; while( tokenized_data_type[ ++current_token ].type[0] != 0 ) { data_type[0] = tokenized_data_type[ current_token ].type[0] ; data_type[1] = tokenized_data_type[ current_token ].type[1] ; array_size = tokenized_data_type[ current_token ].length ; if ( convert_dir == FROM_FILE_FORMAT ) { delta_from_bytes=tokenized_data_type[ current_token ].file_type_size ; delta_to_bytes =tokenized_data_type[ current_token ].machine_type_size ; } /** end if **/ else { delta_to_bytes =tokenized_data_type[ current_token ].file_type_size ; delta_from_bytes=tokenized_data_type[ current_token ].machine_type_size ; } /** end else **/ for ( s=0; s 12) ) { *error_return = BAD_NUMBER_OF_DIMENSIONS ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check the inputs **/ for( i=0; i=1 **/ if( dims[i] < 1 ) { *error_return = BAD_DIMENSION_VALUE ; return ; } /* end if */ /** Check starting values >=1 and <= dims **/ if( (dim_start[i] < 1) || ((cgulong_t)dim_start[i] > dims[i]) ) { *error_return = START_OUT_OF_DEFINED_RANGE ; return ; } /* end if */ /** Check ending values >=1 and <= dims and >= dim_start **/ if( (dim_end[i] < 1) || ((cgulong_t)dim_end[i] > dims[i]) ) { *error_return = END_OUT_OF_DEFINED_RANGE ; return ; } /* end if */ if( dim_end[i] < dim_start[i] ) { *error_return = MINIMUM_GT_MAXIMUM ; return ; } /* end if */ /** Check stride >= 1 **/ if( dim_stride[i] < 1 ) { *error_return = BAD_STRIDE_VALUE ; return ; } /* end if */ } /* end for */ total = 1 ; offset = 0 ; accumlated_size = 1 ; for( i=0; i>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, 11-bit exponent, 52-bit mantissa ***Cray (Cray CFT77 Reference Manual, pages G-1 G-2) I8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 MSB-----------------------------------------------------LSB R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, exponent-sign, 14-bit exponent, 48-bit mantissa Note: Exponent sign: 1 in this bits indicates a positive exponent sign, thus bit 62 is the inverse of bit 61 (the sign in the exponent). The exception to this is a zero, in which all 64 bits are zero! The interpretation of the floating-point number is: >>> .mantissia(fraction) X 2^exponent. <<< The mantissia is left justified (the leftmost bit is a 1). This MUST be done! *** Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADFI_cray_to_big_endian( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ) { int i, exp ; if( (from_data == NULL) || (to_data == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (delta_from_bytes == 0) || (delta_to_bytes == 0) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (from_format == 'N') || (to_format == 'N') ) { *error_return = CANNOT_CONVERT_NATIVE_FORMAT ; return ; } /* end if */ *error_return = NO_ERROR ; switch( EVAL_2_BYTES( data_type[0], data_type[1] ) ) { case EVAL_2_BYTES( 'M', 'T' ): *error_return = NO_DATA ; return ; case EVAL_2_BYTES( 'C', '1' ): case EVAL_2_BYTES( 'B', '1' ): to_data[0] = from_data[0] ; break ; case EVAL_2_BYTES( 'I', '4' ): case EVAL_2_BYTES( 'U', '4' ): to_data[0] = from_data[4] ; to_data[1] = from_data[5] ; to_data[2] = from_data[6] ; to_data[3] = from_data[7] ; break ; case EVAL_2_BYTES( 'I', '8' ): case EVAL_2_BYTES( 'U', '8' ): for( i=0; i<(int) delta_to_bytes; i++ ) to_data[i] = from_data[8-delta_to_bytes+i] ; break ; case EVAL_2_BYTES( 'R', '4' ): for( i=0; i<4; i++ ) to_data[i] = 0x00 ; /** Check for zero: a special case on the Cray (exponent sign) **/ if( (from_data[0] == 0x00) && (from_data[1] == 0x00) && (from_data[2] == 0x00) && (from_data[3] == 0x00) && (from_data[4] == 0x00) && (from_data[5] == 0x00) && (from_data[6] == 0x00) && (from_data[7] == 0x00) ) break ; /** Convert the sign **/ to_data[0] = from_data[0] & 0x80 ; /** Convert the exponent **/ /** 14 bits to 8 bits. Sign extent from 8 to 14 **/ /** Cray exponent is 2 greater than the Iris **/ exp = from_data[1] + ((from_data[0]&0x3f)<<8) ; if( (from_data[0] & 0x40) == 0x00 ) /* set sign */ exp -= 16384 ; exp -= 2 ; if( exp >= 128 ) { *error_return = NUMERIC_OVERFLOW ; return ; } /* end if */ else if ( exp < -128 ) { for( i=0; i<4; i++ ) to_data[i] = 0x00 ; /* underflow set to 0 */ break; } /* end else */ to_data[0] |= ((exp&0x7F) >> 1) ; if( (exp & 0x01) == 0x01 ) /* LSBit of the exponent */ to_data[1] |= 0x80 ; if( exp >= 0 ) /* Set exponent sign */ to_data[0] |= 0x40 ; /** Convert the mantissia **/ /** 48 bits to 23 bits, skip the first '1' (2.fract) **/ to_data[1] |= (from_data[2] & 0x7f) ; to_data[2] = from_data[3] ; to_data[3] = from_data[4] ; break ; case EVAL_2_BYTES( 'R', '8' ): for( i=0; i<8; i++ ) to_data[i] = 0x00 ; /** Check for zero: a special case on the Cray (exponent sign) **/ if( (from_data[0] == 0x00) && (from_data[1] == 0x00) && (from_data[2] == 0x00) && (from_data[3] == 0x00) ) break ; /** Convert the sign **/ to_data[0] = from_data[0] & 0x80 ; /** Convert the exponent **/ /** 14 bits to 11 bits **/ /** Cray exponent is 2 greater than the Iris **/ exp = from_data[1] + ((from_data[0]&0x3f)<<8) ; /* set sign if exponent is non-zero */ if( (exp != 0) && ((from_data[0] & 0x40) == 0x00) ) exp -= 16384 ; exp -= 2 ; if( exp >= 1024 ) { *error_return = NUMERIC_OVERFLOW ; return ; } /* end if */ else if ( exp < -1024 ) { for( i=0; i<4; i++ ) to_data[i] = 0x00 ; /* underflow set to 0 */ break; } /* end else */ to_data[0] |= ((exp & 0x03F0) >> 4) ; to_data[1] |= ((exp & 0x000F) << 4) ; if( exp >= 0 ) /* Set exponent sign */ to_data[0] |= 0x40 ; /** Convert the mantissia **/ /** 48 bits to 52 bits, skip the first '1' (2.fract) **/ to_data[1] |= ((from_data[2] & 0x78) >> 3) ; for( i=2; i<7; i++ ) to_data[i] = ((from_data[i] & 0x07) << 5) | ((from_data[i+1] & 0xf8) >> 3) ; to_data[7] = ((from_data[7] & 0x07) << 5) ; #ifdef PRINT_STUFF printf("from:" ) ; for( i=0; i<8; i++ ) printf("%02x ", from_data[i] ) ; printf("to:" ) ; for( i=0; i<8; i++ ) printf("%02x ", to_data[i] ) ; printf("\n" ) ; #endif break ; case EVAL_2_BYTES( 'X', '4' ): ADFI_cray_to_big_endian( from_format, from_os_size, to_format, to_os_size, "R4", delta_from_bytes, delta_to_bytes, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_cray_to_big_endian( from_format, from_os_size, to_format, to_os_size, "R4", delta_from_bytes, delta_to_bytes, &from_data[8], &to_data[4], error_return ) ; if( *error_return != NO_ERROR ) return ; break ; case EVAL_2_BYTES( 'X', '8' ): ADFI_cray_to_big_endian( from_format, from_os_size, to_format, to_os_size, "R8", delta_from_bytes, delta_to_bytes, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_cray_to_big_endian( from_format, from_os_size, to_format, to_os_size, "R8", delta_from_bytes, delta_to_bytes, &from_data[8], &to_data[8], error_return ) ; if( *error_return != NO_ERROR ) return ; break ; default: *error_return = INVALID_DATA_TYPE ; return ; } /* end switch */ } /* end of ADFI_cray_to_big_endian */ /* end of file ADFI_cray_to_big_endian.c */ /* file ADFI_cray_to_little_endian.c */ /*********************************************************************** ADFI cray to little endian: input: const char from_format Format to convert from. 'B','L','C','N' input: const char from_os_size Format to convert from. 'B','L' input: const char to_format Format to convert to. input: const char to_os_size Format to convert to. 'B','L' input: const char data_type[2] The type of data to convert. MT I4 I8 U4 U8 R4 R8 X4 X8 C1 B1 input: const unsigned long delta_from_bytes Number of from_bytes used. input: const unsigned long delta_to_bytes Number of to_bytes used. input: const char *from_data The data to convert from. output: char *to_data The resulting data. output: int *error_return Error return. Recognized data types: Machine representations Type Notation IEEE_BIG IEEE_L Cray No data MT Integer 32 I4 I4 I4 I4 I4 I8 Integer 64 I8 -- I8 -- I8 I8 Unsigned 32 U4 I4 I4 I4 I4 I8 Unsigned 64 U8 -- I8 -- I8 I8 Real 32 R4 R4 R4 R4 R4 R8 Real 64 R8 R8 R8 R8 R8 R8 Complex 64 X4 R4R4 R4R4 R4R4 R4R4 R8R8 Complex 128 X8 R8R8 R8R8 R8R8 R8R8 R8R8 Character (unsigned byte) C1 C1 C1 C1 C1 C1 Byte (unsigned byte) B1 C1 C1 C1 C1 C1 Machine Numeric Formats: ***IEEE_BIG (SGI-Iris Assembly Language Programmer's Guide, pages 1-2, 6-3) I4: Byte0 Byte1 Byte2 Byte3 MSB---------------------LSB R4: Byte0 Byte1 Byte2 Byte3 Bits: sign-bit, 8-bit exponent, 23-bit mantissa The sign of the exponent is: 1=positive, 0=negative (NOT 2's complement) The interpretation of the floating-point number is: >>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, 11-bit exponent, 52-bit mantissa ***Cray (Cray CFT77 Reference Manual, pages G-1 G-2) I8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 MSB-----------------------------------------------------LSB R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, exponent-sign, 14-bit exponent, 48-bit mantissa Note: Exponent sign: 1 in this bits indicates a positive exponent sign, thus bit 62 is the inverse of bit 61 (the sign in the exponent). The exception to this is a zero, in which all 64 bits are zero! The interpretation of the floating-point number is: >>> .mantissia(fraction) X 2^exponent. <<< The mantissia is left justified (the leftmost bit is a 1). This MUST be done! *** Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADFI_cray_to_little_endian( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ) { int i, exp ; if( (from_data == NULL) || (to_data == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (delta_from_bytes == 0) || (delta_to_bytes == 0) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (from_format == 'N') || (to_format == 'N') ) { *error_return = CANNOT_CONVERT_NATIVE_FORMAT ; return ; } /* end if */ *error_return = NO_ERROR ; switch( EVAL_2_BYTES( data_type[0], data_type[1] ) ) { case EVAL_2_BYTES( 'M', 'T' ): *error_return = NO_DATA ; return ; case EVAL_2_BYTES( 'C', '1' ): case EVAL_2_BYTES( 'B', '1' ): to_data[0] = from_data[0] ; break ; case EVAL_2_BYTES( 'I', '4' ): case EVAL_2_BYTES( 'U', '4' ): to_data[3] = from_data[4] ; to_data[2] = from_data[5] ; to_data[1] = from_data[6] ; to_data[0] = from_data[7] ; break ; case EVAL_2_BYTES( 'I', '8' ): case EVAL_2_BYTES( 'U', '8' ): for( i=0; i<(int) delta_to_bytes; i++ ) to_data[delta_to_bytes-1-i] = from_data[8-delta_to_bytes+i] ; break ; case EVAL_2_BYTES( 'R', '4' ): for( i=0; i<4; i++ ) to_data[i] = 0x00 ; /** Check for zero: a special case on the Cray (exponent sign) **/ if( (from_data[0] == 0x00) && (from_data[1] == 0x00) && (from_data[2] == 0x00) && (from_data[3] == 0x00) && (from_data[4] == 0x00) && (from_data[5] == 0x00) && (from_data[6] == 0x00) && (from_data[7] == 0x00) ) break ; /** Convert the sign **/ to_data[3] = from_data[0] & 0x80 ; /** Convert the exponent **/ /** 14 bits to 8 bits. Sign extent from 8 to 14 **/ /** Cray exponent is 2 greater than the Iris **/ exp = from_data[1] + ((from_data[0]&0x3f)<<8) ; if( (from_data[0] & 0x40) == 0x00 ) /* set sign */ exp -= 16384 ; exp -= 2 ; if( exp >= 128 ) { *error_return = NUMERIC_OVERFLOW ; return ; } /* end if */ else if ( exp < -128 ) { for( i=0; i<4; i++ ) to_data[i] = 0x00 ; /* underflow set to 0 */ break; } /* end else */ to_data[3] |= ((exp&0x7F) >> 1) ; if( (exp & 0x01) == 0x01 ) /* LSBit of the exponent */ to_data[2] |= 0x80 ; if( exp >= 0 ) /* Set exponent sign */ to_data[3] |= 0x40 ; /** Convert the mantissia **/ /** 48 bits to 23 bits, skip the first '1' (2.fract) **/ to_data[2] |= (from_data[2] & 0x7f) ; to_data[1] = from_data[3] ; to_data[0] = from_data[4] ; break ; case EVAL_2_BYTES( 'R', '8' ): for( i=0; i<8; i++ ) to_data[i] = 0x00 ; /** Check for zero: a special case on the Cray (exponent sign) **/ if( (from_data[0] == 0x00) && (from_data[1] == 0x00) && (from_data[2] == 0x00) && (from_data[3] == 0x00) ) break ; /** Convert the sign **/ to_data[7] = from_data[0] & 0x80 ; /** Convert the exponent **/ /** 14 bits to 11 bits **/ /** Cray exponent is 2 greater than the Iris **/ exp = from_data[1] + ((from_data[0]&0x3f)<<8) ; /* set sign if exponent is non-zero */ if( (exp != 0) && ((from_data[0] & 0x40) == 0x00) ) exp -= 16384 ; exp -= 2 ; if( exp >= 1024 ) { *error_return = NUMERIC_OVERFLOW ; return ; } /* end if */ else if ( exp < -1024 ) { for( i=0; i<4; i++ ) to_data[i] = 0x00 ; /* underflow set to 0 */ break; } /* end else */ to_data[7] |= ((exp & 0x03F0) >> 4) ; to_data[6] |= ((exp & 0x000F) << 4) ; if( exp >= 0 ) /* Set exponent sign */ to_data[7] |= 0x40 ; /** Convert the mantissia **/ /** 48 bits to 52 bits, skip the first '1' (2.fract) **/ to_data[6] |= ((from_data[2] & 0x78) >> 3) ; for( i=2; i<7; i++ ) to_data[7-i] = ((from_data[i] & 0x07) << 5) | ((from_data[i+1] & 0xf8) >> 3) ; to_data[0] = ((from_data[7] & 0x07) << 5) ; #ifdef PRINT_STUFF printf("from:" ) ; for( i=0; i<8; i++ ) printf("%02x ", from_data[i] ) ; printf("to:" ) ; for( i=0; i<8; i++ ) printf("%02x ", to_data[i] ) ; printf("\n" ) ; #endif break ; case EVAL_2_BYTES( 'X', '4' ): ADFI_cray_to_little_endian( from_format, from_os_size, to_format, to_os_size, "R4", delta_from_bytes, delta_to_bytes, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_cray_to_little_endian( from_format, from_os_size, to_format, to_os_size, "R4", delta_from_bytes, delta_to_bytes, &from_data[8], &to_data[4], error_return ) ; if( *error_return != NO_ERROR ) return ; break ; case EVAL_2_BYTES( 'X', '8' ): ADFI_cray_to_little_endian( from_format, from_os_size, to_format, to_os_size, "R8", delta_from_bytes, delta_to_bytes, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_cray_to_little_endian( from_format, from_os_size, to_format, to_os_size, "R8", delta_from_bytes, delta_to_bytes, &from_data[8], &to_data[8], error_return ) ; if( *error_return != NO_ERROR ) return ; break ; default: *error_return = INVALID_DATA_TYPE ; return ; } /* end switch */ } /* end of ADFI_cray_to_little_endian */ /* end of file ADFI_cray_to_little_endian.c */ /* file ADFI_delete_data.c */ /*********************************************************************** ADFI delete data: Deletes all data from the file for a node. input: const int file_index The file index. input: const struct NODE_HEADER Node header information. output: int *error_return Error return. ***********************************************************************/ void ADFI_delete_data( const int file_index, const struct NODE_HEADER *node_header, int *error_return ) { struct DATA_CHUNK_TABLE_ENTRY *data_chunk_table ; int i ; *error_return = NO_ERROR ; if( node_header == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ switch( node_header->number_of_data_chunks ) { case 0 : /** No data to free, do nothing **/ return ; case 1 : /** A single data-chunk to free, so free it **/ ADFI_file_free( file_index, &node_header->data_chunks, 0, error_return ) ; if( *error_return != NO_ERROR ) return ; break ; default : /** Multiple data-chunks to free. Free them, and also the data_chunk table **/ /** Allocate memory for the required table space in memory **/ data_chunk_table = (struct DATA_CHUNK_TABLE_ENTRY *) malloc( node_header->number_of_data_chunks * sizeof( *data_chunk_table ) ) ; if( data_chunk_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; return ; } /* end if */ /** Read in the table **/ ADFI_read_data_chunk_table( file_index, &node_header->data_chunks, data_chunk_table, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Free each entry in the table **/ for( i=0; i<(int)node_header->number_of_data_chunks; i++ ) { ADFI_file_free( file_index, &data_chunk_table[i].start, 0, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end for */ free( data_chunk_table ) ; ADFI_file_free( file_index, &node_header->data_chunks, 0, error_return ) ; if( *error_return != NO_ERROR ) return ; break ; }/* end switch */ /** Clear all disk entries off the priority stack for file **/ ADFI_stack_control(file_index, 0, 0, CLEAR_STK_TYPE, DISK_PTR_STK, 0, NULL ) ; } /* end of ADFI_delete_data */ /* end of file ADFI_delete_data.c */ /* file ADFI_delete_from_sub_node_table.c */ /*********************************************************************** ADFI delete from sub node table: Delete a child from a parent's sub-node table. input: const int file_index Index of ADF file. input: const struct DISK_POINTER *parent Location of the parent input: const struct DISK_POINTER *child Location of the child. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_delete_from_sub_node_table( const int file_index, const struct DISK_POINTER *parent, const struct DISK_POINTER *child, int *error_return ) { int i, found ; struct NODE_HEADER parent_node ; struct SUB_NODE_TABLE_ENTRY *sub_node_table ; if( (parent == NULL) || (child == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; ADFI_read_node_header( file_index, parent, &parent_node, error_return ) ; if( *error_return != NO_ERROR ) return ; sub_node_table = (struct SUB_NODE_TABLE_ENTRY *) malloc( parent_node.entries_for_sub_nodes * sizeof( struct SUB_NODE_TABLE_ENTRY ) ) ; if( sub_node_table == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; return ; } /* end if */ ADFI_read_sub_node_table( file_index, &parent_node.sub_node_table, sub_node_table, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Find the child in the parent's sub-node table **/ for( i=0, found = -1 ; i<(int)parent_node.num_sub_nodes ; i++ ) { if( child->block == sub_node_table[i].child_location.block && child->offset == sub_node_table[i].child_location.offset ) { found = i ; break ; } /* end if */ } /* end for */ if( found == -1 ) { *error_return = SUB_NODE_TABLE_ENTRIES_BAD ; free(sub_node_table); return ; } /** Move the rest of the table up to fill the hole **/ for( i=found ; i<(int) (parent_node.num_sub_nodes-1) ; i++ ) { sub_node_table[i].child_location.block = sub_node_table[i+1].child_location.block ; sub_node_table[i].child_location.offset = sub_node_table[i+1].child_location.offset ; strncpy ( sub_node_table[i].child_name, sub_node_table[i+1].child_name, ADF_NAME_LENGTH ) ; } /* end for */ i = parent_node.num_sub_nodes - 1 ; sub_node_table[i].child_location.block = 0 ; sub_node_table[i].child_location.offset = 0 ; strncpy ( sub_node_table[i].child_name, "unused entry in sub-node-table ", ADF_NAME_LENGTH ) ; /** Re-write the parent's sub-node table **/ ADFI_write_sub_node_table( file_index, &parent_node.sub_node_table, parent_node.entries_for_sub_nodes, sub_node_table, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Update the sub-node count and write the parent's node-header **/ parent_node.num_sub_nodes -= 1; ADFI_write_node_header( file_index, parent, &parent_node, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Clear all subnode/disk entries off the priority stack for file **/ ADFI_stack_control(file_index, 0, 0, CLEAR_STK_TYPE, SUBNODE_STK, 0, NULL ) ; ADFI_stack_control(file_index, 0, 0, CLEAR_STK_TYPE, DISK_PTR_STK, 0, NULL ) ; free(sub_node_table); } /* end of ADFI_delete_from_sub_node_table */ /* end of file ADFI_delete_from_sub_node_table.c */ /* file ADFI_delete_sub_node_table.c */ /*********************************************************************** ADFI delete sub node table: Deletes a sub-node table from the file. input: const int file_index Index of ADF file. input: const struct DISK_POINTER *block_offset The block & offset of the sub node table. input: const unsigned int size_sub_node_table Current size of the sub node table (usually node_header.entries_for_sub_nodes). If zero, then no action performed. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED FREE_OF_ROOT_NODE ADF_DISK_TAG_ERROR FREE_OF_FREE_CHUNK_TABLE ***********************************************************************/ void ADFI_delete_sub_node_table( const int file_index, const struct DISK_POINTER *block_offset, const unsigned int size_sub_node_table, int *error_return ) { unsigned int num_bytes ; *error_return = NO_ERROR ; if( block_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ if( size_sub_node_table == 0 ) return ; /* assume nothing to delete */ /* calculate size */ num_bytes = TAG_SIZE + TAG_SIZE + DISK_POINTER_SIZE + size_sub_node_table * (ADF_NAME_LENGTH + DISK_POINTER_SIZE); ADFI_file_free( file_index, block_offset, num_bytes, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Clear all subnode/disk entries off the priority stack for file **/ ADFI_stack_control(file_index, 0, 0, CLEAR_STK_TYPE, SUBNODE_STK, 0, NULL ) ; ADFI_stack_control(file_index, 0, 0, CLEAR_STK_TYPE, DISK_PTR_STK, 0, NULL ) ; } /* end of ADFI_delete_sub_node_table */ /* end of file ADFI_delete_sub_node_table.c */ /* file ADFI_disk_pointer_2_ASCII_Hex.c */ /*********************************************************************** ADFI disk pointer to ASCII Hex: Convert a disk pointer into an ASCII-Hex representation (for disk). input: const struct DISK_POINTER *block_offset Disk-pointer struct. output: char block[8] ASCII block number. output: char offset[4] ASCII offset number. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER NULL_STRING_POINTER ***********************************************************************/ void ADFI_disk_pointer_2_ASCII_Hex( const struct DISK_POINTER *block_offset, char block[8], char offset[4], int *error_return ) { if( block_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (block == NULL) || (offset == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ *error_return = NO_ERROR ; /** Convert into ASCII-Hex form **/ ADFI_unsigned_int_2_ASCII_Hex( (unsigned int)block_offset->block, 0, MAXIMUM_32_BITS, 8, block, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( (unsigned int)block_offset->offset, 0, DISK_BLOCK_SIZE, 4, offset, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end of ADFI_disk_pointer_2_ASCII_Hex */ /* end of file ADFI_disk_pointer_2_ASCII_Hex.c */ /* file ADFI_disk_pointer_from_ASCII_Hex.c */ /*********************************************************************** ADFI disk pointer from ASCII Hex: Convert an ASCII-Hex representation into a disk-pointer (for memory). input: const char block[8] ASCII block number. input: const char offset[4] ASCII offset number. output: struct DISK_POINTER *block_offset Disk-pointer struct. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER NULL_STRING_POINTER ***********************************************************************/ void ADFI_disk_pointer_from_ASCII_Hex( const char block[8], const char offset[4], struct DISK_POINTER *block_offset, int *error_return ) { unsigned int tmp ; if( (block == NULL) || (offset == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( block_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ *error_return = NO_ERROR ; /** Convert into numeric form **/ ADFI_ASCII_Hex_2_unsigned_int( 0, MAXIMUM_32_BITS, 8, block, &tmp, error_return ) ; if( *error_return != NO_ERROR ) return ; block_offset->block = tmp ; ADFI_ASCII_Hex_2_unsigned_int( 0, DISK_BLOCK_SIZE, 4, offset, &tmp, error_return ) ; if( *error_return != NO_ERROR ) return ; block_offset->offset = tmp ; } /* end of ADFI_disk_pointer_from_ASCII_Hex */ /* end of file ADFI_disk_pointer_from_ASCII_Hex.c */ /*----------------------------------------------------------------------------------*/ void ADFI_write_disk_pointer( const unsigned int file_index, const struct DISK_POINTER *block_offset, char block[8], char offset[4], int *error_return) { if (ADF_file[file_index].old_version) { ADFI_disk_pointer_2_ASCII_Hex(block_offset, block, offset, error_return); } else { unsigned int boff = (unsigned int)block_offset->offset; ADFI_convert_integers(8, 1, ADF_this_machine_format, ADF_file[file_index].format, (char *)&block_offset->block, block, error_return); if (*error_return != NO_ERROR) return; ADFI_convert_integers(4, 1, ADF_this_machine_format, ADF_file[file_index].format, (char *)&boff, offset, error_return); } } /*----------------------------------------------------------------------------------*/ void ADFI_read_disk_pointer( const unsigned int file_index, const char block[8], const char offset[4], struct DISK_POINTER *block_offset, int *error_return ) { if (ADF_file[file_index].old_version) { ADFI_disk_pointer_from_ASCII_Hex(block, offset, block_offset, error_return); } else { unsigned int boff; ADFI_convert_integers(8, 1, ADF_file[file_index].format, ADF_this_machine_format, block, (char *)&block_offset->block, error_return); if (*error_return != NO_ERROR) return; ADFI_convert_integers(4, 1, ADF_file[file_index].format, ADF_this_machine_format, offset, (char *)&boff, error_return); block_offset->offset = boff; } } /*----------------------------------------------------------------------------------*/ /* file ADFI_evaluate_datatype.c */ /*********************************************************************** ADFI evaluate datatype: input: const int file_index The file index (0 to MAXIMUM_FILES). input: const char *data_type. Data-type string. output: int *file_bytes. Number of bytes used by the data type. output: int *machine_ bytes. Number of bytes used by the data type. output: struct TOKENIZED_DATA_TYPE *tokenized_data_type Array. output: char *file_format The format of this file. output: char *machine_format The format of this machine. output: int error_return. Error return. Recognized data types: Type Notation No data MT Integer 32 I4 Integer 64 I8 Unsigned 32 U4 Unsigned 64 U8 Real 32 R4 Real 64 R8 Complex 64 X4 Complex 128 X8 Character (unsigned byte) C1 Link (same as C1) LK Byte (unsigned byte) B1 A structure is represented as the string "I4,I4,R8". An array of 25 integers is "I4[25]". Possible errors: NO_ERROR NULL_POINTER NULL_STRING_POINTER DATA_TYPE_TOO_LONG INVALID_DATA_TYPE ***********************************************************************/ void ADFI_evaluate_datatype( const int file_index, const char data_type[], int *file_bytes, int *machine_bytes, struct TOKENIZED_DATA_TYPE *tokenized_data_type, char *file_format, char *machine_format, int *error_return ) { int str_position = 0 ; int current_token = 0 ; int i, str_len, size_file, size_machine ; char data_type_string[ADF_DATA_TYPE_LENGTH + 1 ] ; struct FILE_HEADER file_header ; if( (file_format == NULL) || (machine_format == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (file_bytes == NULL) || (machine_bytes == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ *file_bytes = 0 ; *machine_bytes = 0 ; *error_return = NO_ERROR ; /** Return the file & machine's format info **/ if( file_index >= maximum_files ) { *error_return = FILE_INDEX_OUT_OF_RANGE ; return ; } /* end if */ *file_format = ADF_file[file_index].format ; *machine_format = ADF_this_machine_format ; /** Convert blank-filled datatype into C string **/ ADFI_string_2_C_string( data_type, ADF_DATA_TYPE_LENGTH, data_type_string, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Upper_CASE the data-type string **/ str_len = (int)strlen( data_type_string ) ; if ( str_len == 0 ) { *error_return = STRING_LENGTH_ZERO ; return ; } /** end if **/ for( i=0; i= '0') && (data_type_string[ str_position ] <= '9') ) { array_size = array_size * 10 + (data_type_string[ str_position ] - '0') ; str_position += 1 ; } /* end while */ if( data_type_string[ str_position ] != ']' ) { *error_return = INVALID_DATA_TYPE ; return ; } /* end if */ str_position += 1 ; /** Check for comma between types **/ if( data_type_string[ str_position ] == ',' ) { str_position += 1 ; } /* end if */ *file_bytes = *file_bytes + size_file * array_size ; *machine_bytes = *machine_bytes + size_machine * array_size ; tokenized_data_type[ current_token++ ].length = array_size ; } break ; case ',' : str_position += 1 ; *file_bytes = *file_bytes + size_file ; *machine_bytes = *machine_bytes + size_machine ; break ; default : /** Error condition **/ *error_return = INVALID_DATA_TYPE ; return ; } /* end switch */ } /* end while */ tokenized_data_type[ current_token ].type[0] = 0x00 ; tokenized_data_type[ current_token ].type[1] = 0x00 ; tokenized_data_type[ current_token ].file_type_size = *file_bytes; tokenized_data_type[ current_token ].machine_type_size = *machine_bytes ; } /* end of ADFI_evaluate_datatype */ /* end of file ADFI_evaluate_datatype.c */ /* file ADFI_fflush_file.c */ /*********************************************************************** ADFI fflush file: To flush the file output stream. input: const unsigned int file_index File to use. output: int *error_return Error return. Possible errors: NO_ERROR ADF_FILE_NOT_OPENED FFLUSH_ERROR ***********************************************************************/ void ADFI_fflush_file( const unsigned int file_index, int *error_return ) { int iret ; if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; ADF_sys_err = 0; # ifdef _WIN32 iret = _commit( ADF_file[file_index].file ) ; # else iret = fsync( ADF_file[file_index].file ) ; # endif if (iret < 0) { ADF_sys_err = errno; *error_return = FFLUSH_ERROR ; } /* end if */ } /* end of ADFI_fflush_file */ /* end of file ADFI_fflush_file.c */ /* file ADFI_figure_machine_format.c */ /* file ADFI_figure_machine_format.c */ /*********************************************************************** ADFI figure machine format: Determine if the host computer is IEEE_BIG, IEEE_LITTLE, CRAY, or NATIVE. Once this machines format if determined, look at the requested format. If NATIVE, use this machines format, otherwise use the requested format. input: const char *format IEEE_BIG, IEEE_LITTLE, CRAY, or NATIVE. output: const char *machine_format 'B', 'L', 'C', 'N' output: const char *format_to_use 'B', 'L', 'C', 'N' output: const char *os_to_use 'B', 'L' output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER ***********************************************************************/ static unsigned char bits[NUMBER_KNOWN_MACHINES][8][8] = { /* IEEE BIG 32 */ /* u.i = 123456789: */ { { 0x07, 0x5B, 0xCD, 0x15, 0x00, 0x00, 0x00, 0x00 }, /* u.i = -123456789: */ { 0xF8, 0xA4, 0x32, 0xEB, 0x00, 0x00, 0x00, 0x00 }, /* u.l = 1234567890L: */ { 0x49, 0x96, 0x02, 0xD2, 0x00, 0x00, 0x00, 0x00 }, /* u.l = -1234567890L: */ { 0xB6, 0x69, 0xFD, 0x2E, 0x00, 0x00, 0x00, 0x00 }, /* u.f = 12345.6789: */ { 0x46, 0x40, 0xE6, 0xB7, 0x00, 0x00, 0x00, 0x00 }, /* u.f = -12345.6789: */ { 0xC6, 0x40, 0xE6, 0xB7, 0x00, 0x00, 0x00, 0x00 }, /* u.d = 12345.6789: */ { 0x40, 0xC8, 0x1C, 0xD6, 0xE6, 0x31, 0xF8, 0xA1 }, /* u.d = -12345.6789: */ { 0xC0, 0xC8, 0x1C, 0xD6, 0xE6, 0x31, 0xF8, 0xA1 } }, /* IEEE LITTLE 32 */ /* u.i = 123456789: */ { { 0x15, 0xCD, 0x5B, 0x07, 0x00, 0x00, 0x00, 0x00 }, /* u.i = -123456789: */ { 0xEB, 0x32, 0xA4, 0xF8, 0x00, 0x00, 0x00, 0x00 }, /* u.l = 1234567890L: */ { 0xD2, 0x02, 0x96, 0x49, 0x00, 0x00, 0x00, 0x00 }, /* u.l = -1234567890L: */ { 0x2E, 0xFD, 0x69, 0xB6, 0x00, 0x00, 0x00, 0x00 }, /* u.f = 12345.6789: */ { 0xB7, 0xE6, 0x40, 0x46, 0x00, 0x00, 0x00, 0x00 }, /* u.f = -12345.6789: */ { 0xB7, 0xE6, 0x40, 0xC6, 0x00, 0x00, 0x00, 0x00 }, /* u.d = 12345.6789: */ { 0xA1, 0xF8, 0x31, 0xE6, 0xD6, 0x1C, 0xC8, 0x40 }, /* u.d = -12345.6789: */ { 0xA1, 0xF8, 0x31, 0xE6, 0xD6, 0x1C, 0xC8, 0xC0 } }, /* IEEE BIG 64 */ /* u.i = 123456789: */ { { 0x07, 0x5B, 0xCD, 0x15, 0x00, 0x00, 0x00, 0x00 }, /* u.i = -123456789: */ { 0xF8, 0xA4, 0x32, 0xEB, 0x00, 0x00, 0x00, 0x00 }, /* u.l = 1234567890L: */ { 0x00, 0x00, 0x00, 0x00, 0x49, 0x96, 0x02, 0xD2 }, /* u.l = -1234567890L: */ { 0xFF, 0xFF, 0xFF, 0xFF, 0xB6, 0x69, 0xFD, 0x2E }, /* u.f = 12345.6789: */ { 0x46, 0x40, 0xE6, 0xB7, 0x00, 0x00, 0x00, 0x00 }, /* u.f = -12345.6789: */ { 0xC6, 0x40, 0xE6, 0xB7, 0x00, 0x00, 0x00, 0x00 }, /* u.d = 12345.6789: */ { 0x40, 0xC8, 0x1C, 0xD6, 0xE6, 0x31, 0xF8, 0xA1 }, /* u.d = -12345.6789: */ { 0xC0, 0xC8, 0x1C, 0xD6, 0xE6, 0x31, 0xF8, 0xA1 } }, /* IEEE LITTLE 64 */ /* u.i = 123456789: */ { { 0x15, 0xCD, 0x5B, 0x07, 0x00, 0x00, 0x00, 0x00 }, /* u.i = -123456789: */ { 0xEB, 0x32, 0xA4, 0xF8, 0x00, 0x00, 0x00, 0x00 }, /* u.l = 1234567890L: */ { 0xD2, 0x02, 0x96, 0x49, 0x00, 0x00, 0x00, 0x00 }, /* u.l = -1234567890L: */ { 0x2E, 0xFD, 0x69, 0xB6, 0xFF, 0xFF, 0xFF, 0xFF }, /* u.f = 12345.6789: */ { 0xB7, 0xE6, 0x40, 0x46, 0x00, 0x00, 0x00, 0x00 }, /* u.f = -12345.6789: */ { 0xB7, 0xE6, 0x40, 0xC6, 0x00, 0x00, 0x00, 0x00 }, /* u.d = 12345.6789: */ { 0xA1, 0xF8, 0x31, 0xE6, 0xD6, 0x1C, 0xC8, 0x40 }, /* u.d = -12345.6789: */ { 0xA1, 0xF8, 0x31, 0xE6, 0xD6, 0x1C, 0xC8, 0xC0 } }, /* CRAY */ /* u.i = 123456789: */ { { 0x00, 0x00, 0x00, 0x00, 0x07, 0x5B, 0xCD, 0x15 }, /* u.i = -123456789: */ { 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xA4, 0x32, 0xEB }, /* u.l = 1234567890L: */ { 0x00, 0x00, 0x00, 0x00, 0x49, 0x96, 0x02, 0xD2 }, /* u.l = -1234567890L: */ { 0xFF, 0xFF, 0xFF, 0xFF, 0xB6, 0x69, 0xFD, 0x2E }, /* u.f = 12345.6789: */ { 0x40, 0x0E, 0xC0, 0xE6, 0xB7, 0x31, 0x8F, 0xC5 }, /* u.f = -12345.6789: */ { 0xC0, 0x0E, 0xC0, 0xE6, 0xB7, 0x31, 0x8F, 0xC5 }, /* u.d = 12345.6789: */ { 0x40, 0x0E, 0xC0, 0xE6, 0xB7, 0x31, 0x8F, 0xC5 }, /* u.d = -12345.6789: */ { 0xC0, 0x0E, 0xC0, 0xE6, 0xB7, 0x31, 0x8F, 0xC5 } } } ; void ADFI_figure_machine_format( const char *format, char *machine_format, char *format_to_use, char *os_to_use, int *error_return ) { char requested_format, requested_os, machine_os_size = OS_32_BIT ; union { int i; long l; float f; double d; unsigned char bytes[8]; } u ; int i, k, OK ; if( (machine_format == NULL) || (format_to_use == NULL) || (os_to_use == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check requested format **/ if( format == NULL ) { requested_format = NATIVE_FORMAT_CHAR ; requested_os = OS_32_BIT ; } /* end if */ else if( (format[0] == '\0') || (format[0] == ' ') ) { requested_format = NATIVE_FORMAT_CHAR ; requested_os = OS_32_BIT ; } /* end else if */ else if( ADFI_stridx_c( IEEE_BIG_32_FORMAT_STRING, format ) == 0 ) { requested_format = IEEE_BIG_FORMAT_CHAR ; requested_os = OS_32_BIT ; } /* end else if */ else if( ADFI_stridx_c( IEEE_LITTLE_32_FORMAT_STRING, format ) == 0 ) { requested_format = IEEE_LITTLE_FORMAT_CHAR ; requested_os = OS_32_BIT ; } /* end else if */ else if( ADFI_stridx_c( IEEE_BIG_64_FORMAT_STRING, format ) == 0 ) { requested_format = IEEE_BIG_FORMAT_CHAR ; requested_os = OS_64_BIT ; } /* end else if */ else if( ADFI_stridx_c( IEEE_LITTLE_64_FORMAT_STRING, format ) == 0 ) { requested_format = IEEE_LITTLE_FORMAT_CHAR ; requested_os = OS_64_BIT ; } /* end else if */ else if( ADFI_stridx_c( CRAY_FORMAT_STRING, format ) == 0 ) { requested_format = CRAY_FORMAT_CHAR ; requested_os = OS_64_BIT ; } /* end else if */ else if( ADFI_stridx_c( NATIVE_FORMAT_STRING, format ) == 0 || ADFI_stridx_c( LEGACY_FORMAT_STRING, format ) == 0 ) { requested_format = NATIVE_FORMAT_CHAR ; requested_os = OS_32_BIT ; } /* end else if */ else { *error_return = ADF_FILE_FORMAT_NOT_RECOGNIZED ; return ; } /* end else */ /***** Determine this machine's numeric format *****/ /** Check for numeric bit patterns **/ #define ZERO_UNION() \ for( k=0; k<8; k++ ) \ u.bytes[k] = '\0' ; #define CHECK_UNION(B) \ if( (u.bytes[0] != B[0]) || (u.bytes[1] != B[1]) || \ (u.bytes[2] != B[2]) || (u.bytes[3] != B[3]) || \ (u.bytes[4] != B[4]) || (u.bytes[5] != B[5]) || \ (u.bytes[6] != B[6]) || (u.bytes[7] != B[7]) ) continue ; OK = FALSE ; *machine_format = NATIVE_FORMAT_CHAR ; for( i=0; i= 8 ) machine_os_size = OS_64_BIT ; else machine_os_size = OS_32_BIT ; } /* end if */ if( ADF_this_machine_format == UNDEFINED_FORMAT_CHAR ) { ADF_this_machine_format = *machine_format ; ADF_this_machine_os_size = machine_os_size ; } /* end if */ if( requested_format == NATIVE_FORMAT_CHAR ) { *format_to_use = *machine_format ; *os_to_use = machine_os_size ; } /* end if */ else { *format_to_use = requested_format ; *os_to_use = requested_os ; } /* end if */ if( *machine_format == NATIVE_FORMAT_CHAR ) *error_return = MACHINE_FORMAT_NOT_RECOGNIZED ; } /* end of ADFI_figure_machine_format */ /* end of file ADFI_figure_machine_format.c */ /* end of file ADFI_figure_machine_format.c */ /* file ADFI_file_and_machine_compare.c */ /*********************************************************************** ADFI file and machine compare: Compares file and machine formats. input: const int file_index The file index (0 to MAXIMUM_FILES). output: int *compare 1 = formats compare, 0 = do not output: int *error_return Error return Possible errors: FILE_INDEX_OUT_OF_RANGE ***********************************************************************/ void ADFI_file_and_machine_compare( const int file_index, const struct TOKENIZED_DATA_TYPE *tokenized_data_type, int *compare, int *error_return ) { int machine_size, file_size, token ; *compare = 0 ; *error_return = NO_ERROR ; if( file_index < 0 || file_index >= maximum_files ) { *error_return = FILE_INDEX_OUT_OF_RANGE ; return ; } if( ADF_this_machine_format == NATIVE_FORMAT_CHAR || ADF_file[file_index].format == NATIVE_FORMAT_CHAR ) { unsigned int size_long; struct FILE_HEADER file_header ; /** Get file_header for the file variable sizes **/ ADFI_read_file_header( file_index, &file_header, error_return ) ; if( *error_return != NO_ERROR ) return ; size_long = ADF_file[file_index].old_version ? sizeof(long) : sizeof(cglong_t); /** Make sure the sizes are the same or we are cooked!! **/ if ( ADF_file[file_index].format != NATIVE_FORMAT_CHAR || file_header.sizeof_char != sizeof( char ) || file_header.sizeof_short != sizeof( short ) || file_header.sizeof_int != sizeof( int ) || file_header.sizeof_long != size_long || file_header.sizeof_float != sizeof( float ) || #if 0 file_header.sizeof_double != sizeof( double ) || file_header.sizeof_char_p != sizeof( char * ) || file_header.sizeof_short_p != sizeof( short * ) || file_header.sizeof_int_p != sizeof( int * ) || file_header.sizeof_long_p != sizeof( long * ) || file_header.sizeof_float_p != sizeof( float * ) || file_header.sizeof_double_p != sizeof( double * ) ) { #else file_header.sizeof_double != sizeof( double ) ) { #endif *error_return = MACHINE_FILE_INCOMPATABLE ; return ; } /** end if **/ } /** end if **/ if( ADF_file[file_index].format == ADF_this_machine_format && ADF_file[file_index].os_size == ADF_this_machine_os_size ) { *compare = 1 ; } else if( ADF_file[file_index].format == ADF_this_machine_format ) { /** If the file and machine binary type are the same and only the sizes may be different (like long is 32 or 64), then if all the sizes are the same then no conversion is necessary and ws can avoid the conversion overhead and just do direct read/writes. **/ if ( tokenized_data_type == NULL ) return ; token = -1 ; *compare = 1 ; do { token++ ; machine_size = tokenized_data_type[ token ].machine_type_size ; file_size = tokenized_data_type[ token ].file_type_size ; if ( machine_size != file_size ) { *compare = 0 ; break ; } } while( tokenized_data_type[ token ].type[0] != 0 ) ; } } /* end of ADFI_file_and_machine_compare */ /* end of file ADFI_file_and_machine_compare.c */ /* file ADFI_file_block_offset_2_ID.c */ /*********************************************************************** ADFI file block and offset to ID: Convert an ADF file, block, and offset to an ADF ID. input: const int file_index The file index (0 to MAXIMUM_FILES). input: const unsigned long file_block The block within the file. input: const unsigned long block_offset The offset within the block. output: double *ID The resulting ADF ID. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER FILE_INDEX_OUT_OF_RANGE BLOCK_OFFSET_OUT_OF_RANGE ***********************************************************************/ void ADFI_file_block_offset_2_ID( const int file_index, const cgulong_t file_block, const cgulong_t block_offset, double *ID, int *error_return ) { double dd; unsigned char * cc; if( ID == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ *error_return = NO_ERROR ; if( file_index >= maximum_files ) { *error_return = FILE_INDEX_OUT_OF_RANGE ; return ; } /* end if */ if( block_offset >= DISK_BLOCK_SIZE ) { *error_return = BLOCK_OFFSET_OUT_OF_RANGE ; return ; } /* end if */ /** Map the bytes into the character variable **/ /* Note that there were problems with some machines flushing small numbers to zero causing problems with the encoding of ID (which is not in its self a true number). The IEEE standard says that this is not allowed and so should not be a problem except that you get a major performance hit on the machine if you have it enforce the IEEE standard. Thus I force the sign bit on the exponent to always be positive so that the ID is a number greater than |1|. Previously on the IEEE big endian the numbers would look like 3.132313E-311. The new encoding changes the max number of open files to 16K from 64K */ cc = (unsigned char *) ⅆ #ifdef NEW_ID_MAPPING #if 0 assert(file_index <= 0xfff); assert(file_block <= 0x3fffffffff); assert(block_offset <= 0xfff); if (ADF_this_machine_format == IEEE_LITTLE_FORMAT_CHAR) { cc[7] = (unsigned char)((file_index & 0x0FC0) >> 6) + 0x40; cc[6] = (unsigned char)((file_index & 0x003F) << 2) + (unsigned char)((file_block & 0x3000000000) >> 36); cc[5] = (unsigned char)((file_block & 0x0FF0000000) >> 28); cc[4] = (unsigned char)((file_block & 0x000FF00000) >> 20); cc[3] = (unsigned char)((file_block & 0x00000FF000) >> 12); cc[2] = (unsigned char)((file_block & 0x0000000FF0) >> 4); cc[1] = (unsigned char)((file_block & 0x000000000F) << 4) + (unsigned char)((block_offset & 0x0F00) >> 8); cc[0] = (unsigned char) (block_offset & 0x00FF); } else { cc[0] = (unsigned char)((file_index & 0x0FC0) >> 6) + 0x40; cc[1] = (unsigned char)((file_index & 0x003F) << 2) + (unsigned char)((file_block & 0x3000000000) >> 36); cc[2] = (unsigned char)((file_block & 0x0FF0000000) >> 28); cc[3] = (unsigned char)((file_block & 0x000FF00000) >> 20); cc[4] = (unsigned char)((file_block & 0x00000FF000) >> 12); cc[5] = (unsigned char)((file_block & 0x0000000FF0) >> 4); cc[6] = (unsigned char)((file_block & 0x000000000F) << 4) + (unsigned char)((block_offset & 0x0F00) >> 8); cc[7] = (unsigned char) (block_offset & 0x00FF); } #else if (ADF_this_machine_format == IEEE_LITTLE_FORMAT_CHAR) { cc[7] = (unsigned char)((file_index >> 6) & 0x3F) + 0x40; cc[6] = (unsigned char)((file_index << 2) & 0xFC) + (unsigned char)((file_block >> 36) & 0x03); cc[5] = (unsigned char)((file_block >> 28) & 0xFF); cc[4] = (unsigned char)((file_block >> 20) & 0xFF); cc[3] = (unsigned char)((file_block >> 12) & 0xFF); cc[2] = (unsigned char)((file_block >> 4) & 0xFF); cc[1] = (unsigned char)((file_block << 4) & 0xF0) + (unsigned char)((block_offset >> 8) & 0x0F); cc[0] = (unsigned char) (block_offset & 0xFF); } else { cc[0] = (unsigned char)((file_index >> 6) & 0x3F) + 0x40; cc[1] = (unsigned char)((file_index << 2) & 0xFC) + (unsigned char)((file_block >> 36) & 0x03); cc[2] = (unsigned char)((file_block >> 28) & 0xFF); cc[3] = (unsigned char)((file_block >> 20) & 0xFF); cc[4] = (unsigned char)((file_block >> 12) & 0xFF); cc[5] = (unsigned char)((file_block >> 4) & 0xFF); cc[6] = (unsigned char)((file_block << 4) & 0xF0) + (unsigned char)((block_offset >> 8) & 0x0F); cc[7] = (unsigned char) (block_offset & 0xFF); } #endif #else if ( ADF_this_machine_format == IEEE_BIG_FORMAT_CHAR ) { cc[1] = (unsigned char) (file_index & 0x00ff) ; cc[0] = (unsigned char) (64 + (( file_index >> 8) & 0x003f)) ; cc[2] = (unsigned char) (file_block & 0x000000ff) ; cc[3] = (unsigned char) ((file_block >> 8) & 0x000000ff) ; cc[4] = (unsigned char) ((file_block >> 16) & 0x000000ff) ; cc[5] = (unsigned char) ((file_block >> 24) & 0x000000ff) ; cc[6] = (unsigned char) (block_offset & 0x00ff) ; cc[7] = (unsigned char) ((block_offset >> 8) & 0x00ff) ; } /* end if */ else if ( ADF_this_machine_format == IEEE_LITTLE_FORMAT_CHAR ) { cc[6] = (unsigned char) (file_index & 0x00ff) ; cc[7] = (unsigned char) (64 + (( file_index >> 8) & 0x003f)) ; cc[2] = (unsigned char) (file_block & 0x000000ff) ; cc[3] = (unsigned char) ((file_block >> 8) & 0x000000ff) ; cc[4] = (unsigned char) ((file_block >> 16) & 0x000000ff) ; cc[5] = (unsigned char) ((file_block >> 24) & 0x000000ff) ; cc[0] = (unsigned char) (block_offset & 0x00ff) ; cc[1] = (unsigned char) ((block_offset >> 8) & 0x00ff) ; } /* end else if */ else { cc[0] = (unsigned char) (file_index & 0x00ff) ; cc[1] = (unsigned char) ((file_index >> 8) & 0x00ff) ; cc[2] = (unsigned char) (file_block & 0x000000ff) ; cc[3] = (unsigned char) ((file_block >> 8) & 0x000000ff) ; cc[4] = (unsigned char) ((file_block >> 16) & 0x000000ff) ; cc[5] = (unsigned char) ((file_block >> 24) & 0x000000ff) ; cc[6] = (unsigned char) (block_offset & 0x00ff) ; cc[7] = (unsigned char) ((block_offset >> 8) & 0x00ff) ; } /* end else */ #endif *ID = dd; #ifdef PRINT_STUFF printf("cc[0-7] = %02X %02X %02X %02X %02X %02X %02X %02X \n", cc[0], cc[1], cc[2], cc[3], cc[4], cc[5], cc[6], cc[7] ) ; printf("In ADFI_file_block_offset_2_ID: ID=%lf\n",*ID); #endif } /* end of ADFI_file_block_offset_2_ID */ /* end of file ADFI_file_block_offset_2_ID.c */ /* file ADFI_file_free.c */ /*********************************************************************** ADFI file free: To free-up a chunk of file space. input: const int file_index The file index (0 to MAXIMUM_FILES). input: const struct DISK_POINTER *block_offset Block & offset in the file. input: const long number_of_bytes Number of bytes to free. If 0, then look at type of chunk to get size. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED FREE_OF_ROOT_NODE ADF_DISK_TAG_ERROR FREE_OF_FREE_CHUNK_TABLE ***********************************************************************/ void ADFI_file_free( const int file_index, const struct DISK_POINTER *block_offset, const cglong_t in_number_of_bytes, int *error_return ) { char tag[TAG_SIZE + 1] ; struct DISK_POINTER end_of_chunk_tag ; struct DISK_POINTER tmp_blk_ofst ; struct FREE_CHUNK_TABLE free_chunk_table ; struct FREE_CHUNK free_chunk ; int i ; cglong_t number_of_bytes = in_number_of_bytes ; if( block_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ if( number_of_bytes == 0 ) { /** Check the disk tag to see what kind of disk chunk we have. We need this to determine the length of the chunk. **/ ADFI_read_file( file_index, block_offset->block, block_offset->offset, TAG_SIZE, tag, error_return ) ; if( *error_return != NO_ERROR ) return ; tag[TAG_SIZE] = '\0' ; /* Null terminate the string */ end_of_chunk_tag.block = 0 ; end_of_chunk_tag.offset = 0 ; if( ADFI_stridx_c( tag, node_start_tag ) == 0 ) { /** This is a node **/ if( (block_offset->block == ROOT_NODE_BLOCK) && (block_offset->offset == ROOT_NODE_OFFSET) ) { *error_return = FREE_OF_ROOT_NODE ; return ; } /* end if */ end_of_chunk_tag.block = block_offset->block ; end_of_chunk_tag.offset = block_offset->offset + NODE_HEADER_SIZE - TAG_SIZE ; if ( end_of_chunk_tag.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; } /** Check disk boundary-tag **/ ADFI_read_file( file_index, end_of_chunk_tag.block, end_of_chunk_tag.offset, TAG_SIZE, tag, error_return ) ; if( *error_return != NO_ERROR ) return ; if( ADFI_stridx_c( tag, node_end_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ } /* end if */ else if( ADFI_stridx_c( tag, free_chunk_table_start_tag ) == 0 ) { /** Trying to free the free-chunk-table. This is BAD. **/ *error_return = FREE_OF_FREE_CHUNK_TABLE ; return ; } /* end else if */ else if( ADFI_stridx_c( tag, free_chunk_start_tag ) == 0 ) { /** Set a temporary block/offset to read disk pointer **/ tmp_blk_ofst.block = block_offset->block ; tmp_blk_ofst.offset = block_offset->offset + TAG_SIZE ; if ( tmp_blk_ofst.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &tmp_blk_ofst, error_return ) ; if( *error_return != NO_ERROR ) return ; } /** Get the end_of_chunk-tag block/offset from disk **/ ADFI_read_disk_pointer_from_disk( file_index, tmp_blk_ofst.block, tmp_blk_ofst.offset, &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check disk boundary-tag **/ ADFI_read_file( file_index, end_of_chunk_tag.block, end_of_chunk_tag.offset, TAG_SIZE, tag, error_return ) ; if( *error_return != NO_ERROR ) return ; if( ADFI_stridx_c( tag, free_chunk_end_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ } /* end else if */ else if( ADFI_stridx_c( tag, sub_node_start_tag ) == 0 ) { /** Set a temporary block/offset to read disk pointer **/ tmp_blk_ofst.block = block_offset->block ; tmp_blk_ofst.offset = block_offset->offset + TAG_SIZE ; if ( tmp_blk_ofst.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &tmp_blk_ofst, error_return ) ; if( *error_return != NO_ERROR ) return ; } /** Get the end_of_chunk-tag block/offset from disk **/ ADFI_read_disk_pointer_from_disk( file_index, tmp_blk_ofst.block, tmp_blk_ofst.offset, &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check disk boundary-tag **/ ADFI_read_file( file_index, end_of_chunk_tag.block, end_of_chunk_tag.offset, TAG_SIZE, tag, error_return ) ; if( *error_return != NO_ERROR ) return ; if( ADFI_stridx_c( tag, sub_node_end_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ } /* end else if */ else if( ADFI_stridx_c( tag, data_chunk_table_start_tag ) == 0 ) { /** Set a temporary block/offset to read disk pointer **/ tmp_blk_ofst.block = block_offset->block ; tmp_blk_ofst.offset = block_offset->offset + TAG_SIZE ; if ( tmp_blk_ofst.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &tmp_blk_ofst, error_return ) ; if( *error_return != NO_ERROR ) return ; } /** Get the end_of_chunk-tag block/offset from disk **/ ADFI_read_disk_pointer_from_disk( file_index, tmp_blk_ofst.block, tmp_blk_ofst.offset, &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check disk boundary-tag **/ ADFI_read_file( file_index, end_of_chunk_tag.block, end_of_chunk_tag.offset, TAG_SIZE, tag, error_return ) ; if( *error_return != NO_ERROR ) return ; if( ADFI_stridx_c( tag, data_chunk_table_end_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ } /* end else if */ else if( ADFI_stridx_c( tag, data_chunk_start_tag ) == 0 ) { /** Set a temporary block/offset to read disk pointer **/ tmp_blk_ofst.block = block_offset->block ; tmp_blk_ofst.offset = block_offset->offset + TAG_SIZE ; if ( tmp_blk_ofst.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &tmp_blk_ofst, error_return ) ; if( *error_return != NO_ERROR ) return ; } /** Get the end_of_chunk-tag block/offset from disk **/ ADFI_read_disk_pointer_from_disk( file_index, tmp_blk_ofst.block, tmp_blk_ofst.offset, &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check disk boundary-tag **/ ADFI_read_file( file_index, end_of_chunk_tag.block, end_of_chunk_tag.offset, TAG_SIZE, tag, error_return ) ; if( *error_return != NO_ERROR ) return ; if( ADFI_stridx_c( tag, data_chunk_end_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ } /* end else if */ else { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end else */ number_of_bytes = (end_of_chunk_tag.block - block_offset->block) * DISK_BLOCK_SIZE + (end_of_chunk_tag.offset - block_offset->offset + TAG_SIZE) ; } /* end if */ else { /** Use the number of bytes passed in **/ end_of_chunk_tag.block = block_offset->block ; end_of_chunk_tag.offset = block_offset->offset + number_of_bytes - TAG_SIZE ; ADFI_adjust_disk_pointer( &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end else */ if( number_of_bytes <= SMALLEST_CHUNK_SIZE ) { /** Too small, z-gas **/ /** Initialize the block of 'Z's **/ if( block_of_ZZ_initialized == FALSE ) { for( i=0; ioffset <= 0x1fff); ADFI_write_file( file_index, block_offset->block, block_offset->offset, number_of_bytes, block_of_ZZ, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ else { /** Add this chunk to the free table **/ /** Get the free-chunk-table **/ ADFI_read_free_chunk_table( file_index, &free_chunk_table, error_return ) ; if( *error_return != NO_ERROR ) return ; if( block_offset->block == end_of_chunk_tag.block ) { /* small or medium */ if( (end_of_chunk_tag.offset + TAG_SIZE - block_offset->offset) <= SMALL_CHUNK_MAXIMUM ) { /** SMALL chunk **/ free_chunk.end_of_chunk_tag.block = end_of_chunk_tag.block ; free_chunk.end_of_chunk_tag.offset = end_of_chunk_tag.offset ; free_chunk.next_chunk.block = free_chunk_table.small_first_block.block; free_chunk.next_chunk.offset = free_chunk_table.small_first_block.offset ; free_chunk_table.small_first_block.block = block_offset->block ; free_chunk_table.small_first_block.offset = block_offset->offset ; /** If linked-list was empty, also point to this as the last. **/ if( free_chunk.next_chunk.offset == BLANK_BLOCK_OFFSET ) { free_chunk_table.small_last_block.block = block_offset->block ; free_chunk_table.small_last_block.offset = block_offset->offset ; } /* end if */ } /* end if */ else { /** MEDIUM chunk **/ free_chunk.end_of_chunk_tag.block = end_of_chunk_tag.block ; free_chunk.end_of_chunk_tag.offset = end_of_chunk_tag.offset ; free_chunk.next_chunk.block = free_chunk_table.medium_first_block.block ; free_chunk.next_chunk.offset = free_chunk_table.medium_first_block.offset; free_chunk_table.medium_first_block.block = block_offset->block ; free_chunk_table.medium_first_block.offset = block_offset->offset ; /** If linked-list was empty, also point to this as the last. **/ if( free_chunk.next_chunk.offset == BLANK_BLOCK_OFFSET ) { free_chunk_table.medium_last_block.block = block_offset->block ; free_chunk_table.medium_last_block.offset = block_offset->offset ; } /* end if */ } /* end else */ } /* end if */ else { /** LARGE chunk **/ free_chunk.end_of_chunk_tag.block = end_of_chunk_tag.block ; free_chunk.end_of_chunk_tag.offset = end_of_chunk_tag.offset ; free_chunk.next_chunk.block = free_chunk_table.large_first_block.block; free_chunk.next_chunk.offset = free_chunk_table.large_first_block.offset ; free_chunk_table.large_first_block.block = block_offset->block ; free_chunk_table.large_first_block.offset = block_offset->offset ; /** If linked-list was empty, also point to this as the last. **/ if( free_chunk.next_chunk.offset == BLANK_BLOCK_OFFSET ) { free_chunk_table.large_last_block.block = block_offset->block ; free_chunk_table.large_last_block.offset = block_offset->offset ; } /* end if */ } /* end else */ /** Put the free-chunk tags in place **/ strncpy( free_chunk.start_tag, free_chunk_start_tag, TAG_SIZE ) ; strncpy( free_chunk.end_tag, free_chunk_end_tag, TAG_SIZE ) ; /** Write out the free chunk **/ ADFI_write_free_chunk( file_index, block_offset, &free_chunk, error_return ); if( *error_return != NO_ERROR ) return ; /** Update the free-chunk-table **/ ADFI_write_free_chunk_table( file_index, &free_chunk_table, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end else */ /** Delete the block/offset off the stack **/ ADFI_stack_control(file_index, block_offset->block, (unsigned int)block_offset->offset, DEL_STK_ENTRY, 0, 0, NULL ) ; } /* end of ADFI_file_free */ /* end of file ADFI_file_free.c */ /* file ADFI_file_malloc.c */ /*********************************************************************** ADFI file malloc: To allocate a chunk of disk space. input: const int file_index The file index (0 to MAXIMUM_FILES). input: size_bytes The size in bytes to allocate. output: const struct DISK_POINTER *block_offset Block & offset in the file. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_file_malloc( const int file_index, const cglong_t size_bytes, struct DISK_POINTER *block_offset, int *error_return ) { struct FILE_HEADER file_header ; int memory_found = FALSE ; #if 0 struct FREE_CHUNK_TABLE free_chunk_table ; struct DISK_POINTER disk_pointer, previous_disk_pointer ; struct DISK_POINTER *first_free_block, *last_free_block ; struct FREE_CHUNK free_chunk, previous_free_chunk ; int i ; unsigned long size ; #endif if( block_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ #if 0 /* skip this, and just write to end of file - this gives a significant speedup with only a small increase in file size. If the file is modified, skipping this will leave large holes in the file, but the entire file is rewritten by cg_close so we can ignore it here */ /** Get the free-chunk_table **/ ADFI_read_free_chunk_table( file_index, &free_chunk_table, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Look for the needed space in the 3 free lists. Note that all file control headers are smaller than the SMALLEST_CHUNK_SIZE and so will be fit later into a block at the end of the file. This greatly improves node creation efficiency. **/ for( i=0; i<3; i++ ) { if( memory_found == TRUE || size_bytes <= SMALLEST_CHUNK_SIZE ) break ; ADFI_set_blank_disk_pointer( &previous_disk_pointer ) ; switch( i ) { case 0: /** SMALL CHUNKS **/ if( size_bytes > SMALL_CHUNK_MAXIMUM ) continue ; /** Next in the for loop **/ first_free_block = &free_chunk_table.small_first_block ; last_free_block = &free_chunk_table.small_last_block ; break ; case 1: /** MEDIUM CHUNKS **/ if( size_bytes > MEDIUM_CHUNK_MAXIMUM ) continue ; /** Next in the for loop **/ first_free_block = &free_chunk_table.medium_first_block ; last_free_block = &free_chunk_table.medium_last_block ; break ; case 2: /** LARGE CHUNKS **/ first_free_block = &free_chunk_table.large_first_block ; last_free_block = &free_chunk_table.large_last_block ; break ; } /* end switch */ disk_pointer = *first_free_block ; while( (memory_found != TRUE) && ((disk_pointer.block != BLANK_FILE_BLOCK) || (disk_pointer.offset != BLANK_BLOCK_OFFSET)) ) { ADFI_read_free_chunk( file_index, &disk_pointer, &free_chunk, error_return ) ; if( *error_return != NO_ERROR ) return ; size = (free_chunk.end_of_chunk_tag.block - disk_pointer.block) * DISK_BLOCK_SIZE + (free_chunk.end_of_chunk_tag.offset - disk_pointer.offset) + TAG_SIZE ; if( (long int) size >= size_bytes ) { *block_offset = disk_pointer ; if( (previous_disk_pointer.block != BLANK_FILE_BLOCK) || (previous_disk_pointer.offset != BLANK_BLOCK_OFFSET) ) { /** Link previous free-chunk to the next free-chunk, removing this free-chunk from the list **/ ADFI_read_free_chunk( file_index, &previous_disk_pointer, &previous_free_chunk, error_return ) ; if( *error_return != NO_ERROR ) return ; previous_free_chunk.next_chunk = free_chunk.next_chunk ; ADFI_write_free_chunk( file_index, &previous_disk_pointer, &previous_free_chunk, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ else { /** Free-chunk was the first one, change entry in the free-chunk-header **/ *first_free_block = free_chunk.next_chunk ; ADFI_write_free_chunk_table( file_index, &free_chunk_table, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end else */ if((last_free_block->block == disk_pointer.block) && (last_free_block->offset == disk_pointer.offset)){ if( (previous_disk_pointer.block != BLANK_FILE_BLOCK) || (previous_disk_pointer.offset != BLANK_BLOCK_OFFSET) ) { *last_free_block = previous_disk_pointer ; } /* end if */ else { ADFI_set_blank_disk_pointer( last_free_block ) ; } /* end else */ ADFI_write_free_chunk_table( file_index, &free_chunk_table, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ size -= size_bytes ; if ( size > 0 ) { disk_pointer.offset += size_bytes ; ADFI_adjust_disk_pointer( &disk_pointer, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_file_free( file_index, &disk_pointer, size, error_return ) ; if( *error_return != NO_ERROR ) return ; } memory_found = TRUE ; } /* end if */ else { previous_disk_pointer = disk_pointer ; disk_pointer = free_chunk.next_chunk ; } /* end else */ } /* end while */ } /* end if */ #endif /** The end-of_file pointer points to the last byte USED, NOT the next byte TO USE. **/ if( memory_found != TRUE ) { /* Append memory at end of file **/ ADFI_read_file_header( file_index, &file_header, error_return ) ; if( *error_return != NO_ERROR ) return ; /** If the end-of_file is NOT at a block boundary, then see if the new allocated chunk will span a block boundary. If it will, then start at the new block if it will fit within the block. This helps efficiency to have file control headers located within a block boundary. **/ if( file_header.end_of_file.offset != DISK_BLOCK_SIZE - 1 ) { if( (file_header.end_of_file.offset+size_bytes) >= DISK_BLOCK_SIZE && size_bytes <= DISK_BLOCK_SIZE ) { /** Free rest of block, allocate from next block **/ file_header.end_of_file.offset++ ; ADFI_file_free( file_index, &file_header.end_of_file, DISK_BLOCK_SIZE - file_header.end_of_file.offset, error_return ) ; if( *error_return != NO_ERROR ) return ; block_offset->block = file_header.end_of_file.block + 1 ; block_offset->offset = 0 ; file_header.end_of_file.block++ ; file_header.end_of_file.offset = size_bytes - 1 ; ADFI_adjust_disk_pointer( &file_header.end_of_file, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ else { /** Use the remaining block **/ block_offset->block = file_header.end_of_file.block ; block_offset->offset = file_header.end_of_file.offset + 1 ; file_header.end_of_file.offset += size_bytes ; ADFI_adjust_disk_pointer( &file_header.end_of_file, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end else */ } /* end if */ else { /* already pointing to start of block **/ block_offset->block = file_header.end_of_file.block + 1 ; block_offset->offset = 0 ; file_header.end_of_file.block++ ; file_header.end_of_file.offset = size_bytes - 1 ; ADFI_adjust_disk_pointer( &file_header.end_of_file, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end else */ /** Write out the modified file header **/ ADFI_write_file_header( file_index, &file_header, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ } /* end of ADFI_file_malloc */ /* end of file ADFI_file_malloc.c */ /* file ADFI_fill_initial_file_header.c */ /*********************************************************************** ADFI fill initial file header: To determine the file header information... input: const char format 'B', 'L', 'C', 'N' input: const char os_size 'B', 'L' input: const char *what_string UNIX "what" identifier. output: struct FILE_HEADER *file_header The resulting file header information. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER NULL_STRING_POINTER ADF_FILE_FORMAT_NOT_RECOGNIZED ***********************************************************************/ void ADFI_fill_initial_file_header( const char format, const char os_size, const char *what_string, struct FILE_HEADER *file_header, int *error_return ) { int i ; if( what_string == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( file_header == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (format != IEEE_BIG_FORMAT_CHAR) && (format != IEEE_LITTLE_FORMAT_CHAR) && (format != CRAY_FORMAT_CHAR) && (format != NATIVE_FORMAT_CHAR) ) { *error_return = ADF_FILE_FORMAT_NOT_RECOGNIZED ; return ; } /* end if */ /** Put the boundary tags in first. If we then overwrite them, we'll know **/ strncpy( file_header->tag0, file_header_tags[0], TAG_SIZE ) ; strncpy( file_header->tag1, file_header_tags[1], TAG_SIZE ) ; strncpy( file_header->tag2, file_header_tags[2], TAG_SIZE ) ; strncpy( file_header->tag3, file_header_tags[3], TAG_SIZE ) ; strncpy( file_header->tag4, file_header_tags[4], TAG_SIZE ) ; strncpy( file_header->tag5, file_header_tags[5], TAG_SIZE ) ; /** The UNIX "what" string" - blank terminated **/ strncpy( file_header->what, what_string, WHAT_STRING_SIZE ) ; if ( strlen(what_string) < WHAT_STRING_SIZE ) { ADFI_blank_fill_string ( file_header->what, WHAT_STRING_SIZE ) ; } /** File creation date/time - blank terminated **/ ADFI_get_current_date( file_header->creation_date ) ; /** File modification date/time - same as creation time **/ strncpy( file_header->modification_date, file_header->creation_date, DATE_TIME_SIZE ) ; file_header->numeric_format = format ; file_header->os_size = os_size ; /** Set sizeof() information for file data **/ if( (format==ADF_this_machine_format && os_size==ADF_this_machine_os_size) || format==NATIVE_FORMAT_CHAR ) { file_header->sizeof_char = sizeof( char ) ; file_header->sizeof_short = sizeof( short ) ; file_header->sizeof_int = sizeof( int ) ; #if 0 file_header->sizeof_long = sizeof( long ) ; #else file_header->sizeof_long = sizeof( cglong_t ) ; #endif file_header->sizeof_float = sizeof( float ) ; file_header->sizeof_double = sizeof( double ) ; file_header->sizeof_char_p = sizeof( char * ) ; file_header->sizeof_short_p = sizeof( short * ) ; file_header->sizeof_int_p = sizeof( int * ) ; #if 0 file_header->sizeof_long_p = sizeof( long * ) ; #else file_header->sizeof_long_p = sizeof( cglong_t * ) ; #endif file_header->sizeof_float_p = sizeof( float * ) ; file_header->sizeof_double_p = sizeof( double * ) ; } /** end if **/ else { switch( EVAL_2_BYTES( format, os_size ) ) { case EVAL_2_BYTES( 'B', 'L' ): i = IEEE_BIG_32_FORMAT - 1 ; break ; case EVAL_2_BYTES( 'L', 'L' ): i = IEEE_LITTLE_32_FORMAT - 1 ; break ; case EVAL_2_BYTES( 'B', 'B' ): i = IEEE_BIG_64_FORMAT - 1 ; break ; case EVAL_2_BYTES( 'L', 'B' ): i = IEEE_LITTLE_64_FORMAT - 1 ; break ; case EVAL_2_BYTES( 'C', 'B' ): i = CRAY_FORMAT - 1 ; break ; default: *error_return = MACHINE_FORMAT_NOT_RECOGNIZED ; return ; } /* end switch */ file_header->sizeof_char = (unsigned int)machine_sizes[i][ 0] ; file_header->sizeof_short = (unsigned int)machine_sizes[i][ 3] ; file_header->sizeof_int = (unsigned int)machine_sizes[i][ 5] ; #if 0 file_header->sizeof_long = (unsigned int)machine_sizes[i][ 7] ; #else file_header->sizeof_long = (unsigned int)sizeof(cglong_t) ; #endif file_header->sizeof_float = (unsigned int)machine_sizes[i][ 9] ; file_header->sizeof_double = (unsigned int)machine_sizes[i][10] ; file_header->sizeof_char_p = (unsigned int)machine_sizes[i][11] ; file_header->sizeof_short_p = (unsigned int)machine_sizes[i][12] ; file_header->sizeof_int_p = (unsigned int)machine_sizes[i][12] ; #if 0 file_header->sizeof_long_p = (unsigned int)machine_sizes[i][13] ; #else file_header->sizeof_long_p = (unsigned int)sizeof(cglong_t *) ; #endif file_header->sizeof_float_p = (unsigned int)machine_sizes[i][14] ; file_header->sizeof_double_p = (unsigned int)machine_sizes[i][15] ; } /** end else **/ /** Set root node table pointers **/ file_header->root_node.block = ROOT_NODE_BLOCK ; file_header->root_node.offset = ROOT_NODE_OFFSET ; file_header->end_of_file.block = ROOT_NODE_BLOCK ; file_header->end_of_file.offset = ROOT_NODE_OFFSET + NODE_HEADER_SIZE - 1 ; file_header->free_chunks.block = FREE_CHUNKS_BLOCK ; file_header->free_chunks.offset = FREE_CHUNKS_OFFSET ; ADFI_set_blank_disk_pointer( &file_header->extra ) ; } /* end of ADFI_fill_initial_file_header */ /* end of file ADFI_fill_initial_file_header.c */ /* file ADFI_fill_initial_free_chunk_table.c */ /*********************************************************************** ADFI fill initial free chunk header: To fill out a new free chunk header. output: struct FREE_CHUNK_TABLE *free_chunk_table Resulting header info. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ***********************************************************************/ void ADFI_fill_initial_free_chunk_table( struct FREE_CHUNK_TABLE *free_chunk_table, int *error_return ) { if( free_chunk_table == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ strncpy( free_chunk_table->start_tag, free_chunk_table_start_tag, TAG_SIZE ) ; strncpy( free_chunk_table->end_tag, free_chunk_table_end_tag, TAG_SIZE ) ; /** Small: First and Last Blocks **/ ADFI_set_blank_disk_pointer( &free_chunk_table->small_first_block ) ; ADFI_set_blank_disk_pointer( &free_chunk_table->small_last_block ) ; /** Medium: First and Last Blocks **/ ADFI_set_blank_disk_pointer( &free_chunk_table->medium_first_block ) ; ADFI_set_blank_disk_pointer( &free_chunk_table->medium_last_block ) ; /** large: First and Last Blocks **/ ADFI_set_blank_disk_pointer( &free_chunk_table->large_first_block ) ; ADFI_set_blank_disk_pointer( &free_chunk_table->large_last_block ) ; } /* end of ADFI_fill_initial_free_chunk_table */ /* end of file ADFI_fill_initial_free_chunk_table.c */ /* file ADFI_fill_initial_node_header.c */ /*********************************************************************** ADFI fill initial node header: To fill out a new node header. output: struct NODE_HEADER *node_header The resulting node header information. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ***********************************************************************/ void ADFI_fill_initial_node_header( struct NODE_HEADER *node_header, int *error_return ) { int i ; if( node_header == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ strncpy( node_header->node_start_tag, node_start_tag, TAG_SIZE ) ; strncpy( node_header->node_end_tag, node_end_tag, TAG_SIZE ) ; /** Blank out the name **/ for( i=0; iname[i] = ' ' ; /** Blank out the label **/ for( i=0; ilabel[i] = ' ' ; /** Set number of sub nodes to zero **/ node_header->num_sub_nodes = 0 ; node_header->entries_for_sub_nodes = 0 ; ADFI_set_blank_disk_pointer( &node_header->sub_node_table ) ; /** Blank out the Data-Type, then set to eMpTy. **/ for( i=2; idata_type[i] = ' ' ; node_header->data_type[0] = 'M' ; node_header->data_type[1] = 'T' ; /** Zero out number of dimensions & Set dimension values to zero **/ node_header->number_of_dimensions = 0 ; for( i=0; idimension_values[i] = 0 ; /** Set number of data chunks to zero, zero out data chunk pointer **/ node_header->number_of_data_chunks = 0 ; ADFI_set_blank_disk_pointer( &node_header->data_chunks ) ; } /* end of ADFI_fill_initial_node_header */ /* end of file ADFI_fill_initial_node_header.c */ /* file ADFI_flush_buffers.c */ /*********************************************************************** ADFI Flush buffers: input: const unsigned int file_index The file index. output: int *error_return Error return. Possible errors: NO_ERROR ADF_FILE_NOT_OPENED FWRITE_ERROR ***********************************************************************/ void ADFI_flush_buffers( const unsigned int file_index, int flush_mode, int *error_return ) { char data; if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; if ( (int)file_index == last_wr_file ) { /** Flush any active write buffer, file block is set to a nonsense value so that the buffer flags are not reset **/ ADFI_write_file ( file_index, MAXIMUM_32_BITS, 0, 0, &data, error_return ) ; /** Reset control flags **/ if ( flush_mode == FLUSH_CLOSE ) { last_wr_block = -2; last_wr_file = -2; flush_wr_block = -2 ; } } if ( (int) file_index == last_rd_file && flush_mode == FLUSH_CLOSE ) { /** Reset control flags **/ last_rd_block = -1; last_rd_file = -1; num_in_rd_block = -1; } } /* end of ADFI_flush_buffers */ /* end of file ADFI_flush_buffers.c */ /* file ADFI_fseek_file.c */ /*********************************************************************** ADFI_fseek_file: To position the current position for fread() or fwrite(). Need to allow for files larger than what a long int can represent (the offset for fseek). input: const unsigned int file_index File to use. input: const unsigned long file_block Block within the file. input: const unsigned long block_offset Offset within the block. output: int *error_return Error return. Possible errors: NO_ERROR ADF_FILE_NOT_OPENED FSEEK_ERROR ***********************************************************************/ void ADFI_fseek_file( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, int *error_return ) { file_offset_t offset; file_offset_t iret; if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ offset = (file_offset_t)(file_block * DISK_BLOCK_SIZE + block_offset) ; if (offset < 0) { *error_return = MAX_FILE_SIZE_EXCEEDED; return; } *error_return = NO_ERROR ; ADF_sys_err = 0; iret = file_seek( ADF_file[file_index].file, offset, SEEK_SET ) ; if( iret < 0 ) { ADF_sys_err = errno; *error_return = FSEEK_ERROR ; } /* end if */ } /* end of ADFI_fseek_file */ /* end of file ADFI_fseek_file.c */ /* file ADFI_get_current_date.c */ /*********************************************************************** ADFI get current date: Returns the current date and time in a blank-filled character array. output: char date[] Current date/time in an array blank-filled to DATE_TIME_SIZE. Array must be allocated to at least DATE_TIME_SIZE. No null added. ***********************************************************************/ void ADFI_get_current_date( char date[] ) { time_t ct ; int i_len ; char *current_time_p ; /** get the current time **/ ct = time( (time_t *)NULL ) ; current_time_p = ctime( &ct ) ; /** remove '\n' from ctime format **/ i_len = (int)strcspn ( current_time_p, "\n" ) ; strcpy( date, current_time_p ) ; date[i_len] = '\0' ; /** blank fill **/ ADFI_blank_fill_string ( date, DATE_TIME_SIZE ) ; } /* end of ADFI_get_current_date */ /* end of file ADFI_get_current_date.c */ /* file ADFI_get_direct_children_ids.c */ /*********************************************************************** ADFI get direct children ids: Get Children ids of a Node. Return the ids of children nodes directly associated with a parent node (no links are followed). The ids of the children are NOT guaranteed to be returned in any particular order. If it is desired to follow potential links for the node ID, then call ADFI_chase_link() and pass the resultant link ID to this function. NOTE: link nodes do not have direct children. ADFI_get_direct_children_ids( ID, num_ids, ids, error_return ) input: const unsigned int file_index The file index. input: const struct DISK_POINTER *node_block_offset Block & offset in file. output: int *num_ids The number of ids returned. output: double **ids An allocated array of ids (free this space). output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER MEMORY_ALLOCATION_FAILED FILE_INDEX_OUT_OF_RANGE BLOCK_OFFSET_OUT_OF_RANGE ADF_FILE_NOT_OPENED ADF_DISK_TAG_ERROR ADF_MEMORY_TAG_ERROR ***********************************************************************/ void ADFI_get_direct_children_ids( const unsigned int file_index, const struct DISK_POINTER *node_block_offset, int *num_ids, double **ids, int *error_return ) { int i ; struct DISK_POINTER sub_node_block_offset ; struct NODE_HEADER node ; struct SUB_NODE_TABLE_ENTRY sub_node_table_entry ; *error_return = NO_ERROR ; if( num_ids == NULL || ids == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ *num_ids = 0 ; *ids = NULL ; ADFI_read_node_header( file_index, node_block_offset, &node, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check for zero children, return if 0 **/ if( node.num_sub_nodes == 0 ) { return ; } /* end if */ *ids = (double *) malloc ( node.num_sub_nodes * sizeof(double) ) ; if( *ids == NULL ) { *error_return = MEMORY_ALLOCATION_FAILED ; return ; } /* end if */ /** point to the first child **/ sub_node_block_offset.block = node.sub_node_table.block ; sub_node_block_offset.offset = node.sub_node_table.offset + (TAG_SIZE + DISK_POINTER_SIZE ) ; /** Return the ids for all the children **/ *num_ids = node.num_sub_nodes ; for( i=0; i< *num_ids; i++ ) { ADFI_adjust_disk_pointer( &sub_node_block_offset, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Read one sub-node table entry **/ ADFI_read_sub_node_table_entry( file_index, &sub_node_block_offset, &sub_node_table_entry, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Get the ID from the sub-node table **/ ADFI_file_block_offset_2_ID( file_index, sub_node_table_entry.child_location.block, sub_node_table_entry.child_location.offset, &(*ids)[i], error_return ) ; if( *error_return != NO_ERROR ) return ; /** Increment the disk-pointer **/ sub_node_block_offset.offset += (ADF_NAME_LENGTH + DISK_POINTER_SIZE) ; } /* end for */ } /* end of file ADFI_get_direct_children_ids.c */ /* file ADFI_get_file_index_from_name.c */ /*********************************************************************** ADFI get file index from name: Searches file list for given name. Returns file index and Root ID if name is found in list. input: const char *file_name Name of file output: int *found 1 = name found, 0 = not found output: unsigned int *file_index File-index output: double *ID ID of files root node output: int *error_return Error return ***********************************************************************/ void ADFI_get_file_index_from_name( const char *file_name, int *found, unsigned int *file_index, double *ID, int *error_return ) { double root_ID = 0; int i ; *error_return = NO_ERROR ; if( (file_index == NULL) || (ID == NULL) || (found == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_name == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ *found = 0; for( i=0; i 12) ) { *error_return = BAD_NUMBER_OF_DIMENSIONS ; return ; } /* end if */ *error_return = NO_ERROR ; offset = 0 ; accumlated_size = 1 ; for( i=0; i>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, 11-bit exponent, 52-bit mantissa Machine Numeric Formats: ***IEEE_LITTLE ( The backwards Big Endian ) I4: Byte0 Byte1 Byte2 Byte3 LSB---------------------MSB R4: Byte0 Byte1 Byte2 Byte3 Bits: 23-bit mantissa, 8-bit exponent, sign-bit The sign of the exponent is: 1=positive, 0=negative (NOT 2's complement) The interpretation of the floating-point number is: >>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: 52-bit mantissa, 11-bit exponent, sign-bit Note: To convert between these two formats the order of the bytes is reversed since by definition the Big endian starts at the LSB and goes to the MSB where the little goes form the MSB to the LSB of the word. *** Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADFI_little_endian_32_swap_64( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ) { if( (from_data == NULL) || (to_data == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (delta_from_bytes == 0) || (delta_to_bytes == 0) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (from_format == 'N') || (to_format == 'N') ) { *error_return = CANNOT_CONVERT_NATIVE_FORMAT ; return ; } /* end if */ *error_return = NO_ERROR ; if ( delta_to_bytes == delta_from_bytes ) { memcpy( to_data, from_data, (size_t)delta_from_bytes ) ; } /* end if */ else if ( delta_from_bytes < delta_to_bytes ) { switch( EVAL_2_BYTES( data_type[0], data_type[1] ) ) { case EVAL_2_BYTES( 'I', '8' ): if( (from_data[3] & 0x80) == 0x80 ) { /* Negative number */ to_data[7] = 0xff ; to_data[6] = 0xff ; to_data[5] = 0xff ; to_data[4] = 0xff ; } /* end if */ else { to_data[7] = 0x00 ; to_data[6] = 0x00 ; to_data[5] = 0x00 ; to_data[4] = 0x00 ; } /* end else */ to_data[3] = from_data[3] ; to_data[2] = from_data[2] ; to_data[1] = from_data[1] ; to_data[0] = from_data[0] ; break ; default: *error_return = INVALID_DATA_TYPE ; return ; } /* end switch */ } /* end else if */ else { switch( EVAL_2_BYTES( data_type[0], data_type[1] ) ) { case EVAL_2_BYTES( 'I', '8' ): to_data[3] = from_data[3] ; to_data[2] = from_data[2] ; to_data[1] = from_data[1] ; to_data[0] = from_data[0] ; break ; default: *error_return = INVALID_DATA_TYPE ; return ; } /* end switch */ } /* end else */ } /* end of ADFI_little_endian_32_swap_64 */ /* end of file ADFI_little_endian_32_swap_64.c */ /* file ADFI_little_endian_to_cray.c */ /*********************************************************************** ADFI little endian to cray: input: const char from_format Format to convert from. 'B','L','C','N' input: const char from_os_size Format to convert from. 'B','L' input: const char to_format Format to convert to. input: const char to_os_size Format to convert to. 'B','L' input: const char data_type[2] The type of data to convert. MT I4 I8 U4 U8 R4 R8 X4 X8 C1 B1 input: const unsigned long delta_from_bytes Number of from_bytes used. input: const unsigned long delta_to_bytes Number of to_bytes used. input: const char *from_data The data to convert from. output: char *to_data The resulting data. output: int *error_return Error return. Recognized data types: Machine representations Type Notation IEEE_BIG IEEE_LITTLE Cray 32 64 32 64 No data MT Integer 32 I4 I4 I4 I4 I4 I8 Integer 64 I8 -- I8 -- I8 I8 Unsigned 32 U4 I4 I4 I4 I4 I8 Unsigned 64 U8 -- I8 -- I8 I8 Real 32 R4 R4 R4 R4 R4 R8 Real 64 R8 R8 R8 R8 R8 R8 Complex 64 X4 R4R4 R4R4 R4R4 R4R4 R8R8 Complex 128 X8 R8R8 R8R8 R8R8 R8R8 R8R8 Character (unsigned byte) C1 C1 C1 C1 C1 C1 Byte (unsigned byte) B1 C1 C1 C1 C1 C1 Machine Numeric Formats: ***IEEE_BIG (SGI-Iris Assembly Language Programmer's Guide, pages 1-2, 6-3) I4: Byte0 Byte1 Byte2 Byte3 MSB---------------------LSB R4: Byte0 Byte1 Byte2 Byte3 Bits: sign-bit, 8-bit exponent, 23-bit mantissa The sign of the exponent is: 1=positive, 0=negative (NOT 2's complement) The interpretation of the floating-point number is: >>> 2.mantissia(fraction) X 2^exponent. <<< R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, 11-bit exponent, 52-bit mantissa ***Cray (Cray CFT77 Reference Manual, pages G-1 G-2) I8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 MSB-----------------------------------------------------LSB R8: Byte0 Byte1 Byte2 Byte 3 Byte 4 Byte5 Byte6 Byte7 Bits: sign-bit, exponent-sign, 14-bit exponent, 48-bit mantissa Note: Exponent sign: 1 in this bits indicates a positive exponent sign, thus bit 62 is the inverse of bit 61 (the sign in the exponent). The exception to this is a zero, in which all 64 bits are zero! The interpretation of the floating-point number is: >>> .mantissia(fraction) X 2^exponent. <<< The mantissia is left justified (the leftmost bit is a 1). This MUST be done! *** Possible errors: NO_ERROR NULL_STRING_POINTER NULL_POINTER ***********************************************************************/ void ADFI_little_endian_to_cray( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ) { int i, exp ; if( (from_data == NULL) || (to_data == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (delta_from_bytes == 0) || (delta_to_bytes == 0) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (from_format == 'N') || (to_format == 'N') ) { *error_return = CANNOT_CONVERT_NATIVE_FORMAT ; return ; } /* end if */ *error_return = NO_ERROR ; switch( EVAL_2_BYTES( data_type[0], data_type[1] ) ) { case EVAL_2_BYTES( 'M', 'T' ): *error_return = NO_DATA ; return ; case EVAL_2_BYTES( 'C', '1' ): case EVAL_2_BYTES( 'B', '1' ): to_data[0] = from_data[0] ; break ; case EVAL_2_BYTES( 'I', '4' ): if( (from_data[3] & 0x80) == 0x80 ) { /* Negative number */ to_data[0] = 0xff ; to_data[1] = 0xff ; to_data[2] = 0xff ; to_data[3] = 0xff ; } /* end if */ else { to_data[0] = 0x00 ; to_data[1] = 0x00 ; to_data[2] = 0x00 ; to_data[3] = 0x00 ; } /* end else */ to_data[4] = from_data[3] ; to_data[5] = from_data[2] ; to_data[6] = from_data[1] ; to_data[7] = from_data[0] ; break ; case EVAL_2_BYTES( 'U', '4' ): to_data[0] = 0x00 ; to_data[1] = 0x00 ; to_data[2] = 0x00 ; to_data[3] = 0x00 ; to_data[4] = from_data[3] ; to_data[5] = from_data[2] ; to_data[6] = from_data[1] ; to_data[7] = from_data[0] ; break ; case EVAL_2_BYTES( 'I', '8' ): if( (from_data[3] & 0x80) == 0x80 ) { /* Negative number */ to_data[0] = 0xff ; to_data[1] = 0xff ; to_data[2] = 0xff ; to_data[3] = 0xff ; } /* end if */ else { to_data[0] = 0x00 ; to_data[1] = 0x00 ; to_data[2] = 0x00 ; to_data[3] = 0x00 ; } /* end else */ for( i=0; i<(int)delta_from_bytes; i++ ) to_data[8-delta_from_bytes+i] = from_data[delta_from_bytes-1-i] ; break ; case EVAL_2_BYTES( 'U', '8' ): to_data[0] = 0x00 ; to_data[1] = 0x00 ; to_data[2] = 0x00 ; to_data[3] = 0x00 ; for( i=0; i<(int)delta_from_bytes; i++ ) to_data[8-delta_from_bytes+i] = from_data[delta_from_bytes-1-i] ; break ; case EVAL_2_BYTES( 'R', '4' ): for( i=0; i<8; i++ ) to_data[i] = 0x00 ; /** Check for zero: a special case on the Cray (exponent sign) **/ if( (from_data[3] == 0x00) && (from_data[2] == 0x00) && (from_data[1] == 0x00) && (from_data[0] == 0x00) ) break ; /** Convert the sign **/ to_data[0] = from_data[3] & 0x80 ; /** Convert the exponent **/ /** 8 bits to 14 bits. Sign extent from 8 to 14 **/ /** Cray exponent is 2 greater than the Iris **/ exp = (from_data[3] & 0x3f) << 1 ; if( (from_data[2] & 0x80) == 0x80 ) exp += 1 ; if( (from_data[3] & 0x40) == 0x00 ) /* set sign */ exp -= 128 ; exp += 2 ; to_data[1] = exp & 0xff ; if( exp < 0 ) to_data[0] |= 0x3f ; /* exponent sign 0, sign extend exponent */ else to_data[0] |= 0x40 ; /* exponent sign 1 */ /** Convert the mantissia **/ /** 23 bits to 48 bits. Left shift 25 bits, zero fill **/ to_data[2] = from_data[2] | 0x80 ; to_data[3] = from_data[1] ; to_data[4] = from_data[0] ; break ; case EVAL_2_BYTES( 'R', '8' ): for( i=0; i<8; i++ ) to_data[i] = 0x00 ; /** Check for zero: a special case on the Cray (exponent sign) **/ if( (from_data[7] == 0x00) && (from_data[6] == 0x00) && (from_data[5] == 0x00) && (from_data[4] == 0x00) ) break ; /** Convert the sign **/ to_data[0] = from_data[7] & 0x80 ; /** Convert the exponent **/ /** 11 bits to 14 bits. Sign extent from 11 to 14 **/ /** Cray exponent is 2 greater than the Iris **/ exp = ((from_data[7] & 0x3f) << 4) + ((from_data[6]>>4)&0x0f) ; if( (from_data[7] & 0x40) == 0x00 ) /* set sign */ exp -= 1024 ; exp += 2 ; to_data[1] = (unsigned int)(exp & 0xff) ; to_data[0] |= ((exp>>8) & 0x03) ; if( exp < 0 ) to_data[0] |= 0x3c ; /* exponent sign 0, sign extend exponent */ else to_data[0] |= 0x40 ; /* exponent sign 1 */ /** Convert the mantissia **/ /** 52 bits to 48 bits. Use 48, drop last 4 bits **/ to_data[2] = 0x80 | ((from_data[6]<<3)&0x78) | ((from_data[5]>>5)&0x07) ; for( i=3; i<8; i++ ) to_data[i] = ((from_data[7-i+1]<<3)&0xF8) | ((from_data[7-i]>>5)&0x07) ; #ifdef PRINT_STUFF printf("from:" ) ; for( i=0; i<8; i++ ) printf("%02x ", from_data[i] ) ; printf("to:" ) ; for( i=0; i<8; i++ ) printf("%02x ", to_data[i] ) ; printf("\n" ) ; #endif break ; case EVAL_2_BYTES( 'X', '4' ): ADFI_little_endian_to_cray( from_format, from_os_size, to_format, to_os_size, "R4", delta_from_bytes, delta_to_bytes, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_little_endian_to_cray( from_format, from_os_size, to_format, to_os_size, "R4", delta_from_bytes, delta_to_bytes, &from_data[4], &to_data[8], error_return ) ; if( *error_return != NO_ERROR ) return ; break ; case EVAL_2_BYTES( 'X', '8' ): ADFI_little_endian_to_cray( from_format, from_os_size, to_format, to_os_size, "R8", delta_from_bytes, delta_to_bytes, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_little_endian_to_cray( from_format, from_os_size, to_format, to_os_size, "R8", delta_from_bytes, delta_to_bytes, &from_data[8], &to_data[8], error_return ) ; if( *error_return != NO_ERROR ) return ; break ; default: *error_return = INVALID_DATA_TYPE ; return ; } /* end switch */ } /* end of ADFI_little_endian_to_cray */ /* end of file ADFI_little_endian_to_cray.c */ /* file ADFI_open_file.c */ /*********************************************************************** ADFI open file: Track the files used by index. Also track which files are within a given system so a close for the system can close all related files. input: const char *file The filename to open. input: const char *status The status in which to open the file. Allowable values are: READ_ONLY - File must exist. Writing NOT allowed. OLD - File must exist. Reading and writing allowed. NEW - File must not exist. SCRATCH - New file. Filename is ignored. UNKNOWN - OLD if file exists, else NEW is used. input: const int top_file_index -1 if this is the top file. output: unsigned int *file_index Returned index of the file. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER NULL_STRING_POINTER TOO_MANY_ADF_FILES_OPENED ADF_FILE_STATUS_NOT_RECOGNIZED FILE_OPEN_ERROR ***********************************************************************/ void ADFI_open_file( const char *file, const char *status, unsigned int *file_index, int *error_return ) { int index; int f_ret, f_mode; char header_data[102]; if( (status == NULL) || ((file == NULL) && (ADFI_stridx_c( status, "SCRATCH" ) != 0) ) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( file_index == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ *error_return = NO_ERROR ; for( index=0; index= maximum_files ) { ADF_FILE *files; /* I don't use realloc, because I don't want to lose any currently open file information if it fails */ files = (ADF_FILE *) calloc (maximum_files + ADF_FILE_INC, sizeof(ADF_FILE)); if (files == NULL) { *error_return = MEMORY_ALLOCATION_FAILED ; return ; } if (maximum_files) { memcpy (files, ADF_file, maximum_files * sizeof(ADF_FILE)); free (ADF_file); } else { ADFI_stack_control(0,0,0,INIT_STK,0,0,NULL); } ADF_file = files; index = maximum_files; maximum_files += ADF_FILE_INC; } /* end if */ if (index > MAXIMUM_FILES) { *error_return = TOO_MANY_ADF_FILES_OPENED; return; } ADF_file[index].in_use = 1 ; ADF_file[index].nlinks = 0; ADF_file[index].links = NULL; ADF_file[index].file_name = NULL; ADF_file[index].version_update[0] = '\0' ; ADF_file[index].format = UNDEFINED_FORMAT ; ADF_file[index].os_size = UNDEFINED_FORMAT ; ADF_file[index].link_separator = '>' ; ADF_file[index].old_version = 0 ; /*** READ_ONLY - File must exist. Writing NOT allowed. OLD - File must exist. Reading and writing allowed. NEW - File must not exist. SCRATCH - New file. Filename is ignored. UNKNOWN - OLD if file exists, else NEW is used. ***/ ADF_file[index].file = -1; ADF_sys_err = 0; #ifdef _WIN32 f_mode = O_BINARY ; #else f_mode = 0; #endif if( ADFI_stridx_c( status, "READ_ONLY" ) == 0 ) f_ret = file_open( file, f_mode | O_RDONLY, 0666); else if( ADFI_stridx_c( status, "OLD" ) == 0 ) f_ret = file_open( file, f_mode | O_RDWR, 0666); else if( ADFI_stridx_c( status, "NEW" ) == 0 ) f_ret = file_open( file, f_mode | O_RDWR | O_CREAT, 0666); else if( ADFI_stridx_c( status, "SCRATCH" ) == 0 ) { FILE *ftmp = tmpfile(); f_ret = ftmp == NULL ? -1 : FILENO(ftmp); } else if( ADFI_stridx_c( status, "UNKNOWN" ) == 0 ) f_ret = file_open( file, f_mode | O_RDWR | O_CREAT, 0666); else { *error_return = ADF_FILE_STATUS_NOT_RECOGNIZED ; goto Error_Exit ; } /* end else */ if( f_ret < 0 ) { ADF_sys_err = errno; if (errno == EMFILE) *error_return = TOO_MANY_ADF_FILES_OPENED; else *error_return = FILE_OPEN_ERROR ; goto Error_Exit ; } /* end if */ ADF_file[index].file = f_ret ; *file_index = index ; strcpy( ADF_file[index].open_mode, status); if( ADFI_stridx_c( status, "SCRATCH" ) ) { ADF_file[index].file_name = (char *) malloc (strlen(file) + 1); if (ADF_file[index].file_name == NULL) { *error_return = MEMORY_ALLOCATION_FAILED; goto Error_Exit; } strcpy( ADF_file[index].file_name, file ) ; } /* end else */ /* try to read first part of header to determine version and format */ if (102 == READ(f_ret, header_data, 102)) { if (header_data[25] != 'B') ADF_file[index].old_version = 1; ADF_file[index].format = header_data[100]; ADF_file[index].os_size = header_data[101]; } return ; Error_Exit: /** Clear this file's entry **/ if( ADF_file[index].file >= 0 ) { if( CLOSE( ADF_file[index].file ) < 0 ) { ADF_sys_err = errno; *error_return = FILE_CLOSE_ERROR ; } } /* end if */ ADF_file[index].file = -1 ; ADF_file[index].in_use = 0 ; if (ADF_file[index].file_name != NULL) { free (ADF_file[index].file_name); ADF_file[index].file_name = NULL; } } /* end of ADFI_open_file */ /* end of file ADFI_open_file.c */ /* file ADFI_read_chunk_length.c */ /*********************************************************************** ADFI read chunk length: Read the header of the chunk. If it is a variable sized chunk, then the first 2 things in is are: Tag, and pointer to end_of_chunk-tag If NOT variable, then determine what type of chunk it is and return a pointer to the end_of_chunk-tag: If the incoming pointers are 0 0, then we are looking at the file header. input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. output: char tag[TAG_SIZE] The tag from the chunk. output: struct DISK_POINTER *end_of_chunk_tag End of chunk. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER NULL_STRING_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_read_chunk_length( const unsigned int file_index, const struct DISK_POINTER *block_offset, char tag[TAG_SIZE+1], struct DISK_POINTER *end_of_chunk_tag, int *error_return ) { char info[ TAG_SIZE + DISK_POINTER_SIZE ] ; struct DISK_POINTER current_block_offset ; cgulong_t count ; if( (block_offset == NULL) || (end_of_chunk_tag == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( tag == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; end_of_chunk_tag->block = 0 ; end_of_chunk_tag->offset = 0 ; /** File Header **/ if( (block_offset->block == 0) && (block_offset->offset == 0) ) { /** point to end-tag **/ end_of_chunk_tag->offset = FILE_HEADER_SIZE - TAG_SIZE ; tag[0] = file_header_tags[0][0] ; tag[1] = file_header_tags[0][1] ; tag[2] = file_header_tags[0][2] ; tag[3] = file_header_tags[0][3] ; } /* end if */ /** Free-Chunk Table **/ else if( (block_offset->block == 0) && (block_offset->offset == FREE_CHUNKS_OFFSET) ) { /** point to end-tag **/ end_of_chunk_tag->offset = (FREE_CHUNKS_OFFSET + FREE_CHUNK_TABLE_SIZE) - TAG_SIZE ; tag[0] = free_chunk_table_start_tag[0] ; tag[1] = free_chunk_table_start_tag[1] ; tag[2] = free_chunk_table_start_tag[2] ; tag[3] = free_chunk_table_start_tag[3] ; } /* end if */ else { /** Check for 'z's in the file. This is free-data, too small to include tags and pointers **/ count = 0 ; ADFI_read_file( file_index, block_offset->block, block_offset->offset, 1, info, error_return ) ; if( *error_return != NO_ERROR ) return ; if( info[0] == 'z' ) { current_block_offset.block = block_offset->block ; current_block_offset.offset = block_offset->offset ; while( info[0] == 'z' ) { count++ ; current_block_offset.offset++ ; ADFI_adjust_disk_pointer( ¤t_block_offset, error_return ) ; if( *error_return != NO_ERROR ) return ; info[0] = '\0' ; ADFI_read_file( file_index, current_block_offset.block, current_block_offset.offset, 1, info, error_return ) ; if( (*error_return == FSEEK_ERROR) || (*error_return == FREAD_ERROR)){ break ; } /* end if */ if( *error_return != NO_ERROR ) return ; } /* end while */ end_of_chunk_tag->block = block_offset->block ; end_of_chunk_tag->offset = block_offset->offset + count - TAG_SIZE ; ADFI_adjust_disk_pointer( end_of_chunk_tag, error_return ) ; tag[0] = tag[1] = tag[2] = tag[3] = 'z' ; if( *error_return != NO_ERROR ) return ; } /* end if */ else { /** Read TAG and disk_pointer **/ ADFI_read_file( file_index, block_offset->block, block_offset->offset, TAG_SIZE + DISK_POINTER_SIZE, info, error_return ) ; if( *error_return != NO_ERROR ) return ; /* Copy the tag **/ tag[0] = info[0] ; tag[1] = info[1] ; tag[2] = info[2] ; tag[3] = info[3] ; tag[4] = '\0' ; /** Check for known tags **/ if( ADFI_stridx_c( tag, node_start_tag ) == 0 ) { /** Node **/ end_of_chunk_tag->block = block_offset->block ; end_of_chunk_tag->offset = block_offset->offset + NODE_HEADER_SIZE - TAG_SIZE ; ADFI_adjust_disk_pointer( end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ else { /** Convert pointers into numeric form **/ #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &info[TAG_SIZE], &info[DISK_POINTER_SIZE], end_of_chunk_tag, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &info[TAG_SIZE], &info[DISK_POINTER_SIZE], end_of_chunk_tag, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; } /* end else */ } /* end else */ } /* end else */ } /* end of ADFI_read_chunk_length */ /* end of file ADFI_read_chunk_length.c */ /* file ADFI_read_data_chunk.c */ /*********************************************************************** ADFI read data chunk: input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. input: const char *data_type The defined datatype. input: const int data_size Size of data entity in bytes. input: const long chunk_bytes Number of bytes in data chunk. input: const long start_offset Starting offset into the data chunk input: const long total_bytes Number of bytes to read in data chunk. output: char *data Pointer to the resulting data. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ADF_DISK_TAG_ERROR REQUESTED_DATA_TOO_LONG ***********************************************************************/ void ADFI_read_data_chunk( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct TOKENIZED_DATA_TYPE *tokenized_data_type, const int data_size, const cglong_t chunk_bytes, const cglong_t start_offset, const cglong_t total_bytes, char *data, int *error_return ) { int format_compare ; char tag[TAG_SIZE + 1] ; struct DISK_POINTER data_start, end_of_chunk_tag ; cglong_t chunk_total_bytes ; if( block_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (tokenized_data_type == NULL) || (data == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ if( total_bytes+start_offset > chunk_bytes ) { *error_return = REQUESTED_DATA_TOO_LONG ; return ; } /* end if */ *error_return = NO_ERROR ; /** Get tag and chunk length **/ ADFI_read_chunk_length( file_index, block_offset, tag, &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; tag[TAG_SIZE] = '\0' ; /** Check start-of-chunk tag **/ if( ADFI_stridx_c( tag, data_chunk_start_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ /** Check end-of-chunk tag **/ ADFI_read_file( file_index, end_of_chunk_tag.block, end_of_chunk_tag.offset, TAG_SIZE, tag, error_return ) ; if( *error_return != NO_ERROR ) return ; tag[TAG_SIZE] = '\0' ; if( ADFI_stridx_c( tag, data_chunk_end_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ /** Point to the start of the data **/ data_start.block = block_offset->block ; data_start.offset = block_offset->offset + start_offset + DISK_POINTER_SIZE + TAG_SIZE ; ADFI_adjust_disk_pointer( &data_start, error_return ) ; if( *error_return != NO_ERROR ) return ; /** calculate the total number of data bytes **/ chunk_total_bytes = end_of_chunk_tag.offset - data_start.offset + start_offset + (end_of_chunk_tag.block - data_start.block) * DISK_BLOCK_SIZE ; if( chunk_bytes > chunk_total_bytes ) { *error_return = REQUESTED_DATA_TOO_LONG ; return ; } /* end if */ else { if( chunk_bytes < chunk_total_bytes ) *error_return = REQUESTED_DATA_TOO_LONG ; /** check for need of data translation **/ ADFI_file_and_machine_compare( file_index, tokenized_data_type, &format_compare, error_return ); if( *error_return != NO_ERROR ) return ; if( format_compare == 1 ) { /** Read the data off of disk **/ assert(data_start.offset <= 0x1fff); ADFI_read_file( file_index, data_start.block, data_start.offset, total_bytes, data, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ else { ADFI_read_data_translated( file_index, data_start.block, data_start.offset, tokenized_data_type, data_size, total_bytes, data, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end else */ } /* end else */ } /* end of ADFI_read_data_chunk */ /* end of file ADFI_read_data_chunk.c */ /* file ADFI_read_data_chunk_table.c */ /*********************************************************************** ADFI read data chunk table: input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. output: struct DATA_CHUNK_TABLE_ENTRY data_chunk_table[] Array of DC entries. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_read_data_chunk_table( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct DATA_CHUNK_TABLE_ENTRY data_chunk_table[], int *error_return ) { char tag[ TAG_SIZE + 1 ] ; struct DISK_POINTER end_of_chunk_tag, tmp_block_offset ; cgulong_t i, number_of_bytes_to_read ; if( (block_offset == NULL) || (data_chunk_table == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Get the tag and the length **/ ADFI_read_chunk_length( file_index, block_offset, tag, &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; tag[TAG_SIZE] = '\0' ; /** Compare the start tag **/ if( ADFI_stridx_c( tag, data_chunk_table_start_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ number_of_bytes_to_read = (end_of_chunk_tag.block - block_offset->block) * DISK_BLOCK_SIZE + (end_of_chunk_tag.offset - block_offset->offset) - (TAG_SIZE + DISK_POINTER_SIZE) ; /** Read the data from disk **/ tmp_block_offset.block = block_offset->block ; tmp_block_offset.offset = block_offset->offset + TAG_SIZE ; for( i=0; i number_of_data_elements ) { chunk_size -= (unsigned int)( number_of_elements_read - number_of_data_elements ) ; delta_from_bytes = chunk_size * data_size ; delta_to_bytes = chunk_size * machine_size ; } ADFI_read_file( file_index, disk_pointer.block, disk_pointer.offset, delta_from_bytes, (char *)from_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_convert_number_format( ADF_file[file_index].format, /* from format */ ADF_file[file_index].os_size, /* from os size */ ADF_this_machine_format, /* to format */ ADF_this_machine_os_size, /* to os size */ FROM_FILE_FORMAT, tokenized_data_type, chunk_size, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; to_data += delta_to_bytes ; disk_pointer.offset += delta_from_bytes ; if ( disk_pointer.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &disk_pointer, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ } /* end while */ } /* end of ADFI_read_data_translated */ /* end of file ADFI_read_data_translated.c */ /* file ADFI_read_disk_block.c */ /*********************************************************************** ADFI read disk block: Possible errors: NO_ERROR ***********************************************************************/ void ADFI_read_disk_block() { fprintf(stderr,"Subroutine ADFI_read_disk_block is not yet implemented...\n" ) ; } /* end of ADFI_read_disk_block */ /* end of file ADFI_read_disk_block.c */ /* file ADFI_read_disk_pointer_from_disk.c */ /*********************************************************************** ADFI read disk pointer from disk: Given a pointer to a disk pointer, read it from disk and convert it into numeric form. input: const unsigned int file_index File to read from. input: const unsigned long file_block Block within the file. input: const unsigned long block_offset Offset within the block. output: struct DISK_POINTER *block_and_offset Resulting disk pointer. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_read_disk_pointer_from_disk( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, struct DISK_POINTER *block_and_offset, int *error_return ) { char disk_block_offset[DISK_POINTER_SIZE] ; if( block_and_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( block_offset > DISK_BLOCK_SIZE ) { *error_return = BLOCK_OFFSET_OUT_OF_RANGE ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check the stack for block/offset **/ #if 0 if ( ADFI_stack_control(file_index, file_block, (unsigned int)block_offset, GET_STK, DISK_PTR_STK, DISK_POINTER_SIZE, disk_block_offset ) != NO_ERROR ) { #endif /** Get the block/offset from disk **/ ADFI_read_file( file_index, file_block, block_offset, DISK_POINTER_SIZE, disk_block_offset, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Set the block/offset onto the stack **/ #if 0 ADFI_stack_control(file_index, file_block, (unsigned int)block_offset, SET_STK, DISK_PTR_STK, DISK_POINTER_SIZE, disk_block_offset ); } /* end if */ #endif /** Convert into numeric form **/ #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_block_offset[0], &disk_block_offset[8], block_and_offset, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_block_offset[0], &disk_block_offset[8], block_and_offset, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; } /* end of ADFI_read_disk_pointer_from_disk */ /* end of file ADFI_read_disk_pointer_from_disk.c */ /***********************************************************************/ cglong_t ADFI_read ( const unsigned int file_index, const cglong_t data_length, char *data) { char *data_ptr = data; cglong_t bytes_left = data_length; cglong_t bytes_read = 0; int nbytes, to_read; ADF_sys_err = 0; while (bytes_left > 0) { to_read = bytes_left > CG_MAX_INT32 ? CG_MAX_INT32 : (int)bytes_left; nbytes = (int) READ (ADF_file[file_index].file, data_ptr, to_read); if (0 == nbytes) break; if (-1 == nbytes) { if (EINTR != errno) { ADF_sys_err = errno; return -1; } } else { bytes_left -= nbytes; bytes_read += nbytes; data_ptr += nbytes; } } return bytes_read; } /* file ADFI_read_file.c */ /*********************************************************************** ADFI read file: Read a number of bytes from an open ADF file from a given file, block, and offset. Buffering is done in an attempt to improve performance of repeatedly reading small pieces of contiguous data. Note: read buffering also affects the write function, i.e, all writes must reset the read buffer. input: const unsigned int file_index File to read from. input: const unsigned long file_block Block within the file. input: const unsigned long block_offset Offset within the block. input: const unsigned int data_length Length of the data to read. input: char *data Address of the data. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER ADF_FILE_NOT_OPENED FREAD_ERROR ***********************************************************************/ void ADFI_read_file( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, const cglong_t data_length, char *data, int *error_return ) { cglong_t iret ; if( data == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** No need to buffer large pieces of data or to take special measures to cross block boundaries **/ if( data_length + block_offset > DISK_BLOCK_SIZE ) { /** Position the file **/ ADFI_fseek_file( file_index, file_block, block_offset, error_return ) ; if( *error_return != NO_ERROR ) { return ; } /* end if */ /** Read the data from disk **/ iret = ADFI_read ( file_index, data_length, data ) ; if( iret != data_length ) { *error_return = FREAD_ERROR ; return ; } /* end if */ return; } /* end if */ /** For smaller pieces of data, read a block at a time. This will improve performance if neighboring data is requested a small piece at a time (strided reads, file overhead). Some assumptions apply to the block size. With some experimenting, 1K blocks do not offer much improvement. 4K blocks (4096 bytes) do improve performance remarkably. This is due to the fact that the file structure is based of 4K blocks with offsets. **/ if( num_in_rd_block < DISK_BLOCK_SIZE || /*- buffer is not full -*/ (cglong_t) file_block != last_rd_block || /*- a different block -*/ (int) file_index != last_rd_file ) { /*- entirely different file -*/ /** buffer is not current, re-read **/ if ( (cglong_t) file_block == last_wr_block && (int) file_index == last_wr_file ) { /* Copy data from write buffer */ memcpy( rd_block_buffer, wr_block_buffer, DISK_BLOCK_SIZE ); iret = DISK_BLOCK_SIZE; } else { /** Position the file **/ ADFI_fseek_file( file_index, file_block, 0, error_return ) ; if( *error_return != NO_ERROR ) { return ; } /* end if */ /** Read the data from disk **/ iret = ADFI_read( file_index, DISK_BLOCK_SIZE, rd_block_buffer ) ; if( iret <= 0 ) { *error_return = FREAD_ERROR ; return ; } /* end if */ } /* end if */ /** Remember buffer information **/ last_rd_block = file_block ; last_rd_file = (int)file_index ; num_in_rd_block = (int)iret ; } /* end if */ /*read from buffer*/ memcpy( data, &rd_block_buffer[block_offset], (size_t)data_length ); } /* end of ADFI_read_file */ /* end of file ADFI_read_file.c */ /* file ADFI_read_file_header.c */ /*********************************************************************** ADFI read file header: input: const unsigned int file_index The file index. output: struct FILE_HEADER *file_header Pointer to a file-header struct. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ADF_MEMORY_TAG_ERROR ***********************************************************************/ void ADFI_read_file_header( const unsigned int file_index, struct FILE_HEADER *file_header, int *error_return ) { char disk_header[ FILE_HEADER_SIZE ] ; if( file_header == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check the stack for header **/ if ( ADFI_stack_control(file_index, 0, 0, GET_STK, FILE_STK, FILE_HEADER_SIZE, disk_header ) != NO_ERROR ) { /** Read in the header into memory **/ ADFI_read_file( file_index, 0, 0, FILE_HEADER_SIZE, disk_header, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check memory tags for proper data **/ if( strncmp( &disk_header[32], file_header_tags[0], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( &disk_header[64], file_header_tags[1], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( &disk_header[96], file_header_tags[2], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( &disk_header[102], file_header_tags[3], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( &disk_header[130], file_header_tags[4], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( &disk_header[182], file_header_tags[5], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ /** Set the header onto the stack **/ ADFI_stack_control(file_index, 0, 0, SET_STK, FILE_STK, FILE_HEADER_SIZE, disk_header ); } /* end if */ /** OK the memory tags look good, let's convert disk-formatted header into memory **/ strncpy( (char *)file_header->what, &disk_header[ 0], 32 ) ; strncpy( (char *)file_header->tag0, &disk_header[ 32], TAG_SIZE ) ; strncpy( (char *)file_header->creation_date, &disk_header[ 36], DATE_TIME_SIZE); strncpy( (char *)file_header->tag1, &disk_header[ 64], TAG_SIZE ) ; strncpy( (char *)file_header->modification_date, &disk_header[ 68], DATE_TIME_SIZE ) ; strncpy( (char *)file_header->tag2, &disk_header[ 96], TAG_SIZE ) ; file_header->numeric_format = disk_header[100] ; file_header->os_size = disk_header[101] ; strncpy( (char *)file_header->tag3, &disk_header[102], TAG_SIZE ) ; #if 0 #ifdef NEW_DISK_POINTER if (ADF_file[file_index].format == UNDEFINED_FORMAT) ADF_file[file_index].format = file_header->numeric_format; if (ADF_file[file_index].os_size == UNDEFINED_FORMAT) ADF_file[file_index].os_size = file_header->os_size; #endif #else assert(ADF_file[file_index].format != UNDEFINED_FORMAT); assert(ADF_file[file_index].os_size != UNDEFINED_FORMAT); #endif ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[106], &file_header->sizeof_char, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[108], &file_header->sizeof_short, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[110], &file_header->sizeof_int, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[112], &file_header->sizeof_long, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[114], &file_header->sizeof_float, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[116], &file_header->sizeof_double, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[118], &file_header->sizeof_char_p, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[120], &file_header->sizeof_short_p, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[122], &file_header->sizeof_int_p, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[124], &file_header->sizeof_long_p, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[126], &file_header->sizeof_float_p, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, 255, 2, &disk_header[128], &file_header->sizeof_double_p, error_return ) ; if( *error_return != NO_ERROR ) return ; strncpy( file_header->tag4, &disk_header[130], TAG_SIZE ) ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_header[134], &disk_header[142], &file_header->root_node, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_header[134], &disk_header[142], &file_header->root_node, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_header[146], &disk_header[154], &file_header->end_of_file, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_header[146], &disk_header[154], &file_header->end_of_file, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_header[158], &disk_header[166], &file_header->free_chunks, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_header[158], &disk_header[166], &file_header->free_chunks, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_header[170], &disk_header[178], &file_header->extra, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_header[170], &disk_header[178], &file_header->extra, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; strncpy( file_header->tag5, &disk_header[182], TAG_SIZE ) ; /** Check memory tags for proper data **/ if( strncmp( file_header->tag0, file_header_tags[0], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag1, file_header_tags[1], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag2, file_header_tags[2], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag3, file_header_tags[3], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag4, file_header_tags[4], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag5, file_header_tags[5], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ } /* end of ADFI_read_file_header */ /* end of file ADFI_read_file_header.c */ /* file ADFI_read_free_chunk.c */ /*********************************************************************** ADFI read free chunk: input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. output: struct DISK_POINTER *end_of_chunk_tag End of free chunk tag. output: struct DISK_POINTER *next_chunk Next free chunk in list. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ADF_DISK_TAG_ERROR ***********************************************************************/ void ADFI_read_free_chunk( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct FREE_CHUNK *free_chunk, int *error_return ) { char tag[TAG_SIZE + 1] ; struct DISK_POINTER chunk_block_offset ; if( (block_offset == NULL) || (free_chunk == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Get the tag and the length **/ ADFI_read_chunk_length( file_index, block_offset, tag, &(free_chunk->end_of_chunk_tag), error_return ) ; if( *error_return != NO_ERROR ) return ; tag[TAG_SIZE] = '\0' ; /** Compare the start tag **/ if( ADFI_stridx_c( tag, free_chunk_start_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ /** Set block offset to the start of the chunk **/ chunk_block_offset = *block_offset ; chunk_block_offset.offset += TAG_SIZE + DISK_POINTER_SIZE ; ADFI_adjust_disk_pointer( &chunk_block_offset, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Read the data from disk **/ ADFI_read_disk_pointer_from_disk( file_index, chunk_block_offset.block, chunk_block_offset.offset, &(free_chunk->next_chunk), error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_read_file( file_index, free_chunk->end_of_chunk_tag.block, free_chunk->end_of_chunk_tag.offset, TAG_SIZE, tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Compare the end tag **/ if( ADFI_stridx_c( tag, free_chunk_end_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ strncpy( free_chunk->start_tag, free_chunk_start_tag, 4 ) ; strncpy( free_chunk->end_tag, free_chunk_end_tag, 4 ) ; } /* end of ADFI_read_free_chunk */ /* end of file ADFI_read_free_chunk.c */ /* file ADFI_read_free_chunk_table.c */ /*********************************************************************** ADFI read free chunk table: input: const unsigned int file_index The file index. output: struct FREE_CHUNK_TABLE *free_chunk_table Pointer to table. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ADF_DISK_TAG_ERROR ADF_MEMORY_TAG_ERROR ***********************************************************************/ void ADFI_read_free_chunk_table( const unsigned int file_index, struct FREE_CHUNK_TABLE *free_chunk_table, int *error_return ) { char disk_free_chunk_data[ FREE_CHUNK_TABLE_SIZE ] ; if( free_chunk_table == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check the stack for free chunk **/ if ( ADFI_stack_control(file_index, FREE_CHUNKS_BLOCK, FREE_CHUNKS_OFFSET, GET_STK, FREE_CHUNK_STK, FREE_CHUNK_TABLE_SIZE, disk_free_chunk_data ) != NO_ERROR ) { /** Read the free-chunk table off of disk **/ ADFI_read_file( file_index, FREE_CHUNKS_BLOCK, FREE_CHUNKS_OFFSET, FREE_CHUNK_TABLE_SIZE, disk_free_chunk_data, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check disk tags **/ if( ADFI_stridx_c( &disk_free_chunk_data[0], free_chunk_table_start_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end of */ if( ADFI_stridx_c( &disk_free_chunk_data[FREE_CHUNK_TABLE_SIZE - TAG_SIZE], free_chunk_table_end_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end of */ /** Set the free chunk onto the stack **/ ADFI_stack_control(file_index, FREE_CHUNKS_BLOCK, FREE_CHUNKS_OFFSET, SET_STK, FREE_CHUNK_STK, FREE_CHUNK_TABLE_SIZE, disk_free_chunk_data ); } /* end if */ /** Convert into memory **/ strncpy( (char *)free_chunk_table->start_tag, &disk_free_chunk_data[ 0], TAG_SIZE ) ; strncpy( (char *)free_chunk_table->end_tag, &disk_free_chunk_data[ FREE_CHUNK_TABLE_SIZE - TAG_SIZE ], TAG_SIZE ) ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_free_chunk_data[ TAG_SIZE], &disk_free_chunk_data[DISK_POINTER_SIZE], &free_chunk_table->small_first_block, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_free_chunk_data[ TAG_SIZE], &disk_free_chunk_data[DISK_POINTER_SIZE], &free_chunk_table->small_first_block, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_free_chunk_data[16], &disk_free_chunk_data[24], &free_chunk_table->small_last_block, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_free_chunk_data[16], &disk_free_chunk_data[24], &free_chunk_table->small_last_block, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_free_chunk_data[28], &disk_free_chunk_data[36], &free_chunk_table->medium_first_block, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_free_chunk_data[28], &disk_free_chunk_data[36], &free_chunk_table->medium_first_block, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_free_chunk_data[40], &disk_free_chunk_data[48], &free_chunk_table->medium_last_block, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_free_chunk_data[40], &disk_free_chunk_data[48], &free_chunk_table->medium_last_block, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_free_chunk_data[52], &disk_free_chunk_data[60], &free_chunk_table->large_first_block, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_free_chunk_data[52], &disk_free_chunk_data[60], &free_chunk_table->large_first_block, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_free_chunk_data[64], &disk_free_chunk_data[72], &free_chunk_table->large_last_block, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_free_chunk_data[64], &disk_free_chunk_data[72], &free_chunk_table->large_last_block, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; /** Check memory tags **/ if( ADFI_stridx_c( free_chunk_table->start_tag, free_chunk_table_start_tag ) != 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end of */ if( ADFI_stridx_c( free_chunk_table->end_tag, free_chunk_table_end_tag ) != 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end of */ } /* end of ADFI_read_free_chunk_table */ /* end of file ADFI_read_free_chunk_table.c */ /* file ADFI_read_node_header.c */ /*********************************************************************** ADFI read node header: input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. output: struct NODE_HEADER *node_header Pointer to node header. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ADF_DISK_TAG_ERROR ADF_MEMORY_TAG_ERROR ***********************************************************************/ void ADFI_read_node_header( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct NODE_HEADER *node_header, int *error_return ) { char disk_node_data[ NODE_HEADER_SIZE ] ; int i ; if( (block_offset == NULL) || (node_header == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check the stack for header **/ if ( ADFI_stack_control(file_index, block_offset->block, (unsigned int)block_offset->offset, GET_STK, NODE_STK, NODE_HEADER_SIZE, disk_node_data ) != NO_ERROR ) { /** Get the node header from disk **/ ADFI_read_file( file_index, block_offset->block, block_offset->offset, NODE_HEADER_SIZE, disk_node_data, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Check disk tags **/ if( ADFI_stridx_c( &disk_node_data[0], node_start_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end of */ if( ADFI_stridx_c( &disk_node_data[ NODE_HEADER_SIZE - TAG_SIZE ], node_end_tag ) != 0 ) { *error_return = ADF_DISK_TAG_ERROR ; return ; } /* end if */ /** Set the header onto the stack **/ ADFI_stack_control(file_index, block_offset->block, (unsigned int)block_offset->offset, SET_STK, NODE_STK, NODE_HEADER_SIZE, disk_node_data ); } /* end if */ /** Convert into memory **/ strncpy( (char *)node_header->node_start_tag, &disk_node_data[ 0], TAG_SIZE ) ; strncpy( (char *)node_header->node_end_tag, &disk_node_data[ NODE_HEADER_SIZE - TAG_SIZE], TAG_SIZE ) ; strncpy( (char *)node_header->name, &disk_node_data[ TAG_SIZE], ADF_NAME_LENGTH ) ; strncpy( (char *)node_header->label, &disk_node_data[ 36], ADF_LABEL_LENGTH ) ; ADFI_ASCII_Hex_2_unsigned_int( 0, MAXIMUM_32_BITS, 8, &disk_node_data[ 68], &node_header->num_sub_nodes, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_ASCII_Hex_2_unsigned_int( 0, MAXIMUM_32_BITS, 8, &disk_node_data[ 76], &node_header->entries_for_sub_nodes, error_return ) ; if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_node_data[84], &disk_node_data[92], &node_header->sub_node_table, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_node_data[84], &disk_node_data[92], &node_header->sub_node_table, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; strncpy( (char *)node_header->data_type, &disk_node_data[ 96], ADF_DATA_TYPE_LENGTH ) ; ADFI_ASCII_Hex_2_unsigned_int( 0, 12, 2, &disk_node_data[128], &node_header->number_of_dimensions, error_return ) ; if( *error_return != NO_ERROR ) return ; if (ADF_file[file_index].old_version) { unsigned int dim; for( i=0; idimension_values[i] = dim; } /* end for */ } else { ADFI_convert_integers(8, 12, ADF_file[file_index].format, ADF_this_machine_format, &disk_node_data[130], (char *)node_header->dimension_values, error_return); if( *error_return != NO_ERROR ) return ; } ADFI_ASCII_Hex_2_unsigned_int( 0, 65535, 4, &disk_node_data[226], &node_header->number_of_data_chunks, error_return ) ; if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &disk_node_data[230], &disk_node_data[238], &node_header->data_chunks, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &disk_node_data[230], &disk_node_data[238], &node_header->data_chunks, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; /** Check memory tags **/ if( ADFI_stridx_c( node_header->node_start_tag, node_start_tag ) != 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end of */ if( ADFI_stridx_c( node_header->node_end_tag, node_end_tag ) != 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end of */ } /* end of ADFI_read_node_header */ /* end of file ADFI_read_node_header.c */ /* file ADFI_read_sub_node_table.c */ /*********************************************************************** ADFI read sub node table: At this point, reading of the ENTIRE table is required. input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. output: struct SUB_NODE_TABLE_ENTRY sub_node_table[] Array of SN entries. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_read_sub_node_table( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct SUB_NODE_TABLE_ENTRY sub_node_table[], int *error_return ) { char tag[TAG_SIZE + 1] ; struct DISK_POINTER end_of_chunk_tag, current_child ; unsigned int number_of_children, i ; if( (block_offset == NULL) || (sub_node_table == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Get tag and length **/ ADFI_read_chunk_length( file_index, block_offset, tag, &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; tag[TAG_SIZE] = '\0' ; /** calculate the number of chuldren in the sub-node table **/ number_of_children = (unsigned int)( (end_of_chunk_tag.block - block_offset->block) * DISK_BLOCK_SIZE + (end_of_chunk_tag.offset - block_offset->offset) ) / (DISK_POINTER_SIZE + ADF_NAME_LENGTH) ; current_child.block = block_offset->block ; current_child.offset = block_offset->offset + TAG_SIZE + DISK_POINTER_SIZE ; ADFI_adjust_disk_pointer( ¤t_child, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Read and convert the variable-length table into memory **/ for( i=0; i= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check the stack for subnode **/ if ( ADFI_stack_control(file_index, block_offset->block, (unsigned int)block_offset->offset, GET_STK, SUBNODE_STK, ADF_NAME_LENGTH + DISK_POINTER_SIZE, sub_node_entry_disk_data ) != NO_ERROR ) { /** Read the entry from disk **/ ADFI_read_file( file_index, block_offset->block, block_offset->offset, ADF_NAME_LENGTH + DISK_POINTER_SIZE, sub_node_entry_disk_data, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Set the subnode onto the stack **/ ADFI_stack_control(file_index, block_offset->block, (unsigned int)block_offset->offset, SET_STK, SUBNODE_STK, ADF_NAME_LENGTH + DISK_POINTER_SIZE, sub_node_entry_disk_data ); } /* end if */ /** Copy the name **/ strncpy( sub_node_table_entry->child_name, &sub_node_entry_disk_data[0], ADF_NAME_LENGTH ) ; /** Convert the disk-pointer **/ #ifdef NEW_DISK_POINTER ADFI_read_disk_pointer( file_index, &sub_node_entry_disk_data[ ADF_NAME_LENGTH ], &sub_node_entry_disk_data[ ADF_NAME_LENGTH + 8 ], &sub_node_table_entry->child_location, error_return ) ; #else ADFI_disk_pointer_from_ASCII_Hex( &sub_node_entry_disk_data[ ADF_NAME_LENGTH ], &sub_node_entry_disk_data[ ADF_NAME_LENGTH + 8 ], &sub_node_table_entry->child_location, error_return ) ; #endif if( *error_return != NO_ERROR ) return ; } /* end of ADFI_read_sub_node_table_entry */ /* end of file ADFI_read_sub_node_table_entry.c */ /* file ADFI_remember_file_format.c */ /********************************************************************** ADFI remember file format: Track the file format used: input: const int file_index Index for the file. input: const char numeric_format Format for the file. input: const char os_size operating system size for the file. output: int *error_return Error return. Possible errors: NO_ERROR FILE_INDEX_OUT_OF_RANGE **********************************************************************/ void ADFI_remember_file_format( const int file_index, const char numeric_format, const char os_size, int *error_return ) { if( (file_index < 0) || (file_index >= maximum_files) ) { *error_return = FILE_INDEX_OUT_OF_RANGE ; return ; } /* end if */ *error_return = NO_ERROR ; ADF_file[file_index].format = numeric_format ; ADF_file[file_index].os_size = os_size ; } /* end of file ADFI_remember_file_format.c */ /* file ADFI_remember_version_update.c */ /*********************************************************************** ADFI remember version update: Stores the what-string (which contains the file version number) so that it can be written after the first successful update. After the file has been updated once, the remembered what-string is "forgotten". input: const int file_index File index to write to. input: const char *what_string What string to remember (contains version) output: int *error_return Error return. Possible errors: FILE_INDEX_OUT_OF_RANGE NULL_STRING_POINTER STRING_LENGTH_ZERO ***********************************************************************/ void ADFI_remember_version_update( const int file_index, const char *what_string, int *error_return ) { *error_return = NO_ERROR ; if( (file_index < 0) || (file_index >= maximum_files) ) { *error_return = FILE_INDEX_OUT_OF_RANGE ; return ; } /* end if */ if( what_string == NULL ) { *error_return = NULL_STRING_POINTER ; return; } /* end if */ if( what_string[0] == '\0' ) { *error_return = STRING_LENGTH_ZERO ; return; } /* end if */ if( strlen( what_string ) > WHAT_STRING_SIZE ) { *error_return = STRING_LENGTH_TOO_BIG ; return ; } /* end if */ strcpy( ADF_file[file_index].version_update, what_string ) ; } /* end of ADFI_remember_version_update */ /* end of file ADFI_remember_version_update.c */ /* file ADFI_set_blank_disk_pointer.c */ /********************************************************************** ADFI_set_blank_disk_pointer: Set the block and offset to the defined "blank", or unused values. output: struct DISK_POINTER *block_offset Block & offset in the file. Possible errors: None allowed **********************************************************************/ void ADFI_set_blank_disk_pointer( struct DISK_POINTER *block_offset ) { block_offset->block = BLANK_FILE_BLOCK ; block_offset->offset = BLANK_BLOCK_OFFSET ; } /* end of ADFI_set_blank_disk_pointer */ /* end of file ADFI_set_blank_disk_pointer.c */ /* file ADFI_stack_control.c */ /*********************************************************************** ADFI stack control: input: const unsigned int file_index The file index. input: const unsigned long file_block Block within the file. input: const unsigned long block_offset Offset within the block. input: const int stack_mode Control mode: INIT, GET or SET input; const int stack_type Type of stack entry to process: FILE, NODE, etc.. input: const unsigned int data_length Length of the data to buffer. input/output: char *stack_data The character string buffered, is input for mode SET and output for mode GET. Possible errors: NO_ERROR NULL_STRING_POINTER ADF_FILE_NOT_OPENED PRISTK_NOT_FOUND Note: errors are only important for GET mode since you must then go ahead and read the data from the file. The stack is only meant to speed things up, not stop the process !!! ***********************************************************************/ int ADFI_stack_control( const unsigned int file_index, const cgulong_t file_block, const unsigned int block_offset, const int stack_mode, const int stack_type, const unsigned int data_length, char *stack_data ) { int i; int low_priority; int insert_index = 0; int found; if( stack_data == NULL && (stack_mode == GET_STK || stack_mode == SET_STK) ) { return NULL_STRING_POINTER ; } /* end if */ if( ((int)file_index >= maximum_files || ADF_file[file_index].in_use == 0) && stack_mode != INIT_STK ) { return ADF_FILE_NOT_OPENED ; } /* end if */ /* Process depending on the mode */ switch( stack_mode ) { case INIT_STK: case CLEAR_STK: case CLEAR_STK_TYPE: /* Clear all entries with current file_index and or type, if file_index is 0 then clear all the entries!! */ for (i=0; i 0 ) free(PRISTK[i].stack_data); PRISTK[i].file_index = -1; PRISTK[i].file_block = 0; PRISTK[i].block_offset = 0; PRISTK[i].stack_type = -1; PRISTK[i].priority_level = -1; } /* end for */ /* just in case link or linked-to node deleted */ last_link_ID = 0.0; break ; case GET_STK: /* Try and find the entry in the current stack by matching the file index, block and offset, if found copy data else if not return with an error. */ for (i=0; i= 0 ) { /* Existing entry so lower its priority, if it is the lowest then save its index for possible replacement. */ if ( PRISTK[i].priority_level > low_priority ) { low_priority = PRISTK[i].priority_level; insert_index = i; } /* end if */ PRISTK[i].priority_level++; } /* end else if */ else if ( found == 'f' ) { /* An empty entry set pointer for possible insertion */ low_priority = MAX_STACK * MAX_STACK; insert_index = i; found = 'e'; } /* end else if */ } /* end for */ /* If the item was already on the stack then we are done */ if ( found == 't' ) return NO_ERROR; /* Insert the data onto the stack at the index_insert location. */ i = insert_index; if ( PRISTK[i].priority_level > 0 ) free(PRISTK[i].stack_data); PRISTK[i].stack_data = ( char * ) malloc((size_t)data_length*sizeof(char)); if ( PRISTK[i].stack_data == NULL ) { /* Error allocating memory buffer so clear stack and punt */ PRISTK[i].file_index = -1; PRISTK[i].file_block = 0; PRISTK[i].block_offset = 0; PRISTK[i].stack_type = -1; PRISTK[i].priority_level = -1; return NO_ERROR; } /* end if */ memcpy( PRISTK[i].stack_data, stack_data, (size_t)data_length ); PRISTK[i].file_index = file_index; PRISTK[i].file_block = file_block; PRISTK[i].block_offset = (unsigned int)block_offset; PRISTK[i].stack_type = stack_type; PRISTK[i].priority_level = 1; break ; } /* end switch */ return NO_ERROR; } /* end of ADFI_stack_control */ /* end of file ADFI_stack_control.c */ /* file ADFI_stridx_c.c */ /********************************************************************** ADFI stridx c: To find the location of a substring within a string. This routine is case InSeNsItIvE!!! It is NOT assumed that the substring is already upper-case!!! input: const char *str The string to search in. input: const char *substr The substring to search for. output: int return-value The position in str where substr was found. -1 if substr was not found. Possible errors: none: Errors are not allowed. ***********************************************************************/ int ADFI_stridx_c( const char *str, const char *substr ) { int i, j, k ; if( str == NULL || substr == NULL || substr[0] == '\0' ) { return -1 ; /* not found - nothing to check */ } for( i=0; str[i] != '\0'; i++ ) { for( j=i, k=0; TO_UPPER( str[j] ) == TO_UPPER( substr[k] ); j++ ) { if( substr[++k] == '\0' ) return i ; /* the substring was found */ } /* end for */ } /* end for */ return -1 ; /* the substring was not found */ } /* end of ADFI_stridx_c */ /* end of file ADFI_stridx_c.c */ /* file ADFI_string_2_C_string.c */ /********************************************************************** ADFI string to C string: Create a C string of the maximum length (+1 for null) which is null terminated and has no trailing blanks. input: const char *string Input string. input: const int string_length Length of input string to use. output: char *c_string Returned C string. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER **********************************************************************/ void ADFI_string_2_C_string( const char *string, const int string_length, char *c_string, int *error_return ) { int i, iend ; if( (string == NULL) || (c_string == NULL) ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ *error_return = NO_ERROR ; /** Search for early NULL termination **/ for( iend=0; iend < string_length; iend++ ) { if( string[ iend ] == '\0' ) { break ; } /* end if */ } /* end for */ iend--; /** Skip and trailing blanks **/ for( ; iend>=0; iend-- ) { if( string[ iend ] != ' ' ) { break ; } /* end if */ } /* end for */ /** Copy the non-trailing blank portion of the string **/ for( i=0; i<=iend; i++ ) c_string[i] = string[i] ; /** NULL terminate the C string **/ c_string[i] = '\0' ; } /* end of ADFI_string_2_C_string */ /* end of file ADFI_string_2_C_string.c */ /* file ADFI_unsigned_int_2_ASCII_Hex.c */ /*********************************************************************** ADFI unsigned int to ASCII hex: Convert an unsigned int to an ASCII-Hex string. input: const unsigned int number The integer number to convert to ASCII. input: const unsigned int minimum The expected minimum number in the int. input: const unsigned int maximum The expected maximum number in the int. input: const unsigned int string_length The length of the returned string. output: char string[] The string. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER NUMBER_LESS_THAN_MINIMUM NUMBER_GREATER_THAN_MAXIMUM STRING_LENGTH_ZERO STRING_LENGTH_TOO_BIG ***********************************************************************/ void ADFI_unsigned_int_2_ASCII_Hex( const unsigned int number, const unsigned int minimum, const unsigned int maximum, const unsigned int string_length, char string[], int *error_return ) { unsigned int i, /** Index from 0 to string_length - 1 **/ ir, /** Index from string_length - 1 to 0 **/ j, /** Temoprary integer variable **/ num ; /** Working value of the number **/ if( string == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( number < minimum ) { *error_return = NUMBER_LESS_THAN_MINIMUM ; return ; } /* end if */ if( number > maximum ) { *error_return = NUMBER_GREATER_THAN_MAXIMUM ; return ; } /* end if */ if( string_length == 0 ) { *error_return = STRING_LENGTH_ZERO ; return ; } /* end if */ if( string_length > 8 ) { *error_return = STRING_LENGTH_TOO_BIG ; return ; } /* end if */ *error_return = NO_ERROR ; /** Convert the number using power-of-2 table **/ num = number ; for( i=0, ir=string_length - 1; i= pows[ ir ] ) { j = num / pows[ ir ] ; num = num - j * pows[ ir ] ; } /* end if */ else j = 0 ; string[i] = ASCII_Hex[ j ] ; } /* end for */ } /* end of ADFI_unsignedlong_2_ASCII_Hex */ /* end of file ADFI_unsigned_int_2_ASCII_Hex.c */ /* file ADFI_write_data_chunk.c */ /*********************************************************************** ADFI write data chunk: input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. input: const struct TOKENIZED_DATA_TYPE *tokenized_data_type Array. input: const int data_size Size of data entity in bytes. input: const long chunk_bytes Number of bytes in data chunk. input: const long start_offset Starting offset into the data chunk input: const long total_bytes Number of bytes to write in data chunk. input: const char *data Pointer to the data. If 0, zero data. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER NULL_STRING_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_write_data_chunk( const unsigned int file_index, const struct DISK_POINTER *block_offset, const struct TOKENIZED_DATA_TYPE *tokenized_data_type, const int data_size, const cglong_t chunk_bytes, const cglong_t start_offset, const cglong_t total_bytes, const char *data, int *error_return ) { int format_compare ; struct DISK_POINTER current_location, end_of_chunk_tag ; if( block_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( tokenized_data_type == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ if( total_bytes+start_offset > chunk_bytes ) { *error_return = REQUESTED_DATA_TOO_LONG ; return ; } /* end if */ *error_return = NO_ERROR ; /** Write the tag **/ ADFI_write_file( file_index, block_offset->block, block_offset->offset, TAG_SIZE, data_chunk_start_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Calculate the end-of-chunk-tag pointer **/ end_of_chunk_tag.block = block_offset->block ; end_of_chunk_tag.offset = block_offset->offset + TAG_SIZE + DISK_POINTER_SIZE + chunk_bytes ; ADFI_adjust_disk_pointer( &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Adjust location and write end-of-chunk pointer **/ current_location.block = block_offset->block ; current_location.offset = block_offset->offset + TAG_SIZE ; ADFI_adjust_disk_pointer( ¤t_location, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_write_disk_pointer_2_disk( file_index, current_location.block, current_location.offset, &end_of_chunk_tag, error_return ) ; current_location.offset += start_offset + DISK_POINTER_SIZE ; ADFI_adjust_disk_pointer( ¤t_location, error_return ) ; if( *error_return != NO_ERROR ) return ; /** write the data **/ if( data == NULL ) { /** Zero out the file data **/ /** If the data-pointer is NULL, write zeros to the file **/ /** Initialize the block of zeros **/ if( block_of_00_initialized == FALSE ) { int i ; for( i=0; i DISK_BLOCK_SIZE ) { cglong_t t_bytes = total_bytes ; /** If the number of bytes to write is larger than the block of zeros we have, write out a series of zero blocks... **/ /** write out the remainder of this block **/ assert(current_location.offset <= 0x1fff); ADFI_write_file( file_index, current_location.block, current_location.offset, DISK_BLOCK_SIZE - current_location.offset + 1, block_of_00, error_return ) ; if( *error_return != NO_ERROR ) return ; current_location.block++ ; current_location.offset = 0 ; t_bytes -= (DISK_BLOCK_SIZE - current_location.offset + 1) ; /** Write blocks of zeros, then a partial block **/ while( t_bytes > 0 ) { assert(current_location.offset <= 0x1fff); ADFI_write_file( file_index, current_location.block, current_location.offset, MIN( DISK_BLOCK_SIZE, t_bytes), block_of_00, error_return ) ; if( *error_return != NO_ERROR ) return ; t_bytes -= (MIN( DISK_BLOCK_SIZE, t_bytes)) ; } /* end while */ } /* end if */ else { /** Write a partial block of zeros to disk **/ assert(current_location.offset <= 0x1fff); ADFI_write_file( file_index, current_location.block, current_location.offset, total_bytes, block_of_00, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end else */ } /* end if */ else { /** check for need of data translation **/ ADFI_file_and_machine_compare( file_index, tokenized_data_type, &format_compare, error_return ); if( *error_return != NO_ERROR ) return ; if( format_compare == 1 ) { /** Write the data to disk **/ assert(current_location.offset <= 0x1fff); ADFI_write_file( file_index, current_location.block, current_location.offset, total_bytes, data, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ else { ADFI_write_data_translated( file_index, current_location.block, current_location.offset, tokenized_data_type, data_size, total_bytes, data, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end else */ } /* end else */ /** Write the ending tag to disk **/ ADFI_write_file( file_index, end_of_chunk_tag.block, end_of_chunk_tag.offset, TAG_SIZE, data_chunk_end_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end of ADFI_write_data_chunk */ /* end of file ADFI_write_data_chunk.c */ /* file ADFI_write_data_chunk_table.c */ /*********************************************************************** ADFI write data chunk table: input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. input: const int number_of_data_chunks Number of entries to write. output: struct DATA_CHUNK_TABLE_ENTRY data_chunk_table[] Array of entries. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_write_data_chunk_table( const unsigned int file_index, const struct DISK_POINTER *block_offset, const int number_of_data_chunks, struct DATA_CHUNK_TABLE_ENTRY data_chunk_table[], int *error_return ) { struct DISK_POINTER disk_pointer, end_of_chunk_tag ; int i ; if( (block_offset == NULL) || (data_chunk_table == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Write Starting boundary tag **/ disk_pointer.block = block_offset->block ; disk_pointer.offset = block_offset->offset ; ADFI_write_file( file_index, disk_pointer.block, disk_pointer.offset, TAG_SIZE, data_chunk_table_start_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; disk_pointer.offset += TAG_SIZE ; ADFI_adjust_disk_pointer( &disk_pointer, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Calculate the end-of-chunk-tag location **/ end_of_chunk_tag.block = disk_pointer.block ; end_of_chunk_tag.offset = disk_pointer.offset + DISK_POINTER_SIZE + number_of_data_chunks * 2 * DISK_POINTER_SIZE ; ADFI_adjust_disk_pointer( &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_write_disk_pointer_2_disk( file_index, disk_pointer.block, disk_pointer.offset, &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Write data chunk table entries **/ disk_pointer.offset += DISK_POINTER_SIZE ; for( i=0; i number_of_data_elements ) { chunk_size -= (unsigned int)( number_of_elements_written - number_of_data_elements ) ; delta_to_bytes = chunk_size * data_size ; delta_from_bytes = chunk_size * machine_size ; } ADFI_convert_number_format( ADF_this_machine_format, /* from format */ ADF_this_machine_os_size, /* from os size */ ADF_file[file_index].format, /* to format */ ADF_file[file_index].os_size, /* to os size */ TO_FILE_FORMAT, tokenized_data_type, chunk_size, from_data, to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_write_file( file_index, disk_pointer.block, disk_pointer.offset, delta_to_bytes, (char *)to_data, error_return ) ; if( *error_return != NO_ERROR ) return ; from_data += delta_from_bytes ; disk_pointer.offset += delta_to_bytes ; if ( disk_pointer.offset > DISK_BLOCK_SIZE ) { ADFI_adjust_disk_pointer( &disk_pointer, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ } /* end while */ } /* end of ADFI_write_data_translated */ /* end of file ADFI_write_data_translated.c */ /* file ADFI_write_disk_block.c */ /*********************************************************************** ADFI write disk block: ***********************************************************************/ void ADFI_write_disk_block() { fprintf(stderr,"Subroutine ADFI_write_disk_block is not yet implemented...\n" ) ; } /* end of ADFI_write_disk_block */ /* end of file ADFI_write_disk_block.c */ /* file ADFI_write_disk_pointer_2_disk.c */ /*********************************************************************** ADFI write disk pointer 2 disk: Given a pointer to a disk pointer, convert it to ASCII Hex and write it to disk. input: const unsigned int file_index File to write to. input: const unsigned long file_block Block within the file. input: const unsigned long block_offset Offset within the block. input: const struct DISK_POINTER *block_and_offset Disk pointer. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_write_disk_pointer_2_disk( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, const struct DISK_POINTER *block_and_offset, int *error_return ) { char disk_block_offset[DISK_POINTER_SIZE] ; if( block_and_offset == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Convert into ASCII_Hex form **/ #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, block_and_offset, &disk_block_offset[0], &disk_block_offset[8], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( block_and_offset, &disk_block_offset[0], &disk_block_offset[8], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; /** Put the block/offset to disk **/ ADFI_write_file( file_index, file_block, block_offset, DISK_POINTER_SIZE, disk_block_offset, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Set the block/offset onto the stack **/ #if 0 ADFI_stack_control(file_index, file_block, (unsigned int)block_offset, SET_STK, DISK_PTR_STK, DISK_POINTER_SIZE, disk_block_offset ); #endif } /* end of ADFI_write_disk_pointer_2_disk */ /* end of file ADFI_write_disk_pointer_2_disk.c */ /***********************************************************************/ cglong_t ADFI_write ( const unsigned int file_index, const cglong_t data_length, const char *data) { char *data_ptr = (char *)data; cglong_t bytes_left = data_length; cglong_t bytes_out = 0; int nbytes, to_write; ADF_sys_err = 0; while (bytes_left > 0) { to_write = bytes_left > CG_MAX_INT32 ? CG_MAX_INT32 : (int)bytes_left; nbytes = (int) WRITE (ADF_file[file_index].file, data_ptr, to_write); if (-1 == nbytes) { if (EINTR != errno) { ADF_sys_err = errno; return -1; } } else { bytes_left -= nbytes; bytes_out += nbytes; data_ptr += nbytes; } } return bytes_out; } /* file ADFI_write_file.c */ /*********************************************************************** ADFI write file: Write a number of bytes to an ADF file, given the file, block, and block offset. input: const unsigned int file_index File to write to. input: const unsigned long file_block Block within the file. input: const unsigned long block_offset Offset within the block. input: const unsigned int data_length Length of the data to write. input: const char *data Address of the data. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER ADF_FILE_NOT_OPENED FWRITE_ERROR ***********************************************************************/ void ADFI_write_file( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, const cglong_t data_length, const char *data, int *error_return ) { cglong_t iret; cglong_t end_block; if( data == NULL ) { *error_return = NULL_STRING_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** If the read buffer overlaps the buffer then reset it to make sure its current **/ end_block = file_block+(block_offset+data_length)/DISK_BLOCK_SIZE+1; if ( last_rd_file == (int) file_index && last_rd_block >= (cglong_t) file_block && last_rd_block <= end_block ) { last_rd_block = -1; last_rd_file = -1; num_in_rd_block = -1 ; } /** Check to see if we need to flush the write buffer. this happens if we are writing a large chunk or the write moves out of the current block. If the data length is zero then just flush the buffer and return. Note that the ADF_modification_date routine will flush the buffer after any write operations !! **/ if( ( (cgulong_t) data_length + block_offset > DISK_BLOCK_SIZE || last_wr_block != (cglong_t) file_block || last_wr_file != (int) file_index || data_length == 0 ) && flush_wr_block > 0 ) { /** Position the file **/ ADFI_fseek_file( last_wr_file, last_wr_block, 0, error_return ) ; if( *error_return != NO_ERROR ) { return ; } /* end if */ /** write the buffer **/ iret= ADFI_write( last_wr_file, DISK_BLOCK_SIZE, wr_block_buffer ); flush_wr_block = -2 ; /** Make sure we don't flush twice due to error **/ if( iret != DISK_BLOCK_SIZE ) { *error_return = FWRITE_ERROR ; return ; } /* end if */ /** If the write buffer overlaps the buffer then reset it to make sure its current, set flush buffer flag to false. **/ if ( last_wr_file == (int) file_index && last_wr_block >= (cglong_t) file_block && last_wr_block <= (cglong_t) end_block ) { last_wr_block = -2; last_wr_file = -2; } } /* end if */ if ( data_length == 0 ) return; /** Just a buffer flush **/ /** No need to buffer large pieces of data or to take special measures to cross block boundaries **/ if( data_length + block_offset > DISK_BLOCK_SIZE ) { /** Position the file **/ ADFI_fseek_file( file_index, file_block, block_offset, error_return ) ; if( *error_return != NO_ERROR ) { return ; } /* end if */ /** write the data **/ iret = ADFI_write( file_index, data_length, data ) ; if( iret != data_length ) { *error_return = FWRITE_ERROR ; return ; } /* end if */ return; } /* end if */ /** For smaller pieces of data, write a block at a time. This will improve performance if neighboring data is written a small piece at a time (strided reads, file overhead). Some assumptions apply to the block size. With some experimenting, 1K blocks do not offer much improvement. 4K blocks (4096 bytes) do improve performance remarkably. This is due to the fact that the file structure is based of 4K blocks with offsets. Also the CRAY loves 4K block writes!! **/ if( (cglong_t) file_block != last_wr_block || /*- a different block -*/ (int) file_index != last_wr_file ) { /*- entirely different file -*/ /** buffer is not current, re-read **/ if ( (cglong_t) file_block == last_rd_block && (int) file_index == last_rd_file ) { /* Copy data from read buffer */ memcpy( wr_block_buffer, rd_block_buffer, DISK_BLOCK_SIZE ); iret = num_in_rd_block; } else { /** Position the file **/ ADFI_fseek_file( file_index, file_block, 0, error_return ) ; if( *error_return != NO_ERROR ) { return ; } /* end if */ /** Read the data from disk **/ iret = ADFI_read( file_index, DISK_BLOCK_SIZE, wr_block_buffer ) ; if( iret < DISK_BLOCK_SIZE ) { if ( iret < 0 ) iret = 0; memset( &wr_block_buffer[iret], (size_t) ' ', (size_t)(DISK_BLOCK_SIZE-iret) ); } /* end if */ } /* end if */ /** Remember buffer information **/ last_wr_block = file_block ; last_wr_file = (int)file_index ; } /* end if */ /** Write into the buffer and set flush buffer flag **/ memcpy( &wr_block_buffer[block_offset], data, (size_t)data_length ); flush_wr_block = 1 ; } /* end of ADFI_write_file */ /* end of file ADFI_write_file.c */ /* file ADFI_write_file_header.c */ /*********************************************************************** ADFI write file header: To take information in the FILE_HEADER structure and format it for disk, and write it out. input: const int file_index File index to write to. input: const FILE_HEADER *file_header The file header structure. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ADF_MEMORY_TAG_ERROR ADF_DISK_TAG_ERROR ***********************************************************************/ void ADFI_write_file_header( const int file_index, const struct FILE_HEADER *file_header, int *error_return ) { char disk_header[ FILE_HEADER_SIZE ] ; if( file_header == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check memory tags for proper data **/ if( strncmp( file_header->tag0, file_header_tags[0], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag1, file_header_tags[1], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag2, file_header_tags[2], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag3, file_header_tags[3], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag4, file_header_tags[4], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( file_header->tag5, file_header_tags[5], TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ /** OK the memory tags look good, let's format the file header information into the disk format and write it out. **/ strncpy( &disk_header[ 0], (char *)file_header->what, WHAT_STRING_SIZE ) ; strncpy( &disk_header[ 32], (char *)file_header->tag0, TAG_SIZE ) ; strncpy( &disk_header[ 36], (char *)file_header->creation_date, DATE_TIME_SIZE); strncpy( &disk_header[ 64], (char *)file_header->tag1, TAG_SIZE ) ; strncpy( &disk_header[ 68], (char *)file_header->modification_date, DATE_TIME_SIZE ) ; strncpy( &disk_header[ 96], (char *)file_header->tag2, TAG_SIZE ) ; disk_header[100] = file_header->numeric_format ; disk_header[101] = file_header->os_size ; strncpy( &disk_header[102], (char *)file_header->tag3, TAG_SIZE ) ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_char, 0, 255, 2, &disk_header[106], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_short, 0, 255, 2, &disk_header[108], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_int, 0, 255, 2, &disk_header[110], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_long, 0, 255, 2, &disk_header[112], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_float, 0, 255, 2, &disk_header[114], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_double, 0, 255, 2, &disk_header[116], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_char_p, 0, 255, 2, &disk_header[118], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_short_p, 0, 255, 2, &disk_header[120], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_int_p, 0, 255, 2, &disk_header[122], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_long_p, 0, 255, 2, &disk_header[124], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_float_p, 0, 255, 2, &disk_header[126], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( file_header->sizeof_double_p, 0, 255, 2, &disk_header[128], error_return ) ; if( *error_return != NO_ERROR ) return ; strncpy( &disk_header[130], file_header->tag4, TAG_SIZE ) ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &file_header->root_node, &disk_header[134], &disk_header[142], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &file_header->root_node, &disk_header[134], &disk_header[142], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &file_header->end_of_file, &disk_header[146], &disk_header[154], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &file_header->end_of_file, &disk_header[146], &disk_header[154], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &file_header->free_chunks, &disk_header[158], &disk_header[166], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &file_header->free_chunks, &disk_header[158], &disk_header[166], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &file_header->extra, &disk_header[170], &disk_header[178], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &file_header->extra, &disk_header[170], &disk_header[178], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; strncpy( &disk_header[182], file_header->tag5, TAG_SIZE ) ; /** Now write the disk header out... **/ ADFI_write_file( file_index, 0, 0, FILE_HEADER_SIZE, disk_header, error_return ) ; /** Set the header onto the stack **/ ADFI_stack_control(file_index, 0, 0, SET_STK, FILE_STK, FILE_HEADER_SIZE, disk_header ); } /* end of ADFI_write_file_header */ /* end of file ADFI_write_file_header.c */ /* file ADFI_write_free_chunk.c */ /*********************************************************************** ADFI write free chunk: input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. input: const struct FREE_CHUNK *free_chunk Pointer to free-chunk. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ADF_MEMORY_TAG_ERROR ***********************************************************************/ void ADFI_write_free_chunk( const int file_index, const struct DISK_POINTER *block_offset, const struct FREE_CHUNK *free_chunk, int *error_return ) { unsigned int i ; struct DISK_POINTER current_location ; if( (block_offset == NULL) || (free_chunk == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Initialize the block of 'X's **/ if( block_of_XX_initialized == FALSE ) { for( i=0; istart_tag, free_chunk_start_tag, TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( free_chunk->end_tag, free_chunk_end_tag, TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ /** Write start TAG **/ ADFI_write_file( file_index, block_offset->block, block_offset->offset, TAG_SIZE, free_chunk->start_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Write disk pointers **/ current_location.block = block_offset->block ; current_location.offset = block_offset->offset + TAG_SIZE ; ADFI_adjust_disk_pointer( ¤t_location, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_write_disk_pointer_2_disk( file_index, current_location.block, current_location.offset, &free_chunk->end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; current_location.offset += DISK_POINTER_SIZE ; ADFI_adjust_disk_pointer( ¤t_location, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_write_disk_pointer_2_disk( file_index, current_location.block, current_location.offset, &free_chunk->next_chunk, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Write out a bunch of 'x's in the free chunk's empty space **/ current_location.offset += DISK_POINTER_SIZE ; ADFI_adjust_disk_pointer( ¤t_location, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Fill in partial end of a block **/ if( (current_location.block != free_chunk->end_of_chunk_tag.block) && (current_location.offset != 0 ) ) { assert(current_location.offset < DISK_BLOCK_SIZE); ADFI_write_file( file_index, current_location.block, current_location.offset, DISK_BLOCK_SIZE - current_location.offset, block_of_XX, error_return ) ; if( *error_return != NO_ERROR ) return ; current_location.block++ ; current_location.offset = 0 ; } /* end if */ /** Fill in intermediate whole blocks **/ while( current_location.block < free_chunk->end_of_chunk_tag.block ) { ADFI_write_file( file_index, current_location.block, 0, DISK_BLOCK_SIZE, block_of_XX, error_return ) ; if( *error_return != NO_ERROR ) return ; current_location.block++ ; } /* end if */ /** Fill in partial block to end-of-free-chunk **/ if( current_location.offset < free_chunk->end_of_chunk_tag.offset ) { ADFI_write_file( file_index, current_location.block, current_location.offset, free_chunk->end_of_chunk_tag.offset - current_location.offset, block_of_XX, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end if */ /** Now (finally) write out the free_chunk-end_tag **/ ADFI_write_file( file_index, current_location.block, free_chunk->end_of_chunk_tag.offset, TAG_SIZE, free_chunk->end_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; } /* end of ADFI_write_free_chunk */ /* end of file ADFI_write_free_chunk.c */ /* file ADFI_write_free_chunk_table.c */ /*********************************************************************** ADFI write free chunk table: To take information in the FREE_CHUNK_TABLE structure and format it for disk, and write it out. input: const int file_index File index to write to. input: const FREE_CHUNK_TABLE *free_chunk_table The free_chunk header struct. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ADF_MEMORY_TAG_ERROR ***********************************************************************/ void ADFI_write_free_chunk_table( const int file_index, const struct FREE_CHUNK_TABLE *free_chunk_table, int *error_return ) { char disk_free_chunk_data[ FREE_CHUNK_TABLE_SIZE ] ; if( free_chunk_table == NULL ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check memory tags for proper data **/ if( strncmp( free_chunk_table->start_tag, free_chunk_table_start_tag, TAG_SIZE ) != 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( free_chunk_table->end_tag, free_chunk_table_end_tag, TAG_SIZE ) != 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ /** OK the memory tags look good, let's format the free_chunk header information into the disk format and write it out. **/ strncpy( &disk_free_chunk_data[ 0], (char *)free_chunk_table->start_tag, TAG_SIZE ) ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &free_chunk_table->small_first_block, &disk_free_chunk_data[TAG_SIZE], &disk_free_chunk_data[DISK_POINTER_SIZE], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &free_chunk_table->small_first_block, &disk_free_chunk_data[TAG_SIZE], &disk_free_chunk_data[DISK_POINTER_SIZE], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &free_chunk_table->small_last_block, &disk_free_chunk_data[16], &disk_free_chunk_data[24], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &free_chunk_table->small_last_block, &disk_free_chunk_data[16], &disk_free_chunk_data[24], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &free_chunk_table->medium_first_block, &disk_free_chunk_data[28], &disk_free_chunk_data[36], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &free_chunk_table->medium_first_block, &disk_free_chunk_data[28], &disk_free_chunk_data[36], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &free_chunk_table->medium_last_block, &disk_free_chunk_data[40], &disk_free_chunk_data[48], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &free_chunk_table->medium_last_block, &disk_free_chunk_data[40], &disk_free_chunk_data[48], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &free_chunk_table->large_first_block, &disk_free_chunk_data[52], &disk_free_chunk_data[60], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &free_chunk_table->large_first_block, &disk_free_chunk_data[52], &disk_free_chunk_data[60], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &free_chunk_table->large_last_block, &disk_free_chunk_data[64], &disk_free_chunk_data[72], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &free_chunk_table->large_last_block, &disk_free_chunk_data[64], &disk_free_chunk_data[72], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; strncpy( &disk_free_chunk_data[ 76], (char *)free_chunk_table->end_tag, TAG_SIZE ) ; /** Now write the free_chunk header out to disk... **/ ADFI_write_file( file_index, FREE_CHUNKS_BLOCK, FREE_CHUNKS_OFFSET, FREE_CHUNK_TABLE_SIZE, disk_free_chunk_data, error_return ) ; /** Set the free chunk onto the stack **/ ADFI_stack_control(file_index, FREE_CHUNKS_BLOCK, FREE_CHUNKS_OFFSET, SET_STK, FREE_CHUNK_STK, FREE_CHUNK_TABLE_SIZE, disk_free_chunk_data ); } /* end of ADFI_write_free_chunk_table */ /* end of file ADFI_write_free_chunk_table.c */ /* file ADFI_write_modification_date.c */ /*********************************************************************** ADFI write modification date: Writes the current date/time into the modification date field of the file header. Also updates the file version (what string) in the header if the file version global variable has been set - after writing, file version global variable is unset so that it is only written once. input: const int file_index File index to write to. output: int *error_return Error return. Possible errors: NO_ERROR NULL_STRING_POINTER ADF_FILE_NOT_OPENED FWRITE_ERROR ***********************************************************************/ void ADFI_write_modification_date( const int file_index, int *error_return ) { int i_block_offset ; char mod_date[DATE_TIME_SIZE] ; *error_return = NO_ERROR ; ADFI_get_current_date( mod_date ) ; /** block offset depends on the location the of modification date in the FILE_HEADER structure **/ i_block_offset = WHAT_STRING_SIZE + TAG_SIZE + DATE_TIME_SIZE + TAG_SIZE ; ADFI_write_file( file_index, 0, i_block_offset, DATE_TIME_SIZE, mod_date, error_return ) ; if( *error_return != NO_ERROR ) { return; } /* end if */ /** Flush the write buffer to ensure the file is current!! **/ ADFI_flush_buffers( file_index, FLUSH, error_return ); if( *error_return != NO_ERROR ) { return; } /* end if */ if( ADF_file[file_index].version_update[0] != '\0' ) { i_block_offset = 0 ; /* what-string is first field in header */ ADFI_write_file( file_index, 0, i_block_offset, WHAT_STRING_SIZE, ADF_file[file_index].version_update, error_return ) ; /** reset the version to default so that it only gets updated once **/ ADF_file[file_index].version_update[0] = '\0' ; if( *error_return != NO_ERROR ) { return; } /* end if */ } /* end if */ } /* end of ADFI_write_modification_date */ /* end of file ADFI_write_modification_date.c */ /* file ADFI_write_node_header.c */ /*********************************************************************** ADFI write node header: To take information in the NODE_HEADER structure and format it for disk, and write it out. input: const int file_index File index to write to. input: const struct DISK_POINTER *block_offset Block & offset in the file. input: const NODE_HEADER *node_header The node header structure. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ADF_MEMORY_TAG_ERROR ***********************************************************************/ void ADFI_write_node_header( const int file_index, const struct DISK_POINTER *block_offset, const struct NODE_HEADER *node_header, int *error_return ) { int i ; char disk_node_data[ NODE_HEADER_SIZE ] ; if( (block_offset == NULL) || (node_header == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Check memory tags for proper data **/ if( strncmp( node_header->node_start_tag, node_start_tag, TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ if( strncmp( node_header->node_end_tag, node_end_tag, TAG_SIZE )!= 0 ) { *error_return = ADF_MEMORY_TAG_ERROR ; return ; } /* end if */ /** OK the memory tags look good, let's format the node header information into the disk format and write it out. **/ strncpy( &disk_node_data[ 0], (char *)node_header->node_start_tag, TAG_SIZE ) ; strncpy( &disk_node_data[ TAG_SIZE], (char *)node_header->name, ADF_NAME_LENGTH ); strncpy( &disk_node_data[ 36], (char *)node_header->label, ADF_LABEL_LENGTH ) ; ADFI_unsigned_int_2_ASCII_Hex( node_header->num_sub_nodes, 0, MAXIMUM_32_BITS, 8, &disk_node_data[ 68], error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_unsigned_int_2_ASCII_Hex( node_header->entries_for_sub_nodes, 0, MAXIMUM_32_BITS, 8, &disk_node_data[ 76], error_return ) ; if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer(file_index, &node_header->sub_node_table, &disk_node_data[84], &disk_node_data[92], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &node_header->sub_node_table, &disk_node_data[84], &disk_node_data[92], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; strncpy( &disk_node_data[ 96], (char *)node_header->data_type, ADF_DATA_TYPE_LENGTH ) ; ADFI_unsigned_int_2_ASCII_Hex( node_header->number_of_dimensions, 0, 12, 2, &disk_node_data[128], error_return ) ; if( *error_return != NO_ERROR ) return ; if (ADF_file[file_index].old_version) { for( i=0; idimension_values[i] > MAXIMUM_32_BITS) { *error_return = NUMBER_GREATER_THAN_MAXIMUM ; } else { ADFI_unsigned_int_2_ASCII_Hex( (unsigned int)node_header->dimension_values[i], 0, MAXIMUM_32_BITS, 8, &disk_node_data[130+(i*8)], error_return ) ; } if( *error_return != NO_ERROR ) return ; } /* end for */ } else { ADFI_convert_integers(8, 12, ADF_this_machine_format, ADF_file[file_index].format, (char *)node_header->dimension_values, &disk_node_data[130], error_return); if( *error_return != NO_ERROR ) return ; } ADFI_unsigned_int_2_ASCII_Hex( node_header->number_of_data_chunks, 0, 65535, 4, &disk_node_data[226], error_return ) ; if( *error_return != NO_ERROR ) return ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer(file_index, &node_header->data_chunks, &disk_node_data[230], &disk_node_data[238], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &node_header->data_chunks, &disk_node_data[230], &disk_node_data[238], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; strncpy( &disk_node_data[242], (char *)node_header->node_end_tag, TAG_SIZE ) ; /** Now write the node-header out to disk... **/ ADFI_write_file( file_index, block_offset->block, block_offset->offset, NODE_HEADER_SIZE, disk_node_data, error_return ) ; /** Set the header onto the stack **/ ADFI_stack_control(file_index, block_offset->block, (unsigned int)block_offset->offset, SET_STK, NODE_STK, NODE_HEADER_SIZE, disk_node_data ); } /* end of ADFI_write_node_header */ /* end of file ADFI_write_node_header.c */ /* file ADFI_write_sub_node_table.c */ /*********************************************************************** ADFI write sub node table: input: const unsigned int file_index The file index. input: const struct DISK_POINTER *block_offset Block & offset in the file. input: const int number_of_sub_nodes Number of sub-node entries. input: struct SUB_NODE_TABLE_ENTRY sub_node_table[] Array of sub-node entries. output: int *error_return Error return. Possible errors: NO_ERROR NULL_POINTER ADF_FILE_NOT_OPENED ***********************************************************************/ void ADFI_write_sub_node_table( const unsigned int file_index, const struct DISK_POINTER *block_offset, const int number_of_sub_nodes, struct SUB_NODE_TABLE_ENTRY sub_node_table[], int *error_return ) { int i ; struct DISK_POINTER end_of_chunk_tag, current_child ; if( (block_offset == NULL) || (sub_node_table == NULL) ) { *error_return = NULL_POINTER ; return ; } /* end if */ if( (int)file_index >= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** calculate the end-of-chunk tag pointer **/ end_of_chunk_tag.block = block_offset->block ; end_of_chunk_tag.offset = block_offset->offset + TAG_SIZE + DISK_POINTER_SIZE + number_of_sub_nodes * (ADF_NAME_LENGTH + DISK_POINTER_SIZE) ; ADFI_adjust_disk_pointer( &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Write start TAG **/ ADFI_write_file( file_index, block_offset->block, block_offset->offset, TAG_SIZE, sub_node_start_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Write disk pointer **/ current_child.block = block_offset->block ; current_child.offset = block_offset->offset + TAG_SIZE ; ADFI_adjust_disk_pointer( ¤t_child, error_return ) ; if( *error_return != NO_ERROR ) return ; ADFI_write_disk_pointer_2_disk( file_index, current_child.block, current_child.offset, &end_of_chunk_tag, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Format and write out the table entries **/ current_child.offset += DISK_POINTER_SIZE ; for( i=0; i= maximum_files || ADF_file[file_index].in_use == 0 ) { *error_return = ADF_FILE_NOT_OPENED ; return ; } /* end if */ *error_return = NO_ERROR ; /** Format the tag and disk pointer in memory **/ strncpy( &sub_node_entry_disk_data[0], sub_node_table_entry->child_name, ADF_NAME_LENGTH ) ; #ifdef NEW_DISK_POINTER ADFI_write_disk_pointer( file_index, &sub_node_table_entry->child_location, &sub_node_entry_disk_data[ ADF_NAME_LENGTH ], &sub_node_entry_disk_data[ ADF_NAME_LENGTH + 8 ], error_return ) ; #else ADFI_disk_pointer_2_ASCII_Hex( &sub_node_table_entry->child_location, &sub_node_entry_disk_data[ ADF_NAME_LENGTH ], &sub_node_entry_disk_data[ ADF_NAME_LENGTH + 8 ], error_return ) ; #endif if( *error_return != NO_ERROR ) return ; /** Now write it out to disk **/ ADFI_write_file( file_index, block_offset->block, block_offset->offset, ADF_NAME_LENGTH + DISK_POINTER_SIZE, sub_node_entry_disk_data, error_return ) ; if( *error_return != NO_ERROR ) return ; /** Set the subnode onto the stack **/ ADFI_stack_control(file_index, block_offset->block, (unsigned int)block_offset->offset, SET_STK, SUBNODE_STK, ADF_NAME_LENGTH + DISK_POINTER_SIZE, sub_node_entry_disk_data ); } /* end of ADFI_write_sub_node_table_entry */ /* end of file ADFI_write_sub_node_table_entry.c */ /* file ADFI_strtok.c */ /*********************************************************************** ADFI get string token: This routine simulates strtok except it returns the current position in the string tobe used later. Thas avoids the problem of trying using strtok in a recursive subroutine call which does not work! input/output: *string - the string to parse tokens from. returns string with token replaced by nil. input/output: *string_pos - the string position to begin parsing should be placed at the beginning of the string. returns position after last token to continue string parsing. Token may change from last call. input: *token - The token to search for. function return: - a pointer to the desired substring. A NULL returns indicates the end of the string. ***********************************************************************/ char *ADFI_strtok( char *string, char **string_pos, char *token ) { char *tmp_ptr ; char *sub_string ; int string_len ; if ( string_pos == NULL ) return NULL ; if( token == NULL || string == NULL || *string_pos == NULL ) return NULL ; /* Get the length left in the string */ string_len = (int)strlen ( *string_pos ) ; if ( string_len == 0 ) return NULL ; /* Find the first character in the string which does not match the token */ tmp_ptr = *string_pos ; while ( string_len > 0 ) { if ( tmp_ptr[0] == token[0] ) { tmp_ptr++ ; string_len-- ; } else { break ; } /* end if */ } /* end while */ if ( string_len == 0 ) return NULL ; /* Set the beginning of the sub string */ sub_string = tmp_ptr ; /* Find the next token or the end of the string */ while ( string_len > 0 ) { if ( tmp_ptr[0] != token[0] ) { tmp_ptr++ ; string_len-- ; } else { tmp_ptr[0] = '\0' ; break ; } /* end if */ } /* end while */ /* Set location for the next search */ if ( string_len > 0 ) *string_pos = &tmp_ptr[1] ; else *string_pos = NULL ; return sub_string ; } /* end of ADFI_strtok */ /* end of file ADFI_strtok.c */ /* end of combine 2.0 */ CGNS-4.5.0/src/adf/ADF_internals.h000066400000000000000000001023671474000356600164330ustar00rootroot00000000000000/** File: ADF_internals.h ---------------------------------------------------------------------- BOEING ---------------------------------------------------------------------- Project: CGNS Author: Tom Dickens 865-6122 tpd6908@yak.ca.boeing.com Date: 3/2/1995 Purpose: Provide declarations for the internal ADF-Core routines. ---------------------------------------------------------------------- ---------------------------------------------------------------------- **/ #ifndef ADF_INTERNALS_INCLUDE #define ADF_INTERNALS_INCLUDE #include "ADF.h" #include /* needed for toupper */ #define NEW_ID_MAPPING #define NEW_DISK_POINTER /*********************************************************************** Defines ***********************************************************************/ /* the length of items in a sub_node_list is a multiple of LIST_CHUNK */ #define LIST_CHUNK 8 #define LIST_CHUNK_GROW_FACTOR 1.5 /** File parameters **/ #ifndef DISK_BLOCK_SIZE #define DISK_BLOCK_SIZE 4096 #endif #ifdef NEW_ID_MAPPING # define MAXIMUM_FILES 0xfff #else # define MAXIMUM_FILES 0x3fff #endif #define MAXIMUM_32_BITS (4294967295U) #define BLANK_FILE_BLOCK 0 #define BLANK_BLOCK_OFFSET DISK_BLOCK_SIZE /** Sizes of things on disk **/ #define FILE_HEADER_SIZE 186 #define FREE_CHUNK_TABLE_SIZE 80 #define FREE_CHUNK_ENTRY_SIZE 32 #define NODE_HEADER_SIZE 246 #define DISK_POINTER_SIZE 12 #define TAG_SIZE 4 #define WHAT_STRING_SIZE 32 #define DATE_TIME_SIZE 28 /* smallest amount of data (chunk) to be allocated. Minimum size corresponds to the free-chunk minimum size for the free-chunk linked lists. */ #define SMALLEST_CHUNK_SIZE NODE_HEADER_SIZE #define SMALL_CHUNK_MAXIMUM 1024 #define MEDIUM_CHUNK_MAXIMUM DISK_BLOCK_SIZE #define FREE_CHUNKS_BLOCK 0 #define FREE_CHUNKS_OFFSET FILE_HEADER_SIZE #define ROOT_NODE_BLOCK 0 #define ROOT_NODE_OFFSET (FREE_CHUNKS_OFFSET + FREE_CHUNK_TABLE_SIZE) #define ROOT_NODE_NAME "ADF MotherNode" #define ROOT_NODE_LABEL "Root Node of ADF File" /** Machine formats **/ #define UNDEFINED_FORMAT 0 #define IEEE_BIG_32_FORMAT 1 #define IEEE_LITTLE_32_FORMAT 2 #define IEEE_BIG_64_FORMAT 3 #define IEEE_LITTLE_64_FORMAT 4 #define CRAY_FORMAT 5 #define NATIVE_FORMAT 99 #define UNDEFINED_FORMAT_CHAR 'U' #define IEEE_BIG_FORMAT_CHAR 'B' #define IEEE_LITTLE_FORMAT_CHAR 'L' #define CRAY_FORMAT_CHAR 'C' #define NATIVE_FORMAT_CHAR 'N' #define OS_64_BIT 'B' #define OS_32_BIT 'L' #define IEEE_BIG_32_FORMAT_STRING "IEEE_BIG_32" #define IEEE_LITTLE_32_FORMAT_STRING "IEEE_LITTLE_32" #define IEEE_BIG_64_FORMAT_STRING "IEEE_BIG_64" #define IEEE_LITTLE_64_FORMAT_STRING "IEEE_LITTLE_64" #define CRAY_FORMAT_STRING "CRAY" #define NATIVE_FORMAT_STRING "NATIVE" #define LEGACY_FORMAT_STRING "LEGACY" #ifndef FALSE #define FALSE (0) #endif #ifndef TRUE #define TRUE (-1) #endif /*********************************************************************** Defined Marcos ***********************************************************************/ /** Upper case a character **/ /** Need to use the system macros for the Cray optimizer **/ #define TO_UPPER( c ) ((islower(c))?(toupper(c)):(c)) #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) /*********************************************************************** Structures: ***********************************************************************/ /** A DISK_POINTER tracks the block number (from 0) and the offset within a block. **/ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ struct DISK_POINTER { cgulong_t block ; /* 0 to 4,294,967,295 (8 ASCII-Hex bytes) */ cgulong_t offset ; /* 0 to 4096 (4 ASCII-Hex bytes) */ } ; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ struct FILE_HEADER { char what [WHAT_STRING_SIZE] ; char tag0 [TAG_SIZE] ; char creation_date [DATE_TIME_SIZE] ; char tag1 [TAG_SIZE] ; char modification_date [DATE_TIME_SIZE] ; char tag2 [TAG_SIZE] ; char numeric_format ; char os_size ; char tag3 [TAG_SIZE] ; unsigned int sizeof_char ; unsigned int sizeof_short ; unsigned int sizeof_int ; unsigned int sizeof_long ; unsigned int sizeof_float ; unsigned int sizeof_double ; unsigned int sizeof_char_p ; unsigned int sizeof_short_p ; unsigned int sizeof_int_p ; unsigned int sizeof_long_p ; unsigned int sizeof_float_p ; unsigned int sizeof_double_p ; char tag4 [TAG_SIZE] ; struct DISK_POINTER root_node ; struct DISK_POINTER end_of_file ; struct DISK_POINTER free_chunks ; struct DISK_POINTER extra ; char tag5 [TAG_SIZE] ; } ; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ struct FREE_CHUNK_TABLE { char start_tag [TAG_SIZE] ; struct DISK_POINTER small_first_block ; struct DISK_POINTER small_last_block ; struct DISK_POINTER medium_first_block ; struct DISK_POINTER medium_last_block ; struct DISK_POINTER large_first_block ; struct DISK_POINTER large_last_block ; char end_tag [TAG_SIZE] ; } ; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ struct FREE_CHUNK { char start_tag [TAG_SIZE] ; struct DISK_POINTER end_of_chunk_tag ; struct DISK_POINTER next_chunk ; char end_tag [TAG_SIZE] ; } ; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ struct NODE_HEADER { char node_start_tag [TAG_SIZE] ; char name [ADF_NAME_LENGTH] ; char label [ADF_LABEL_LENGTH] ; unsigned int num_sub_nodes ; unsigned int entries_for_sub_nodes ; struct DISK_POINTER sub_node_table ; char data_type [ADF_DATA_TYPE_LENGTH] ; unsigned int number_of_dimensions ; cgulong_t dimension_values [ADF_MAX_DIMENSIONS] ; unsigned int number_of_data_chunks ; struct DISK_POINTER data_chunks ; char node_end_tag [TAG_SIZE] ; } ; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ struct DATA_CHUNK_TABLE_ENTRY { struct DISK_POINTER start ; struct DISK_POINTER end ; } ; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ struct SUB_NODE_TABLE_ENTRY { char child_name[ ADF_NAME_LENGTH ] ; struct DISK_POINTER child_location ; } ; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ struct TOKENIZED_DATA_TYPE { char type[2] ; int file_type_size ; int machine_type_size ; unsigned int length ; } ; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /*********************************************************************** Data structures for open ADF files in_use: number of times this file has been 'opened' nlinks : number of linked files opened by this file links : the list of linked files opened file_name : name of the open file open_mode: The mode the file was opened in. version_update: If library file version is greater than file version, library file version (what-string) is temporarily stored in this array to update to the file. The file only needs its version updated once while open, so don't expect the version to persist until file closing. Otherwise, the first byte in the string is null ('\0'). format : format of the file os_size : operating system size link_separator : separator character for links file: The system-returned file descriptor of an opened file. ***********************************************************************/ typedef struct { int in_use; int nlinks; unsigned int *links; char *file_name; char open_mode[10]; char version_update[WHAT_STRING_SIZE+1]; char format; char os_size; char link_separator; char old_version; int file; } ADF_FILE; extern ADF_FILE *ADF_file; extern int maximum_files; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /*********************************************************************** Prototypes for Internal CORE Utility Routines ***********************************************************************/ #if defined (__cplusplus) extern "C" { #endif extern void ADFI_Abort( const int error_code ) ; extern void ADFI_ASCII_Hex_2_unsigned_int( const unsigned int minimum, const unsigned int maximum, const unsigned int string_length, const char string[], unsigned int *number, int *error_return ) ; extern void ADFI_add_2_sub_node_table( const int file_index, const struct DISK_POINTER *parent, const struct DISK_POINTER *child, int *error_return ) ; extern void ADFI_adjust_disk_pointer( struct DISK_POINTER *block_offset, int *error_return ) ; extern void ADFI_big_endian_to_cray( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ); extern void ADFI_big_little_endian_swap( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ); extern void ADFI_big_endian_32_swap_64( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ); extern void ADFI_blank_fill_string( char *str, const int length ) ; extern void ADFI_chase_link( const double ID, double *LID, unsigned int *file_index, struct DISK_POINTER *block_offset, struct NODE_HEADER *node_header, int *error_return ) ; extern void ADFI_check_4_child_name( const int file_index, const struct DISK_POINTER *parent, const char *name, int *found, struct DISK_POINTER *sub_node_entry_location, struct SUB_NODE_TABLE_ENTRY *sub_node_entry, int *error_return ) ; extern void ADFI_check_string_length( const char *str, const int max_length, int *error_return ) ; extern void ADFI_close_file( const int top_file_index, int *error_return ) ; extern void ADFI_compare_node_names( const char *name, const char *new_name, int *names_match, int *error_return ) ; extern void ADFI_convert_number_format( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const int convert_dir, const struct TOKENIZED_DATA_TYPE *tokenized_data_type, const unsigned int length, unsigned char *from_data, unsigned char *to_data, int *error_return ) ; extern void ADFI_count_total_array_points( const unsigned int ndim, const cgulong_t dims[], const cgsize_t dim_start[], const cgsize_t dim_end[], const cgsize_t dim_stride[], cgulong_t *total_points, cgulong_t *starting_offset, int *error_return ) ; extern void ADFI_cray_to_big_endian( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ); extern void ADFI_cray_to_little_endian( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ); extern void ADFI_delete_data( const int file_index, const struct NODE_HEADER *node_header, int *error_return ) ; extern void ADFI_delete_from_sub_node_table( const int file_index, const struct DISK_POINTER *parent, const struct DISK_POINTER *child, int *error_return ) ; extern void ADFI_delete_sub_node_table( const int file_index, const struct DISK_POINTER *block_offset, const unsigned int size_sub_node_table, int *error_return ) ; extern void ADFI_disk_pointer_2_ASCII_Hex( const struct DISK_POINTER *block_offset, char block[8], char offset[4], int *error_return ) ; extern void ADFI_disk_pointer_from_ASCII_Hex( const char block[8], const char offset[4], struct DISK_POINTER *block_offset, int *error_return ) ; extern void ADFI_evaluate_datatype( const int file_index, const char data_type[], int *bytes_file, int *bytes_machine, struct TOKENIZED_DATA_TYPE *tokenized_data_type, char *file_format, char *machine_format, int *error_return ) ; extern void ADFI_figure_machine_format( const char *format, char *machine_format, char *format_to_use, char *os_to_use, int *error_return ) ; extern void ADFI_file_and_machine_compare( const int file_index, const struct TOKENIZED_DATA_TYPE *tokenized_data_type, int *compare, int *error_return ) ; extern void ADFI_file_block_offset_2_ID( const int file_index, const cgulong_t file_block, const cgulong_t block_offset, double *ID, int *error_return ) ; extern void ADFI_file_free( const int file_index, const struct DISK_POINTER *block_offset, const cglong_t number_of_bytes, int *error_return ) ; extern void ADFI_file_malloc( const int file_index, const cglong_t size_bytes, struct DISK_POINTER *block_offset, int *error_return ) ; extern void ADFI_fill_initial_file_header( const char format, const char os_size, const char *what_string, struct FILE_HEADER *file_header, int *error_return ) ; extern void ADFI_fill_initial_free_chunk_table( struct FREE_CHUNK_TABLE *free_chunk_table, int *error_return ) ; extern void ADFI_fill_initial_node_header( struct NODE_HEADER *node_header, int *error_return ) ; extern void ADFI_fseek_file( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, int *error_return ) ; extern void ADFI_get_current_date( char date[] ) ; extern void ADFI_get_direct_children_ids( const unsigned int file_index, const struct DISK_POINTER *node_block_offset, int *num_ids, double **ids, int *error_return ) ; extern void ADFI_get_file_index_from_name( const char *file_name, int *found, unsigned int *file_index, double *ID, int *error_return ) ; extern void ADFI_ID_2_file_block_offset( const double ID, unsigned int *file_index, cgulong_t *file_block, cgulong_t *block_offset, int *error_return ) ; extern void ADFI_increment_array( const unsigned int ndim, const cgulong_t dims[], const cgsize_t dim_start[], const cgsize_t dim_end[], const cgsize_t dim_stride[], cglong_t current_position[], cgulong_t *element_offset, int *error_return ) ; extern void ADFI_is_block_in_core(void) ; extern void ADFI_little_endian_to_cray( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ); extern void ADFI_little_endian_32_swap_64( const char from_format, const char from_os_size, const char to_format, const char to_os_size, const char data_type[2], const cgulong_t delta_from_bytes, const cgulong_t delta_to_bytes, const unsigned char *from_data, unsigned char *to_data, int *error_return ); extern void ADFI_open_file( const char *file, const char *status, unsigned int *file_index, int *error_return ) ; extern void ADFI_read_chunk_length( const unsigned int file_index, const struct DISK_POINTER *block_offset, char tag[4], struct DISK_POINTER *end_of_chunk_tag, int *error_return ) ; extern void ADFI_read_data_chunk( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct TOKENIZED_DATA_TYPE *tokenized_data_type, const int data_size, const cglong_t chunk_bytes, const cglong_t start_offset, const cglong_t total_bytes, char *data, int *error_return ) ; extern void ADFI_read_data_chunk_table( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct DATA_CHUNK_TABLE_ENTRY data_chunk_table[], int *error_return ) ; extern void ADFI_read_data_translated( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, const struct TOKENIZED_DATA_TYPE *tokenized_data_type, const int data_size, const cglong_t total_bytes, char *data, int *error_return ) ; extern void ADFI_read_disk_block(void) ; extern void ADFI_read_disk_pointer_from_disk( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, struct DISK_POINTER *block_and_offset, int *error_return ) ; extern void ADFI_read_file( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, const cglong_t data_length, char *data, int *error_return ) ; extern void ADFI_read_file_header( const unsigned int file_index, struct FILE_HEADER *file_header, int *error_return ) ; extern void ADFI_read_free_chunk( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct FREE_CHUNK *free_chunk, int *error_return ) ; extern void ADFI_read_free_chunk_table( const unsigned int file_index, struct FREE_CHUNK_TABLE *free_chunk_table, int *error_return ) ; extern void ADFI_read_node_header( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct NODE_HEADER *node_header, int *error_return ) ; extern void ADFI_read_sub_node_table( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct SUB_NODE_TABLE_ENTRY sub_node_table[], int *error_return ) ; extern void ADFI_read_sub_node_table_entry( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct SUB_NODE_TABLE_ENTRY *sub_node_table_entry, int *error_return ) ; extern void ADFI_remember_file_format( const int file_index, const char numeric_format, const char os_size, int *error_return ) ; extern void ADFI_remember_version_update( const int file_index, const char *what_string, int *error_return ) ; extern void ADFI_set_blank_disk_pointer( struct DISK_POINTER *block_offset) ; extern int ADFI_stridx_c( const char *str1, const char *str2 ) ; extern void ADFI_string_2_C_string( const char *string, const int string_length, char *c_string, int *error_return ) ; extern char *ADFI_strtok( char *string, char **string_pos, char *token ) ; extern void ADFI_unsigned_int_2_ASCII_Hex( const unsigned int number, const unsigned int minimum, const unsigned int maximum, const unsigned int string_length, char string[], int *error_return ) ; extern void ADFI_write_data_chunk( const unsigned int file_index, const struct DISK_POINTER *block_offset, const struct TOKENIZED_DATA_TYPE *tokenized_data_type, const int data_size, const cglong_t chunk_bytes, const cglong_t start_offset, const cglong_t total_bytes, const char *data, int *error_return ) ; extern void ADFI_write_data_chunk_table( const unsigned int file_index, const struct DISK_POINTER *block_offset, const int number_of_data_chunks, struct DATA_CHUNK_TABLE_ENTRY data_chunk_table[], int *error_return ) ; extern void ADFI_write_data_translated( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, const struct TOKENIZED_DATA_TYPE *tokenized_data_type, const int data_size, const cglong_t total_bytes, const char *data, int *error_return ) ; extern void ADFI_write_disk_block(void) ; extern void ADFI_write_disk_pointer_2_disk( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, const struct DISK_POINTER *block_and_offset, int *error_return ) ; extern void ADFI_write_file( const unsigned int file_index, const cgulong_t file_block, const cgulong_t block_offset, const cglong_t data_length, const char *data, int *error_return ) ; extern void ADFI_write_file_header( const int file_index, const struct FILE_HEADER *file_header, int *error_return ) ; extern void ADFI_write_free_chunk( const int file_index, const struct DISK_POINTER *block_offset, const struct FREE_CHUNK *free_chunk, int *error_return ) ; extern void ADFI_write_free_chunk_table( const int file_index, const struct FREE_CHUNK_TABLE *free_chunk_table, int *error_return ) ; extern void ADFI_write_modification_date( const int file_index, int *error_return ) ; extern void ADFI_write_node_header( const int file_index, const struct DISK_POINTER *block_offset, const struct NODE_HEADER *node_header, int *error_return ) ; extern void ADFI_write_sub_node_table( const unsigned int file_index, const struct DISK_POINTER *block_offset, const int number_of_sub_nodes, struct SUB_NODE_TABLE_ENTRY sub_node_table[], int *error_return ) ; extern void ADFI_write_sub_node_table_entry( const unsigned int file_index, const struct DISK_POINTER *block_offset, struct SUB_NODE_TABLE_ENTRY *sub_node_table_entry, int *error_return ) ; extern void ADFI_flush_buffers( const unsigned int file_index, int flush_mode, int *error_return ) ; extern void ADFI_fflush_file( const unsigned int file_index, int *error_return ) ; extern int ADFI_stack_control( const unsigned int file_index, const cgulong_t file_block, const unsigned int block_offset, const int stack_mode, const int stack_type, const unsigned int data_length, char *stack_data ) ; /*********************************************************************** Prototypes for the FORTRAN to C Interface Routines ***********************************************************************/ #include "ADF_fbind.h" extern void FNAME(adfcna2,ADFCNA2)( const Fdouble *PID, const Fint *istart, const Fint *imaxnum, const Fint *idim, const Fint *name_length, Fint *inum_ret, Fchar names, Fint *error_return ) ; extern void FNAME(adfcid2,ADFCID2)( const Fdouble *PID, const Fint *istart, const Fint *imaxnum, Fint *inum_ret, Fdouble *cIDs, Fint *error_return ) ; extern void FNAME(adfcre2,ADFCRE2)( const Fdouble *PID, const Fchar name, const Fint *name_length, Fdouble *ID, Fint *error_return ) ; extern void FNAME(adfdcl2,ADFDCL2)( const Fdouble *Root_ID, Fint *error_return ) ; extern void FNAME(adfdde2,ADFDDE2)( const Fchar filename, const Fint *name_length, Fint *error_return ) ; extern void FNAME(adfdgc2,ADFDGC2)( const Fdouble *ID, Fint *error_return ) ; extern void FNAME(adfdgf2,ADFDGF2)( const Fdouble *Root_ID, Fchar format, const Fint *format_length, Fint *error_return ) ; extern void FNAME(adfdop2,ADFDOP2)( const Fchar filename, const Fint *filename_length, Fchar status_in, const Fint *status_length, const Fchar format, const Fint *format_length, Fdouble *Root_ID, Fint *error_return ) ; extern void FNAME(adfdsf2,ADFDSF2)( const Fdouble *Root_ID, const Fchar format, const Fint *format_length, Fint *error_return ) ; extern void FNAME(adfdve2,ADFDVE2)( const Fdouble *Root_ID, Fchar version, Fchar creation_date, Fchar modification_date, const Fint *v_length, const Fint *c_length, const Fint *m_length, Fint *error_return ) ; extern void FNAME(adfdel2,ADFDEL2)( const Fdouble *PID, const Fdouble *ID, Fint *error_return ) ; extern void FNAME(adferr2,ADFERR2)( const Fint *error_return_input, Fchar error_string, const Fint *str_length ) ; extern void FNAME(adfftd2,ADFFTD2)( const Fdouble *ID, Fint *error_return ) ; extern void FNAME(adfgdt2,ADFGDT2)( const Fdouble *ID, Fchar data_type, const Fint *data_type_length, Fint *error_return ) ; extern void FNAME(adfgdv2,ADFGDV2)( const Fdouble *ID, Fint dim_vals[], Fint *error_return ) ; extern void FNAME(adfges2,ADFGES2)( Fint *error_state, Fint *error_return ) ; extern void FNAME(adfglb2,ADFGLB2)( const Fdouble *ID, Fchar label, const Fint *label_length, Fint *error_return ) ; extern void FNAME(adfglk2,ADFGLK2)( const Fdouble *ID, Fchar filename, const Fint *filename_length, Fchar link_path, const Fint *link_path_length, Fint *error_return ) ; extern void FNAME(adfgna2,ADFGNA2)( const Fdouble *ID, Fchar name, const Fint *name_length, Fint *error_return ) ; extern void FNAME(adfgni2,ADFGNI2)( const Fdouble *PID, const Fchar name, const Fint *name_length, Fdouble *ID, Fint *error_return ) ; extern void FNAME(adfgnd2,ADFGND2)( const Fdouble *ID, Fint *num_dims, Fint *error_return ) ; extern void FNAME(adfgri2,ADFGRI2)( const Fdouble *ID, Fdouble *Root_ID, Fint *error_return ) ; extern void FNAME(adfisl2,ADFISL2)( const Fdouble *ID, Fint *link_path_length, Fint *error_return ) ; extern void FNAME(adflve2,ADFLVE2)( Fchar version, const Fint *version_length, Fint *error_return ) ; extern void FNAME(adflin2,ADFLIN2)( const Fdouble *PID, const Fchar name, const Fchar file, const Fchar name_in_file, const Fint *name_length, const Fint *file_length, const Fint *nfile_length, Fdouble *ID, Fint *error_return ) ; extern void FNAME(adfmov2,ADFMOV2)( const Fdouble *PID, const Fdouble *ID, const Fdouble *NPID, Fint *error_return ) ; extern void FNAME(adfncl2,ADFNCL2)( const Fdouble *ID, Fint *num_children, Fint *error_return ) ; extern void FNAME(adfpdi2,ADFPDI2)( const Fdouble *ID, const Fchar data_type, const Fint *data_type_length, const Fint *dims, const Fint dim_vals[], Fint *error_return ) ; extern void FNAME(adfpna2,ADFPNA2)( const Fdouble *PID, const Fdouble *ID, const Fchar name, const Fint *name_length, Fint *error_return ) ; extern void FNAME(adfrall,ADFRALL)( const Fdouble *ID, Fchar data, Fint *error_return ) ; extern void FNAME(adfrblk,ADFRBLK)( const Fdouble *ID, const int *b_start, const int *b_end, Fchar data, Fint *error_return ) ; extern void FNAME(adfread,ADFREAD)( const Fdouble *ID, const Fint s_start[], const Fint s_end[], const Fint s_stride[], const Fint *m_num_dims, const Fint m_dims[], const Fint m_start[], const Fint m_end[], const Fint m_stride[], Fchar data, Fint *error_return ) ; extern void FNAME(adfses2,ADFSES2)( const Fint *error_state, Fint *error_return ) ; extern void FNAME(adfslb2,ADFSLB2)( const Fdouble *ID, const Fchar label, const Fint *label_length, Fint *error_return ) ; extern void FNAME(adfwall,ADFWALL)( const Fdouble *ID, const Fchar data, Fint *error_return ) ; extern void FNAME(adfwblk,ADFWBLK)( const Fdouble *ID, const int *b_start, const int *b_end, Fchar data, Fint *error_return ) ; extern void FNAME(adfwrit,ADFWRIT)( const Fdouble *ID, const Fint s_start[], const Fint s_end[], const Fint s_stride[], const Fint *m_num_dims, const Fint m_dims[], const Fint m_start[], const Fint m_end[], const Fint m_stride[], const Fchar data, Fint *error_return ) ; #if defined (__cplusplus) } #endif #endif CGNS-4.5.0/src/adf/adf_ftoc.c000066400000000000000000000212371474000356600155160ustar00rootroot00000000000000/*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ #include #include #include "fortran_macros.h" #include "ADF_internals.h" #if defined(_WIN32) && defined(BUILD_DLL) # define CGNSDLL __declspec(dllexport) #else # define CGNSDLL #endif /* ADF Fortran to C interface */ CGNSDLL void FMNAME(adfcnam, ADFCNAM) (double *ID, int *istart, int *inum, int *inamlen, int *inumret, STR_PSTR(names), int *ier STR_PLEN(names)) { int len_names = (int)STR_LEN(names); FMCALL(adfcna2,ADFCNA2)(ID, istart, inum, inamlen, &len_names, inumret, STR_PTR(names), ier); } CGNSDLL void FMNAME(adfcids, ADFCIDS) (double *ID, int *istart, int *inum, int *inumret, double *cIDs, int *ier) { FMCALL(adfcid2,ADFCID2)(ID, istart, inum, inumret, cIDs, ier); } CGNSDLL void FMNAME(adfcre, ADFCRE) (double *PID, STR_PSTR(name), double *ID, int *ier STR_PLEN(name)) { int len_name = (int)STR_LEN(name); FMCALL(adfcre2, ADFCRE2)(PID, STR_PTR(name), &len_name, ID, ier); } CGNSDLL void FMNAME(adfdclo, ADFDCLO) (double *RootID, int *ier) { FMCALL(adfdcl2, ADFDCL2)(RootID, ier); } CGNSDLL void FMNAME(adfddel, ADFDDEL) (STR_PSTR(filename), int *ier STR_PLEN(filename)) { int len_filename = (int)STR_LEN(filename); FMCALL(adfdde2, ADFDDE2)(STR_PTR(filename), &len_filename, ier); } CGNSDLL void FMNAME(adfdel, ADFDEL) (double *PID, double *ID, int *ier) { FMCALL(adfdel2, ADFDEL2)(PID, ID, ier); } CGNSDLL void FMNAME(adfdgc, ADFDGC) (double *ID, int *ier) { FMCALL(adfdgc2, ADFDGC2)(ID, ier); } CGNSDLL void FMNAME(adfdgf, ADFDGF) (double *RootID, STR_PSTR(format), int *ier STR_PLEN(format)) { int len_format = (int)STR_LEN(format); FMCALL(adfdgf2, ADFDGF2)(RootID, STR_PTR(format), &len_format, ier); } CGNSDLL void FMNAME(adfdopn, ADFDOPN) (STR_PSTR(filename), STR_PSTR(status), STR_PSTR(format), double *RootID, int *ier STR_PLEN(filename) STR_PLEN(status) STR_PLEN(format)) { int len_filename = (int)STR_LEN(filename); int len_status = (int)STR_LEN(status); int len_format = (int)STR_LEN(format); FMCALL(adfdop2, ADFDOP2)(STR_PTR(filename), &len_filename, STR_PTR(status), &len_status, STR_PTR(format), &len_format, RootID, ier); } CGNSDLL void FMNAME(adfdsf, ADFDSF) (double *RootID, STR_PSTR(format), int *ier STR_PLEN(format)) { int len_format = (int)STR_LEN(format); FMCALL(adfdsf2, ADFDSF2)(RootID, STR_PTR(format), &len_format, ier); } CGNSDLL void FMNAME(adfdver, ADFDVER) (double *RootID, STR_PSTR(version), STR_PSTR(cdate), STR_PSTR(mdate), int *ier STR_PLEN(version) STR_PLEN(cdate) STR_PLEN(mdate)) { int len_version = (int)STR_LEN(version); int len_cdate = (int)STR_LEN(cdate); int len_mdate = (int)STR_LEN(mdate); FMCALL(adfdve2, ADFDVE2)(RootID, STR_PTR(version), STR_PTR(cdate), STR_PTR(mdate), &len_version, &len_cdate, &len_mdate, ier); } CGNSDLL void FMNAME(adferr, ADFERR) (int *ier, STR_PSTR(errstr) STR_PLEN(errstr)) { int len_errstr = (int)STR_LEN(errstr); FMCALL(adferr2, ADFERR2)(ier, STR_PTR(errstr), &len_errstr); } CGNSDLL void FMNAME(adfftd, ADFFTD) (double *ID, int *ier) { FMCALL(adfftd2, ADFFTD2)(ID, ier); } CGNSDLL void FMNAME(adfgdt, ADFGDT) (double *ID, STR_PSTR(dtype), int *ier STR_PLEN(dtype)) { int len_dtype = (int)STR_LEN(dtype); FMCALL(adfgdt2, ADFGDT2)(ID, STR_PTR(dtype), &len_dtype, ier); } CGNSDLL void FMNAME(adfgdv, ADFGDV) (double *ID, int *dvals, int *ier) { FMCALL(adfgdv2, ADFGDV2)(ID, dvals, ier); } CGNSDLL void FMNAME(adfges, ADFGES) (int *estate, int *ier) { FMCALL(adfges2, ADFGES2)(estate, ier); } CGNSDLL void FMNAME(adfglb, ADFGLB) (double *ID, STR_PSTR(label), int *ier STR_PLEN(label)) { int len_label = (int)STR_LEN(label); FMCALL(adfglb2, ADFGLB2)(ID, STR_PTR(label), &len_label, ier); } CGNSDLL void FMNAME(adfglkp, ADFGLKP) (double *ID, STR_PSTR(file), STR_PSTR(name), int *ier STR_PLEN(file) STR_PLEN(name)) { int len_file = (int)STR_LEN(file); int len_name = (int)STR_LEN(name); FMCALL(adfglk2, ADFGLK2)(ID, STR_PTR(file), &len_file, STR_PTR(name), &len_name, ier); } CGNSDLL void FMNAME(adfgnam, ADFGNAM) (double *ID, STR_PSTR(name), int *ier STR_PLEN(name)) { int len_name = (int)STR_LEN(name); FMCALL(adfgna2, ADFGNA2)(ID, STR_PTR(name), &len_name, ier); } CGNSDLL void FMNAME(adfgnd, ADFGND) (double *ID, int *ndims, int *ier) { FMCALL(adfgnd2, ADFGND2)(ID, ndims, ier); } CGNSDLL void FMNAME(adfgnid, ADFGNID) (double *PID, STR_PSTR(name), double *ID, int *ier STR_PLEN(name)) { int len_name = (int)STR_LEN(name); FMCALL(adfgni2, ADFGNI2)(PID, STR_PTR(name), &len_name, ID, ier); } CGNSDLL void FMNAME(adfgrid, ADFGRID) (double *ID, double *RootID, int *ier) { FMCALL(adfgri2, ADFGRI2)(ID, RootID, ier); } CGNSDLL void FMNAME(adfislk, ADFISLK) (double *ID, int *lplen, int *ier) { FMCALL(adfisl2, ADFISL2)(ID, lplen, ier); } CGNSDLL void FMNAME(adflink, ADFLINK) (double *PID, STR_PSTR(name), STR_PSTR(file), STR_PSTR(nfile), double *ID, int *ier STR_PLEN(name) STR_PLEN(file) STR_PLEN(nfile)) { int len_name = (int)STR_LEN(name); int len_file = (int)STR_LEN(file); int len_nfile = (int)STR_LEN(nfile); FMCALL(adflin2, ADFLIN2)(PID, STR_PTR(name), STR_PTR(file), STR_PTR(nfile), &len_name, &len_file, &len_nfile, ID, ier); } CGNSDLL void FMNAME(adflver, ADFLVER) (STR_PSTR(version), int *ier STR_PLEN(version)) { int len_version = (int)STR_LEN(version); FMCALL(adflve2, ADFLVE2)(STR_PTR(version), &len_version, ier); } CGNSDLL void FMNAME(adfmove, ADFMOVE) (double *PID, double *ID, double *NPID, int *ier) { FMCALL(adfmov2, ADFMOV2)(PID, ID, NPID, ier); } CGNSDLL void FMNAME(adfncld, ADFNCLD) (double *ID, int *numcld, int *ier) { FMCALL(adfncl2, ADFNCL2)(ID, numcld, ier); } CGNSDLL void FMNAME(adfpdim, ADFPDIM) (double *ID, STR_PSTR(dtype), int *dims, int *dvals, int *ier STR_PLEN(dtype)) { int len_dtype = (int)STR_LEN(dtype); FMCALL(adfpdi2, ADFPDI2)(ID, STR_PTR(dtype), &len_dtype, dims, dvals, ier); } CGNSDLL void FMNAME(adfpnam, ADFPNAM) (double *PID, double *ID, STR_PSTR(name), int *ier STR_PLEN(name)) { int len_name = (int)STR_LEN(name); FMCALL(adfpna2, ADFPNA2)(PID, ID, STR_PTR(name), &len_name, ier); } CGNSDLL void FMNAME(adfses, ADFSES) (int *estate, int *ier) { FMCALL(adfses2, ADFSES2)(estate, ier); } CGNSDLL void FMNAME(adfslb, ADFSLB) (double *ID, STR_PSTR(label), int *ier STR_PLEN(label)) { int len_label = (int)STR_LEN(label); FMCALL(adfslb2, ADFSLB2)(ID, STR_PTR(label), &len_label, ier); } /* added mainly to handle character output under windows */ CGNSDLL void FMNAME(adfreadc, ADFREADC) (double *ID, int *s_start, int *s_end, int *s_stride, int *m_num_dims, int *m_dims, int *m_start, int *m_end, int *m_stride, STR_PSTR(data), int *ier STR_PLEN(data)) { FMCALL(adfread,ADFREAD)(ID, s_start, s_end, s_stride, m_num_dims, m_dims, m_start, m_end, m_stride, STR_PTR(data), ier); } CGNSDLL void FMNAME(adfrallc, ADFRALLC) (double *ID, STR_PSTR(data), int *ier STR_PLEN(data)) { FMCALL(adfrall, ADFRALL)(ID, STR_PTR(data), ier); } CGNSDLL void FMNAME(adfrblkc, ADFRBLKC) (double *ID, int *b_start, int *b_end, STR_PSTR(data), int *ier STR_PLEN(data)) { FMCALL(adfrblk, ADFRBLK)(ID, b_start, b_end, STR_PTR(data), ier); } CGNSDLL void FMNAME(adfwritc, ADFWRITC) (double *ID, int *s_start, int *s_end, int *s_stride, int *m_num_dims, int *m_dims, int *m_start, int *m_end, int *m_stride, STR_PSTR(data), int *ier STR_PLEN(data)) { FMCALL(adfwrit,ADFWRIT)(ID, s_start, s_end, s_stride, m_num_dims, m_dims, m_start, m_end, m_stride, STR_PTR(data), ier); } CGNSDLL void FMNAME(adfwallc, ADFWALLC) (double *ID, STR_PSTR(data), int *ier STR_PLEN(data)) { FMCALL(adfwall, ADFWALL)(ID, STR_PTR(data), ier); } CGNSDLL void FMNAME(adfwblkc, ADFWBLKC) (double *ID, int *b_start, int *b_end, STR_PSTR(data), int *ier STR_PLEN(data)) { FMCALL(adfwblk, ADFWBLK)(ID, b_start, b_end, STR_PTR(data), ier); } CGNS-4.5.0/src/adfh/000077500000000000000000000000001474000356600137505ustar00rootroot00000000000000CGNS-4.5.0/src/adfh/ADF.h000066400000000000000000000041531474000356600145160ustar00rootroot00000000000000/*------------------------------------------------------------------- * this is a replacement for ADF.h for HDF5 implementation *-------------------------------------------------------------------*/ #ifndef _ADF_H_ #define _ADF_H_ /* map ADF calls to ADFH calls */ #define ADF_Children_Names ADFH_Children_Names #define ADF_Children_IDs ADFH_Children_IDs #define ADF_Create ADFH_Create #define ADF_Database_Close ADFH_Database_Close #define ADF_Database_Delete ADFH_Database_Delete #define ADF_Database_Garbage_Collection ADFH_Database_Garbage_Collection #define ADF_Database_Get_Format ADFH_Database_Get_Format #define ADF_Database_Open ADFH_Database_Open #define ADF_Database_Valid ADFH_Database_Valid #define ADF_Database_Set_Format ADFH_Database_Set_Format #define ADF_Database_Version ADFH_Database_Version #define ADF_Delete ADFH_Delete #define ADF_Error_Message ADFH_Error_Message #define ADF_Flush_to_Disk ADFH_Flush_to_Disk #define ADF_Get_Data_Type ADFH_Get_Data_Type #define ADF_Get_Dimension_Values ADFH_Get_Dimension_Values #define ADF_Get_Error_State ADFH_Get_Error_State #define ADF_Get_Label ADFH_Get_Label #define ADF_Get_Link_Path ADFH_Get_Link_Path #define ADF_Get_Name ADFH_Get_Name #define ADF_Get_Node_ID ADFH_Get_Node_ID #define ADF_Get_Number_of_Dimensions ADFH_Get_Number_of_Dimensions #define ADF_Get_Root_ID ADFH_Get_Root_ID #define ADF_Is_Link ADFH_Is_Link #define ADF_Library_Version ADFH_Library_Version #define ADF_Link ADFH_Link #define ADF_Move_Child ADFH_Move_Child #define ADF_Number_of_Children ADFH_Number_of_Children #define ADF_Put_Dimension_Information ADFH_Put_Dimension_Information #define ADF_Put_Name ADFH_Put_Name #define ADF_Read_All_Data ADFH_Read_All_Data #define ADF_Read_Block_Data ADFH_Read_Block_Data #define ADF_Read_Data ADFH_Read_Data #define ADF_Set_Error_State ADFH_Set_Error_State #define ADF_Set_Label ADFH_Set_Label #define ADF_Write_All_Data ADFH_Write_All_Data #define ADF_Write_Block_Data ADFH_Write_Block_Data #define ADF_Write_Data ADFH_Write_Data #define ADF_Release_ID ADFH_Release_ID /* include ADFH.h */ #include "ADFH.h" #endif CGNS-4.5.0/src/adfh/ADFH.c000066400000000000000000003330561474000356600146300ustar00rootroot00000000000000/*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ /*------------------------------------------------------------------- * HDF5 interface to ADF *-------------------------------------------------------------------*/ #ifndef _WIN32 #define _POSIX_C_SOURCE 200112L #endif #include #include #include #include #include #if defined(_WIN32) && !defined(__NUTC__) # include # define ACCESS _access # define UNLINK _unlink #else # include # define ACCESS access # define UNLINK unlink #endif #include "ADFH.h" #include "hdf5.h" #include "cgns_io.h" /* for cgio_find_file */ #if CG_BUILD_PARALLEL #include "mpi.h" #endif #include "cgio_internal_type.h" /* for cgns_io_ctx_t */ extern cgns_io_ctx_t ctx_cgio; /* located in cgns_io.c */ #define ADFH_FORCE_ID_CLOSE /*#define ADFH_H5F_CLOSE_STRONG*/ /*#define ADFH_DEBUG_ON*/ #define ADFH_NO_ORDER #define ADFH_USE_STRINGS #define ADFH_FORTRAN_INDEXING static int CompressData = -1; #define ADFH_CONFIG_DEFAULT 0 #if H5_VERSION_GE(1,10,3) && !defined(H5_USE_18_API) && !defined(H5_USE_16_API) #define ADFH_HDF5_HAVE_110_API 1 #else #define ADFH_HDF5_HAVE_110_API 0 #endif #if H5_VERSION_GE(1,12,0) && !defined(H5_USE_110_API) && !defined(H5_USE_18_API) && !defined(H5_USE_16_API) #define ADFH_HDF5_HAVE_112_API 1 #else #define ADFH_HDF5_HAVE_112_API 0 #endif /*** HDF5's CORE FILE DRIVER PARAMETERS ****/ /* Enables using the core file driver */ static int core_vfd = ADFH_CONFIG_DEFAULT; /* specifies the increment by which allocated memory is * to be increased each time more memory is required, 10MiB default. */ static size_t core_vfd_increment = 10L*1024L*1024L; /* write the file contents to disk when the file is closed */ static hbool_t core_vfd_backing_store = ADFH_CONFIG_DEFAULT; /** MISC. HDF5 OPTIMIZATION TUNING PARAMETERS */ static hsize_t h5pset_alignment_threshold = ADFH_CONFIG_DEFAULT; static hsize_t h5pset_alignment_alignment = ADFH_CONFIG_DEFAULT; static hsize_t h5pset_meta_block_size_size = ADFH_CONFIG_DEFAULT; static hsize_t h5pset_buffer_size_size = ADFH_CONFIG_DEFAULT; static hsize_t h5pset_sieve_buf_size_size = ADFH_CONFIG_DEFAULT; static unsigned h5pset_elink_file_cache_size_size = ADFH_CONFIG_DEFAULT; #define TO_UPPER( c ) ((islower(c))?(toupper(c)):(c)) /* HDF5 compact storage limit */ #define CGNS_64KB (64 * 1024) /* * ADF names are not allowed to start with a space. * Since HDF5 allows this, use the space to hide data */ /* dataset and group names */ #define D_PREFIX ' ' #ifdef ADFH_FORTRAN_INDEXING #define D_VERSION " hdf5version" #define D_OLDVERS " version" #else #define D_VERSION " version" #endif #define D_FORMAT " format" #define D_DATA " data" #define D_FILE " file" #define D_PATH " path" #define D_LINK " link" /* attribute names */ #define A_NAME "name" #define A_LABEL "label" #define A_TYPE "type" #define A_ORDER "order" #define A_MOUNT "mount" #define A_FILE "file" #define A_REFCNT "refcnt" #define A_FLAGS "flags" /* debugging */ #define ADFH_CHECK_HID( hid ) \ if (hid <0) {printf("#### BAD ID [%5d] ",__LINE__);fflush(stdout); } #define ADFH_PREFIX "#### DBG " #ifdef ADFH_DEBUG_ON #define ADFH_DEBUG(aaa) \ printf("#### DBG [%5d] ",__LINE__);fflush(stdout); \ printf aaa ; printf("\n"); fflush(stdout); #define DROP( msg ) printf("XX " msg "\n");fflush(stdout); #else #define ADFH_DEBUG(a) {;} #define DROP( msg ) {;} #endif /* ADF data types */ #define ADFH_MT "MT" #define ADFH_LK "LK" #define ADFH_B1 "B1" #define ADFH_C1 "C1" #define ADFH_I4 "I4" #define ADFH_I8 "I8" #define ADFH_U4 "U4" #define ADFH_U8 "U8" #define ADFH_R4 "R4" #define ADFH_R8 "R8" /* these have experimental support */ #define ADFH_X4 "X4" #define ADFH_X8 "X8" /* HDF5 Compound names used for complex value */ #define CMPLX_REAL_NAME "r" #define CMPLX_IMAG_NAME "i" /* file open modes */ #define ADFH_MODE_NEW 1 #define ADFH_MODE_OLD 2 #define ADFH_MODE_RDO 3 /* the following keeps track of open and mounted files */ #define ADFH_MAXIMUM_FILES 1024 /* Start to prepare re-entrance into lib, gather static variables in one global struct */ /* Then, you'll just have to handle struct with something else but a static... */ /* MTA stands for... Multi-Threads-Aware */ typedef struct _ADFH_MTA { int g_init; /* set when initialization done */ int g_error_state; /* zero means do not stop on error (one stops) */ int i_start; int i_len; int n_length; int n_names; #ifdef ADFH_NO_ORDER int i_count; #endif /* HDF5 property lists */ hid_t g_proplink; hid_t g_propgroupcreate; hid_t g_propdataset; int g_flags; hid_t g_files[ADFH_MAXIMUM_FILES]; /* tracking and indexing settings for link creation order */ unsigned int link_create_order; #ifndef ADFH_FORCE_ID_CLOSE /* object ids returned to API user that should be closed */ hid_t *g_extids[ADFH_MAXIMUM_FILES]; int n_extids[ADFH_MAXIMUM_FILES]; /* number of extids */ int x_extids[ADFH_MAXIMUM_FILES]; /* max allocated in g_extids */ #endif } ADFH_MTA; static ADFH_MTA *mta_root=NULL; /* error codes and messages - do not care about multi-threading here */ static struct _ErrorList { int errcode; char *errmsg; } ErrorList[] = { {NO_ERROR, "No Error"}, {STRING_LENGTH_ZERO, "String length of zero or blank string detected"}, {STRING_LENGTH_TOO_BIG, "String length longer than maximum allowable length"}, {TOO_MANY_ADF_FILES_OPENED,"Too many files opened"}, {ADF_FILE_STATUS_NOT_RECOGNIZED,"File status was not recognized"}, {FILE_OPEN_ERROR, "File-open error"}, {NULL_STRING_POINTER, "A string pointer is NULL"}, {REQUESTED_NEW_FILE_EXISTS,"File Open Error: NEW - File already exists"}, {ADF_FILE_FORMAT_NOT_RECOGNIZED,"File format was not recognized"}, {REQUESTED_OLD_FILE_NOT_FOUND,"File Open Error: OLD - File does not exist"}, {MEMORY_ALLOCATION_FAILED,"Memory allocation failed"}, {DUPLICATE_CHILD_NAME, "Duplicate child name under a parent node"}, {ZERO_DIMENSIONS, "Node has no dimensions"}, {BAD_NUMBER_OF_DIMENSIONS,"Node's number-of-dimensions is not in legal range"}, {CHILD_NOT_OF_GIVEN_PARENT,"Specified child is NOT a child of the specified parent"}, {INVALID_DATA_TYPE, "Invalid Data-Type"}, {NULL_POINTER, "A pointer is NULL"}, {NO_DATA, "Node has no data associated with it"}, {END_OUT_OF_DEFINED_RANGE,"Bad end value"}, {BAD_STRIDE_VALUE, "Bad stride value"}, {MINIMUM_GT_MAXIMUM, "Minimum value is greater than the maximum value"}, {DATA_TYPE_NOT_SUPPORTED, "The data format is not support on a particular machine"}, {FILE_CLOSE_ERROR, "File Close error"}, {START_OUT_OF_DEFINED_RANGE,"Bad start value"}, {ZERO_LENGTH_VALUE, "A value of zero is not allowable"}, {BAD_DIMENSION_VALUE, "Bad dimension value"}, {BAD_ERROR_STATE, "Error state must be either a 0 (zero) or a 1 (one)"}, {UNEQUAL_MEMORY_AND_DISK_DIMS,"Unequal dimensional specifications for disk and memory"}, {NODE_IS_NOT_A_LINK, "The node is not a link. It was expected to be a link"}, {LINK_TARGET_NOT_THERE, "The linked-to node does not exist"}, {LINKED_TO_FILE_NOT_THERE,"The file of a linked-node is not accessible"}, {INVALID_NODE_NAME, "Node name contains invalid characters"}, {FFLUSH_ERROR, "H5Fflush:flush error"}, {NULL_NODEID_POINTER, "The node ID pointer is NULL"}, {MAX_FILE_SIZE_EXCEEDED, "The maximum size for a file exceeded"}, {MAX_INT32_SIZE_EXCEEDED, "dimensions exceed that for a 32-bit integer"}, {ADFH_ERR_GLINK, "H5Glink:soft link creation failed"}, {ADFH_ERR_NO_ATT, "Node attribute doesn't exist"}, {ADFH_ERR_AOPEN, "H5Aopen:open of node attribute failed"}, {ADFH_ERR_IGET_NAME, "H5Iget_name:failed to get node path from ID"}, {ADFH_ERR_LMOVE, "H5Lmove:moving a node group failed"}, {ADFH_ERR_GUNLINK, "H5Gunlink:node group deletion failed"}, {ADFH_ERR_GOPEN, "H5Gopen:open of a node group failed"}, {ADFH_ERR_DGET_SPACE, "H5Dget_space:couldn't get node dataspace"}, {ADFH_ERR_DOPEN, "H5Dopen:open of the node data failed"}, {ADFH_ERR_DEXTEND, "H5Dextend:couldn't extend the node dataspace"}, {ADFH_ERR_DCREATE, "H5Dcreate:node data creation failed"}, {ADFH_ERR_SCREATE_SIMPLE, "H5Screate_simple:dataspace creation failed"}, {ADFH_ERR_ACREATE, "H5Acreate:node attribute creation failed"}, {ADFH_ERR_GCREATE, "H5Gcreate:node group creation failed"}, {ADFH_ERR_DWRITE, "H5Dwrite:write to node data failed"}, {ADFH_ERR_DREAD, "H5Dread:read of node data failed"}, {ADFH_ERR_AWRITE, "H5Awrite:write to node attribute failed"}, {ADFH_ERR_AREAD, "H5Aread:read of node attribute failed"}, {ADFH_ERR_FMOUNT, "H5Fmount:file mount failed"}, {ADFH_ERR_LINK_MOVE, "Can't move a linked-to node"}, {ADFH_ERR_LINK_DATA, "Can't change the data for a linked-to node"}, {ADFH_ERR_LINK_NODE, "Parent of node is a link"}, {ADFH_ERR_LINK_DELETE, "Can't delete a linked-to node"}, {ADFH_ERR_NOT_HDF5_FILE, "File does not exist or is not a HDF5 file"}, {ADFH_ERR_FILE_DELETE, "unlink (delete) of file failed"}, {ADFH_ERR_FILE_INDEX, "couldn't get file index from node ID"}, {ADFH_ERR_TCOPY, "H5Tcopy:copy of existing datatype failed"}, {ADFH_ERR_AGET_TYPE, "H5Aget_type:couldn't get attribute datatype"}, {ADFH_ERR_TSET_SIZE, "H5Tset_size:couldn't set datatype size"}, {ADFH_ERR_NOT_IMPLEMENTED,"routine not implemented"}, {ADFH_ERR_NOTXLINK, "H5L: Link target is not an HDF5 external link"}, {ADFH_ERR_LIBREG, "HDF5: No external link feature available"}, {ADFH_ERR_OBJINFO_FAILED, "HDF5: Internal problem with objinfo"}, {ADFH_ERR_XLINK_NOVAL, "HDF5: No value for external link"}, {ADFH_ERR_XLINK_UNPACK, "HDF5: Cannot unpack external link"}, {ADFH_ERR_ROOTNULL, "HDF5: Root descriptor is NULL"}, {ADFH_ERR_NEED_TRANSPOSE, "dimensions need transposed - open in modify mode"}, {ADFH_ERR_INVALID_OPTION, "invalid configuration option"}, {ADFH_ERR_INVALID_USER_DATA, "invalid configuration data passed in"}, {ADFH_ERR_SENTINEL, ""} }; #define NUM_ERRORS ((int)(sizeof(ErrorList)/sizeof(struct _ErrorList))) #define ROOT_OR_DIE(err) \ if (mta_root == NULL){set_error(ADFH_ERR_ROOTNULL, err);return;} #define ROOT_OR_DIE_ERR(err) \ if (mta_root == NULL){set_error(ADFH_ERR_ROOTNULL, err);return 1;} /* useful macros */ #define CMP_OINFO(r,n) ((r)->fileno==(n)->fileno && \ (r)->addr==(n)->addr && (r)->addr != HADDR_UNDEF) static herr_t gfind_by_name(hid_t, const char *, const H5L_info_t*, void *); static herr_t find_by_name(hid_t, const char *, const H5A_info_t*, void *); #if ADFH_HDF5_HAVE_112_API #define has_child(ID,NAME) H5Literate2(ID, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, gfind_by_name, (void *)NAME) #define has_data(ID) H5Literate2(ID, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, gfind_by_name, (void *)D_DATA) #else #define has_child(ID,NAME) H5Literate(ID, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, gfind_by_name, (void *)NAME) #define has_data(ID) H5Literate(ID, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, gfind_by_name, (void *)D_DATA) #endif #define child_exists(ID,NAME) H5Lexists(ID, NAME, H5P_DEFAULT) #define data_exists(ID) H5Lexists(ID, D_DATA, H5P_DEFAULT) #define has_att(ID,NAME) H5Aiterate2(ID,H5_INDEX_NAME,H5_ITER_NATIVE,NULL,find_by_name,(void *)NAME) #if 0 static herr_t gprint_name(hid_t, const char *, void *); static herr_t print_name(hid_t, const char *, const H5A_info_t*, void *); #define show_grp(ID) H5Literate_by_name(ID, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, gprint_name, (void *)"GRP", H5P_DEFAULT) #define show_att(ID,NAME) H5Aiterate2(ID,H5_INDEX_NAME,H5_ITER_NATIVE,NULL,print_name,(void *)NAME) #endif /* ---------------------------------------------------------------- * set error and terminate if error state set * ---------------------------------------------------------------- */ static void set_error(int errcode, int *err) { if ((mta_root != NULL)&&(errcode != NO_ERROR)&&(mta_root->g_error_state)) { char errmsg[ADF_MAX_ERROR_STR_LENGTH+1]; ADFH_Error_Message(errcode, errmsg); fprintf(stderr, "ERROR:%s\n", errmsg); exit(1); } *err = errcode; } /* ----- handle HDF5 errors --------------------------------------- */ static herr_t print_H5_error(int n, H5E_error2_t *desc, void *data) { const char *p; if ((p = strrchr(desc->file_name, '/')) == NULL && (p = strrchr(desc->file_name, '\\')) == NULL) p = desc->file_name; else p++; fprintf(stderr, "%s line %u in %s(): %s\n", p, desc->line, desc->func_name, desc->desc); return 0; } /* ----------------------------------------------------------------- */ static herr_t walk_H5_error(hid_t estack, void *data) { if ((mta_root != NULL) && (mta_root->g_error_state)) { fflush(stdout); fprintf(stderr, "\nHDF5 Error Trace Back\n"); return H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, (H5E_walk2_t)print_H5_error, data); } return 0; } /* ----------------------------------------------------------------- * get file ID from node ID * ----------------------------------------------------------------- */ static hid_t get_file_id (hid_t id) { ssize_t n, nobj; hid_t *objs, fid = -1; H5O_info_t gstat, rstat; int token_cmp; /* find the file ID from the root ID */ #if ADFH_HDF5_HAVE_112_API if (H5Oget_info_by_name3(id, "/", &gstat, H5O_INFO_BASIC, H5P_DEFAULT) >=0) { #else if (H5Oget_info_by_name(id, "/", &gstat, H5P_DEFAULT) >=0) { #endif nobj = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_FILE); if (nobj > 0) { objs = (hid_t *) malloc (nobj * sizeof(hid_t)); if (objs == NULL) return fid; H5Fget_obj_ids(H5F_OBJ_ALL, H5F_OBJ_FILE, -1, objs); for (n = 0; n < nobj; n++) { #if ADFH_HDF5_HAVE_112_API H5Oget_info_by_name3(objs[n], "/", &rstat, H5O_INFO_BASIC, H5P_DEFAULT); token_cmp = 1; if(gstat.fileno == rstat.fileno){ H5Otoken_cmp(id, &gstat.token, &rstat.token, &token_cmp); } if (!token_cmp){ #else H5Oget_info_by_name(objs[n], "/", &rstat, H5P_DEFAULT); if (CMP_OINFO(&gstat, &rstat)) { #endif fid = objs[n]; break; } } free (objs); } } return fid; } /* ----------------------------------------------------------------- */ static int get_file_number (hid_t id, int *err) { int n; hid_t fid = get_file_id(id); if (mta_root == NULL) return -1; for (n = 0; n < ADFH_MAXIMUM_FILES; n++) { if (fid == mta_root->g_files[n]) { set_error(NO_ERROR, err); return n; } } set_error(ADFH_ERR_FILE_INDEX, err); return -1; } #ifndef ADFH_FORCE_ID_CLOSE /* ----------------------------------------------------------------- */ static track_id(hid_t refid, hid_t trackid) { int fn,er; int sname; char oname[256]; size_t maxhid; memset(oname,'\0',256); sname=H5Iget_name(trackid,oname,0); sname=H5Iget_name(trackid,oname,sname+1); fn=get_file_number(refid,&er); if (fn==-1) { ADFH_DEBUG((">ADFH track_ids cannot stat [%d][%s]",trackid,oname)); } else { if (mta_root->n_extids[fn]>mta_root->x_extids[fn]) { mta_root->x_extids[fn]+=256; maxhid=mta_root->x_extids[fn]*sizeof(hid_t*); mta_root->g_extids[fn]=(hid_t*)realloc(mta_root->g_extids[fn],maxhid); ADFH_DEBUG((">ADFH track_ids realloc up to [%d]",\ mta_root->x_extids[fn])); } mta_root->g_extids[fn][mta_root->n_extids[fn]]=trackid; ADFH_DEBUG((">ADFH track_ids [%d][%d][%s]",\ mta_root->n_extids[fn],trackid,oname)); mta_root->n_extids[fn]++; } } #endif /*----------------------------------------------------------------- * get the native format - returns pointer to static storage *----------------------------------------------------------------- */ static char *native_format(void) { static char format[ADF_FORMAT_LENGTH+1]; hid_t type = H5Tcopy(H5T_NATIVE_FLOAT); ADFH_CHECK_HID(type); if (H5Tequal(type, H5T_IEEE_F32BE)) strcpy(format, "IEEE_BIG_32"); else if (H5Tequal(type, H5T_IEEE_F32LE)) strcpy(format, "IEEE_LITTLE_32"); else if (H5Tequal(type, H5T_IEEE_F64BE)) strcpy(format, "IEEE_BIG_64"); else if (H5Tequal(type, H5T_IEEE_F64LE)) strcpy(format, "IEEE_LITTLE_64"); else sprintf(format, "NATIVE_%d", (int)H5Tget_precision(type)); H5Tclose(type); return format; } /* ----------------------------------------------------------------- * set/get attribute values * ----------------------------------------------------------------- */ static hid_t get_att_id(hid_t id, const char *name, int *err) { hid_t aid = H5Aopen_by_name(id, ".", name, H5P_DEFAULT, H5P_DEFAULT); /* H5Aclose() performed elsewhere */ if (aid < 0) { if (!has_att(id, name)) set_error(ADFH_ERR_NO_ATT, err); else set_error(ADFH_ERR_AOPEN, err); } else set_error(NO_ERROR, err); return aid; } /* ----------------------------------------------------------------- */ static int new_str_att(hid_t id, const char *name, const char *value, int max_size, int *err) { #ifdef ADFH_USE_STRINGS hid_t sid, tid, aid; herr_t status; /* [1] the attribute is set on the GROUP (id is a group id) */ /* [2] all datatypes should be H5T_STRING and not H5T_NATIVE_CHAR which requires an array (see case below with a H5Screate_simple and provides an array of chars) */ sid = H5Screate(H5S_SCALAR); if (sid < 0) { set_error(ADFH_ERR_SCREATE_SIMPLE, err); return 1; } tid = H5Tcopy(H5T_C_S1); if (tid < 0) { H5Sclose(sid); set_error(ADFH_ERR_TCOPY, err); return 1; } if (H5Tset_size(tid, max_size + 1) < 0) { H5Tclose(tid); H5Sclose(sid); set_error(ADFH_ERR_TSET_SIZE, err); return 1; } aid = H5Acreate2(id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT); if (aid < 0) { H5Tclose(tid); H5Sclose(sid); set_error(ADFH_ERR_ACREATE, err); return 1; } status = H5Awrite(aid, tid, value); H5Aclose(aid); H5Tclose(tid); H5Sclose(sid); if (status < 0) { set_error(ADFH_ERR_AWRITE, err); return 1; } set_error(NO_ERROR, err); return 0; #else /* CAUTION: only use this for strings <= ADF_FILENAME_LENGTH */ hid_t sid, aid; hsize_t dim; herr_t status; char buff[ADF_FILENAME_LENGTH+1]; dim = max_size + 1; sid = H5Screate_simple(1, &dim, NULL); if (sid < 0) { set_error(ADFH_ERR_SCREATE_SIMPLE, err); return 1; } aid = H5Acreate2(id, name, H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT); if (aid < 0) { H5Sclose(sid); set_error(ADFH_ERR_ACREATE, err); return 1; } memset(buff, 0, ADF_FILENAME_LENGTH+1); strcpy(buff, value); status = H5Awrite(aid, H5T_NATIVE_CHAR, buff); H5Aclose(aid); H5Sclose(sid); if (status < 0) { set_error(ADFH_ERR_AWRITE, err); return 1; } set_error(NO_ERROR, err); return 0; #endif } /* ----------------------------------------------------------------- */ static int get_str_att(hid_t id, const char *name, char *value, int *err) { #ifdef ADFH_USE_STRINGS hid_t tid, att_id; herr_t status; ADFH_DEBUG((">ADFH get_str_att [%s]",name)); if ((att_id = get_att_id(id, name, err)) < 0) return 1; #if 0 status = H5Aread(att_id, H5T_NATIVE_CHAR, value); #else tid = H5Aget_type(att_id); if (tid < 0) { H5Aclose(att_id); set_error(ADFH_ERR_AGET_TYPE, err); return 1; } status = H5Aread(att_id, tid, value); H5Tclose(tid); #endif H5Aclose(att_id); ADFH_DEBUG(("i_count - mta_root->i_start; if (order >= 0 && order < mta_root->i_len) { p = (char *)namelist + order * mta_root->n_length; strncpy(p, name, mta_root->n_length-1); p[mta_root->n_length-1] = 0; mta_root->n_names++; } #else if ((gid = H5Gopen2(id, name, H5P_DEFAULT)) < 0) return 1; ADFH_DEBUG(("ADFH children_names [%d]",gid)); if (get_int_att(gid, A_ORDER, &order, &err)) { H5Gclose(gid); return 1; } order -= mta_root->i_start; if (order >= 0 && order < mta_root->i_len) { p = (char *)namelist + order * mta_root->n_length; strncpy(p, name, mta_root->n_length-1); p[mta_root->n_length-1] = 0; mta_root->n_names++; } H5Gclose(gid); #endif return 0; } /* ----------------------------------------------------------------- */ static herr_t children_ids(hid_t id, const char *name, const H5L_info_t *linfo, void *idlist) { hid_t gid; int order, err; ADFH_DEBUG((">ADFH children_ids [%s]",name)); ROOT_OR_DIE_ERR(&err); if (*name == D_PREFIX) return 0; if ((gid = H5Gopen2(id, name, H5P_DEFAULT)) < 0) return 1; #ifdef ADFH_NO_ORDER order = ++mta_root->i_count - mta_root->i_start; ADFH_DEBUG((">ADFH children_ids [%s] order is [%d]",name,order)); if (order >= 0 && order < mta_root->i_len) { to_ADF_ID(gid,((double *)idlist)[order]); mta_root->n_names++; #ifndef ADFH_FORCE_ID_CLOSE track_id(id,gid); #endif } else H5Gclose(gid); #else if (get_int_att(gid, A_ORDER, &order, &err)) { H5Gclose(gid); return 1; } order -= mta_root->i_start; if (order >= 0 && order < mta_root->i_len) { to_ADF_ID(gid,((double *)idlist)[order]); mta_root->n_names++; #ifndef ADFH_FORCE_ID_CLOSE track_id(id,gid); #endif } else H5Gclose(gid); #endif return 0; } #ifndef ADFH_NO_ORDER /* ----------------------------------------------------------------- called via H5Literate in Move_Child & Delete functions. removes gaps in _order index attributes */ static herr_t fix_order(hid_t id, const char *name, void *data) { int start, order, err, ret = 0; hid_t gid, aid; if (mta_root == NULL) return ADFH_ERR_ROOTNULL; if (*name == D_PREFIX) return 0; if ((gid = H5Gopen2(id, name, H5P_DEFAULT)) < 0) return ADFH_ERR_GOPEN; if ((aid = get_att_id(gid, A_ORDER, &err)) < 0) { H5Gclose(gid); return err; } if (H5Aread(aid, H5T_NATIVE_INT, &order) < 0) ret = ADFH_ERR_AREAD; else { start = *((int *)data); if (order > start) { order--; if (H5Awrite(aid, H5T_NATIVE_INT, &order) < 0) ret = ADFH_ERR_AWRITE; } } ADFH_DEBUG(("ADFH fix_order [%d]",gid)); H5Aclose(aid); H5Gclose(gid); return ret; } #endif /* ----------------------------------------------------------------- */ static herr_t compare_children(hid_t id, const char *name, const H5L_info_t *linfo, void *data) { H5O_info_t stat, *pstat; int token_cmp; if (*name != D_PREFIX) { pstat = (H5O_info_t *)data; #if ADFH_HDF5_HAVE_112_API if (H5Oget_info_by_name3(id, name, &stat, H5O_INFO_BASIC, H5P_DEFAULT) >= 0){ token_cmp = 1; if(pstat->fileno == stat.fileno){ H5Otoken_cmp(id, &pstat->token, &stat.token, &token_cmp); } if (!token_cmp){ return 1; } return 0; } #else if (H5Oget_info_by_name(id, name, &stat, H5P_DEFAULT) >= 0){ return CMP_OINFO(&stat, pstat); } #endif } return 0; } #if 0 /* ----------------------------------------------------------------- */ static herr_t print_children(hid_t id, const char *name, void *data) { if (*name != D_PREFIX) printf(" %s", name); return 0; } #endif /* ================================================================ * routines for dealing with links * ================================================================ */ static hid_t open_link(hid_t id, int *err) { hid_t lid; herr_t herr; const char *file; const char *path; H5L_info_t sb; char querybuff[512]; #ifdef ADFH_DEBUG_ON H5O_info_t oinfo;/* debug purpose only */ char buffname[ADF_NAME_LENGTH+1]; get_str_att(id, A_NAME, buffname, err); ADFH_DEBUG((">ADFH open_link [%s]",buffname)); #endif if (H5Lis_registered(H5L_TYPE_EXTERNAL) != 1) { set_error(ADFH_ERR_LIBREG, err); return -1; } herr = H5Lget_info(id, D_LINK, &sb, H5P_DEFAULT); if (herr<0) { ADFH_DEBUG((">ADFH open_link type [%d][%d]",herr,sb.type)); set_error(ADFH_ERR_OBJINFO_FAILED, err); return -1; } /* Soft link -> link to our current file */ /* Hard link (User defined) -> link to an external file */ if (H5L_TYPE_SOFT != sb.type) { if (H5L_TYPE_EXTERNAL != sb.type) { set_error(ADFH_ERR_NOTXLINK, err); return -1; } if (H5Lget_val(id,D_LINK,querybuff,sizeof(querybuff),H5P_DEFAULT)<0) { set_error(ADFH_ERR_XLINK_NOVAL, err); return -1; } if (H5Lunpack_elink_val(querybuff,sb.u.val_size,NULL,&file,&path)<0) { set_error(ADFH_ERR_XLINK_UNPACK, err); return -1; } /* open the actual link >> IN THE LINK GROUP << */ ADFH_DEBUG((">ADFH open_link (external)")); if ((lid = H5Gopen2(id, D_LINK, H5P_DEFAULT)) < 0) { set_error(LINK_TARGET_NOT_THERE, err); return lid; } } else { ADFH_DEBUG((">ADFH open_link (symbolic)")); if ((lid = H5Gopen2(id, D_LINK, H5P_DEFAULT)) < 0) { set_error(LINK_TARGET_NOT_THERE, err); return lid; } } #ifdef ADFH_DEBUG_ON #if ADFH_HDF5_HAVE_112_API H5Oget_info3(lid, &oinfo, H5O_INFO_BASIC); #else H5Oget_info(lid, &oinfo); #endif ADFH_DEBUG(("[%d]:%d",id,lid,oinfo.rc)); #endif return lid; } /* ----------------------------------------------------------------- */ static int is_link(hid_t id) { char type[3]; int err; if ((!get_str_att(id, A_TYPE, type, &err) && (0 == strcmp(ADFH_LK, type)))) { return 1; } return 0; } /* ----------------------------------------------------------------- */ static hid_t open_node(double id, int *err) { hid_t hid, gid, lid; ADFH_DEBUG((">ADFH open_node")); to_HDF_ID(id,hid); set_error(NO_ERROR, err); if (is_link(hid)) { lid=open_link(hid, err); /* bad id trapped in the function */ ADFH_DEBUG(("ADFH H5Gclose failed")); if (nid < 0) return nid; id = nid; } nid = parse_path(id, p, err); if (H5Gclose(id)<0) ADFH_DEBUG((">ADFH H5Gclose failed")); ADFH_DEBUG(("ADFH parse_path [%d]",nid)); return nid; } /* ----------------------------------------------------------------- * deletion routines * ----------------------------------------------------------------- */ static void delete_node(hid_t pid, const char *name) { H5Ldelete(pid, name, H5P_DEFAULT); /* do we care about link ? no ? */ } /* ----------------------------------------------------------------- */ static herr_t delete_children(hid_t id, const char *name, const H5L_info_t* linfo, void *data) { if (*name == D_PREFIX) { ADFH_DEBUG(("delete_children single")); if (! is_link(id)) { ADFH_DEBUG(("delete_children is not link [%s]",name)); H5Ldelete(id, name, H5P_DEFAULT); } else { ADFH_DEBUG(("delete_children is link")); } ADFH_DEBUG(("delete_children single done")); } else { ADFH_DEBUG(("delete_children loop")); #if ADFH_HDF5_HAVE_112_API if (! is_link(id)) H5Literate_by_name2(id, name, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, delete_children, data, H5P_DEFAULT); #else if (! is_link(id)) H5Literate_by_name(id, name, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, delete_children, data, H5P_DEFAULT); #endif delete_node(id, name); } return 0; } /* ----------------------------------------------------------------- * check for valid node name * The return points to static storage - make a copy if needed * ----------------------------------------------------------------- */ static char *check_name(const char *new_name, int *err) { char *p; static char name[ADF_NAME_LENGTH+1]; if (new_name == NULL) { set_error(NULL_STRING_POINTER, err); return NULL; } /* skip leading space */ for (p = (char *)new_name; *p && isspace(*p); p++) ; if (!*p) { set_error(STRING_LENGTH_ZERO, err); return NULL; } if (strlen(p) > ADF_NAME_LENGTH) { set_error(STRING_LENGTH_TOO_BIG, err); return NULL; } strcpy(name, p); /* remove trailing space */ for (p = name+strlen(name)-1; p >= name && isspace(*p); p--) ; *++p = 0; if (!*name) { set_error(STRING_LENGTH_ZERO, err); return NULL; } /* these may cause problems with HDF5 */ if (NULL != strchr(name, '/') || 0 == strcmp (name, ".")) { set_error(INVALID_NODE_NAME, err); return NULL; } set_error(NO_ERROR, err); return name; } #ifdef ADFH_FORTRAN_INDEXING /*------------------------------------------------------------------ * transpose multi-dimensional indices recursively *------------------------------------------------------------------*/ static int swap_dimensions (hid_t gid) { char verstr[ADF_NAME_LENGTH+1]; sprintf(verstr, "/%s", D_OLDVERS); if (H5Lexists(gid, verstr, H5P_DEFAULT)) return 0; return 1; } static void transpose_dimensions (hid_t hid, const char *name) { #if 0 hid_t did, sid, tid, mid; int i, j, temp, ndims, diffs; hsize_t bytes, dims[ADF_MAX_DIMENSIONS]; void *data = NULL; #else hid_t did, sid; int i, j, ndims, diffs; hsize_t temp, dims[ADF_MAX_DIMENSIONS]; #endif if ((did = H5Dopen2(hid, D_DATA, H5P_DEFAULT)) < 0) return; /* get dimensions and size */ sid = H5Dget_space(did); ndims = H5Sget_simple_extent_dims(sid, dims, NULL); H5Sclose(sid); if (ndims < 2) { H5Dclose(did); return; } #if 0 printf("%s:%d [%d", name, bytes, dims[0]); for (i = 1; i < ndims; i++) printf(",%d", dims[i]); printf("]\n"); fflush(stdout); #endif /* transpose dimensions */ diffs = 0; for (i = 0, j = ndims-1; i < j; i++, j--) { if (dims[i] != dims[j]) { temp = dims[i]; dims[i] = dims[j]; dims[j] = temp; diffs++; } } if (0 == diffs) { H5Dclose(did); return; } #if 0 /* read the data, then delete data set */ bytes = H5Dget_storage_size(did); tid = H5Dget_type(did); mid = H5Tget_native_type(tid, H5T_DIR_ASCEND); if (bytes > 0) { data = malloc ((unsigned)bytes); H5Dread(did, mid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); } H5Dclose(did); H5Ldelete(hid, D_DATA, H5P_DEFAULT); /* rewrite data with new dimensions */ sid = H5Screate_simple(ndims, dims, NULL); did = H5Dcreate2(hid, D_DATA, tid, sid, H5P_DEFAULT, mta_root->g_propdataset, H5P_DEFAULT); if (data != NULL) { H5Dwrite(did, mid, H5S_ALL, sid, H5P_DEFAULT, data); free(data); } H5Tclose(mid); H5Tclose(tid); H5Sclose(sid); #else if (H5Dset_extent(did, dims) < 0) { fprintf(stderr, "H5Dset_extent failed\n"); } #endif H5Dclose(did); } /* ----------------------------------------------------------------- */ static herr_t fix_dimensions(hid_t id, const char *name, const H5L_info_t* linfo, void *data) { hid_t gid; int err; char type[ADF_DATA_TYPE_LENGTH+1]; if (*name != D_PREFIX && (gid = H5Gopen2(id, name, H5P_DEFAULT)) >= 0 && !get_str_att(gid, A_TYPE, type, &err) && strcmp(type, ADFH_LK)) { #if ADFH_HDF5_HAVE_112_API H5Literate2(gid, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, fix_dimensions, NULL); #else H5Literate(gid, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, fix_dimensions, NULL); #endif transpose_dimensions(gid,name); H5Gclose(gid); } return 0; } #endif /* ================================================================= */ /* 1 to 1 mapping of ADF functions to HDF mimic functions */ /* ================================================================= */ void ADFH_Configure(const int option, const void *value, int *err) { if (option == ADFH_CONFIG_RESET && (int)((size_t)value == ADFH_CONFIG_RESET_HDF5)) { core_vfd = ADFH_CONFIG_DEFAULT; h5pset_alignment_threshold = ADFH_CONFIG_DEFAULT; h5pset_alignment_alignment = ADFH_CONFIG_DEFAULT; h5pset_meta_block_size_size = ADFH_CONFIG_DEFAULT; h5pset_buffer_size_size = ADFH_CONFIG_DEFAULT; h5pset_sieve_buf_size_size = ADFH_CONFIG_DEFAULT; h5pset_elink_file_cache_size_size = ADFH_CONFIG_DEFAULT; set_error(NO_ERROR, err); return; } if (option == ADFH_CONFIG_COMPRESS) { int compress = (int)((size_t)value); if (compress < 0) CompressData = 6; else if (compress > 9) CompressData = 9; else CompressData = compress; set_error(NO_ERROR, err); } else if (option == ADFH_CONFIG_CORE) { core_vfd = (int)((size_t)value); set_error(NO_ERROR, err); } else if (option == ADFH_CONFIG_CORE_WRITE) { core_vfd_backing_store = (hbool_t)((size_t)value); set_error(NO_ERROR, err); } else if (option == ADFH_CONFIG_CORE_INCR) { core_vfd_increment = (size_t)value; set_error(NO_ERROR, err); } else if (option == ADFH_CONFIG_ALIGNMENT) { const size_t* val = (const size_t*)value; h5pset_alignment_threshold = (hsize_t)(val[0]); h5pset_alignment_alignment = (hsize_t)(val[1]); set_error(NO_ERROR, err); } else if (option == ADFH_CONFIG_MD_BLOCK_SIZE) { h5pset_meta_block_size_size = (hsize_t)value; set_error(NO_ERROR, err); } else if (option == ADFH_CONFIG_HDF5_BUFFER) { h5pset_buffer_size_size = (hsize_t)value; set_error(NO_ERROR, err); } else if (option == ADFH_CONFIG_HDF5_SIEVE_BUF_SIZE) { h5pset_sieve_buf_size_size = (hsize_t)value; set_error(NO_ERROR, err); } else if (option == ADFH_CONFIG_ELINK_FILE_CACHE_SIZE) { h5pset_elink_file_cache_size_size = (unsigned)((size_t)value); set_error(NO_ERROR, err); } #if CG_BUILD_PARALLEL else if (option == ADFH_CONFIG_MPI_COMM) { MPI_Comm* comm = (MPI_Comm*)value; if (!comm) { set_error(ADFH_ERR_INVALID_USER_DATA, err); } else { ctx_cgio.pcg_mpi_comm = (MPI_Comm)*comm; set_error(NO_ERROR, err); } } #endif else { set_error(ADFH_ERR_INVALID_OPTION, err); } } /* ----------------------------------------------------------------- */ /* move a node */ void ADFH_Move_Child(const double pid, const double id, const double npid, int *err) { hid_t hpid; hid_t hid; hid_t hnpid; ssize_t len; int namelen; #ifndef ADFH_NO_ORDER int old_order, new_order; #endif char buff[2]; char nodename[ADF_NAME_LENGTH+1]; char *newpath; herr_t status; H5O_info_t stat; to_HDF_ID(pid,hpid); to_HDF_ID(id,hid); to_HDF_ID(npid,hnpid); ADFH_DEBUG(("ADFH_Move_Child")); if (is_link(hpid) || is_link(hnpid)) { set_error(ADFH_ERR_LINK_MOVE, err); return; } /* check that node is actually child of the parent */ #if ADFH_HDF5_HAVE_112_API if (H5Oget_info_by_name3(hid, ".", &stat, H5O_INFO_BASIC, H5P_DEFAULT) < 0 || !H5Literate2(hpid, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, compare_children, (void *)&stat)) { #else if (H5Oget_info_by_name(hid, ".", &stat, H5P_DEFAULT) < 0 || !H5Literate(hpid, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, compare_children, (void *)&stat)) { #endif set_error(CHILD_NOT_OF_GIVEN_PARENT, err); return; } /* get node name */ if (get_str_att(hid, A_NAME, nodename, err)) return; namelen = (int)strlen(nodename); /* get new node path */ len = H5Iget_name(hnpid, buff, 2); if (len <= 0) { set_error(ADFH_ERR_IGET_NAME, err); return; } newpath = (char *) malloc (len+namelen+2); if (newpath == NULL) { set_error(MEMORY_ALLOCATION_FAILED, err); return; } H5Iget_name(hnpid, newpath, len+1); newpath[len++] = '/'; strcpy(&newpath[len], nodename); #ifdef ADFH_DEBUG_ON printf("%s move [%s]\n",ADFH_PREFIX,nodename); printf("%s to [%s]\n",ADFH_PREFIX,newpath); #endif status = H5Lmove(hpid, nodename, hnpid, newpath, H5P_DEFAULT, H5P_DEFAULT); free(newpath); if (status < 0) { set_error(ADFH_ERR_LMOVE, err); return; } #ifdef ADFH_NO_ORDER set_error(NO_ERROR, err); #else /*update _order attribute for node we just moved*/ ADFH_Number_of_Children(npid, &new_order, err); if (*err != NO_ERROR) return; /*read/write _order attr*/ if (get_int_att(hid, A_ORDER, &old_order, err) || set_int_att(hid, A_ORDER, new_order, err)) return; /*see if we need to decrement any node _orders under the old parent*/ #if ADFH_HDF5_HAVE_112_API *err = H5Literate2(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, fix_order, (void *)&old_order); #else *err = H5Literate(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, fix_order, (void *)&old_order); #endif if (!*err) set_error(NO_ERROR, err); #endif } /* ----------------------------------------------------------------- */ /* Change the label attribute value */ void ADFH_Set_Label(const double id, const char *label, int *err) { hid_t hid; char label_name[ADF_NAME_LENGTH+1]; to_HDF_ID(id, hid); ADFH_DEBUG(("ADFH_Set_Label [%s]",label)); if (label == NULL) { set_error(NULL_STRING_POINTER, err); return; } if (strlen(label) > ADF_NAME_LENGTH) { set_error(STRING_LENGTH_TOO_BIG, err); return; } if (is_link(hid)) { set_error(ADFH_ERR_LINK_DATA, err); return; } strcpy(label_name, label); set_str_att(hid, A_LABEL, label_name, err); } /* ----------------------------------------------------------------- */ /* Change attribute name and move the group name to new name */ void ADFH_Put_Name(const double pid, const double id, const char *name, int *err) { hid_t hpid; hid_t hid; char *nname, oname[ADF_NAME_LENGTH+1]; to_HDF_ID(pid,hpid); to_HDF_ID(id,hid); ADFH_DEBUG(("ADFH_Put_Name [%s]",name)); if ((nname = check_name(name, err)) == NULL) return; if (is_link(hpid)) { set_error(ADFH_ERR_LINK_DATA, err); return; } if (child_exists(hpid, nname)) { set_error(DUPLICATE_CHILD_NAME, err); return; } if (!get_str_att(hid, A_NAME, oname, err)) { #ifdef ADFH_DEBUG_ON printf("%s change [%s] to [%s]\n",ADFH_PREFIX,oname,nname); #endif if (H5Lmove(hpid, oname, hpid, nname, H5P_DEFAULT, H5P_DEFAULT) < 0) set_error(ADFH_ERR_LMOVE, err); else set_str_att(hid, A_NAME, nname, err); } } /* ----------------------------------------------------------------- */ /* Retrieve the name attribute value (same as group name) */ void ADFH_Get_Name(const double id, char *name, int *err) { hid_t hid; char buffname[ADF_NAME_LENGTH+1]; to_HDF_ID(id,hid); ADFH_DEBUG((">ADFH_Get_Name")); if (name == NULL) { set_error(NULL_STRING_POINTER, err); return; } get_str_att(hid, A_NAME, buffname, err); strcpy(name,buffname); ADFH_DEBUG(("ADFH_Get_Label [%f]",id)); if (label == NULL) { set_error(NULL_STRING_POINTER, err); return; } if ((hid = open_node(id, err)) >= 0) { get_str_att(hid, A_LABEL, bufflabel, err); if (H5Gclose(hid)<0) { ADFH_DEBUG((">ADFH H5Gclose failed (G)")); } } strcpy(label,bufflabel); ADFH_DEBUG(("ADFH_Create [%s][%d]",name,hpid)); if ((pname = check_name(name, err)) == NULL) return; if (id == NULL) { set_error(NULL_NODEID_POINTER, err); return; } /* if (is_link(hpid)) { set_error(ADFH_ERR_LINK_NODE, err); return; } */ if (child_exists(hpid, pname)) { set_error(DUPLICATE_CHILD_NAME, err); return; } *id = 0; gid = H5Gcreate2(hpid, pname, H5P_DEFAULT, mta_root->g_propgroupcreate, H5P_DEFAULT); #ifdef ADFH_DEBUG_ON H5Lget_info(hpid,pname,&lkbuff,H5P_DEFAULT); ADFH_DEBUG((">ADFH_Create [%s] index [%d]",pname,lkbuff.corder)); #endif if (gid < 0) set_error(ADFH_ERR_GCREATE, err); else { #ifdef ADFH_NO_ORDER if (new_str_att(gid, A_NAME, pname, ADF_NAME_LENGTH, err) || new_str_att(gid, A_LABEL, empty_label, ADF_NAME_LENGTH, err) || new_str_att(gid, A_TYPE, ADFH_MT, 2, err) || new_int_att(gid, A_FLAGS, mta_root->g_flags, err)) return; #else int order = 0; #if ADFH_HDF5_HAVE_112_API H5Literate2(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, count_children, (void *)&order); #else H5Literate(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, count_children, (void *)&order); #endif if (new_str_att(gid, A_NAME, pname, ADF_NAME_LENGTH, err) || new_str_att(gid, A_LABEL, empty_label, ADF_NAME_LENGTH, err) || new_str_att(gid, A_TYPE, ADFH_MT, 2, err) || new_int_att(gid, A_ORDER, order, err) || new_int_att(gid, A_FLAGS, mta_root->g_flags, err)) return; #endif to_ADF_ID(gid,*id); #ifndef ADFH_FORCE_ID_CLOSE track_id(hpid,gid); #endif ADFH_DEBUG(("ADFH_Number_of_Children")); if (number == NULL) { set_error(NULL_POINTER, err); return; } *number = 0; if ((hid = open_node(id, err)) >= 0) { #if ADFH_HDF5_HAVE_112_API H5Literate2(hid, mta_root->link_create_order, H5_ITER_NATIVE, &gskip, count_children, (void *)number); #else H5Literate(hid, mta_root->link_create_order, H5_ITER_NATIVE, &gskip, count_children, (void *)number); #endif H5Gclose(hid); } nn=*number; (void)nn; /* avoid unused variable warning */ ADFH_DEBUG(("ADFH_Get_Node_ID [%s][%d]",name,hpid)); *id = 0; set_error(NO_ERROR, err); if (*name == '/') { hid_t rid; char *path = (char *) malloc (strlen(name)+1); if (path == NULL) { set_error(MEMORY_ALLOCATION_FAILED, err); return; } strcpy(path, &name[1]); rid = H5Gopen2(hpid, "/", H5P_DEFAULT); sid = parse_path(rid, path, err); H5Gclose(rid); free(path); } else if (is_link(hpid)) { hid_t lid = open_link(hpid, err); ADFH_DEBUG(("i_start = istart; mta_root->i_len = ilen; mta_root->n_length = name_length; mta_root->n_names = 0; #ifdef ADFH_NO_ORDER mta_root->i_count = 0; #endif /*initialize names to null*/ memset(names, 0, (size_t)ilen*(size_t)name_length); if ((hpid = open_node(pid, err)) >= 0) { #if ADFH_HDF5_HAVE_112_API H5Literate2(hpid,H5_INDEX_CRT_ORDER,H5_ITER_INC, NULL,children_names,(void *)names); #else H5Literate(hpid,H5_INDEX_CRT_ORDER,H5_ITER_INC, NULL,children_names,(void *)names); #endif if (names[0]==0) { #if ADFH_HDF5_HAVE_112_API H5Literate2(hpid,H5_INDEX_NAME,H5_ITER_INC, NULL,children_names,(void *)names); #else H5Literate(hpid,H5_INDEX_NAME,H5_ITER_INC, NULL,children_names,(void *)names); #endif } H5Gclose(hpid); } *ilen_ret = mta_root->n_names; } /* ----------------------------------------------------------------- */ void ADFH_Children_IDs(const double pid, const int istart, const int icount, int *icount_ret, double *IDs, int *err) { hid_t hpid; ADFH_DEBUG(("ADFH_Children_IDs")); ROOT_OR_DIE(err); if (icount_ret == NULL) { set_error(NULL_POINTER, err); return; } if (IDs == NULL) { set_error(NULL_NODEID_POINTER, err); return; } IDs[0]=-1; mta_root->i_start = istart; mta_root->i_len = icount; mta_root->n_names = 0; #ifdef ADFH_NO_ORDER mta_root->i_count = 0; #endif if ((hpid = open_node(pid, err)) >= 0) { #if ADFH_HDF5_HAVE_112_API H5Literate2(hpid,mta_root->link_create_order,H5_ITER_INC, NULL,children_ids,(void *)IDs); #else H5Literate(hpid,mta_root->link_create_order,H5_ITER_INC, NULL,children_ids,(void *)IDs); #endif if (IDs[0]==-1) { set_error(CHILDREN_IDS_NOT_FOUND, err); return; } H5Gclose(hpid); } *icount_ret = mta_root->n_names; return; } /* ----------------------------------------------------------------- */ void ADFH_Release_ID(const double ID) { hid_t hid; ADFH_DEBUG(("ADFH_Release_ID")); to_HDF_ID(ID, hid); H5Gclose(hid); } /* ----------------------------------------------------------------- */ void ADFH_Database_Open(const char *name, const char *stat, const char *fmt, double *root, int *err) { hid_t fid, gid; char *format, buff[ADF_VERSION_LENGTH+1]; static const char root_name[ADF_NAME_LENGTH+1] = "HDF5 MotherNode"; static const char root_label[ADF_NAME_LENGTH+1] = "Root Node of HDF5 File"; int i, pos, mode; hid_t g_propfileopen; /* to be thread safe, should have critical section here */ if (mta_root==NULL) { mta_root=(ADFH_MTA*)malloc(sizeof(struct _ADFH_MTA)); mta_root->g_init = 0; } mta_root->g_error_state = 0; /* flags is int seen as bitfield, fortran flag is first 0x0001 it is found set to 1 in *all* MLL-based HDF5 files */ mta_root->g_flags = 1; mta_root->link_create_order = H5_INDEX_CRT_ORDER; #ifndef ADFH_DEBUG_ON H5Eset_auto2(H5E_DEFAULT, NULL, NULL); #endif if (!mta_root->g_init) { #ifndef ADFH_DEBUG_ON H5Eset_auto2(H5E_DEFAULT, walk_H5_error, NULL); #endif for (i = 0; i < ADFH_MAXIMUM_FILES; i++) mta_root->g_files[i] = 0; mta_root->g_init = 1; /* create properties - these are persistent across all open files. When all files are closed, then delete properties */ /* H5Pclose performed at file close time */ mta_root->g_proplink=H5Pcreate(H5P_LINK_ACCESS); H5Pset_nlinks(mta_root->g_proplink, ADF_MAXIMUM_LINK_DEPTH); mta_root->g_propgroupcreate=H5Pcreate(H5P_GROUP_CREATE); H5Pset_link_creation_order(mta_root->g_propgroupcreate, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); mta_root->g_propdataset=H5Pcreate(H5P_DATASET_CREATE); H5Pset_alloc_time(mta_root->g_propdataset, H5D_ALLOC_TIME_EARLY); H5Pset_fill_time(mta_root->g_propdataset, H5D_FILL_TIME_NEVER); } if (name == NULL || stat == NULL || fmt == NULL) { set_error(NULL_STRING_POINTER, err); return; } ADFH_DEBUG(("ADFH_Database_Open [%s]",name)); /* get open mode */ strncpy(buff, stat, 9); buff[9] = 0; for (i = 0; buff[i]; i++) buff[i] = TO_UPPER(buff[i]); if (0 == strcmp(buff, "NEW")) { mode = ADFH_MODE_NEW; } else if (0 == strcmp(buff, "READ_ONLY")) { mode = ADFH_MODE_RDO; } else if (0 == strcmp(buff, "OLD")) { mode = ADFH_MODE_OLD; } else { set_error(ADF_FILE_STATUS_NOT_RECOGNIZED, err); return; } /* get format */ #if 0 if (mode == ADFH_MODE_NEW) { strncpy(buff, fmt, 11); buff[11] = 0; for (i = 0; buff[i]; i++) buff[i] = TO_UPPER(buff[i]); if (strcmp(buff, "NATIVE") && strncmp(buff, "IEEE_BIG", 8) && strcmp(buff, "IEEE_LITTLE", 11) && strcmp(buff, "CRAY")) { set_error(ADF_FILE_FORMAT_NOT_RECOGNIZED, err); return; } } #endif /* get unused slot */ for (pos = 0; pos < ADFH_MAXIMUM_FILES; pos++) { if (mta_root->g_files[pos] == 0) break; } if (pos == ADFH_MAXIMUM_FILES) { set_error(TOO_MANY_ADF_FILES_OPENED, err); return; } g_propfileopen = H5Pcreate(H5P_FILE_ACCESS); /* HDF5 tuning parameters */ /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title72 * 'Sets the minimum metadata block size.' * Default setting is 2048 bytes. */ if ( h5pset_meta_block_size_size != ADFH_CONFIG_DEFAULT ) { H5Pset_meta_block_size(g_propfileopen, h5pset_meta_block_size_size); } /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title41 * 'Sets alignment properties of a file access property list.' * Default is no alignment. * ATTENTION: this can increase filesize dramatically if lots of small datasets */ if ( h5pset_alignment_alignment != ADFH_CONFIG_DEFAULT ) { H5Pset_alignment(g_propfileopen, h5pset_alignment_threshold, h5pset_alignment_alignment); } /* https://docs.hdfgroup.org/hdf5/develop/group___d_x_p_l.html#title16 * 'Sets type conversion and background buffers. * 1 MByte is default. */ if ( h5pset_buffer_size_size != ADFH_CONFIG_DEFAULT ) { void *tconv=NULL; void *bkg=NULL; H5Pset_buffer(g_propfileopen, h5pset_buffer_size_size, tconv, bkg); } /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title78 * 'Used by file drivers that are capable of using data sieving.' * 1 MByte is default. */ if ( h5pset_sieve_buf_size_size != ADFH_CONFIG_DEFAULT ) { H5Pset_sieve_buf_size(g_propfileopen, h5pset_sieve_buf_size_size); } /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title48 * 'Sets the number of files that can be held open in an external link open file cache.' * 0 size is default. */ if ( h5pset_elink_file_cache_size_size != ADFH_CONFIG_DEFAULT ) { H5Pset_elink_file_cache_size(g_propfileopen, h5pset_elink_file_cache_size_size); } #ifdef ADFH_H5F_CLOSE_STRONG /* set access property to close all open accesses when file closed */ H5Pset_fclose_degree(g_propfileopen, H5F_CLOSE_STRONG); #endif /* open the file */ #if CG_BUILD_PARALLEL int flag = 0; /* check if we are actually running a parallel program */ MPI_Initialized(&flag); if(flag) { /* Set the access property list to use MPI */ if (0 == strcmp(fmt, "PARALLEL")) { if(!ctx_cgio.pcg_mpi_info) ctx_cgio.pcg_mpi_info = MPI_INFO_NULL; #if HDF5_HAVE_COLL_METADATA H5Pset_coll_metadata_write(g_propfileopen, 1); #endif /*HDF5_HAVE_COLL_METADATA*/ H5Pset_fapl_mpio(g_propfileopen, ctx_cgio.pcg_mpi_comm, ctx_cgio.pcg_mpi_info); } } #endif /* check for an error if core file driver is set to write memory to file, but the CGNS file mode was set to read only */ if( (core_vfd_backing_store == 1) && (mode == ADFH_MODE_RDO) ) { ADFH_DEBUG(("File mode read-only, but diskless option set to write")); set_error(ADFH_ERR_INVALID_OPTION, err); return; } if(core_vfd == 1) { H5Pset_fapl_core(g_propfileopen, core_vfd_increment, core_vfd_backing_store); } set_error(NO_ERROR, err); if (mode == ADFH_MODE_NEW) { /* Compatibility with V1.8 */ H5Pset_libver_bounds(g_propfileopen, #if ADFH_HDF5_HAVE_110_API H5F_LIBVER_V18, H5F_LIBVER_V18); #else H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); #endif hid_t g_propfilecreate = H5Pcreate(H5P_FILE_CREATE); /* HDF5 tuning parameters */ /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title72 * 'Sets the minimum metadata block size.' * Default setting is 2048 bytes. */ if ( h5pset_meta_block_size_size != ADFH_CONFIG_DEFAULT ) { H5Pset_meta_block_size(g_propfileopen, h5pset_meta_block_size_size); } /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title41 * 'Sets alignment properties of a file access property list.' * Default is no alignment. * ATTENTION: this can increase filesize dramatically if lots of small datasets */ if ( h5pset_alignment_alignment != ADFH_CONFIG_DEFAULT ) { H5Pset_alignment(g_propfileopen, h5pset_alignment_threshold, h5pset_alignment_alignment); } /* https://docs.hdfgroup.org/hdf5/develop/group___d_x_p_l.html#title16 * 'Sets type conversion and background buffers. * 1 MByte is default. */ if ( h5pset_buffer_size_size != ADFH_CONFIG_DEFAULT ) { void *tconv=NULL; void *bkg=NULL; H5Pset_buffer(g_propfileopen, h5pset_buffer_size_size, tconv, bkg); } /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title78 * 'Used by file drivers that are capable of using data sieving.' * 1 MByte is default. */ if ( h5pset_sieve_buf_size_size != ADFH_CONFIG_DEFAULT ) { H5Pset_sieve_buf_size(g_propfileopen, h5pset_sieve_buf_size_size); } /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title48 * 'Sets the number of files that can be held open in an external link open file cache.' * 0 size is default. */ if ( h5pset_elink_file_cache_size_size != ADFH_CONFIG_DEFAULT ) { H5Pset_elink_file_cache_size(g_propfileopen, h5pset_elink_file_cache_size_size); } #if 0 /* MSB -- DISABLED as it is not compatible with HDF5 1.8 file format, need to resolve this CGNS-166 */ #if HDF5_HAVE_FILE_SPACE_STRATEGY H5Pset_file_space_strategy(g_propfilecreate, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1); #endif #endif /* add creation time for groups (used by iterators) (prop set to file creation )*/ H5Pset_link_creation_order(g_propfilecreate, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); fid = H5Fcreate(name, H5F_ACC_TRUNC, g_propfilecreate, g_propfileopen); H5Pclose(g_propfilecreate); H5Pclose(g_propfileopen); if (fid < 0) { set_error(FILE_OPEN_ERROR, err); return; } gid = H5Gopen2(fid, "/", H5P_DEFAULT); memset(buff, 0, ADF_VERSION_LENGTH+1); ADFH_Library_Version(buff, err); format = native_format(); if (new_str_att(gid, A_NAME, root_name, ADF_NAME_LENGTH, err) || new_str_att(gid, A_LABEL, root_label, ADF_NAME_LENGTH, err) || new_str_att(gid, A_TYPE, ADFH_MT, 2, err) || new_str_data(gid, D_FORMAT, format, (int)strlen(format), err) || new_str_data(gid, D_VERSION, buff, ADF_VERSION_LENGTH, err)) { H5Gclose(gid); return; } } else { #if ADFH_HDF5_HAVE_112_API if (H5Fis_accessible(name, H5P_DEFAULT) <= 0) { #else if (H5Fis_hdf5(name) <= 0) { #endif H5Pclose(g_propfileopen); set_error(ADFH_ERR_NOT_HDF5_FILE, err); return; } #if CG_BUILD_PARALLEL #if HDF5_HAVE_COLL_METADATA H5Pset_all_coll_metadata_ops( g_propfileopen, 1 ); #endif #endif if (mode == ADFH_MODE_RDO) { /* Patch to read file created with CGNS 3.3 and hdf5 > 1.8 */ H5Pset_libver_bounds(g_propfileopen, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); fid = H5Fopen(name, H5F_ACC_RDONLY, g_propfileopen); } else { #if !ADFH_HDF5_HAVE_110_API H5Pset_libver_bounds(g_propfileopen, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); #endif fid = H5Fopen(name, H5F_ACC_RDWR, g_propfileopen); #if ADFH_HDF5_HAVE_110_API hid_t access_fapl = H5Fget_access_plist(fid); H5F_libver_t low, high; /* File format bounds */ H5Pget_libver_bounds(access_fapl, &low, &high); if(low > H5F_LIBVER_V18) { /* NOTE: HDF5 can not downgrade to a lower version bound (which can be done with h5repack), so the best that can be done is not to use a version higher than the lower bound. */ H5Fset_libver_bounds(fid, low, low); } else { H5Fset_libver_bounds(fid, H5F_LIBVER_V18, H5F_LIBVER_V18); } H5Pclose(access_fapl); #endif } H5Pclose(g_propfileopen); if (fid < 0) { set_error(FILE_OPEN_ERROR, err); return; } /* NOTE: Creation order was set by default in CGNS 3.1.3, so a CGNS file created by earlier versions will not have this set. Therefore, it should not be automatically assumed to be set in H5Literate. */ gid = H5Gopen2(fid, "/", H5P_DEFAULT); /* Obtain the group creation flags and check for link creation ordering. */ { hid_t pid; unsigned int crt_order_flags; pid = H5Gget_create_plist(gid); H5Pget_link_creation_order(pid, &crt_order_flags); if (crt_order_flags == 0) { mta_root->link_create_order = H5_INDEX_NAME; } else { mta_root->link_create_order = H5_INDEX_CRT_ORDER; } H5Pclose(pid); } #ifdef ADFH_FORTRAN_INDEXING if (mode != ADFH_MODE_RDO && child_exists(gid, D_OLDVERS)) { #if ADFH_HDF5_HAVE_112_API H5Literate2(gid, mta_root->link_create_order, H5_ITER_INC, NULL, fix_dimensions, NULL); #else H5Literate(gid, mta_root->link_create_order, H5_ITER_INC, NULL, fix_dimensions, NULL); #endif H5Lmove(gid, D_OLDVERS, gid, D_VERSION, H5P_DEFAULT, H5P_DEFAULT); } #endif } mta_root->g_files[pos] = fid; #ifndef ADFH_FORCE_ID_CLOSE mta_root->g_extids[pos]=NULL; mta_root->n_extids[pos]=0; mta_root->x_extids[pos]=-1; track_id(fid,gid); #endif to_ADF_ID(gid, *root); } /* ----------------------------------------------------------------- */ void ADFH_Database_Valid(const char *name, int *err) { if (NULL == name || 0 == *name) *err = NULL_STRING_POINTER; else #if ADFH_HDF5_HAVE_112_API *err = H5Fis_accessible(name, H5P_DEFAULT); #else *err = H5Fis_hdf5(name); #endif } /* ----------------------------------------------------------------- */ void ADFH_Database_Get_Format(const double rootid, char *format, int *err) { char node[ADF_NAME_LENGTH+1]; hid_t did, hid; herr_t status; hid_t xfer_prp = H5P_DEFAULT; ADFH_DEBUG(("ADFH_Database_Get_Format")); if (format == NULL) { set_error(NULL_STRING_POINTER, err); return; } *format = 0; set_error(NO_ERROR, err); sprintf(node, "/%s", D_FORMAT); to_HDF_ID(rootid,hid); if ((did = H5Dopen2(hid, node, H5P_DEFAULT)) < 0) { set_error(ADFH_ERR_DOPEN, err); return; } #if CG_BUILD_PARALLEL hid_t fid = get_file_id(hid); hid_t fapl=H5Fget_access_plist(fid); hid_t driver_id = H5Pget_driver(fapl); H5Pclose(fapl); /* close the property list */ if (driver_id == H5FD_MPIO) { xfer_prp = H5Pcreate(H5P_DATASET_XFER); ADFH_CHECK_HID(xfer_prp); H5Pset_dxpl_mpio(xfer_prp, H5FD_MPIO_COLLECTIVE); } #endif status = H5Dread(did, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, xfer_prp, format); H5Dclose(did); #if CG_BUILD_PARALLEL if (driver_id == H5FD_MPIO) { H5Pclose(xfer_prp); } #endif if (status < 0) set_error(ADFH_ERR_DREAD, err); } /* ----------------------------------------------------------------- */ void ADFH_Database_Set_Format(const double rootid, const char *format, int *err) { ADFH_DEBUG(("ADFH_Database_Set_Format")); set_error(ADFH_ERR_NOT_IMPLEMENTED, err); } /* ----------------------------------------------------------------- */ void ADFH_Database_Delete(const char *name, int *err) { ADFH_DEBUG(("ADFH_Database_Delete [%s]",name)); #if ADFH_HDF5_HAVE_112_API if (H5Fis_accessible(name, H5P_DEFAULT) <=0) #else if (H5Fis_hdf5(name) <= 0) #endif set_error(ADFH_ERR_NOT_HDF5_FILE, err); else if (UNLINK(name)) set_error(ADFH_ERR_FILE_DELETE, err); else set_error(NO_ERROR, err); } /* ----------------------------------------------------------------- */ void ADFH_Database_Close(const double root, int *status) { int fn,idx; hid_t hid,fid; ssize_t nobj,n; #ifdef ADFH_FORCE_ID_CLOSE hid_t *objs; #endif ADFH_DEBUG(("ADFH_Database_Close")); if (mta_root == NULL) { ADFH_DEBUG(("ADFH_Database_Close [mta is null]")); return; } ADFH_DEBUG(("ADFH_Database_Close 4")); to_HDF_ID(root,hid); if ((fn = get_file_number(hid, status)) < 0) return; fid = mta_root->g_files[fn]; mta_root->g_files[fn] = 0; #if !defined(ADFH_H5F_CLOSE_STRONG) && !defined(ADFH_FORCE_ID_CLOSE) /* this gets the file data to disk even if there are open objects */ H5Fflush(fid, H5F_SCOPE_LOCAL); #endif /* free up all open accesses */ #ifndef ADFH_FORCE_ID_CLOSE for (nobj=0;nobjn_extids[fn];nobj++) { ADFH_DEBUG(("ADFH_Database_Close 3 [%.6d/%.6d]:[%d]",\ nobj,mta_root->n_extids[fn],mta_root->g_extids[fn][nobj])); if (H5Iis_valid(mta_root->g_extids[fn][nobj])) { H5Oclose(mta_root->g_extids[fn][nobj]); } } #else ADFH_DEBUG(("ADFH_Database_Close 3")); nobj = H5Fget_obj_count(fid, H5F_OBJ_ALL|H5F_OBJ_LOCAL); if (nobj) { objs = (hid_t *) malloc (nobj * sizeof(hid_t)); /* close datatypes */ nobj = H5Fget_obj_count(fid, H5F_OBJ_DATATYPE|H5F_OBJ_LOCAL); #ifdef ADFH_DEBUG_ON printf("%s close DataType [%zd] HIDs\n",ADFH_PREFIX,nobj); #endif if (nobj) { H5Fget_obj_ids(fid, H5F_OBJ_DATATYPE|H5F_OBJ_LOCAL, -1, objs); for (n = 0; n < nobj; n++) H5Tclose(objs[n]); } /* close datasets */ nobj = H5Fget_obj_count(fid, H5F_OBJ_DATASET|H5F_OBJ_LOCAL); #ifdef ADFH_DEBUG_ON printf("%s close DataSet [%zd] HIDs\n",ADFH_PREFIX,nobj); #endif if (nobj) { H5Fget_obj_ids(fid, H5F_OBJ_DATASET|H5F_OBJ_LOCAL, -1, objs); for (n = 0; n < nobj; n++) H5Dclose(objs[n]); } /* close attributes */ nobj = H5Fget_obj_count(fid, H5F_OBJ_ATTR|H5F_OBJ_LOCAL); #ifdef ADFH_DEBUG_ON printf("%s close Attr [%zd] HIDs\n",ADFH_PREFIX,nobj); #endif if (nobj) { H5Fget_obj_ids(fid, H5F_OBJ_ATTR|H5F_OBJ_LOCAL, -1, objs); for (n = 0; n < nobj; n++) H5Aclose(objs[n]); } /* close groups */ nobj = H5Fget_obj_count(fid, H5F_OBJ_GROUP|H5F_OBJ_LOCAL); #ifdef ADFH_DEBUG_ON printf("%s close Group [%zd] HIDs\n",ADFH_PREFIX,nobj); #endif if (nobj) { H5Fget_obj_ids(fid, H5F_OBJ_GROUP|H5F_OBJ_LOCAL, -1, objs); for (n = 0; n < nobj; n++) H5Gclose(objs[n]); } #if 0 /* close file accesses except for current */ nobj = H5Fget_obj_count(fid, H5F_OBJ_FILE|H5F_OBJ_LOCAL); if (nobj) { H5Fget_obj_ids(fid, H5F_OBJ_FILE|H5F_OBJ_LOCAL, -1, objs); for (n = 0; n < nobj; n++) { if (objs[n] != fid) H5Fclose(objs[n]); } } #endif free (objs); } #endif ADFH_DEBUG(("ADFH_Database_Close 2")); /* close file */ if (H5Fclose(fid) < 0) set_error(FILE_CLOSE_ERROR, status); else set_error(NO_ERROR, status); #ifndef ADFH_FORCE_ID_CLOSE free(mta_root->g_extids[fn]); #endif ADFH_DEBUG(("ADFH_Database_Close 1")); idx=0; for (n = 0; n < ADFH_MAXIMUM_FILES; n++) { if (mta_root->g_files[n]) { idx++; } } /* if no more files open, close properties and free MTA */ if (idx == 0) { H5Pclose(mta_root->g_proplink); H5Pclose(mta_root->g_propgroupcreate); H5Pclose(mta_root->g_propdataset); free(mta_root); mta_root=NULL; } ADFH_DEBUG(("ADFH_Database_Close 0")); } /* ----------------------------------------------------------------- */ void ADFH_Is_Link(const double id, int *link_path_length, int *err) { hid_t hid; to_HDF_ID(id,hid); ADFH_DEBUG(("ADFH_Is_Link")); if (is_link(hid)) { hid_t did, sid; hsize_t size; did = H5Dopen2(hid, D_PATH, H5P_DEFAULT); ADFH_CHECK_HID(did); sid = H5Dget_space(did); ADFH_CHECK_HID(sid); size = H5Sget_simple_extent_npoints(sid); H5Sclose(sid); H5Dclose(did); *link_path_length = (int)size; if (child_exists(hid, D_FILE)) { did = H5Dopen2(hid, D_FILE, H5P_DEFAULT); ADFH_CHECK_HID(did); sid = H5Dget_space(did); ADFH_CHECK_HID(sid); size = H5Sget_simple_extent_npoints(sid); H5Sclose(sid); H5Dclose(did); *link_path_length += (int)size; } } else *link_path_length = 0; set_error(NO_ERROR, err); } /* ----------------------------------------------------------------- */ void ADFH_Link_Size(const double id, int *file_len, int *name_len, int *err) { hid_t hid; to_HDF_ID(id,hid); ADFH_DEBUG(("ADFH_Link_Size")); *name_len = *file_len = 0; if (is_link(hid)) { hid_t did, sid; hsize_t size; did = H5Dopen2(hid, D_PATH, H5P_DEFAULT); sid = H5Dget_space(did); size = H5Sget_simple_extent_npoints(sid); H5Sclose(sid); H5Dclose(did); *name_len = (int)size; if (child_exists(hid, D_FILE)) { did = H5Dopen2(hid, D_FILE, H5P_DEFAULT); sid = H5Dget_space(did); size = H5Sget_simple_extent_npoints(sid); H5Sclose(sid); H5Dclose(did); *file_len = (int)size; } } set_error(NO_ERROR, err); } /* ----------------------------------------------------------------- */ void ADFH_Get_Root_ID(const double id, double *root_id, int *err) { hid_t rid, hid; ADFH_DEBUG(("ADFH_Get_Root_ID")); to_HDF_ID(id, hid); rid = H5Gopen2(hid, "/", H5P_DEFAULT); if (rid < 0) set_error(ADFH_ERR_GOPEN, err); else { to_ADF_ID(rid, *root_id); set_error(NO_ERROR, err); } #ifndef ADFH_FORCE_ID_CLOSE track_id(hid,rid); #endif ADFH_DEBUG(("ADFH_Get_Root_ID root id [%d]",rid)); } /* ----------------------------------------------------------------- */ void ADFH_Get_Data_Type(const double id, char *data_type, int *err) { hid_t hid; char buffdata_type[3]; ADFH_DEBUG(("ADFH_Get_Data_Type")); if ((hid = open_node(id, err)) >= 0) { get_str_att(hid, A_TYPE, buffdata_type, err); H5Gclose(hid); strcpy(data_type,buffdata_type); } } /* ----------------------------------------------------------------- */ void ADFH_Get_Number_of_Dimensions(const double id, int *num_dims, int *err) { hid_t hid, did, sid; char type[3]; ADFH_DEBUG(("ADFH_Get_Number_of_Dimensions")); *num_dims = 0; if ((hid = open_node(id, err)) < 0) return; if (get_str_att(hid, A_TYPE, type, err) || 0 == strcmp(type, ADFH_MT) || 0 == strcmp(type, ADFH_LK)) { H5Gclose(hid); return; } if ((did = H5Dopen2(hid, D_DATA, H5P_DEFAULT)) < 0) set_error(NO_DATA, err); else { if ((sid = H5Dget_space(did)) < 0) set_error(ADFH_ERR_DGET_SPACE, err); else { *num_dims = H5Sget_simple_extent_ndims(sid); H5Sclose(sid); } H5Dclose(did); } H5Gclose(hid); } /* ----------------------------------------------------------------- */ void ADFH_Get_Dimension_Values(const double id, cgsize_t dim_vals[], int *err) { int i, ndims, swap = 0; hid_t hid, did, sid; hsize_t temp_vals[ADF_MAX_DIMENSIONS]; ADFH_DEBUG(("ADFH_Get_Dimension_Values")); ndims=0; dim_vals[0]=0; if ((hid = open_node(id, err)) < 0) return; if ((did = H5Dopen2(hid, D_DATA, H5P_DEFAULT)) < 0) set_error(NO_DATA, err); else { if ((sid = H5Dget_space(did)) < 0) set_error(ADFH_ERR_DGET_SPACE, err); else { ndims = H5Sget_simple_extent_ndims(sid); if (ndims > 0) { H5Sget_simple_extent_dims(sid, temp_vals, NULL); #if CG_SIZEOF_SIZE == 32 for (i = 0; i < ndims; i++) { if (temp_vals[i] > CG_MAX_INT32) { set_error(MAX_INT32_SIZE_EXCEEDED, err); break; } } #endif #ifdef ADFH_FORTRAN_INDEXING if (ndims > 1) swap = swap_dimensions(hid); #endif if (swap) { for (i = 0; i < ndims; i++) { dim_vals[i] = (cgsize_t)temp_vals[ndims-1-i]; } } else { for (i = 0; i < ndims; i++) { dim_vals[i] = (cgsize_t)temp_vals[i]; } } } H5Sclose(sid); } H5Dclose(did); } H5Gclose(hid); } /* ----------------------------------------------------------------- */ void ADFH_Put_Dimension_Information(const double id, const char *data_type, const int dims, const cgsize_t dim_vals[], const int HDF5storage_type, int *err) { hid_t hid; hid_t did, tid, sid; int i, swap = 0; hsize_t new_dims[ADF_MAX_DIMENSIONS]; char new_type[3]; to_HDF_ID(id,hid); ADFH_DEBUG(("ADFH_Put_Dimension_Information [%d]",hid)); if (is_link(hid)) { set_error(ADFH_ERR_LINK_DATA, err); return; } for (i = 0; i < 2; i++) new_type[i] = TO_UPPER(data_type[i]); new_type[2] = 0; if (0 == strcmp(new_type, ADFH_MT)) { if (data_exists(hid)) H5Ldelete(hid, D_DATA, H5P_DEFAULT); set_str_att(hid, A_TYPE, new_type, err); return; } if (check_data_type(new_type, err)) return; if (dims < 1 || dims > ADF_MAX_DIMENSIONS) { set_error(BAD_NUMBER_OF_DIMENSIONS, err); return; } for (i = 0; i < dims; i++) { if (dim_vals[i] < 1) { set_error(BAD_DIMENSION_VALUE, err); return; } } /* * The ADF documentation allows the dimension values to be changed * without affecting the data, so long as the data type and number * of dimensions are the same. With HDF5, we could emulate that by * using extendable data spaces (with chunking). However this only * allows the data size to increase, not decrease, and coming up * with a good value for chunking is difficult. Since changing the * dimension values without rewriting the data is not a common * operation, I decided to use fixed sizes, then buffer the data * in these rare cases. */ if(data_exists(hid)) { ADFH_DEBUG(("ADFH_Put_Dimension_Information unlink [%d]",hid)); H5Ldelete(hid, D_DATA, H5P_DEFAULT); } if (set_str_att(hid, A_TYPE, new_type, err)) { return; } /* recreate the data space with the new values */ #ifdef ADFH_FORTRAN_INDEXING if (dims > 1) swap = swap_dimensions(hid); #endif if (swap) { for (i = 0; i < dims; i++) new_dims[i] = (hsize_t)dim_vals[dims-1-i]; } else { for (i = 0; i < dims; i++) new_dims[i] = (hsize_t)dim_vals[i]; } tid = to_HDF_data_type(new_type); ADFH_CHECK_HID(tid); sid = H5Screate_simple(dims, new_dims, NULL); /* better idea? how to guess the right size? */ if (CompressData >= 0) { H5Pset_deflate(mta_root->g_propdataset, CompressData); } #if 0 this causes a problem with memory allocation. For example, writing an unstructured coordinate array of 5 billion values will result in the HDF5 library trying to allocation 20Gb of memory for the chunk, since the first dimension is 5 billion. We really need to try to do something more intelligent here H5Pset_chunk(mta_root->g_propdataset, dims, new_dims); #endif hssize_t dset_size = H5Sget_select_npoints(sid); size_t dtype_size = H5Tget_size(tid); /* Chunked datasets are currently not supported */ /* Compact storage has a dataset size limit of 64 KiB */ if(HDF5storage_type == CGIO_COMPACT && dset_size*(hssize_t)dtype_size < (hssize_t)CGNS_64KB) H5Pset_layout(mta_root->g_propdataset, H5D_COMPACT); else{ H5Pset_layout(mta_root->g_propdataset, H5D_CONTIGUOUS); H5Pset_alloc_time(mta_root->g_propdataset, H5D_ALLOC_TIME_EARLY); H5Pset_fill_time(mta_root->g_propdataset, H5D_FILL_TIME_NEVER); } ADFH_CHECK_HID(sid); did = H5Dcreate2(hid, D_DATA, tid, sid, H5P_DEFAULT, mta_root->g_propdataset, H5P_DEFAULT); /* H5Eprint1(stdout);*/ ADFH_CHECK_HID(did); H5Sclose(sid); H5Tclose(tid); if (did < 0) set_error(ADFH_ERR_DCREATE, err); else { H5Dclose(did); set_error(NO_ERROR, err); } } /* ----------------------------------------------------------------- */ void ADFH_Get_Link_Path(const double id, char *filename, char *link_path, int *err) { hid_t hid, did; hid_t xfer_prp = H5P_DEFAULT; ADFH_DEBUG(("ADFH_Get_Link_Path")); to_HDF_ID(id,hid); ADFH_CHECK_HID(hid); if (!is_link(hid)) { set_error(NODE_IS_NOT_A_LINK, err); return; } #if CG_BUILD_PARALLEL if (ctx_cgio.pcg_mpi_initialized && strcmp(ctx_cgio.hdf5_access, "PARALLEL") == 0) { xfer_prp = H5Pcreate(H5P_DATASET_XFER); ADFH_CHECK_HID(xfer_prp); H5Pset_dxpl_mpio(xfer_prp, H5FD_MPIO_COLLECTIVE); } #endif did = H5Dopen2(hid, D_PATH, H5P_DEFAULT); ADFH_CHECK_HID(did); H5Dread(did, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, xfer_prp, link_path); H5Dclose(did); if (child_exists(hid, D_FILE)) { did = H5Dopen2(hid, D_FILE, H5P_DEFAULT); ADFH_CHECK_HID(did); H5Dread(did, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, xfer_prp, filename); H5Dclose(did); } else { *filename = 0; } #if CG_BUILD_PARALLEL if (ctx_cgio.pcg_mpi_initialized && strcmp(ctx_cgio.hdf5_access, "PARALLEL") == 0) { H5Pclose(xfer_prp); } #endif set_error(NO_ERROR, err); } /* ----------------------------------------------------------------- */ void ADFH_Link(const double pid, const char *name, const char *file, const char *name_in_file, double *id, int *err) { char *target; herr_t status; hid_t lid, hid; (void)hid; /* avoid unused variable warning */ ADFH_DEBUG(("ADFH_Link [%s][%s][%s]",name,file,name_in_file)); ROOT_OR_DIE(err); ADFH_Create(pid, name, id, err); if (*err != NO_ERROR) return; to_HDF_ID(*id,lid); ADFH_CHECK_HID(lid); if (set_str_att(lid, A_TYPE, ADFH_LK, err)) return; /* * If this is a link to a file, then need to create external link * Otherwise, create a soft link */ if (*file) { /* actual link is in the D_LINK group to avoid collision with "real" node because we cannot have a node ID and a link on this ID (can we?) set actual link to D_LINK name (not the current node) */ H5Lcreate_external(file, name_in_file, lid, D_LINK, H5P_DEFAULT, mta_root->g_proplink); } else { target = (char *) malloc (strlen(name_in_file)+2); if (target == NULL) { set_error(MEMORY_ALLOCATION_FAILED, err); return; } if (*name_in_file == '/') strcpy(target, name_in_file); else sprintf(target, "/%s", name_in_file); /* create a soft link */ status = H5Lcreate_soft(target, lid, D_LINK, H5P_DEFAULT, H5P_DEFAULT); free(target); if (status < 0) { set_error(ADFH_ERR_GLINK, err); return; } } /* save link path and file */ if (new_str_data(lid,D_PATH,name_in_file,(int)strlen(name_in_file),err)) return; if (*file && new_str_data(lid,D_FILE,file,(int)strlen(file),err)) return; #ifndef ADFH_FORCE_ID_CLOSE hid_t hid; to_HDF_ID(pid,hid); track_id(hid,lid); #endif set_error(NO_ERROR, err); } /* ----------------------------------------------------------------- */ void ADFH_Flush_to_Disk(const double id, int *err) { hid_t hid; ADFH_DEBUG(("ADFH_Flush_to_Disk")); to_HDF_ID(id,hid); if(H5Fflush(hid, H5F_SCOPE_LOCAL) >=0 ) set_error(NO_ERROR, err); else set_error(FFLUSH_ERROR, err); } /* ----------------------------------------------------------------- */ void ADFH_Database_Garbage_Collection(const double id, int *err) { ADFH_DEBUG(("ADFH_Database_Garbage_Collection")); if(H5garbage_collect() >= 0) set_error(NO_ERROR, err); else set_error(NO_DATA, err); } /* ----------------------------------------------------------------- */ void ADFH_Database_Version(const double root_id, char *version, char *creation_date, char *modification_date, int *err) { char buff[ADF_VERSION_LENGTH+1]; char node[ADF_NAME_LENGTH+1]; hid_t hid, did; herr_t status; hid_t xfer_prp = H5P_DEFAULT; ADFH_DEBUG(("ADFH_Database_Version")); if (version == NULL) { set_error(NULL_STRING_POINTER, err); return; } *version = 0; if (creation_date != NULL) *creation_date = 0; if (modification_date != NULL) *modification_date = 0; set_error(NO_ERROR, err); sprintf(node, "/%s", D_VERSION); to_HDF_ID(root_id,hid); if ((did = H5Dopen2(hid, node, H5P_DEFAULT)) < 0) { #ifdef ADFH_FORTRAN_INDEXING sprintf(node, "/%s", D_OLDVERS); if ((did = H5Dopen2(hid, node, H5P_DEFAULT)) < 0) { set_error(ADFH_ERR_DOPEN, err); return; } #else set_error(ADFH_ERR_DOPEN, err); return; #endif } #if CG_BUILD_PARALLEL hid_t fid = get_file_id(hid); hid_t fapl = H5Fget_access_plist(fid); hid_t driver_id = H5Pget_driver(fapl); H5Pclose(fapl); /* close the property list */ if (driver_id == H5FD_MPIO) { xfer_prp = H5Pcreate(H5P_DATASET_XFER); ADFH_CHECK_HID(xfer_prp); H5Pset_dxpl_mpio(xfer_prp, H5FD_MPIO_COLLECTIVE); } #endif status = H5Dread(did, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, xfer_prp, buff); H5Dclose(did); #if CG_BUILD_PARALLEL if (driver_id == H5FD_MPIO) { H5Pclose(xfer_prp); } #endif if (status < 0) set_error(ADFH_ERR_DREAD, err); else strcpy(version, buff); } /* ----------------------------------------------------------------- */ void ADFH_Library_Version(char *version, int *err) { unsigned maj, min, rel; ADFH_DEBUG(("ADFH_Library_Version")); if (version == NULL) { set_error(NULL_STRING_POINTER, err); return; } H5get_libversion(&maj, &min, &rel); sprintf(version, "HDF5 Version %u.%u.%u", maj, min, rel); set_error(NO_ERROR, err); } /* ----------------------------------------------------------------- */ void ADFH_Set_Error_State(const int error_state, int *error_return) { ADFH_DEBUG(("ADFH_Set_Error_State")); ROOT_OR_DIE(error_return); mta_root->g_error_state = error_state; set_error(NO_ERROR, error_return); } /* ----------------------------------------------------------------- */ void ADFH_Error_Message(const int error_return_input, char *error_string ) { int i; ADFH_DEBUG(("ADFH_Error_Message")); if (error_string == NULL) return; for (i = 0; i < NUM_ERRORS; i++) { if (ErrorList[i].errcode == error_return_input) { strcpy(error_string, ErrorList[i].errmsg); return; } } sprintf(error_string, "error number %d", error_return_input); } /* ----------------------------------------------------------------- */ void ADFH_Get_Error_State(int *error_state, int *error_return) { ADFH_DEBUG(("ADFH_Get_Error_State")); ROOT_OR_DIE(error_return); *error_state = mta_root->g_error_state; set_error(NO_ERROR, error_return); } /* ----------------------------------------------------------------- */ void ADFH_Read_Block_Data(const double ID, const cgsize_t b_start, const cgsize_t b_end, const char *m_data_type, void *data, int *err ) { hid_t hid, did, mid, dspace; size_t size, count, offset; char *buff; hid_t xfer_prp = H5P_DEFAULT; ADFH_DEBUG(("ADFH_Read_Block_Data")); if (data == NULL) { set_error(NULL_POINTER, err); return; } if (b_start > b_end) { set_error(MINIMUM_GT_MAXIMUM, err); return; } if (b_start < 1) { set_error(START_OUT_OF_DEFINED_RANGE, err); return; } if ((hid = open_node(ID, err)) < 0) return; if (!data_exists(hid)) { H5Gclose(hid); set_error(NO_DATA, err); return; } if ((did = H5Dopen2(hid, D_DATA, H5P_DEFAULT)) < 0) { H5Gclose(hid); set_error(ADFH_ERR_DOPEN, err); return; } dspace = H5Dget_space(did); ADFH_CHECK_HID(dspace); count = (size_t)H5Sget_simple_extent_npoints(dspace); H5Sclose(dspace); if ((size_t)b_end > count) { H5Dclose(did); H5Gclose(hid); set_error(END_OUT_OF_DEFINED_RANGE, err); return; } /* instead of trying to compute data space extents from * b_start and b_end, just read all the data into a * 1-d array and copy the range we want */ if (m_data_type) { mid = to_HDF_data_type(m_data_type); } else { set_error(INVALID_DATA_TYPE, err); return; } ADFH_CHECK_HID(mid); size = H5Tget_size(mid); if ((buff = (char *) malloc (size * count)) == NULL) { H5Tclose(mid); H5Dclose(did); H5Gclose(hid); set_error(MEMORY_ALLOCATION_FAILED, err); return; } #if CG_BUILD_PARALLEL hid_t fid = get_file_id(hid); hid_t fapl=H5Fget_access_plist(fid); hid_t driver_id = H5Pget_driver(fapl); H5Pclose(fapl); /* close the property list */ if (driver_id == H5FD_MPIO) { xfer_prp = H5Pcreate(H5P_DATASET_XFER); ADFH_CHECK_HID(xfer_prp); H5Pset_dxpl_mpio(xfer_prp, H5FD_MPIO_COLLECTIVE); } #endif if (H5Dread(did, mid, H5S_ALL, H5S_ALL, xfer_prp, buff) < 0) set_error(ADFH_ERR_DREAD, err); else { offset = size * (size_t)(b_start - 1); count = size * (size_t)(b_end - b_start + 1); memcpy(data, &buff[offset], count); set_error(NO_ERROR, err); } free (buff); #if CG_BUILD_PARALLEL if (driver_id == H5FD_MPIO) { H5Pclose(xfer_prp); } #endif H5Tclose(mid); H5Dclose(did); H5Gclose(hid); } /* ----------------------------------------------------------------- */ void ADFH_Read_Data(const double ID, const cgsize_t s_start[], const cgsize_t s_end[], const cgsize_t s_stride[], const int m_num_dims, const cgsize_t m_dims[], const cgsize_t m_start[], const cgsize_t m_end[], const cgsize_t m_stride[], const char *m_data_type, char *data, int *err ) { int n, ndim; hid_t hid, did, mid, dspace, mspace; hsize_t dims[ADF_MAX_DIMENSIONS]; hsize_t start[ADF_MAX_DIMENSIONS]; hsize_t stride[ADF_MAX_DIMENSIONS]; hsize_t count[ADF_MAX_DIMENSIONS]; herr_t status; hid_t xfer_prp = H5P_DEFAULT; ADFH_DEBUG(("ADFH_Read_Data")); if ((hid = open_node(ID, err)) < 0) return; if (!data_exists(hid)) { H5Gclose(hid); set_error(NO_DATA, err); return; } if ((did = H5Dopen2(hid, D_DATA, H5P_DEFAULT)) < 0) { H5Gclose(hid); set_error(ADFH_ERR_DOPEN, err); return; } /* get data space extents */ dspace = H5Dget_space(did); ADFH_CHECK_HID(dspace); ndim = H5Sget_simple_extent_ndims(dspace); H5Sget_simple_extent_dims(dspace, dims, NULL); /* create data hyperslab */ #ifdef ADFH_FORTRAN_INDEXING if (ndim > 1 && !swap_dimensions(hid)) { H5Sclose(dspace); H5Dclose(did); H5Gclose(hid); set_error(ADFH_ERR_NEED_TRANSPOSE, err); return; } #endif for (n = 0; n < ndim; n++) { if (s_start[n] < 1) set_error(START_OUT_OF_DEFINED_RANGE, err); #ifdef ADFH_FORTRAN_INDEXING else if ((hsize_t)s_end[n] > dims[ndim-1-n]) #else else if ((hsize_t)s_end[n] > dims[n]) #endif set_error(END_OUT_OF_DEFINED_RANGE, err); else if (s_start[n] > s_end[n]) set_error(MINIMUM_GT_MAXIMUM, err); else if (s_stride[n] < 1 || s_stride[n] > (s_end[n] - s_start[n] + 1)) set_error(BAD_STRIDE_VALUE, err); else set_error(NO_ERROR, err); if (*err != NO_ERROR) { H5Sclose(dspace); H5Dclose(did); H5Gclose(hid); return; } #ifdef ADFH_FORTRAN_INDEXING start[ndim-1-n] = s_start[n] - 1; stride[ndim-1-n] = s_stride[n]; count[ndim-1-n] = (s_end[n] - s_start[n] + 1) / s_stride[n]; #else start[n] = s_start[n] - 1; stride[n] = s_stride[n]; count[n] = (s_end[n] - s_start[n] + 1) / s_stride[n]; #endif } H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, stride, count, NULL); /* create memory hyperslab */ for (n = 0; n < m_num_dims; n++) { if (m_start[n] < 1) set_error(START_OUT_OF_DEFINED_RANGE, err); else if (m_end[n] > m_dims[n]) set_error(END_OUT_OF_DEFINED_RANGE, err); else if (m_start[n] > m_end[n]) set_error(MINIMUM_GT_MAXIMUM, err); else if (m_stride[n] < 1 || m_stride[n] > (m_end[n] - m_start[n] + 1)) set_error(BAD_STRIDE_VALUE, err); else set_error(NO_ERROR, err); if (*err != NO_ERROR) { H5Sclose(dspace); H5Dclose(did); H5Gclose(hid); return; } #ifdef ADFH_FORTRAN_INDEXING dims[m_num_dims-1-n] = m_dims[n]; start[m_num_dims-1-n] = m_start[n] - 1; stride[m_num_dims-1-n] = m_stride[n]; count[m_num_dims-1-n] = (m_end[n] - m_start[n] + 1) / m_stride[n]; #else dims[n] = m_dims[n]; start[n] = m_start[n] - 1; stride[n] = m_stride[n]; count[n] = (m_end[n] - m_start[n] + 1) / m_stride[n]; #endif } mspace = H5Screate_simple(m_num_dims, dims, NULL); ADFH_CHECK_HID(mspace); H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, stride, count, NULL); if (H5Sget_select_npoints(mspace) != H5Sget_select_npoints(dspace)) { H5Sclose(mspace); H5Sclose(dspace); H5Dclose(did); H5Gclose(hid); set_error(UNEQUAL_MEMORY_AND_DISK_DIMS, err); return; } /* read the data */ if (m_data_type) { mid = to_HDF_data_type(m_data_type); } else { set_error(INVALID_DATA_TYPE, err); return; } ADFH_CHECK_HID(mid); #if CG_BUILD_PARALLEL hid_t fid = get_file_id(hid); hid_t fapl=H5Fget_access_plist(fid); hid_t driver_id = H5Pget_driver(fapl); H5Pclose(fapl); /* close the property list */ if (driver_id == H5FD_MPIO) { xfer_prp = H5Pcreate(H5P_DATASET_XFER); ADFH_CHECK_HID(xfer_prp); H5Pset_dxpl_mpio(xfer_prp, ctx_cgio.default_pio_mode); } #endif status = H5Dread(did, mid, mspace, dspace, xfer_prp, data); H5Dclose(did); #if CG_BUILD_PARALLEL if (driver_id == H5FD_MPIO) { H5Pclose(xfer_prp); } #endif H5Sclose(mspace); H5Sclose(dspace); H5Tclose(mid); H5Gclose(hid); if (status < 0) set_error(ADFH_ERR_DREAD, err); else set_error(NO_ERROR, err); } /* ----------------------------------------------------------------- */ void ADFH_Read_All_Data(const double id, const char *m_data_type, char *data, int *err) { hid_t hid, did, mid; hid_t xfer_prp = H5P_DEFAULT; ADFH_DEBUG(("ADFH_Read_All_Data")); if ((hid = open_node(id, err)) < 0) return; if (data_exists(hid)) { did = H5Dopen2(hid, D_DATA, H5P_DEFAULT); ADFH_CHECK_HID(did); if (m_data_type) { mid = to_HDF_data_type(m_data_type); } else { set_error(INVALID_DATA_TYPE, err); return; } ADFH_CHECK_HID(mid); #if CG_BUILD_PARALLEL if (ctx_cgio.pcg_mpi_initialized && strcmp(ctx_cgio.hdf5_access, "PARALLEL") == 0) { xfer_prp = H5Pcreate(H5P_DATASET_XFER); ADFH_CHECK_HID(xfer_prp); H5Pset_dxpl_mpio(xfer_prp, H5FD_MPIO_COLLECTIVE); } #endif if (H5Dread(did, mid, H5S_ALL, H5S_ALL, xfer_prp, data) < 0) set_error(ADFH_ERR_DREAD, err); else set_error(NO_ERROR, err); #if CG_BUILD_PARALLEL if (ctx_cgio.pcg_mpi_initialized && strcmp(ctx_cgio.hdf5_access, "PARALLEL") == 0) { H5Pclose(xfer_prp); } #endif H5Tclose(mid); H5Dclose(did); } else set_error(NO_DATA, err); H5Gclose(hid); } /* ----------------------------------------------------------------- */ void ADFH_Write_Block_Data(const double ID, const cgsize_t b_start, const cgsize_t b_end, char *data, int *err ) { hid_t hid, did, mid, tid, dspace; size_t size, count, offset; char *buff; hid_t xfer_prp = H5P_DEFAULT; ADFH_DEBUG(("ADFH_Write_Block_Data")); if (data == NULL) { set_error(NULL_POINTER, err); return; } if (b_start > b_end) { set_error(MINIMUM_GT_MAXIMUM, err); return; } if (b_start < 1) { set_error(START_OUT_OF_DEFINED_RANGE, err); return; } to_HDF_ID(ID,hid); if (is_link(hid)) { set_error(ADFH_ERR_LINK_DATA, err); return; } if (!data_exists(hid)) { set_error(NO_DATA, err); return; } if ((did = H5Dopen2(hid, D_DATA, H5P_DEFAULT)) < 0) { set_error(ADFH_ERR_DOPEN, err); return; } dspace = H5Dget_space(did); ADFH_CHECK_HID(dspace); count = (size_t)H5Sget_simple_extent_npoints(dspace); H5Sclose(dspace); if ((size_t)b_end > count) { H5Dclose(did); set_error(END_OUT_OF_DEFINED_RANGE, err); return; } /* instead of trying to compute data space extents from * b_start and b_end, just read all the data into a * 1-d array, copy the range we want and rewrite the data */ ADFH_CHECK_HID(did); tid = H5Dget_type(did); ADFH_CHECK_HID(tid); mid = H5Tget_native_type(tid, H5T_DIR_ASCEND); ADFH_CHECK_HID(mid); size = H5Tget_size(mid); if ((buff = (char *) malloc (size * count)) == NULL) { H5Tclose(mid); H5Tclose(tid); H5Dclose(did); set_error(MEMORY_ALLOCATION_FAILED, err); return; } #if CG_BUILD_PARALLEL hid_t fid = get_file_id(hid); hid_t fapl=H5Fget_access_plist(fid); hid_t driver_id = H5Pget_driver(fapl); H5Pclose(fapl); /* close the property list */ if (driver_id == H5FD_MPIO) { xfer_prp = H5Pcreate(H5P_DATASET_XFER); ADFH_CHECK_HID(xfer_prp); H5Pset_dxpl_mpio(xfer_prp, H5FD_MPIO_COLLECTIVE); } #endif if (H5Dread(did, mid, H5S_ALL, H5S_ALL, xfer_prp, buff) < 0) set_error(ADFH_ERR_DREAD, err); else { offset = size * (size_t)(b_start - 1); count = size * (size_t)(b_end - b_start + 1); memcpy(&buff[offset], data, count); if (H5Dwrite(did, mid, H5S_ALL, H5S_ALL, xfer_prp, buff) < 0) set_error(ADFH_ERR_DWRITE, err); else set_error(NO_ERROR, err); } free (buff); #if CG_BUILD_PARALLEL if (driver_id == H5FD_MPIO) { H5Pclose(xfer_prp); } #endif H5Tclose(mid); H5Tclose(tid); H5Dclose(did); } /* ----------------------------------------------------------------- */ void ADFH_Write_Data(const double ID, const cgsize_t s_start[], const cgsize_t s_end[], const cgsize_t s_stride[], const char *m_data_type, const int m_num_dims, const cgsize_t m_dims[], const cgsize_t m_start[], const cgsize_t m_end[], const cgsize_t m_stride[], const char *data, int *err ) { int n, ndim; hid_t hid, did, mid, tid, dspace, mspace; hsize_t dims[ADF_MAX_DIMENSIONS]; hsize_t start[ADF_MAX_DIMENSIONS]; hsize_t stride[ADF_MAX_DIMENSIONS]; hsize_t count[ADF_MAX_DIMENSIONS]; herr_t status; hid_t xfer_prp = H5P_DEFAULT; ADFH_DEBUG(("ADFH_Write_Data")); if (data == NULL) { set_error(NULL_POINTER, err); return; } to_HDF_ID(ID,hid); if (is_link(hid)) { set_error(ADFH_ERR_LINK_DATA, err); return; } if (!data_exists(hid)) { set_error(NO_DATA, err); return; } if ((did = H5Dopen2(hid, D_DATA, H5P_DEFAULT)) < 0) { set_error(ADFH_ERR_DOPEN, err); return; } /* get data space extents */ dspace = H5Dget_space(did); ADFH_CHECK_HID(dspace); ndim = H5Sget_simple_extent_ndims(dspace); H5Sget_simple_extent_dims(dspace, dims, NULL); /* create data hyperslab */ #ifdef ADFH_FORTRAN_INDEXING if (ndim > 1 && !swap_dimensions(hid)) { H5Sclose(dspace); H5Dclose(did); set_error(ADFH_ERR_NEED_TRANSPOSE, err); return; } #endif for (n = 0; n < ndim; n++) { if (s_start[n] < 1) set_error(START_OUT_OF_DEFINED_RANGE, err); #ifdef ADFH_FORTRAN_INDEXING else if ((hsize_t)s_end[n] > dims[ndim-1-n]) #else else if ((hsize_t)s_end[n] > dims[n]) #endif set_error(END_OUT_OF_DEFINED_RANGE, err); else if (s_start[n] > s_end[n]) set_error(MINIMUM_GT_MAXIMUM, err); else if (s_stride[n] < 1 || s_stride[n] > (s_end[n] - s_start[n] + 1)) set_error(BAD_STRIDE_VALUE, err); else set_error(NO_ERROR, err); if (*err != NO_ERROR) { H5Sclose(dspace); H5Dclose(did); return; } #ifdef ADFH_FORTRAN_INDEXING start[ndim-1-n] = s_start[n] - 1; stride[ndim-1-n] = s_stride[n]; count[ndim-1-n] = (s_end[n] - s_start[n] + 1) / s_stride[n]; #else start[n] = s_start[n] - 1; stride[n] = s_stride[n]; count[n] = (s_end[n] - s_start[n] + 1) / s_stride[n]; #endif } H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, stride, count, NULL); /* create memory hyperslab */ for (n = 0; n < m_num_dims; n++) { if (m_start[n] < 1) set_error(START_OUT_OF_DEFINED_RANGE, err); else if (m_end[n] > m_dims[n]) set_error(END_OUT_OF_DEFINED_RANGE, err); else if (m_start[n] > m_end[n]) set_error(MINIMUM_GT_MAXIMUM, err); else if (m_stride[n] < 1 || m_stride[n] > (m_end[n] - m_start[n] + 1)) set_error(BAD_STRIDE_VALUE, err); else set_error(NO_ERROR, err); if (*err != NO_ERROR) { H5Sclose(dspace); H5Dclose(did); return; } #ifdef ADFH_FORTRAN_INDEXING dims[m_num_dims-1-n] = m_dims[n]; start[m_num_dims-1-n] = m_start[n] - 1; stride[m_num_dims-1-n] = m_stride[n]; count[m_num_dims-1-n] = (m_end[n] - m_start[n] + 1) / m_stride[n]; #else dims[n] = m_dims[n]; start[n] = m_start[n] - 1; stride[n] = m_stride[n]; count[n] = (m_end[n] - m_start[n] + 1) / m_stride[n]; #endif } mspace = H5Screate_simple(m_num_dims, dims, NULL); ADFH_CHECK_HID(mspace); H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, stride, count, NULL); if (H5Sget_select_npoints(mspace) != H5Sget_select_npoints(dspace)) { H5Sclose(mspace); H5Sclose(dspace); H5Dclose(did); set_error(UNEQUAL_MEMORY_AND_DISK_DIMS, err); return; } /* write the data */ ADFH_CHECK_HID(did); tid = H5Dget_type(did); ADFH_CHECK_HID(tid); if (m_data_type) { mid = to_HDF_data_type(m_data_type); } else { mid = H5Tget_native_type(tid, H5T_DIR_ASCEND); } ADFH_CHECK_HID(mid); #if CG_BUILD_PARALLEL hid_t fid = get_file_id(hid); hid_t fapl=H5Fget_access_plist(fid); hid_t driver_id = H5Pget_driver(fapl); H5Pclose(fapl); /* close the property list */ if (driver_id == H5FD_MPIO) { xfer_prp = H5Pcreate(H5P_DATASET_XFER); ADFH_CHECK_HID(xfer_prp); H5Pset_dxpl_mpio(xfer_prp, ctx_cgio.default_pio_mode); } #endif status = H5Dwrite(did, mid, mspace, dspace, xfer_prp, data); #if CG_BUILD_PARALLEL if (driver_id == H5FD_MPIO) { H5Pclose(xfer_prp); } #endif H5Sclose(mspace); H5Sclose(dspace); H5Tclose(mid); H5Tclose(tid); H5Dclose(did); if (status < 0) set_error(ADFH_ERR_DWRITE, err); else set_error(NO_ERROR, err); } /* ----------------------------------------------------------------- */ void ADFH_Write_All_Data(const double id, const char *m_data_type, const char *data, int *err) { hid_t hid; hid_t did, tid, mid; hid_t xfer_prp = H5P_DEFAULT; to_HDF_ID(id, hid); ADFH_DEBUG(("ADFH_Write_All_Data")); if (data == NULL) { set_error(NULL_POINTER, err); return; } if (is_link(hid)) { set_error(ADFH_ERR_LINK_DATA, err); return; } if (data_exists(hid)) { ADFH_CHECK_HID(hid); did = H5Dopen2(hid, D_DATA, H5P_DEFAULT); ADFH_CHECK_HID(did); tid = H5Dget_type(did); ADFH_CHECK_HID(tid); if (m_data_type) { mid = to_HDF_data_type(m_data_type); } else { mid = H5Tget_native_type(tid, H5T_DIR_ASCEND); } ADFH_CHECK_HID(mid); #if CG_BUILD_PARALLEL if (ctx_cgio.pcg_mpi_initialized && strcmp(ctx_cgio.hdf5_access, "PARALLEL") == 0) { xfer_prp = H5Pcreate(H5P_DATASET_XFER); ADFH_CHECK_HID(xfer_prp); if (H5Pset_dxpl_mpio(xfer_prp, H5FD_MPIO_COLLECTIVE) < 0) set_error(ADFH_ERR_DWRITE, err); } #endif if (H5Dwrite(did, mid, H5S_ALL, H5S_ALL, xfer_prp, data) < 0) set_error(ADFH_ERR_DWRITE, err); else set_error(NO_ERROR, err); #if CG_BUILD_PARALLEL if (ctx_cgio.pcg_mpi_initialized && strcmp(ctx_cgio.hdf5_access, "PARALLEL") == 0) { H5Pclose(xfer_prp); } #endif H5Tclose(mid); H5Tclose(tid); H5Dclose(did); } else set_error(NO_DATA, err); } CGNS-4.5.0/src/adfh/ADFH.h000066400000000000000000000306311474000356600146260ustar00rootroot00000000000000/* ------------------------------------------------------------------------- * * CGNS - CFD General Notation System (http://www.cgns.org) * * CGNS/MLL - Mid-Level Library header file * * Please see cgnsconfig.h file for this local installation configuration * * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- * This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. * ------------------------------------------------------------------------- */ /*------------------------------------------------------------------- * include file for the HDF5 replacement to ADF *-------------------------------------------------------------------*/ #ifndef _ADFH_H_ #define _ADFH_H_ #include "cgnstypes.h" /* some stuff needed from standard ADF.h */ #ifndef ADF_INCLUDE #define ADF_DATA_TYPE_LENGTH 32 #define ADF_DATE_LENGTH 32 #define ADF_FILENAME_LENGTH 1024 #define ADF_FORMAT_LENGTH 20 #define ADF_LABEL_LENGTH 32 #define ADF_MAXIMUM_LINK_DEPTH 100 #define ADF_MAX_DIMENSIONS 12 #define ADF_MAX_ERROR_STR_LENGTH 80 #define ADF_MAX_LINK_DATA_SIZE 4096 #define ADF_NAME_LENGTH 32 #define ADF_STATUS_LENGTH 32 #define ADF_VERSION_LENGTH 32 #define NO_ERROR 0 #define NUMBER_LESS_THAN_MINIMUM 1 #define NUMBER_GREATER_THAN_MAXIMUM 2 #define STRING_LENGTH_ZERO 3 #define STRING_LENGTH_TOO_BIG 4 #define STRING_NOT_A_HEX_STRING 5 #define TOO_MANY_ADF_FILES_OPENED 6 #define ADF_FILE_STATUS_NOT_RECOGNIZED 7 #define FILE_OPEN_ERROR 8 #define ADF_FILE_NOT_OPENED 9 #define FILE_INDEX_OUT_OF_RANGE 10 #define BLOCK_OFFSET_OUT_OF_RANGE 11 #define NULL_STRING_POINTER 12 #define FSEEK_ERROR 13 #define FWRITE_ERROR 14 #define FREAD_ERROR 15 #define ADF_MEMORY_TAG_ERROR 16 #define ADF_DISK_TAG_ERROR 17 #define REQUESTED_NEW_FILE_EXISTS 18 #define ADF_FILE_FORMAT_NOT_RECOGNIZED 19 #define FREE_OF_ROOT_NODE 20 #define FREE_OF_FREE_CHUNK_TABLE 21 #define REQUESTED_OLD_FILE_NOT_FOUND 22 #define UNIMPLEMENTED_CODE 23 #define SUB_NODE_TABLE_ENTRIES_BAD 24 #define MEMORY_ALLOCATION_FAILED 25 #define DUPLICATE_CHILD_NAME 26 #define ZERO_DIMENSIONS 27 #define BAD_NUMBER_OF_DIMENSIONS 28 #define CHILD_NOT_OF_GIVEN_PARENT 29 #define DATA_TYPE_TOO_LONG 30 #define INVALID_DATA_TYPE 31 #define NULL_POINTER 32 #define NO_DATA 33 #define ERROR_ZEROING_OUT_MEMORY 34 #define REQUESTED_DATA_TOO_LONG 35 #define END_OUT_OF_DEFINED_RANGE 36 #define BAD_STRIDE_VALUE 37 #define MINIMUM_GT_MAXIMUM 38 #define MACHINE_FORMAT_NOT_RECOGNIZED 39 #define CANNOT_CONVERT_NATIVE_FORMAT 40 #define CONVERSION_FORMATS_EQUAL 41 #define DATA_TYPE_NOT_SUPPORTED 42 #define FILE_CLOSE_ERROR 43 #define NUMERIC_OVERFLOW 44 #define START_OUT_OF_DEFINED_RANGE 45 #define ZERO_LENGTH_VALUE 46 #define BAD_DIMENSION_VALUE 47 #define BAD_ERROR_STATE 48 #define UNEQUAL_MEMORY_AND_DISK_DIMS 49 #define LINKS_TOO_DEEP 50 #define NODE_IS_NOT_A_LINK 51 #define LINK_TARGET_NOT_THERE 52 #define LINKED_TO_FILE_NOT_THERE 53 #define NODE_ID_ZERO 54 #define INCOMPLETE_DATA 55 #define INVALID_NODE_NAME 56 #define INVALID_VERSION 57 #define NODES_NOT_IN_SAME_FILE 58 #define PRISTK_NOT_FOUND 59 #define MACHINE_FILE_INCOMPATABLE 60 #define FFLUSH_ERROR 61 #define NULL_NODEID_POINTER 62 #define MAX_FILE_SIZE_EXCEEDED 63 #define MAX_INT32_SIZE_EXCEEDED 64 #define CHILDREN_IDS_NOT_FOUND 65 #endif /* ADF_INCLUDE */ /* end of ADF.h portion */ #define ADFH_ERR_GLINK 70 #define ADFH_ERR_NO_ATT 71 #define ADFH_ERR_AOPEN 72 #define ADFH_ERR_IGET_NAME 73 #define ADFH_ERR_LMOVE 74 #define ADFH_ERR_GUNLINK 75 #define ADFH_ERR_GOPEN 76 #define ADFH_ERR_DGET_SPACE 77 #define ADFH_ERR_DOPEN 78 #define ADFH_ERR_DEXTEND 79 #define ADFH_ERR_DCREATE 80 #define ADFH_ERR_SCREATE_SIMPLE 81 #define ADFH_ERR_ACREATE 82 #define ADFH_ERR_GCREATE 83 #define ADFH_ERR_DWRITE 84 #define ADFH_ERR_DREAD 85 #define ADFH_ERR_AWRITE 86 #define ADFH_ERR_AREAD 87 #define ADFH_ERR_FMOUNT 88 #define ADFH_ERR_LINK_MOVE 89 #define ADFH_ERR_LINK_DATA 90 #define ADFH_ERR_LINK_NODE 91 #define ADFH_ERR_LINK_DELETE 92 #define ADFH_ERR_NOT_HDF5_FILE 93 #define ADFH_ERR_FILE_DELETE 94 #define ADFH_ERR_FILE_INDEX 95 #define ADFH_ERR_TCOPY 96 #define ADFH_ERR_AGET_TYPE 97 #define ADFH_ERR_TSET_SIZE 98 #define ADFH_ERR_NOT_IMPLEMENTED 99 #define ADFH_ERR_NOTXLINK 100 #define ADFH_ERR_LIBREG 101 #define ADFH_ERR_OBJINFO_FAILED 102 #define ADFH_ERR_XLINK_NOVAL 103 #define ADFH_ERR_XLINK_UNPACK 104 #define ADFH_ERR_GCLOSE_LABEL 105 #define ADFH_ERR_ROOTNULL 106 #define ADFH_ERR_NEED_TRANSPOSE 107 #define ADFH_ERR_INVALID_OPTION 108 #define ADFH_ERR_INVALID_USER_DATA 109 #define ADFH_ERR_SENTINEL 999 /* configuration options, relates to CG_CONFIG_HDF5_* in cgnslib.h */ #define ADFH_CONFIG_COMPRESS 1 #define ADFH_CONFIG_MPI_COMM 2 #define ADFH_CONFIG_CORE 3 #define ADFH_CONFIG_CORE_INCR 4 #define ADFH_CONFIG_CORE_WRITE 5 #define ADFH_CONFIG_ALIGNMENT 6 #define ADFH_CONFIG_MD_BLOCK_SIZE 7 #define ADFH_CONFIG_HDF5_BUFFER 8 #define ADFH_CONFIG_HDF5_SIEVE_BUF_SIZE 9 #define ADFH_CONFIG_ELINK_FILE_CACHE_SIZE 10 #define ADFH_CONFIG_RESET 800 #define ADFH_CONFIG_RESET_HDF5 1 /*********************************************************************** Prototypes for Interface Routines ***********************************************************************/ #if defined(_WIN32) && defined(BUILD_DLL) # define EXTERN extern __declspec(dllexport) #else # define EXTERN extern #endif #if defined (__cplusplus) extern "C" { #endif EXTERN void ADFH_Configure( const int option, const void *value, int *error_return ) ; EXTERN void ADFH_Children_Names( const double PID, const int istart, const int ilen, const int name_length, int *ilen_ret, char *names, int *error_return ) ; EXTERN void ADFH_Children_IDs( const double PID, const int istart, const int ilen, int *ilen_ret, double *IDs, int *error_return ) ; EXTERN void ADFH_Create( const double PID, const char *name, double *ID, int *error_return ) ; EXTERN void ADFH_Database_Close( const double ID, int *error_return ) ; EXTERN void ADFH_Database_Delete( const char *filename, int *error_return ) ; EXTERN void ADFH_Database_Garbage_Collection( const double ID, int *error_return ) ; EXTERN void ADFH_Database_Get_Format( const double Root_ID, char *format, int *error_return ) ; EXTERN void ADFH_Database_Open( const char *filename, const char *status, const char *format, double *root_ID, int *error_return ) ; EXTERN void ADFH_Database_Valid( const char *filename, int *error_return ) ; EXTERN void ADFH_Database_Set_Format( const double Root_ID, const char *format, int *error_return ) ; EXTERN void ADFH_Database_Version( const double Root_ID, char *version, char *creation_date, char *modification_date, int *error_return ) ; EXTERN void ADFH_Delete( const double PID, const double ID, int *error_return ) ; EXTERN void ADFH_Error_Message( const int error_return_input, char *error_string ) ; EXTERN void ADFH_Flush_to_Disk( const double ID, int *error_return ) ; EXTERN void ADFH_Get_Data_Type( const double ID, char *data_type, int *error_return ) ; EXTERN void ADFH_Get_Dimension_Values( const double ID, cgsize_t dim_vals[], int *error_return ) ; EXTERN void ADFH_Get_Error_State( int *error_state, int *error_return ) ; EXTERN void ADFH_Get_Label( const double ID, char *label, int *error_return ) ; EXTERN void ADFH_Get_Link_Path( const double ID, char *filename, char *link_path, int *error_return ) ; EXTERN void ADFH_Get_Name( const double ID, char *name, int *error_return ) ; EXTERN void ADFH_Get_Node_ID( const double PID, const char *name, double *ID, int *error_return ) ; EXTERN void ADFH_Get_Number_of_Dimensions( const double ID, int *num_dims, int *error_return ) ; EXTERN void ADFH_Get_Root_ID( const double ID, double *Root_ID, int *error_return ) ; EXTERN void ADFH_Is_Link( const double ID, int *link_path_length, int *error_return ) ; EXTERN void ADFH_Library_Version( char *version, int *error_return ) ; EXTERN void ADFH_Link( const double PID, const char *name, const char *file, const char *name_in_file, double *ID, int *error_return ) ; EXTERN void ADFH_Link_Size( const double ID, int *file_length, int *name_length, int *error_return ) ; EXTERN void ADFH_Move_Child( const double PID, const double ID, const double NPID, int *error_return ) ; EXTERN void ADFH_Number_of_Children( const double ID, int *num_children, int *error_return ) ; EXTERN void ADFH_Put_Dimension_Information( const double ID, const char *data_type, const int dims, const cgsize_t dim_vals[], const int HDF5storage_type, int *error_return ) ; EXTERN void ADFH_Put_Name( const double PID, const double ID, const char *name, int *error_return ) ; EXTERN void ADFH_Read_All_Data( const double ID, const char *m_data_type, char *data, int *error_return ) ; EXTERN void ADFH_Read_Block_Data( const double ID, const cgsize_t b_start, const cgsize_t b_end, const char *m_data_type, void *data, int *error_return ) ; EXTERN void ADFH_Read_Data( const double ID, const cgsize_t s_start[], const cgsize_t s_end[], const cgsize_t s_stride[], const int m_num_dims, const cgsize_t m_dims[], const cgsize_t m_start[], const cgsize_t m_end[], const cgsize_t m_stride[], const char *m_data_type, char *data, int *error_return ) ; EXTERN void ADFH_Set_Error_State( const int error_state, int *error_return ) ; EXTERN void ADFH_Set_Label( const double ID, const char *label, int *error_return ) ; EXTERN void ADFH_Write_All_Data( const double ID, const char *m_data_type, const char *data, int *error_return ) ; EXTERN void ADFH_Write_Block_Data( const double ID, const cgsize_t b_start, const cgsize_t b_end, char *data, int *error_return ) ; EXTERN void ADFH_Write_Data( const double ID, const cgsize_t s_start[], const cgsize_t s_end[], const cgsize_t s_stride[], const char *m_data_type, const int m_num_dims, const cgsize_t m_dims[], const cgsize_t m_start[], const cgsize_t m_end[], const cgsize_t m_stride[], const char *data, int *error_return ) ; #define HAS_ADF_RELEASE_ID EXTERN void ADFH_Release_ID ( const double ID ); #if defined (__cplusplus) } #endif #undef EXTERN #endif /* _ADFH_H_ */ CGNS-4.5.0/src/adfh/ADFH_ftoc.c000066400000000000000000000415461474000356600156430ustar00rootroot00000000000000/*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ #include #include #include "fortran_macros.h" #include "ADFH.h" #if defined(_WIN32) && defined(BUILD_DLL) # define CGNSDLL __declspec(dllexport) #else # define CGNSDLL #endif /*-------------------------------------------------------------------*/ static void StringFtoC(char *string, int string_length, char *c_string, int max_len, int *ierr) { int i, iend; if (string == NULL || c_string == NULL) { *ierr = NULL_STRING_POINTER; return; } /** Skip and trailing blanks **/ for (iend = string_length-1; iend >= 0; iend--) { if (string[iend] != ' ') break; } if (iend >= max_len) { *ierr = STRING_LENGTH_TOO_BIG; return; } /** Copy the non-trailing blank portion of the string **/ for (i = 0; i <= iend; i++) c_string[i] = string[i]; /** NULL terminate the C string **/ c_string[i] = '\0'; *ierr = NO_ERROR; } /*-------------------------------------------------------------------*/ static void StringCtoF(char *c_string, char *string, int string_length, int *ierr) { int i, len; if (c_string == NULL || string == NULL) { *ierr = NULL_STRING_POINTER; return; } len = strlen(c_string); /* string truncated - should this be an error ? */ if (len > string_length) len = string_length; for (i = 0; i < len; i++) string[i] = c_string[i]; while (i < string_length) string[i++] = ' '; *ierr = NO_ERROR; } /*----- ADFH Fortran to C interface -----*/ CGNSDLL void FMNAME(adfcnam, ADFCNAM) (double *ID, int *istart, int *inum, int *inamlen, int *inumret, STR_PSTR(names), int *ier STR_PLEN(names)) { char *tmp, *p = STR_PTR(names); int n, len = *inamlen; *inumret = 0; if (*inum < 1) { *ier = NO_ERROR; return; } tmp = (char *) malloc (*inum * (len + 1)); if (tmp == NULL) { *ier = MEMORY_ALLOCATION_FAILED; return; } ADFH_Children_Names(*ID, *istart, *inum, len+1, inumret, tmp, ier); if (*ier == NO_ERROR) { for (n = 0; n < *inumret; n++) StringCtoF(&tmp[n*(len+1)], &p[n*len], len, ier); } free(tmp); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfcids, ADFCIDS) (double *ID, int *istart, int *inum, int *inumret, double *cIDs, int *ier) { ADFH_Children_IDs(*ID, *istart, *inum, inumret, cIDs, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfrid, ADFRID) (double *ID) { ADFH_Release_ID(*ID); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfcre, ADFCRE) (double *PID, STR_PSTR(name), double *ID, int *ier STR_PLEN(name)) { char c_name[ADF_NAME_LENGTH+1]; StringFtoC(STR_PTR(name), STR_LEN(name), c_name, ADF_NAME_LENGTH, ier); if (*ier == NO_ERROR) ADFH_Create(*PID, c_name, ID, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfdclo, ADFDCLO) (double *RootID, int *ier) { ADFH_Database_Close(*RootID, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfddel, ADFDDEL) (STR_PSTR(filename), int *ier STR_PLEN(filename)) { int len = STR_LEN(filename); char *c_name; if ((c_name = (char *) malloc (len + 1)) == NULL) { *ier = MEMORY_ALLOCATION_FAILED; return; } StringFtoC(STR_PTR(filename), len, c_name, len, ier); if (*ier == NO_ERROR) ADFH_Database_Delete(c_name, ier); free (c_name); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfdel, ADFDEL) (double *PID, double *ID, int *ier) { ADFH_Delete(*PID, *ID, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfdgc, ADFDGC) (double *ID, int *ier) { ADFH_Database_Garbage_Collection(*ID, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfdgf, ADFDGF) (double *RootID, STR_PSTR(format), int *ier STR_PLEN(format)) { char c_format[ADF_FORMAT_LENGTH+1]; ADFH_Database_Get_Format(*RootID, c_format, ier); if (*ier == NO_ERROR) StringCtoF(c_format, STR_PTR(format), STR_LEN(format), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfdopn, ADFDOPN) (STR_PSTR(filename), STR_PSTR(status), STR_PSTR(format), double *RootID, int *ier STR_PLEN(filename) STR_PLEN(status) STR_PLEN(format)) { int len = STR_LEN(filename); char *c_filename; char c_status[ADF_STATUS_LENGTH+1]; char c_format[ADF_FORMAT_LENGTH+1]; StringFtoC(STR_PTR(status), STR_LEN(status), c_status, ADF_STATUS_LENGTH, ier); if (*ier != NO_ERROR) return; StringFtoC(STR_PTR(format), STR_LEN(format), c_format, ADF_FORMAT_LENGTH, ier); if (*ier != NO_ERROR) return; if ((c_filename = (char *) malloc (len + 1)) == NULL) { *ier = MEMORY_ALLOCATION_FAILED; return; } StringFtoC(STR_PTR(filename), len, c_filename, len, ier); if (*ier == NO_ERROR) ADFH_Database_Open(c_filename, c_status, c_format, RootID, ier); free (c_filename); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfdsf, ADFDSF) (double *RootID, STR_PSTR(format), int *ier STR_PLEN(format)) { char c_format[ADF_FORMAT_LENGTH+1]; StringFtoC(STR_PTR(format), STR_LEN(format), c_format, ADF_FORMAT_LENGTH, ier); if (*ier == NO_ERROR) ADFH_Database_Set_Format(*RootID, c_format, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfdver, ADFDVER) (double *RootID, STR_PSTR(version), STR_PSTR(cdate), STR_PSTR(mdate), int *ier STR_PLEN(version) STR_PLEN(cdate) STR_PLEN(mdate)) { char c_version[ADF_VERSION_LENGTH+1]; char c_cdate[ADF_DATE_LENGTH+1]; char c_mdate[ADF_DATE_LENGTH+1]; ADFH_Database_Version(*RootID, c_version, c_cdate, c_mdate, ier); if (*ier == NO_ERROR) { StringCtoF(c_version, STR_PTR(version), STR_LEN(version), ier); StringCtoF(c_cdate, STR_PTR(cdate), STR_LEN(cdate), ier); StringCtoF(c_mdate, STR_PTR(mdate), STR_LEN(mdate), ier); } } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adferr, ADFERR) (int *ier, STR_PSTR(errstr) STR_PLEN(errstr)) { int err; char errmsg[ADF_MAX_ERROR_STR_LENGTH+1]; ADFH_Error_Message(*ier, errmsg); StringCtoF(errmsg, STR_PTR(errstr), STR_LEN(errstr), &err); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfftd, ADFFTD) (double *ID, int *ier) { ADFH_Flush_to_Disk(*ID, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfgdt, ADFGDT) (double *ID, STR_PSTR(dtype), int *ier STR_PLEN(dtype)) { char c_type[ADF_DATA_TYPE_LENGTH+1]; ADFH_Get_Data_Type(*ID, c_type, ier); if (*ier == NO_ERROR) StringCtoF(c_type, STR_PTR(dtype), STR_LEN(dtype), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfgdv, ADFGDV) (double *ID, int *dvals, int *ier) { ADFH_Get_Dimension_Values(*ID, dvals, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfges, ADFGES) (int *estate, int *ier) { ADFH_Get_Error_State(estate, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfglb, ADFGLB) (double *ID, STR_PSTR(label), int *ier STR_PLEN(label)) { char c_label[ADF_LABEL_LENGTH+1]; ADFH_Get_Label(*ID, c_label, ier); if (*ier == NO_ERROR) StringCtoF(c_label, STR_PTR(label), STR_LEN(label), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfglkp, ADFGLKP) (double *ID, STR_PSTR(file), STR_PSTR(name), int *ier STR_PLEN(file) STR_PLEN(name)) { char c_file[ADF_FILENAME_LENGTH+1]; char c_name[ADF_MAX_LINK_DATA_SIZE+1]; ADFH_Get_Link_Path(*ID, c_file, c_name, ier); if (*ier == NO_ERROR) { StringCtoF(c_file, STR_PTR(file), STR_LEN(file), ier); StringCtoF(c_name, STR_PTR(name), STR_LEN(name), ier); } } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfgnam, ADFGNAM) (double *ID, STR_PSTR(name), int *ier STR_PLEN(name)) { char c_name[ADF_NAME_LENGTH+1]; ADFH_Get_Name(*ID, c_name, ier); if (*ier == NO_ERROR) StringCtoF(c_name, STR_PTR(name), STR_LEN(name), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfgnd, ADFGND) (double *ID, int *ndims, int *ier) { ADFH_Get_Number_of_Dimensions(*ID, ndims, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfgnid, ADFGNID) (double *PID, STR_PSTR(name), double *ID, int *ier STR_PLEN(name)) { int len = STR_LEN(name); char *c_name; if ((c_name = (char *) malloc (len+1)) == NULL) { *ier = MEMORY_ALLOCATION_FAILED; return; } StringFtoC(STR_PTR(name), len, c_name, len, ier); if (*ier == NO_ERROR) ADFH_Get_Node_ID(*PID, c_name, ID, ier); free(c_name); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfgrid, ADFGRID) (double *ID, double *RootID, int *ier) { ADFH_Get_Root_ID(*ID, RootID, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfislk, ADFISLK) (double *ID, int *lplen, int *ier) { ADFH_Is_Link(*ID, lplen, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adflink, ADFLINK) (double *PID, STR_PSTR(name), STR_PSTR(file), STR_PSTR(nfile), double *ID, int *ier STR_PLEN(name) STR_PLEN(file) STR_PLEN(nfile)) { char c_name[ADF_NAME_LENGTH+1]; char c_file[ADF_FILENAME_LENGTH+1]; char c_nfile[ADF_MAX_LINK_DATA_SIZE+1]; StringFtoC(STR_PTR(name), STR_LEN(name), c_name, ADF_NAME_LENGTH, ier); if (*ier != NO_ERROR) return; StringFtoC(STR_PTR(file), STR_LEN(file), c_file, ADF_FILENAME_LENGTH, ier); if (*ier != NO_ERROR) return; StringFtoC(STR_PTR(nfile), STR_LEN(nfile), c_nfile, ADF_MAX_LINK_DATA_SIZE, ier); if (*ier == NO_ERROR) ADFH_Link(*PID, c_name, c_file, c_nfile, ID, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adflver, ADFLVER) (STR_PSTR(version), int *ier STR_PLEN(version)) { char c_version[ADF_VERSION_LENGTH+1]; ADFH_Library_Version(c_version, ier); if (*ier == NO_ERROR) StringCtoF(c_version, STR_PTR(version), STR_LEN(version), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfmove, ADFMOVE) (double *PID, double *ID, double *NPID, int *ier) { ADFH_Move_Child(*PID, *ID, *NPID, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfncld, ADFNCLD) (double *ID, int *numcld, int *ier) { ADFH_Number_of_Children(*ID, numcld, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfpdim, ADFPDIM) (double *ID, STR_PSTR(dtype), int *dims, int *dvals, int *ier STR_PLEN(dtype)) { char c_type[ADF_DATA_TYPE_LENGTH+1]; StringFtoC(STR_PTR(dtype), STR_LEN(dtype), c_type, ADF_DATA_TYPE_LENGTH, ier); if (*ier == NO_ERROR) ADFH_Put_Dimension_Information(*ID, c_type, *dims, dvals, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfpnam, ADFPNAM) (double *PID, double *ID, STR_PSTR(name), int *ier STR_PLEN(name)) { char c_name[ADF_NAME_LENGTH+1]; StringFtoC(STR_PTR(name), STR_LEN(name), c_name, ADF_NAME_LENGTH, ier); if (*ier == NO_ERROR) ADFH_Put_Name(*PID, *ID, c_name, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfses, ADFSES) (int *estate, int *ier) { ADFH_Set_Error_State(*estate, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfslb, ADFSLB) (double *ID, STR_PSTR(label), int *ier STR_PLEN(label)) { char c_label[ADF_LABEL_LENGTH+1]; StringFtoC(STR_PTR(label), STR_LEN(label), c_label, ADF_LABEL_LENGTH, ier); if (*ier == NO_ERROR) ADFH_Set_Label(*ID, c_label, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfread, ADFREAD) (double *ID, int *s_start, int *s_end, int *s_stride, int *m_num_dims, int *m_dims, int *m_start, int *m_end, int *m_stride, char *data, int *ier) { ADFH_Read_Data(*ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, data, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfrall, ADFRALL) (double *ID, char *data, int *ier) { ADFH_Read_All_Data(*ID, data, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfrblk, ADFRBLK) (double *ID, int *b_start, int *b_end, char *data, int *ier) { ADFH_Read_Block_Data(*ID, *b_start, *b_end, data, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfwrit, ADFWRIT) (double *ID, int *s_start, int *s_end, int *s_stride, int *m_num_dims, int *m_dims, int *m_start, int *m_end, int *m_stride, char *data, int *ier) { ADFH_Write_Data(*ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, data, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfwall, ADFWALL) (double *ID, char *data, int *ier) { ADFH_Write_All_Data(*ID, data, ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfwblk, ADFRWBLK) (double *ID, int *b_start, int *b_end, char *data, int *ier) { ADFH_Write_Block_Data(*ID, *b_start, *b_end, data, ier); } /*----- added mainly to handle character output under windows -----*/ CGNSDLL void FMNAME(adfreadc, ADFREADC) (double *ID, int *s_start, int *s_end, int *s_stride, int *m_num_dims, int *m_dims, int *m_start, int *m_end, int *m_stride, STR_PSTR(data), int *ier STR_PLEN(data)) { ADFH_Read_Data(*ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, STR_PTR(data), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfrallc, ADFRALLC) (double *ID, STR_PSTR(data), int *ier STR_PLEN(data)) { ADFH_Read_All_Data(*ID, STR_PTR(data), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfrblkc, ADFRBLKC) (double *ID, int *b_start, int *b_end, STR_PSTR(data), int *ier STR_PLEN(data)) { ADFH_Read_Block_Data(*ID, *b_start, *b_end, STR_PTR(data), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfwritc, ADFWRITC) (double *ID, int *s_start, int *s_end, int *s_stride, int *m_num_dims, int *m_dims, int *m_start, int *m_end, int *m_stride, STR_PSTR(data), int *ier STR_PLEN(data)) { ADFH_Write_Data(*ID, s_start, s_end, s_stride, *m_num_dims, m_dims, m_start, m_end, m_stride, STR_PTR(data), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfwallc, ADFWALLC) (double *ID, STR_PSTR(data), int *ier STR_PLEN(data)) { ADFH_Write_All_Data(*ID, STR_PTR(data), ier); } /*-------------------------------------------------------------------*/ CGNSDLL void FMNAME(adfwblkc, ADFRBWLKC) (double *ID, int *b_start, int *b_end, STR_PSTR(data), int *ier STR_PLEN(data)) { ADFH_Write_Block_Data(*ID, *b_start, *b_end, STR_PTR(data), ier); } CGNS-4.5.0/src/cg_ftoc.c000066400000000000000000003731741474000356600146350ustar00rootroot00000000000000/*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. _____ _______ ____ _____ _ / ____|__ __/ __ \| __ \| | | (___ | | | | | | |__) | | \___ \ | | | | | | ___/| | ____) | | | | |__| | | |_| |_____/ |_| \____/|_| (_) _____ ______ _____ _____ ______ _____ _______ ______ _____ | __ \| ____| __ \| __ \| ____/ ____| /\|__ __| ____| __ \ | | | | |__ | |__) | |__) | |__ | | / \ | | | |__ | | | | | | | | __| | ___/| _ /| __|| | / /\ \ | | | __| | | | | | |__| | |____| | | | \ \| |___| |____ / ____ \| | | |____| |__| | |_____/|______|_| |_| \_\______\_____/_/ \_\_| |______|_____/ Developer Notes: (1) The approach of invoking a C function wrapper from Fortran, as used here, which subsequently calls the C CGNS function, is being discontinued. (2) If the C wrapper functions here encounter an issue, they should be reimplemented in Fortran within the cgns_f.F90 file, and the problem should be addressed in Fortran. (3) All new Fortran CGNS functions should be added to the cgns_f.F90 file and should directly call the CGNS C APIs. (4) Pull requests that alter this file will likely be rejected to uphold the principles of (1)-(3). -------------------------------------------------------------------------*/ #include #include #include #include "fortran_macros.h" #include "cgnslib.h" #include "cgns_header.h" #include #include "cgns_io.h" #ifdef MEM_DEBUG #include "cg_malloc.h" #endif #if CG_BUILD_PARALLEL #include "pcgnslib.h" #endif /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Convert between Fortran and C strings * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static void string_2_C_string(char *string, int string_length, char *c_string, int max_len, cgint_f *ierr) { int i, iend; if (string == NULL || c_string == NULL) { cgi_error ("NULL string pointer"); *ierr = (cgint_f)CG_ERROR; return; } /** Skip and trailing blanks **/ for (iend = string_length-1; iend >= 0; iend--) { if (string[iend] != ' ') break; } if (iend >= max_len) iend = max_len - 1; /** Copy the non-trailing blank portion of the string **/ for (i = 0; i <= iend; i++) c_string[i] = string[i]; /** NULL terminate the C string **/ c_string[i] = '\0'; *ierr = (cgint_f)CG_OK; } /*-----------------------------------------------------------------------*/ static void string_2_F_string(char *c_string, char *string, int string_length, cgint_f *ierr) { int i, len; if (c_string == NULL || string == NULL) { cgi_error ("NULL string pointer"); *ierr = (cgint_f)CG_ERROR; return; } len = (int)strlen(c_string); if (len > string_length) len = string_length; for (i = 0; i < len; i++) string[i] = c_string[i]; while (i < string_length) string[i++] = ' '; *ierr = (cgint_f)CG_OK; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * LIBRARY FUNCTIONS * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /*-----------------------------------------------------------------------*/ CGNSDLL void cg_configure_c_ptr(cgint_f *what, void *value, cgint_f *ier) { /* CHARACTERS */ if( (int)*what == CG_CONFIG_SET_PATH || (int)*what == CG_CONFIG_ADD_PATH) { *ier = (cgint_f)cg_configure((int)*what, value); } else if( (int)*what == CG_CONFIG_ERROR) { *ier = (cgint_f)CG_ERROR; /* MPI COMMUNICATOR */ #if CG_BUILD_PARALLEL } else if( (int)*what == CG_CONFIG_HDF5_MPI_COMM ) { MPI_Fint F_comm = *(MPI_Fint *)value; MPI_Comm C_comm = MPI_Comm_f2c(F_comm); *ier = (cgint_f)cg_configure((int)*what, &C_comm); #endif /* RIND */ } else if( (int)*what == CG_CONFIG_RIND_INDEX) { if(*(int*)value == 0) { *ier = (cgint_f)cg_configure((int)*what, CG_CONFIG_RIND_ZERO); } else if(*(int*)value == 1) { *ier = (cgint_f)cg_configure((int)*what, CG_CONFIG_RIND_CORE); } else { *ier = (cgint_f)CG_ERROR; return; } /* EVERYTHING ELSE */ } else { *ier = (cgint_f)cg_configure((int)*what, (void *)(*(size_t *)value)); } } CGNSDLL void cg_configure_c_funptr(cgint_f *what, void *value, cgint_f *ier) { if ( (int)*what == CG_CONFIG_ERROR ) { *ier = (cgint_f)cg_configure((int)*what, value); } else { *ier = (cgint_f)CG_ERROR; } return; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridCoordinates_t/DataArray_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_coord_read_f, CG_COORD_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(coordname), CGNS_ENUMT(DataType_t) *type, cgsize_t *rmin, cgsize_t *rmax, void *coord, cgint_f *ier STR_PLEN(coordname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(coordname), STR_LEN(coordname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("coordname='%s'\n", c_name); #endif *ier = (cgint_f)cg_coord_read((int)*fn, (int)*B, (int)*Z, c_name, *type, rmin, rmax, coord); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_coord_general_read_f, CG_COORD_GENERAL_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(coordname), cgsize_t *s_rmin, cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) *m_type, cgint_f *m_numdim, cgsize_t *m_dimvals, cgsize_t *m_rmin, cgsize_t *m_rmax, void *coord, cgint_f *ier STR_PLEN(coordname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(coordname), STR_LEN(coordname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("coordname='%s'\n", c_name); #endif *ier = (cgint_f)cg_coord_general_read( (int)*fn, (int)*B, (int)*Z, c_name, s_rmin, s_rmax, *m_type, (int)*m_numdim, m_dimvals, m_rmin, m_rmax, coord); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_coord_write_f, CG_COORD_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, CGNS_ENUMT(DataType_t) *type, STR_PSTR(coordname), void *coord, cgint_f *C, cgint_f *ier STR_PLEN(coordname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_C; string_2_C_string(STR_PTR(coordname), STR_LEN(coordname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf(" coordname='%s'\n", c_name); #endif *ier = (cgint_f)cg_coord_write((int)*fn, (int)*B, (int)*Z, (CGNS_ENUMT(DataType_t))*type, c_name, coord, &i_C); *C = (cgint_f)i_C; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_coord_partial_write_f, CG_COORD_PARTIAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, CGNS_ENUMT(DataType_t) *type, STR_PSTR(coordname), cgsize_t *rmin, cgsize_t *rmax, void *coord, cgint_f *C, cgint_f *ier STR_PLEN(coordname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_C; string_2_C_string(STR_PTR(coordname), STR_LEN(coordname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf(" coordname='%s'\n", c_name); #endif *ier = (cgint_f)cg_coord_partial_write((int)*fn, (int)*B, (int)*Z, (CGNS_ENUMT(DataType_t))*type, c_name, rmin, rmax, coord, &i_C); *C = (cgint_f)i_C; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_coord_general_write_f, CG_COORD_GENERAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(coordname), CGNS_ENUMT(DataType_t) *s_type, cgsize_t *s_rmin, cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) *m_type, cgint_f *m_numdim, cgsize_t *m_dims, cgsize_t *m_rmin, cgsize_t *m_rmax, void *coord, cgint_f *C, cgint_f *ier STR_PLEN(coordname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_C; string_2_C_string(STR_PTR(coordname), STR_LEN(coordname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf(" coordname='%s'\n", c_name); #endif *ier = (cgint_f)cg_coord_general_write((int)*fn, (int)*B, (int)*Z, c_name, *s_type, s_rmin, s_rmax, *m_type, (int)*m_numdim, m_dims, m_rmin, m_rmax, coord, &i_C); *C = (cgint_f)i_C; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Elements_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_section_read_f, CG_SECTION_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *E, STR_PSTR(section_name), CGNS_ENUMT(ElementType_t) *type, cgsize_t *start, cgsize_t *end, cgint_f *nbndry, cgint_f *parent_flag, cgint_f *ier STR_PLEN(section_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(ElementType_t) i_type; int i_nbndry, i_parent_flag; *ier = (cgint_f)cg_section_read((int)*fn, (int)*B, (int)*Z, (int)*E, c_name, &i_type, start, end, &i_nbndry, &i_parent_flag); if (*ier) return; *type = (CGNS_ENUMT(ElementType_t))i_type; *nbndry = (cgint_f)i_nbndry; *parent_flag = (cgint_f)i_parent_flag; string_2_F_string(c_name, STR_PTR(section_name), STR_LEN(section_name), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_elements_read_f, CG_ELEMENTS_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *E, cgsize_t *elements, cgsize_t *parent_data, cgint_f *ier) { *ier = (cgint_f)cg_elements_read((int)*fn, (int)*B, (int)*Z, (int)*E, elements, parent_data); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_poly_elements_read_f, CG_POLY_ELEMENTS_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *E, cgsize_t *elements, cgsize_t *connect_offset, cgsize_t *parent_data, cgint_f *ier) { *ier = (cgint_f)cg_poly_elements_read((int)*fn, (int)*B, (int)*Z, (int)*E, elements, connect_offset, parent_data); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_elementdatasize_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *E, cgsize_t *ElementDataSize, cgint_f *ier) { *ier = (cgint_f)cg_ElementDataSize((int)*fn, (int)*B, (int)*Z, (int)*E, ElementDataSize); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_elementpartialsize_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *E, cgsize_t *start, cgsize_t *end, cgsize_t *ElementDataSize, cgint_f *ier) { *ier = (cgint_f)cg_ElementPartialSize((int)*fn, (int)*B, (int)*Z, (int)*E, *start, *end, ElementDataSize); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_section_write_f, CG_SECTION_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(section_name), CGNS_ENUMT(ElementType_t)*type, cgsize_t *start, cgsize_t *end, cgint_f *nbndry, cgsize_t *elements, cgint_f *S, cgint_f *ier STR_PLEN(section_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_S; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(section_name), STR_LEN(section_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_section_write((int)*fn, (int)*B, (int)*Z, c_name, *type, *start, *end, (int)*nbndry, elements, &i_S); *S = (cgint_f)i_S; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_poly_section_write_f, CG_POLY_SECTION_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(section_name), CGNS_ENUMT(ElementType_t)*type, cgsize_t *start, cgsize_t *end, cgint_f *nbndry, cgsize_t *elements, cgsize_t *connect_offset, cgint_f *S, cgint_f *ier STR_PLEN(section_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_S; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(section_name), STR_LEN(section_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_poly_section_write((int)*fn, (int)*B, (int)*Z, c_name, *type, *start, *end, (int)*nbndry, elements, connect_offset, &i_S); *S = (cgint_f)i_S; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_section_general_write_f, CG_SECTION_GENERAL_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(section_name), CGNS_ENUMT(ElementType_t)*type, CGNS_ENUMT(DataType_t)* elementDataType, cgsize_t *start, cgsize_t *end, cgsize_t *elementDataSize, cgint_f *nbndry, cgint_f *S, cgint_f *ier STR_PLEN(section_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_S; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(section_name), STR_LEN(section_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_section_general_write((int)*fn, (int)*B, (int)*Z, c_name, *type, *elementDataType, *start, *end, *elementDataSize, (int)*nbndry, &i_S); *S = (cgint_f)i_S; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_section_initialize_f, CG_SECTION_INITIALIZE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgint_f *ier) { *ier = (cgint_f)cg_section_initialize((int)*fn, (int)*B, (int)*Z, (int) *S); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_parent_data_write_f, CG_PARENT_DATA_WRITE_F )(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *parent_data, cgint_f *ier) { *ier = (cgint_f)cg_parent_data_write((int)*fn, (int)*B, (int)*Z, (int)*S, parent_data); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_section_partial_write_f, CG_SECTION_PARTIAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(section_name), CGNS_ENUMT(ElementType_t)*type, cgsize_t *start, cgsize_t *end, cgint_f *nbndry, cgint_f *S, cgint_f *ier STR_PLEN(section_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_S; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(section_name), STR_LEN(section_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_section_partial_write((int)*fn, (int)*B, (int)*Z, c_name, *type, *start, *end, (int)*nbndry, &i_S); *S = (cgint_f)i_S; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_elements_partial_write_f, CG_ELEMENTS_PARTIAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, cgsize_t *elements, cgint_f *ier) { *ier = (cgint_f)cg_elements_partial_write((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, elements); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_elements_general_write_f, CG_ELEMENTS_GENERAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, CGNS_ENUMT(DataType_t) *mtype, void *elements, cgint_f *ier) { *ier = (cgint_f)cg_elements_general_write((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, *mtype, elements); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_poly_elements_partial_write_f, CG_POLY_ELEMENTS_PARTIAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, cgsize_t *elements, cgsize_t *connect_offset, cgint_f *ier) { *ier = (cgint_f)cg_poly_elements_partial_write((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, elements, connect_offset); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_poly_elements_general_write_f, CG_POLY_ELEMENTS_GENERAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, CGNS_ENUMT(DataType_t) *mtype, void *elements, void *connect_offset, cgint_f *ier) { *ier = (cgint_f)cg_poly_elements_general_write((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, *mtype, elements, connect_offset); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_parent_data_partial_write_f, CG_PARENT_DATA_PARTIAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, cgsize_t *parent_data, cgint_f *ier) { *ier = (cgint_f)cg_parent_data_partial_write((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, parent_data); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_elements_partial_read_f, CG_ELEMENTS_PARTIAL_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, cgsize_t *elements, cgsize_t *parent, cgint_f *ier) { *ier = (cgint_f)cg_elements_partial_read((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, elements, parent); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_poly_elements_partial_read_f, CG_POLY_ELEMENTS_PARTIAL_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, cgsize_t *elements, cgsize_t *connect_offset, cgsize_t *parent, cgint_f *ier) { *ier = (cgint_f)cg_poly_elements_partial_read((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, elements, connect_offset, parent); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_elements_general_read_f, CG_ELEMENTS_GENERAL_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, CGNS_ENUMT(DataType_t) *mtype, void *elements, cgint_f *ier) { *ier = (cgint_f)cg_elements_general_read((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, *mtype, elements); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_poly_elements_general_read_f, CG_POLY_ELEMENTS_GENERAL_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, CGNS_ENUMT(DataType_t) *mtype, void *elements, void *connect_offset, cgint_f *ier) { *ier = (cgint_f)cg_poly_elements_general_read((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, *mtype, elements, connect_offset); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_parent_elements_general_read_f, CG_PARENT_ELEMENTS_GENERAL_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, CGNS_ENUMT(DataType_t) *mtype, void *parelem, cgint_f *ier) { *ier = (cgint_f)cg_parent_elements_general_read((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, *mtype, parelem); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_parent_elements_position_general_read_f, CG_PARENT_ELEMENTS_POSITION_GENERAL_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *rmin, cgsize_t *rmax, CGNS_ENUMT(DataType_t) *mtype, void *parface, cgint_f *ier) { *ier = (cgint_f)cg_parent_elements_position_general_read((int)*fn, (int)*B, (int)*Z, (int)*S, *rmin, *rmax, *mtype, parface); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write FlowSolution_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_nsols_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *nsols, cgint_f *ier) { int i_nsols; *ier = (cgint_f)cg_nsols((int)*fn, (int)*B, (int)*Z, &i_nsols); *nsols = (cgint_f)i_nsols; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_sol_info_f, CG_SOL_INFO_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, STR_PSTR(solname), CGNS_ENUMT(GridLocation_t) *location, cgint_f *ier STR_PLEN(solname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(GridLocation_t) i_location; *ier = (cgint_f)cg_sol_info((int)*fn, (int)*B, (int)*Z, (int)*S, c_name, &i_location); if (*ier) return; *location = (cgint_f)i_location; string_2_F_string(c_name, STR_PTR(solname), STR_LEN(solname), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_sol_id_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, double *sol_id, cgint_f *ier) { *ier = (cgint_f)cg_sol_id((int)*fn, (int)*B, (int)*Z, (int)*S, sol_id); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_sol_write_f, CG_SOL_WRITE_F)(cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(solname), CGNS_ENUMT(GridLocation_t)*location, cgint_f *S, cgint_f *ier STR_PLEN(solname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_S; string_2_C_string(STR_PTR(solname), STR_LEN(solname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("\n solname='%s'\n", c_name); #endif *ier = (cgint_f)cg_sol_write((int)*fn, (int)*B, (int)*Z, c_name, *location, &i_S); *S = (cgint_f)i_S; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_sol_size_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgint_f *ndim, cgsize_t *dims, cgint_f *ier) { int i_ndim; *ier = (cgint_f)cg_sol_size((int)*fn, (int)*B, (int)*Z, (int)*S, &i_ndim, dims); *ndim = (cgint_f)i_ndim; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_sol_ptset_info_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, CGNS_ENUMT(PointSetType_t) *ptype, cgsize_t *npnts, cgint_f *ier) { CGNS_ENUMT(PointSetType_t) i_ptype; *ier = (cgint_f)cg_sol_ptset_info((int)*fn, (int)*B, (int)*Z, (int)*S, &i_ptype, npnts); *ptype = i_ptype; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_sol_ptset_read_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *pnts, cgint_f *ier) { *ier = (cgint_f)cg_sol_ptset_read((int)*fn, (int)*B, (int)*Z, (int)*S, pnts); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_sol_ptset_write_f, CG_SOL_PTSET_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(name), CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptype, cgsize_t *npnts, cgsize_t *pnts, cgint_f *S, cgint_f *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_S; string_2_C_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_sol_ptset_write((int)*fn, (int)*B, (int)*Z, c_name, *location, *ptype, *npnts, pnts, &i_S); *S = (cgint_f)i_S; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write solution DataArray_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_nfields_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgint_f *nfields, cgint_f *ier) { int i_nfields; *ier = (cgint_f)cg_nfields((int)*fn, (int)*B, (int)*Z, (int)*S, &i_nfields); *nfields = (cgint_f)i_nfields; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_field_info_f, CG_FIELD_INFO_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgint_f *F, CGNS_ENUMT(DataType_t) *type, STR_PSTR(fieldname), cgint_f *ier STR_PLEN(fieldname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(DataType_t) i_type; *ier = (cgint_f)cg_field_info((int)*fn, (int)*B, (int)*Z, (int)*S, (int)*F, &i_type, c_name); if (*ier) return; *type = i_type; string_2_F_string(c_name, STR_PTR(fieldname), STR_LEN(fieldname), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_field_read_f, CG_FIELD_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, STR_PSTR(fieldname), CGNS_ENUMT(DataType_t) *type, cgsize_t *rmin, cgsize_t *rmax, void *field_ptr, cgint_f *ier STR_PLEN(fieldname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(fieldname), STR_LEN(fieldname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("fieldname='%s'\n", c_name); #endif *ier = (cgint_f)cg_field_read((int)*fn, (int)*B, (int)*Z, (int)*S, c_name, *type, rmin, rmax, field_ptr); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_field_general_read_f, CG_FIELD_GENERAL_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, STR_PSTR(fieldname), cgsize_t *s_rmin, cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) *m_type, cgint_f *m_numdim, cgsize_t *m_dimvals, cgsize_t *m_rmin, cgsize_t *m_rmax, void *field_ptr, cgint_f *ier STR_PLEN(fieldname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(fieldname), STR_LEN(fieldname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("fieldname='%s'\n", c_name); #endif *ier = (cgint_f)cg_field_general_read( (int)*fn, (int)*B, (int)*Z, (int)*S, c_name, s_rmin, s_rmax, *m_type, (int)*m_numdim, m_dimvals, m_rmin, m_rmax, field_ptr); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_field_id_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgint_f *F, double *field_id, cgint_f *ier) { *ier = (cgint_f)cg_field_id((int)*fn, (int)*B, (int)*Z, (int)*S, (int)*F, field_id); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_field_write_f, CG_FIELD_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, CGNS_ENUMT(DataType_t) *type, STR_PSTR(fieldname), void *field_ptr, cgint_f *F, cgint_f *ier STR_PLEN(fieldname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_F; string_2_C_string(STR_PTR(fieldname), STR_LEN(fieldname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf(" fieldname='%s'\n", c_name); #endif *ier = (cgint_f)cg_field_write((int)*fn, (int)*B, (int)*Z, (int)*S, *type, c_name, field_ptr, &i_F); *F = (cgint_f)i_F; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_field_partial_write_f, CG_FIELD_PARTIAL_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, CGNS_ENUMT(DataType_t) *type, STR_PSTR(fieldname), cgsize_t *rmin, cgsize_t *rmax, void *field_ptr, cgint_f *F, cgint_f *ier STR_PLEN(fieldname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_F; string_2_C_string(STR_PTR(fieldname), STR_LEN(fieldname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf(" fieldname='%s'\n", c_name); #endif *ier = (cgint_f)cg_field_partial_write((int)*fn, (int)*B, (int)*Z, (int)*S, *type, c_name, rmin, rmax, field_ptr, &i_F); *F = (cgint_f)i_F; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_field_general_write_f, CG_FIELD_GENERAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, STR_PSTR(fieldname), CGNS_ENUMT(DataType_t) *s_type, cgsize_t *s_rmin, cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) *m_type, cgint_f *m_numdim, cgsize_t *m_dims, cgsize_t *m_rmin, cgsize_t *m_rmax, void *field_ptr, cgint_f *F, cgint_f *ier STR_PLEN(fieldname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_F; string_2_C_string(STR_PTR(fieldname), STR_LEN(fieldname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf(" fieldname='%s'\n", c_name); #endif *ier = (cgint_f)cg_field_general_write((int)*fn, (int)*B, (int)*Z, (int)*S, c_name, *s_type, s_rmin, s_rmax, *m_type, (int)*m_numdim, m_dims, m_rmin, m_rmax, field_ptr, &i_F); *F = (cgint_f)i_F; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ZoneSubRegion_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_nsubregs_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *nsubreg, cgint_f *ier) { int i_nsub; *ier = (cgint_f)cg_nsubregs((int)*fn, (int)*B, (int)*Z, &i_nsub); *nsubreg = (cgint_f)i_nsub; } CGNSDLL void FMNAME(cg_subreg_info_f, CG_SUBREG_INFO_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, STR_PSTR(regname), cgint_f *dimension, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, cgint_f *bcname_len, cgint_f *gcname_len, cgint_f *ier STR_PLEN(regname)) { char c_regname[CGIO_MAX_NAME_LENGTH+1]; int i_dimension, i_bcname_len, i_gcname_len; CGNS_ENUMT(GridLocation_t) i_location; CGNS_ENUMT(PointSetType_t) i_ptset_type; *ier = (cgint_f)cg_subreg_info((int)*fn, (int)*B, (int)*Z, (int)*S, c_regname, &i_dimension, &i_location, &i_ptset_type, npnts, &i_bcname_len, &i_gcname_len); if (*ier) return; string_2_F_string(c_regname, STR_PTR(regname), STR_LEN(regname), ier); *dimension = (cgint_f)i_dimension; *location = i_location; *ptset_type = i_ptset_type; *bcname_len = (cgint_f)i_bcname_len; *gcname_len = (cgint_f)i_gcname_len; } CGNSDLL void cg_subreg_ptset_read_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *pnts, cgint_f *ier) { *ier = (cgint_f)cg_subreg_ptset_read((int)*fn, (int)*B, (int)*Z, (int)*S, pnts); } CGNSDLL void FMNAME(cg_subreg_bcname_read_f, CG_SUBREG_BCNAME_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, STR_PSTR(bcname), cgint_f *ier STR_PLEN(bcname)) { char *name = 0; char regname[CGIO_MAX_NAME_LENGTH+1]; int dimension, bclen, gclen; CGNS_ENUMT(GridLocation_t) location; CGNS_ENUMT(PointSetType_t) ptset_type; cgsize_t npnts; *ier = (cgint_f)cg_subreg_info((int)*fn, (int)*B, (int)*Z, (int)*S, regname, &dimension, &location, &ptset_type, &npnts, &bclen, &gclen); if (*ier) return; if (bclen) name = CGNS_NEW(char, bclen+1); *ier = (cgint_f)cg_subreg_bcname_read((int)*fn, (int)*B, (int)*Z, (int)*S, name); if (!*ier && name) string_2_F_string(name, STR_PTR(bcname), STR_LEN(bcname), ier); CGNS_FREE(name); } CGNSDLL void FMNAME(cg_subreg_gcname_read_f, CG_SUBREG_GCNAME_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, STR_PSTR(gcname), cgint_f *ier STR_PLEN(gcname)) { char *name = 0; char regname[CGIO_MAX_NAME_LENGTH+1]; int dimension, bclen, gclen; CGNS_ENUMT(GridLocation_t) location; CGNS_ENUMT(PointSetType_t) ptset_type; cgsize_t npnts; *ier = (cgint_f)cg_subreg_info((int)*fn, (int)*B, (int)*Z, (int)*S, regname, &dimension, &location, &ptset_type, &npnts, &bclen, &gclen); if (*ier) return; if (gclen) name = CGNS_NEW(char, gclen+1); *ier = (cgint_f)cg_subreg_gcname_read((int)*fn, (int)*B, (int)*Z, (int)*S, name); if (!*ier && name) string_2_F_string(name, STR_PTR(gcname), STR_LEN(gcname), ier); CGNS_FREE(name); } CGNSDLL void FMNAME(cg_subreg_ptset_write_f, CG_SUBREG_PTSET_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(regname), cgint_f *dimension, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, cgsize_t *pnts, cgint_f *S, cgint_f *ier STR_PLEN(regname)) { char c_regname[CGIO_MAX_NAME_LENGTH+1]; int i_S; string_2_C_string(STR_PTR(regname), STR_LEN(regname), c_regname, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_subreg_ptset_write((int)*fn, (int)*B, (int)*Z, c_regname, (int)*dimension, *location, *ptset_type, *npnts, pnts, &i_S); *S = (cgint_f)i_S; } CGNSDLL void FMNAME(cg_subreg_bcname_write_f, CG_SUBREG_BCNAME_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(regname), cgint_f *dimension, STR_PSTR(bcname), cgint_f *S, cgint_f *ier STR_PLEN(regname) STR_PLEN(bcname)) { char c_regname[CGIO_MAX_NAME_LENGTH+1]; char *name; int length, i_S; string_2_C_string(STR_PTR(regname), STR_LEN(regname), c_regname, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; length = (int)STR_LEN(bcname); name = CGNS_NEW(char, length+1); string_2_C_string(STR_PTR(bcname), STR_LEN(bcname), name, length, ier); if (!*ier) { *ier = (cgint_f)cg_subreg_bcname_write((int)*fn, (int)*B, (int)*Z, c_regname, (int)*dimension, name, &i_S); *S = (cgint_f)i_S; } CGNS_FREE(name); } CGNSDLL void FMNAME(cg_subreg_gcname_write_f, CG_SUBREG_GCNAME_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(regname), cgint_f *dimension, STR_PSTR(gcname), cgint_f *S, cgint_f *ier STR_PLEN(regname) STR_PLEN(gcname)) { char c_regname[CGIO_MAX_NAME_LENGTH+1]; char *name; int length, i_S; string_2_C_string(STR_PTR(regname), STR_LEN(regname), c_regname, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; length = (int)STR_LEN(gcname); name = CGNS_NEW(char, length+1); string_2_C_string(STR_PTR(gcname), STR_LEN(gcname), name, length, ier); if (!*ier) { *ier = (cgint_f)cg_subreg_gcname_write((int)*fn, (int)*B, (int)*Z, c_regname, (int)*dimension, name, &i_S); *S = (cgint_f)i_S; } CGNS_FREE(name); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ZoneGridConnectivity_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_nzconns_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *nzconns, cgint_f *ier) { int i_nzconns; *ier = (cgint_f)cg_nzconns((int)*fn, (int)*B, (int)*Z, &i_nzconns); *nzconns = (cgint_f)i_nzconns; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_zconn_read_f, CG_ZCONN_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *C, STR_PSTR(name), cgint_f *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; *ier = (cgint_f)cg_zconn_read((int)*fn, (int)*B, (int)*Z, (int)*C, c_name); if (!*ier) string_2_F_string(c_name, STR_PTR(name), STR_LEN(name), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_zconn_write_f, CG_ZCONN_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(name), cgint_f *C, cgint_f *ier STR_PLEN(name)) { int i_C; char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_zconn_write((int)*fn, (int)*B, (int)*Z, c_name, &i_C); *C = (cgint_f)i_C; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_zconn_get_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *C, cgint_f *ier) { int i_C; *ier = (cgint_f)cg_zconn_get((int)*fn, (int)*B, (int)*Z, &i_C); *C = (cgint_f)i_C; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_zconn_set_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *C, cgint_f *ier) { *ier = (cgint_f)cg_zconn_set((int)*fn, (int)*B, (int)*Z, (int)*C); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write OversetHoles_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_nholes_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *nholes, cgint_f *ier) { int i_nholes; *ier = (cgint_f)cg_nholes((int)*fn, (int)*B, (int)*Z, &i_nholes); *nholes = (cgint_f)i_nholes; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_hole_info_f, CG_HOLE_INFO_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, STR_PSTR(holename), CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *nptsets, cgsize_t *npnts, cgint_f *ier STR_PLEN(holename)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(GridLocation_t) i_location; CGNS_ENUMT(PointSetType_t) i_ptset_type; int i_nptsets; *ier = (cgint_f)cg_hole_info((int)*fn, (int)*B, (int)*Z, (int)*I, c_name, &i_location, &i_ptset_type, &i_nptsets, npnts); if (*ier) return; *location = i_location; *ptset_type = i_ptset_type; *nptsets = i_nptsets; string_2_F_string(c_name, STR_PTR(holename), STR_LEN(holename), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_hole_read_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, cgsize_t *pnts, cgint_f *ier) { *ier = (cgint_f)cg_hole_read((int)*fn, (int)*B, (int)*Z, (int)*I, pnts); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_hole_id_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, double *hole_id, cgint_f *ier) { *ier = (cgint_f)cg_hole_id((int)*fn, (int)*B, (int)*Z, (int)*I, hole_id); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_hole_write_f, CG_HOLE_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(holename), CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, cgint_f *nptsets, cgsize_t *npnts, cgsize_t *pnts, cgint_f *I, cgint_f *ier STR_PLEN(holename)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_I; string_2_C_string(STR_PTR(holename), STR_LEN(holename), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("holename='%s'\n", c_name); #endif *ier = (cgint_f)cg_hole_write((int)*fn, (int)*B, (int)*Z, c_name, *location, *ptset_type, (int)*nptsets, *npnts, pnts, &i_I); *I = (cgint_f)i_I; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridConnectivity_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_nconns_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *nconns, cgint_f *ier) { int i_nconns; *ier = (cgint_f)cg_nconns((int)*fn, (int)*B, (int)*Z, &i_nconns); *nconns = (cgint_f)i_nconns; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_conn_info_f, CG_CONN_INFO_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, STR_PSTR(connectname), CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(GridConnectivityType_t) *type, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, STR_PSTR(donorname), CGNS_ENUMT(ZoneType_t) *donor_zonetype, CGNS_ENUMT(PointSetType_t) *donor_ptset_type, CGNS_ENUMT(DataType_t) *donor_datatype, cgsize_t *ndata_donor, cgint_f *ier STR_PLEN(connectname) STR_PLEN(donorname)) { char cc_name[CGIO_MAX_NAME_LENGTH+1], dc_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(GridLocation_t) i_location; CGNS_ENUMT(GridConnectivityType_t) i_type; CGNS_ENUMT(PointSetType_t) i_ptset_type; CGNS_ENUMT(ZoneType_t) i_donor_zonetype; CGNS_ENUMT(PointSetType_t) i_donor_ptset_type; CGNS_ENUMT(DataType_t) i_donor_datatype; *ier = (cgint_f)cg_conn_info((int)*fn, (int)*B, (int)*Z, (int)*I, cc_name, &i_location, &i_type, &i_ptset_type, npnts, dc_name, &i_donor_zonetype, &i_donor_ptset_type, &i_donor_datatype, ndata_donor); if (*ier) return; string_2_F_string(cc_name, STR_PTR(connectname), STR_LEN(connectname), ier); if (*ier) return; string_2_F_string(dc_name, STR_PTR(donorname), STR_LEN(donorname), ier); if (*ier) return; *location = i_location; *type = i_type; *ptset_type = i_ptset_type; *donor_zonetype = i_donor_zonetype; *donor_ptset_type = i_donor_ptset_type; *donor_datatype = i_donor_datatype; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_conn_read_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, cgsize_t *pnts, CGNS_ENUMT(DataType_t) *donor_datatype, cgsize_t *donor_data, cgint_f *ier) { *ier = (cgint_f)cg_conn_read((int)*fn, (int)*B, (int)*Z, (int)*I, pnts, *donor_datatype, donor_data); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_conn_read_short_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, cgsize_t *pnts, cgint_f *ier) { *ier = (cgint_f)cg_conn_read_short((int)*fn, (int)*B, (int)*Z, (int)*I, pnts); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_conn_id_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, double *conn_id, cgint_f *ier) { *ier = (cgint_f)cg_conn_id((int)*fn, (int)*B, (int)*Z, (int)*I, conn_id); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_conn_write_f, CG_CONN_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(connectname), CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(GridConnectivityType_t) *type, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, cgsize_t *pnts, STR_PSTR(donorname), CGNS_ENUMT(ZoneType_t)*donor_zonetype, CGNS_ENUMT(PointSetType_t)*donor_ptset_type, CGNS_ENUMT(DataType_t)*donor_datatype, cgsize_t *ndata_donor, cgsize_t *donor_data, cgint_f *I, cgint_f *ier STR_PLEN(connectname) STR_PLEN(donorname)) { char cc_name[CGIO_MAX_NAME_LENGTH+1], dc_name[CGIO_MAX_NAME_LENGTH+1]; int i_I; string_2_C_string(STR_PTR(connectname), STR_LEN(connectname), cc_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; string_2_C_string(STR_PTR(donorname), STR_LEN(donorname), dc_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("connectname='%s'\n", cc_name); printf("donorname='%s'\n", dc_name); #endif *ier = (cgint_f)cg_conn_write((int)*fn, (int)*B, (int)*Z, cc_name, *location, *type, *ptset_type, *npnts, pnts, dc_name, *donor_zonetype, *donor_ptset_type, *donor_datatype, *ndata_donor, donor_data, &i_I); *I = (cgint_f)i_I; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_conn_write_short_f, CG_CONN_WRITE_SHORT_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(connectname), CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(GridConnectivityType_t) *type, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, cgsize_t *pnts, STR_PSTR(donorname), cgint_f *I, cgint_f *ier STR_PLEN(connectname) STR_PLEN(donorname)) { char cc_name[CGIO_MAX_NAME_LENGTH+1], dc_name[CGIO_MAX_NAME_LENGTH+1]; int i_I; string_2_C_string(STR_PTR(connectname), STR_LEN(connectname), cc_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; string_2_C_string(STR_PTR(donorname), STR_LEN(donorname), dc_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("connectname='%s'\n", cc_name); printf("donorname='%s'\n", dc_name); #endif *ier = (cgint_f)cg_conn_write_short((int)*fn, (int)*B, (int)*Z, cc_name, *location, *type, *ptset_type, *npnts, pnts, dc_name, &i_I); *I = (cgint_f)i_I; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridConnectivity1to1_t Nodes in a zone * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_n1to1_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f*n1to1, cgint_f *ier) { int i_n1to1; *ier = (cgint_f)cg_n1to1((int)*fn, (int)*B, (int)*Z, &i_n1to1); *n1to1 = (cgint_f)i_n1to1; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_1to1_read_f, CG_1TO1_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, STR_PSTR(connectname), STR_PSTR(donorname), cgsize_t *range, cgsize_t *donor_range, cgint_f *transform, cgint_f *ier STR_PLEN(connectname) STR_PLEN(donorname)) { char cc_name[CGIO_MAX_NAME_LENGTH+1], dc_name[CGIO_MAX_NAME_LENGTH+1]; int n, index_dim, i_transform[3]; *ier = (cgint_f)cg_index_dim((int)*fn, (int)*B, (int)*Z, &index_dim); if (*ier) return; *ier = (cgint_f)cg_1to1_read((int)*fn, (int)*B, (int)*Z, (int)*I, cc_name, dc_name, range, donor_range, i_transform); if (*ier) return; string_2_F_string(cc_name, STR_PTR(connectname), STR_LEN(connectname), ier); if (*ier) return; string_2_F_string(dc_name, STR_PTR(donorname), STR_LEN(donorname), ier); if (*ier) return; for (n = 0; n < index_dim; n++) transform[n] = (cgint_f)i_transform[n]; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_1to1_id_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, double *one21_id, cgint_f *ier) { *ier = (cgint_f)cg_1to1_id((int)*fn, (int)*B, (int)*Z, (int)*I, one21_id); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_1to1_write_f, CG_1TO1_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(connectname), STR_PSTR(donorname), cgsize_t *range, cgsize_t *donor_range, cgint_f *transform, cgint_f *I, cgint_f *ier STR_PLEN(connectname) STR_PLEN(donorname)) { char cc_name[CGIO_MAX_NAME_LENGTH+1], dc_name[CGIO_MAX_NAME_LENGTH+1]; int n, index_dim, i_I, i_transform[3]; *ier = (cgint_f)cg_index_dim((int)*fn, (int)*B, (int)*Z, &index_dim); if (*ier) return; string_2_C_string(STR_PTR(connectname), STR_LEN(connectname), cc_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; string_2_C_string(STR_PTR(donorname), STR_LEN(donorname), dc_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("connectname='%s'\n", cc_name); printf("donorname='%s'\n", dc_name); #endif for (n = 0; n < index_dim; n++) i_transform[n] = (int)transform[n]; *ier = (cgint_f)cg_1to1_write((int)*fn, (int)*B, (int)*Z, cc_name, dc_name, range, donor_range, i_transform, &i_I); *I = (cgint_f)i_I; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read all GridConnectivity1to1_t Nodes of a base * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_n1to1_global_f(cgint_f *fn, cgint_f *B, cgint_f *n1to1_global, cgint_f *ier) { int i_n1to1_global; *ier = (cgint_f)cg_n1to1_global((int)*fn, (int)*B, &i_n1to1_global); *n1to1_global = (cgint_f)i_n1to1_global; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_1to1_read_global_f, CG_1TO1_READ_GLOBAL_F) (cgint_f *fn, cgint_f *B, STR_PSTR(connectname), STR_PSTR(zonename), STR_PSTR(donorname), cgsize_t *range, cgsize_t *donor_range, cgint_f *transform, cgint_f *ier STR_PLEN(connectname) STR_PLEN(zonename) STR_PLEN(donorname)) { int n, i, step, len; int cell_dim, phys_dim; /* number of dimension for model */ int Ndim; /* indexDimension */ int Nglobal; /* number of 1to1 interface in base */ char **c_connectname = NULL, **c_zonename = NULL, **c_donorname = NULL; char basename[CGIO_MAX_NAME_LENGTH+1]; cgsize_t **c_range = NULL, **c_donor_range = NULL; int **c_transform; /* get number of dimension for model: Ndim */ *ier = (cgint_f)cg_base_read((int)*fn, (int)*B, basename, &cell_dim, &phys_dim); if (*ier) return; /* For structured grid: */ Ndim = cell_dim; /* get number of 1to1 interface in base: Nglobal */ *ier = (cgint_f)cg_n1to1_global((int)*fn, (int)*B, &Nglobal); if (*ier) return; if (Nglobal < 1) { cgi_error("Number of interface must equal 1 or more"); *ier = 1; return; } /* allocate memory for C-arrays (ptr-to-ptr) */ if ((c_connectname = (char **)malloc(Nglobal*sizeof(char *)))==NULL || (c_zonename = (char **)malloc(Nglobal*sizeof(char *)))==NULL || (c_donorname = (char **)malloc(Nglobal*sizeof(char *)))==NULL || (c_range = (cgsize_t **)malloc(Nglobal*sizeof(cgsize_t *)))==NULL || (c_donor_range = (cgsize_t **)malloc(Nglobal*sizeof(cgsize_t *)))==NULL || (c_transform = (int **)malloc(Nglobal*sizeof(int *)))==NULL) { cgi_error("Error allocating memory..."); *ier = 1; goto cleanup; } len = CGIO_MAX_NAME_LENGTH+1; for (n = 0; n < Nglobal; n++) { if ((c_connectname[n] = (char *)malloc(len*sizeof(char)))==NULL || (c_zonename[n] = (char *)malloc(len*sizeof(char)))==NULL || (c_donorname[n] = (char *)malloc(len*sizeof(char)))==NULL || (c_range[n] = (cgsize_t *)malloc(6*sizeof(cgsize_t)))==NULL || (c_donor_range[n] = (cgsize_t *)malloc(6*sizeof(cgsize_t)))==NULL || (c_transform[n] = (int *)malloc(3*sizeof(int)))==NULL) { cgi_error("Error allocating memory..."); *ier = 1; goto cleanup; } } /* get all 1to1 interfaces */ *ier = (cgint_f)cg_1to1_read_global((int)*fn, (int)*B, c_connectname, c_zonename, c_donorname, c_range, c_donor_range, c_transform); /* copy C-arrays in Fortran arrays */ if (*ier == 0) { for (n = 0; n < Nglobal; n++) { step = n*CGIO_MAX_NAME_LENGTH; string_2_F_string(c_connectname[n], STR_PTR(connectname)+step, CGIO_MAX_NAME_LENGTH, ier); if (*ier) break; string_2_F_string(c_zonename[n], STR_PTR(zonename) +step, CGIO_MAX_NAME_LENGTH, ier); if (*ier) break; string_2_F_string(c_donorname[n], STR_PTR(donorname) +step, CGIO_MAX_NAME_LENGTH, ier); if (*ier) break; for (i = 0; i < Ndim; i++) { step = Ndim*2*n; range[step+i] = c_range[n][i]; range[step+i+Ndim] = c_range[n][i+Ndim]; donor_range[step+i] = c_donor_range[n][i]; donor_range[step+i+Ndim] = c_donor_range[n][i+Ndim]; transform[Ndim*n+i] = (cgint_f)c_transform[n][i]; } #if DEBUG_FTOC printf("c_connectname[n]='%s'\n",c_connectname[n]); printf("c_zonename [n]='%s'\n",c_zonename[n]); printf("c_donorname [n]='%s'\n",c_donorname[n]); printf("..................12345678901234567890123456789012\n"); #endif } #if DEBUG_FTOC printf("connectname='%s'\n",connectname); printf("zonename ='%s'\n",zonename); printf("donorname ='%s'\n",donorname); printf(".............+2345678901234567890123456789012+2345678901234567890123456789012\n"); #endif } cleanup: for (n = 0; n < Nglobal; n++) { CGNS_FREE(c_connectname[n]); CGNS_FREE(c_zonename[n]); CGNS_FREE(c_donorname[n]); CGNS_FREE(c_range[n]); CGNS_FREE(c_donor_range[n]); CGNS_FREE(c_transform[n]); } CGNS_FREE(c_connectname); CGNS_FREE(c_zonename); CGNS_FREE(c_donorname); CGNS_FREE(c_range); CGNS_FREE(c_donor_range); CGNS_FREE(c_transform); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BC_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_nbocos_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *nbocos, cgint_f *ier) { int i_nbocos; *ier = (cgint_f)cg_nbocos((int)*fn, (int)*B, (int)*Z, &i_nbocos); *nbocos = (cgint_f)i_nbocos; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_boco_info_f, CG_BOCO_INFO_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, STR_PSTR(boconame), CGNS_ENUMT(BCType_t) *bocotype, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, cgint_f *NormalIndex, cgsize_t *NormalListSize, CGNS_ENUMT(DataType_t) *NormalDataType, cgint_f *ndataset, cgint_f *ier STR_PLEN(boconame)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(BCType_t) i_bocotype; CGNS_ENUMT(PointSetType_t) i_ptset_type; CGNS_ENUMT(DataType_t) i_NormalDataType; int n, i_ndataset, index_dim, i_NormalIndex[3]; *ier = (cgint_f)cg_index_dim((int)*fn, (int)*B, (int)*Z, &index_dim); if (*ier) return; *ier = (cgint_f)cg_boco_info((int)*fn, (int)*B, (int)*Z, (int)*BC, c_name, &i_bocotype, &i_ptset_type, npnts, i_NormalIndex, NormalListSize, &i_NormalDataType, &i_ndataset); if (*ier) return; string_2_F_string(c_name, STR_PTR(boconame), STR_LEN(boconame), ier); *bocotype = i_bocotype; *ptset_type = i_ptset_type; *NormalDataType = i_NormalDataType; *ndataset = (cgint_f)i_ndataset; for (n = 0; n < index_dim; n++) NormalIndex[n] = (cgint_f)i_NormalIndex[n]; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_boco_read_f,CG_BOCO_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, cgsize_t *pnts, void *NormalList, cgint_f *ier) { *ier = (cgint_f)cg_boco_read((int)*fn, (int)*B, (int)*Z, (int)*BC, pnts, NormalList); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_boco_id_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, double *boco_id, cgint_f *ier) { *ier = (cgint_f)cg_boco_id((int)*fn, (int)*B, (int)*Z, (int)*BC, boco_id); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_boco_write_f, CG_BOCO_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(boconame), CGNS_ENUMT(BCType_t) *bocotype, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, cgsize_t *pnts, cgint_f *BC, cgint_f *ier STR_PLEN(boconame)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_BC; string_2_C_string(STR_PTR(boconame), STR_LEN(boconame), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("boconame='%s'\n", c_name); #endif *ier = (cgint_f)cg_boco_write((int)*fn, (int)*B, (int)*Z, c_name, *bocotype, *ptset_type, *npnts, pnts, &i_BC); *BC = (cgint_f)i_BC; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_boco_normal_write_f, CG_BOCO_NORMAL_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, cgsize_t *NormalIndex, cgint_f *NormalListFlag, CGNS_ENUMT(DataType_t) *NormalDataType, void *NormalList, cgint_f *ier) { int n, index_dim, i_NormalIndex[3]; *ier = (cgint_f)cg_index_dim((int)*fn, (int)*B, (int)*Z, &index_dim); if (*ier) return; for (n = 0; n < index_dim; n++) i_NormalIndex[n] = (int)NormalIndex[n]; *ier = (cgint_f)cg_boco_normal_write((int)*fn, (int)*B, (int)*Z, (int)*BC, i_NormalIndex, (int)*NormalListFlag, *NormalDataType, NormalList); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_boco_gridlocation_read_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, CGNS_ENUMT(GridLocation_t) *location, cgint_f *ier) { CGNS_ENUMT(GridLocation_t) i_location; *ier = (cgint_f)cg_boco_gridlocation_read((int)*fn, (int)*B, (int)*Z, (int)*BC, &i_location); *location = i_location; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_boco_gridlocation_write_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, CGNS_ENUMT(GridLocation_t) *location, cgint_f *ier) { *ier = (cgint_f)cg_boco_gridlocation_write((int)*fn, (int)*B, (int)*Z, (int)*BC, *location); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BCProperty_t/WallFunction_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_bc_wallfunction_read_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, CGNS_ENUMT(WallFunctionType_t) *WallFunctionType, cgint_f *ier) { CGNS_ENUMT(WallFunctionType_t) i_WallFunctionType; *ier = (cgint_f)cg_bc_wallfunction_read((int)*fn, (int)*B, (int)*Z, (int)*BC, &i_WallFunctionType); *WallFunctionType = i_WallFunctionType; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_bc_wallfunction_write_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, CGNS_ENUMT(WallFunctionType_t) *WallFunctionType, cgint_f *ier) { *ier = (cgint_f)cg_bc_wallfunction_write((int)*fn, (int)*B, (int)*Z, (int)*BC, *WallFunctionType); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BCProperty_t/Area_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_bc_area_read_f, CG_BC_AREA_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, CGNS_ENUMT(AreaType_t) *AreaType, float *SurfaceArea, STR_PSTR(RegionName), cgint_f *ier STR_PLEN(RegionName)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(AreaType_t) i_AreaType; *ier = (cgint_f)cg_bc_area_read((int)*fn, (int)*B, (int)*Z, (int)*BC, &i_AreaType, SurfaceArea, c_name); if (*ier) return; string_2_F_string(c_name, STR_PTR(RegionName), STR_LEN(RegionName), ier); *AreaType = i_AreaType; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_bc_area_write_f, CG_BC_AREA_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, CGNS_ENUMT(AreaType_t) *AreaType, float *SurfaceArea, STR_PSTR(RegionName), cgint_f *ier STR_PLEN(RegionName)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; #if DEBUG_FTOC int n; #endif string_2_C_string(STR_PTR(RegionName), STR_LEN(RegionName), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("RegionName='"); for (n=0; n<32; n++) printf("%c",*((STR_PTR(RegionName))+n)); printf("', c_name='%s'\n", c_name); #endif *ier = (cgint_f)cg_bc_area_write((int)*fn, (int)*B, (int)*Z, (int)*BC, *AreaType, *SurfaceArea, c_name); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridConnectivityProperty_t/Periodic_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_conn_periodic_read_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, float *RotationCenter, float *RotationAngle, float *Translation, cgint_f *ier) { *ier = (cgint_f)cg_conn_periodic_read((int)*fn, (int)*B, (int)*Z, (int)*I, RotationCenter, RotationAngle, Translation); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_conn_periodic_write_f ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, float *RotationCenter, float *RotationAngle, float *Translation, cgint_f *ier) { *ier = (cgint_f)cg_conn_periodic_write((int)*fn, (int)*B, (int)*Z, (int)*I, RotationCenter, RotationAngle, Translation); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_1to1_periodic_read_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, float *RotationCenter, float *RotationAngle, float *Translation, cgint_f *ier) { *ier = (cgint_f)cg_1to1_periodic_read((int)*fn, (int)*B, (int)*Z, (int)*I, RotationCenter, RotationAngle, Translation); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_1to1_periodic_write_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, float *RotationCenter, float *RotationAngle, float *Translation, cgint_f *ier) { *ier = (cgint_f)cg_1to1_periodic_write((int)*fn, (int)*B, (int)*Z, (int)*I, RotationCenter, RotationAngle, Translation); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridConnectivityProperty_t/AverageInterface_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_conn_average_read_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType, cgint_f *ier) { CGNS_ENUMT(AverageInterfaceType_t) i_AverageInterfaceType; *ier = (cgint_f)cg_conn_average_read((int)*fn, (int)*B, (int)*Z, (int)*I, &i_AverageInterfaceType); *AverageInterfaceType = i_AverageInterfaceType; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_conn_average_write_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType, cgint_f *ier) { *ier = (cgint_f)cg_conn_average_write((int)*fn, (int)*B, (int)*Z, (int)*I, *AverageInterfaceType); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_1to1_average_read_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType, cgint_f *ier) { CGNS_ENUMT(AverageInterfaceType_t) i_AverageInterfaceType; *ier = (cgint_f)cg_1to1_average_read((int)*fn, (int)*B, (int)*Z, (int)*I, &i_AverageInterfaceType); *AverageInterfaceType = i_AverageInterfaceType; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_1to1_average_write_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *I, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType, cgint_f *ier) { *ier = (cgint_f)cg_1to1_average_write((int)*fn, (int)*B, (int)*Z, (int)*I, *AverageInterfaceType); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BCDataSet_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_dataset_read_f, CG_DATASET_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, cgint_f *DSet, STR_PSTR(Dataset_name), CGNS_ENUMT(BCType_t) *BCType, cgint_f *DirichletFlag, cgint_f *NeumannFlag, cgint_f *ier STR_PLEN(Dataset_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(BCType_t) i_BCType; int i_DirichletFlag, i_NeumannFlag; *ier = (cgint_f)cg_dataset_read((int)*fn, (int)*B, (int)*Z, (int)*BC, (int)*DSet, c_name, &i_BCType, &i_DirichletFlag, &i_NeumannFlag); if (*ier) return; string_2_F_string(c_name, STR_PTR(Dataset_name), STR_LEN(Dataset_name), ier); *BCType = i_BCType; *DirichletFlag = (cgint_f)i_DirichletFlag; *NeumannFlag = (cgint_f)i_NeumannFlag; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_dataset_write_f, CG_DATASET_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, STR_PSTR(Dataset_name), CGNS_ENUMT(BCType_t) *BCType, cgint_f *Dset, cgint_f *ier STR_PLEN(Dataset_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_Dset; string_2_C_string(STR_PTR(Dataset_name), STR_LEN(Dataset_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("Dataset_name='%s'\n", c_name); #endif *ier = (cgint_f)cg_dataset_write((int)*fn, (int)*B, (int)*Z, (int)*BC, c_name, *BCType, &i_Dset); *Dset = (cgint_f)i_Dset; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_bcdataset_write_f, CG_BCDATASET_WRITE_F) ( STR_PSTR(Dataset_name), CGNS_ENUMT(BCType_t) *BCType, CGNS_ENUMT(BCDataType_t) *BCDataType, cgint_f *ier STR_PLEN(Dataset_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(Dataset_name), STR_LEN(Dataset_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf("Dataset_name='%s'\n", c_name); #endif *ier = (cgint_f)cg_bcdataset_write(c_name, *BCType, *BCDataType); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_bcdataset_info_f( cgint_f *ndataset, cgint_f *ier STR_PLEN(Dataset_name)) { int i_ndataset; *ier = (cgint_f)cg_bcdataset_info(&i_ndataset); *ndataset = (cgint_f)i_ndataset; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_bcdataset_read_f, CG_BCDATASET_READ_F) ( cgint_f *index, STR_PSTR(Dataset_name), CGNS_ENUMT(BCType_t) *BCType, cgint_f *DirichletFlag, cgint_f *NeumannFlag, cgint_f *ier STR_PLEN(Dataset_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(BCType_t) i_BCType; int i_DirichletFlag, i_NeumannFlag; *ier = (cgint_f)cg_bcdataset_read((int)*index, c_name, &i_BCType, &i_DirichletFlag, &i_NeumannFlag); if (*ier) return; *BCType = i_BCType; *DirichletFlag = (cgint_f)i_DirichletFlag; *NeumannFlag = (cgint_f)i_NeumannFlag; string_2_F_string(c_name, STR_PTR(Dataset_name), STR_LEN(Dataset_name), ier); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BCData_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_bcdata_write_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *BC, cgint_f *Dset, CGNS_ENUMT(BCDataType_t) *BCDataType, cgint_f *ier) { *ier = (cgint_f)cg_bcdata_write((int)*fn, (int)*B, (int)*Z, (int)*BC, (int)*Dset, *BCDataType); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write RigidGridMotion_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_n_rigid_motions_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *n_rigid_motions, cgint_f *ier) { int i_n_rigid_motions; *ier = (cgint_f)cg_n_rigid_motions((int)*fn, (int)*B, (int)*Z, &i_n_rigid_motions); *n_rigid_motions = (cgint_f)i_n_rigid_motions; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_rigid_motion_read_f, CG_RIGID_MOTION_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *R, STR_PSTR(rmotion_name), CGNS_ENUMT(RigidGridMotionType_t) *type, cgint_f *ier STR_PLEN(rmotion_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(RigidGridMotionType_t) i_type; *ier = (cgint_f)cg_rigid_motion_read((int)*fn, (int)*B, (int)*Z, (int)*R, c_name, &i_type); if (*ier) return; *type = i_type; string_2_F_string(c_name, STR_PTR(rmotion_name), STR_LEN(rmotion_name), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_rigid_motion_write_f, CG_RIGID_MOTION_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(rmotion_name), CGNS_ENUMT(RigidGridMotionType_t) *type, cgint_f *R, cgint_f *ier STR_PLEN(rmotion_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_R; string_2_C_string(STR_PTR(rmotion_name), STR_LEN(rmotion_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_rigid_motion_write((int)*fn, (int)*B, (int)*Z, c_name, *type, &i_R); *R = (cgint_f)i_R; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ArbitraryGridMotion_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_n_arbitrary_motions_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *n_arbitrary_motions, cgint_f *ier) { int i_n_arbitrary_motions; *ier = (cgint_f)cg_n_arbitrary_motions((int)*fn, (int)*B, (int)*Z, &i_n_arbitrary_motions); *n_arbitrary_motions = (cgint_f)i_n_arbitrary_motions; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_arbitrary_motion_read_f, CG_ARBITRARY_MOTION_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *A, STR_PSTR(amotion_name), CGNS_ENUMT(ArbitraryGridMotionType_t) *type, cgint_f *ier STR_PLEN(amotion_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(ArbitraryGridMotionType_t) i_type; *ier = (cgint_f)cg_arbitrary_motion_read((int)*fn, (int)*B, (int)*Z, (int)*A, c_name, &i_type); if (*ier) return; *type = i_type; string_2_F_string(c_name, STR_PTR(amotion_name), STR_LEN(amotion_name), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_arbitrary_motion_write_f, CG_ARBITRARY_MOTION_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(amotion_name), CGNS_ENUMT(ArbitraryGridMotionType_t) *type, cgint_f *A, cgint_f *ier STR_PLEN(amotion_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_A; string_2_C_string(STR_PTR(amotion_name), STR_LEN(amotion_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_arbitrary_motion_write((int)*fn, (int)*B, (int)*Z, c_name, *type, &i_A); *A = (cgint_f)i_A; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridCoordinates_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_ngrids_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *ngrids, cgint_f *ier) { int i_ngrids; *ier = (cgint_f)cg_ngrids((int)*fn, (int)*B, (int)*Z, &i_ngrids); *ngrids = (cgint_f)i_ngrids; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_grid_read_f, CG_GRID_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *G, STR_PSTR(gridname), cgint_f *ier STR_PLEN(gridname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; *ier = (cgint_f)cg_grid_read((int)*fn, (int)*B, (int)*Z, (int)*G, c_name); if (!*ier) string_2_F_string(c_name, STR_PTR(gridname), STR_LEN(gridname), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_grid_write_f, CG_GRID_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(gridname), cgint_f *G, cgint_f *ier STR_PLEN(gridname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_G; string_2_C_string(STR_PTR(gridname), STR_LEN(gridname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_grid_write((int)*fn, (int)*B, (int)*Z, c_name, &i_G); *G = (cgint_f)i_G; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_grid_bounding_box_write_f, CG_GRID_BOUNDING_BOX_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *G, CGNS_ENUMT(DataType_t) *datatype, void *bbox_array, cgint_f *ier) { *ier = (cgint_f)cg_grid_bounding_box_write( (int)*fn, (int)*B, (int)*Z, (int)*G, *datatype, bbox_array); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_grid_bounding_box_read_f, CG_GRID_BOUNDING_BOX_READ_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *G, CGNS_ENUMT(DataType_t) *datatype, void *bbox_array, cgint_f *ier) { *ier = (cgint_f)cg_grid_bounding_box_read( (int)*fn, (int)*B, (int)*Z, (int)*G, *datatype, bbox_array); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write SimulationType_t Node * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_simulation_type_read_f ( cgint_f *fn, cgint_f *B, CGNS_ENUMT(SimulationType_t) *type, cgint_f *ier) { CGNS_ENUMT(SimulationType_t) i_type; *ier = (cgint_f)cg_simulation_type_read((int)*fn, (int)*B, &i_type); *type = i_type; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_simulation_type_write_f( cgint_f *fn, cgint_f *B, CGNS_ENUMT(SimulationType_t) *type, cgint_f *ier) { *ier = (cgint_f)cg_simulation_type_write((int)*fn, (int)*B, *type); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BaseIterativeData_t Node * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_biter_read_f, CG_BITER_READ_F) (cgint_f *fn, cgint_f *B, STR_PSTR(bitername), cgint_f *nsteps, cgint_f *ier STR_PLEN(bitername)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_nsteps; *ier = (cgint_f)cg_biter_read((int)*fn, (int)*B, c_name, &i_nsteps); if (*ier) return; *nsteps = (cgint_f)i_nsteps; string_2_F_string(c_name, STR_PTR(bitername), STR_LEN(bitername), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_biter_write_f, CG_BITER_WRITE_F) (cgint_f *fn, cgint_f *B, STR_PSTR(bitername), cgint_f *nsteps, cgint_f *ier STR_PLEN(bitername)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(bitername), STR_LEN(bitername), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier == 0) *ier = (cgint_f)cg_biter_write((int)*fn, (int)*B, c_name, (int)*nsteps); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ZoneIterativeData_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_ziter_read_f, CG_ZITER_READ_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(zitername), cgint_f *ier STR_PLEN(zitername)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; *ier = (cgint_f)cg_ziter_read((int)*fn, (int)*B, (int)*Z, c_name); if (*ier == 0) { string_2_F_string(c_name, STR_PTR(zitername), STR_LEN(zitername), ier); } } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_ziter_write_f, CG_ZITER_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(zitername), cgint_f *ier STR_PLEN(zitername)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(zitername), STR_LEN(zitername), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier == 0) *ier = (cgint_f)cg_ziter_write((int)*fn, (int)*B, (int)*Z, c_name); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Gravity_t Node * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_gravity_read_f(cgint_f *fn, cgint_f *B, float *gravity_vector, cgint_f *ier) { *ier = (cgint_f)cg_gravity_read((int)*fn, (int)*B, gravity_vector); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_gravity_write_f(cgint_f *fn, cgint_f *B, float *gravity_vector, cgint_f *ier) { *ier = (cgint_f)cg_gravity_write((int)*fn, (int)*B, gravity_vector); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Axisymmetry_t Node * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_axisym_read_f(cgint_f *fn, cgint_f *B, float *ref_point, float *axis, cgint_f *ier) { *ier = (cgint_f)cg_axisym_read((int)*fn, (int)*B, ref_point, axis); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_axisym_write_f(cgint_f *fn, cgint_f *B, float *ref_point, float *axis, cgint_f *ier) { *ier = (cgint_f)cg_axisym_write((int)*fn, (int)*B, ref_point, axis); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write RotatingCoordinates_t Node * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_rotating_read_f( float *rot_rate, float *rot_center, cgint_f *ier) { *ier = (cgint_f)cg_rotating_read(rot_rate, rot_center); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_rotating_write_f( float *rot_rate, float *rot_center, cgint_f *ier) { *ier = (cgint_f)cg_rotating_write(rot_rate, rot_center); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write IndexArray/Range_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cg_ptset_info_f( CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, cgint_f *ier) { CGNS_ENUMT(PointSetType_t) i_ptset_type; *ier = (cgint_f)cg_ptset_info(&i_ptset_type, npnts); *ptset_type = i_ptset_type; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_ptset_read_f, CG_PTSET_READ_F) (cgsize_t *pnts, cgint_f *ier) { *ier = (cgint_f)cg_ptset_read(pnts); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_ptset_write_f, CG_PTSET_WRITE_F) ( CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, cgsize_t *pnts, cgint_f *ier) { *ier = (cgint_f)cg_ptset_write(*ptset_type, *npnts, pnts); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Go - To Function * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_goto_fc1(int fn, int B, char *c_name, int index) { char *c_label[2]; int c_index[2], n; int ier = 0; if (index < 0) { cgi_error("Incorrect input to function cg_goto_f"); ier = 1; return ier; } c_label[0] = c_name; c_label[1] = "end"; c_index[0] = (int)index; c_index[1] = 0; if (ier == 0) { if (c_label[0][0] == ' ' || 0 == strncmp(c_label[0],"end",3) || 0 == strncmp(c_label[0],"END",3)) { n=0; } else { n=1; } ier = (int)cgi_set_posit((int)fn, (int)B, n, c_index, c_label); } return ier; } CGNSDLL int cg_gorel_fc1(int fn, char* c_name, int index) { int length; char *c_label[2]; int c_index[2], n; int ier = 0; if (posit == 0) { cgi_error ("position not set with cg_goto"); ier = (cgint_f)CG_ERROR; return ier; } if ((int)fn != posit_file) { cgi_error("current position is in the wrong file"); ier = (cgint_f)CG_ERROR; return ier; } if (index < 0) { cgi_error("Incorrect input to function cg_gorel_f1"); ier = 1; return ier; } c_label[0] = c_name; c_label[1] = "end"; c_index[0] = (int)index; c_index[1] = 0; if (ier == 0) { if (c_label[0][0] == ' ' || 0 == strncmp(c_label[0],"end",3) || 0 == strncmp(c_label[0],"END",3)) { n=0; } else { n=1; } ier = (int)cgi_update_posit(n, c_index, c_label); } return ier; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read Multiple path nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_famname_read_f, CG_FAMNAME_READ_F) ( STR_PSTR(famname), cgint_f *ier STR_PLEN(famname)) { char c_name[(CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH+1]; *ier = (cgint_f)cg_famname_read(c_name); if (*ier == 0) string_2_F_string(c_name, STR_PTR(famname), STR_LEN(famname), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_nmultifam_f(cgint_f *nfam, cgint_f *ier) { int i_nfam; *ier = (cgint_f)cg_nmultifam(&i_nfam); *nfam = (cgint_f)i_nfam; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_multifam_read_f, CG_MULTIFAM_READ_F) (cgint_f *N, STR_PSTR(name), STR_PSTR(family), cgint_f *ier STR_PLEN(name) STR_PLEN(family)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; char c_family[(CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH+1]; *ier = (cgint_f)cg_multifam_read((int)*N, c_name, c_family); if (*ier) return; string_2_F_string(c_name, STR_PTR(name), STR_LEN(name), ier); if (*ier) return; string_2_F_string(c_family, STR_PTR(family), STR_LEN(family), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_convergence_read_f, CG_CONVERGENCE_READ_F) ( cgint_f *iterations, STR_PSTR(NormDefinitions), cgint_f *ier STR_PLEN(NormDefinitions)) { char *c_descr_text; int i_iterations; *ier = (cgint_f)cg_convergence_read(&i_iterations, &c_descr_text); if (*ier) return; string_2_F_string(c_descr_text, STR_PTR(NormDefinitions), STR_LEN(NormDefinitions), ier); *iterations = (cgint_f)i_iterations; CGNS_FREE(c_descr_text); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_state_size_f( cgint_f *size, cgint_f *ier) { char *c_descr_text; *ier = (cgint_f)cg_state_read(&c_descr_text); if (*ier) return; *size = (cgint_f)strlen(c_descr_text); CGNS_FREE(c_descr_text); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_state_read_f, CG_STATE_READ_F) ( STR_PSTR(StateDescription), cgint_f *ier STR_PLEN(StateDescription)) { char *c_descr_text; *ier = (cgint_f)cg_state_read(&c_descr_text); if (*ier) return; string_2_F_string(c_descr_text, STR_PTR(StateDescription), STR_LEN(StateDescription), ier); CGNS_FREE(c_descr_text); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_equationset_read_f( cgint_f *EquationDimension, cgint_f *GoverningEquationsFlag, cgint_f *GasModelFlag, cgint_f *ViscosityModelFlag, cgint_f *ThermalConductivityModelFlag, cgint_f *TurbulenceClosureFlag, cgint_f *TurbulenceModelFlag, cgint_f *ier) { int i_EquationDimension, i_GoverningEquationsFlag, i_GasModelFlag; int i_ViscosityModelFlag, i_ThermalConductivityModelFlag; int i_TurbulenceClosureFlag, i_TurbulenceModelFlag; *ier = (cgint_f)cg_equationset_read(&i_EquationDimension, &i_GoverningEquationsFlag, &i_GasModelFlag, &i_ViscosityModelFlag, &i_ThermalConductivityModelFlag, &i_TurbulenceClosureFlag, &i_TurbulenceModelFlag); #if DEBUG_FTOC printf("in cg_ftoc, EquationDimension=%d\n",*EquationDimension); #endif *EquationDimension = (cgint_f)i_EquationDimension; *GoverningEquationsFlag = (cgint_f)i_GoverningEquationsFlag; *GasModelFlag = (cgint_f)i_GasModelFlag; *ViscosityModelFlag = (cgint_f)i_ViscosityModelFlag; *ThermalConductivityModelFlag = (cgint_f)i_ThermalConductivityModelFlag; *TurbulenceClosureFlag = (cgint_f)i_TurbulenceClosureFlag; *TurbulenceModelFlag = (cgint_f)i_TurbulenceModelFlag; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_equationset_chemistry_read_f( cgint_f *ThermalRelaxationFlag, cgint_f *ChemicalKineticsFlag, cgint_f *ier) { int i_ThermalRelaxationFlag, i_ChemicalKineticsFlag; *ier = (cgint_f)cg_equationset_chemistry_read(&i_ThermalRelaxationFlag, &i_ChemicalKineticsFlag); *ThermalRelaxationFlag = (cgint_f)i_ThermalRelaxationFlag; *ChemicalKineticsFlag = (cgint_f)i_ChemicalKineticsFlag; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_equationset_elecmagn_read_f( cgint_f *ElecFldModelFlag, cgint_f *MagnFldModelFlag, cgint_f *ConductivityModelFlag, cgint_f *ier) { int i_ElecFldModelFlag, i_MagnFldModelFlag, i_ConductivityModelFlag; *ier = (cgint_f)cg_equationset_elecmagn_read(&i_ElecFldModelFlag, &i_MagnFldModelFlag, &i_ConductivityModelFlag); *ElecFldModelFlag = (cgint_f)i_ElecFldModelFlag; *MagnFldModelFlag = (cgint_f)i_MagnFldModelFlag; *ConductivityModelFlag = (cgint_f)i_ConductivityModelFlag; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_governing_read_f( CGNS_ENUMT(GoverningEquationsType_t) *EquationsType, cgint_f *ier) { CGNS_ENUMT(GoverningEquationsType_t) i_EquationsType; *ier = (cgint_f)cg_governing_read(&i_EquationsType); *EquationsType = i_EquationsType; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_diffusion_read_f(cgint_f *diffusion_model, cgint_f *ier) { int n, index_dim, ndata, i_diffusion_model[6]; index_dim = cgi_posit_index_dim(); if (index_dim == 1) ndata = 1; else if (index_dim == 2) ndata = 3; else if (index_dim == 3) ndata = 6; else { cgi_error("invalid value for IndexDimension"); *ier = (cgint_f)CG_ERROR; return; } *ier = (cgint_f)cg_diffusion_read(i_diffusion_model); if (*ier) return; for (n = 0; n < ndata; n++) diffusion_model[n] = (cgint_f)i_diffusion_model[n]; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_model_read_f, CG_MODEL_READ_F) (STR_PSTR(ModelLabel), CGNS_ENUMT(ModelType_t) *ModelType, cgint_f *ier STR_PLEN(ModelLabel)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(ModelType_t) i_ModelType; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(ModelLabel), STR_LEN(ModelLabel), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_model_read(c_name, &i_ModelType); *ModelType = i_ModelType; } /*-----------------------------------------------------------------------*/ #ifdef WIN32_FORTRAN CGNSDLL void __stdcall cg_array_read_f(cgint_f *A, void *Data, ...) { va_list ap; cgint_f *ier; int DataDimension; cgsize_t DimensionVector[CGIO_MAX_DIMENSIONS]; char ArrayName[CGIO_MAX_NAME_LENGTH+1]; CGNS_ENUMT(DataType_t) DataType; cg_array_info((int)*A, ArrayName, &DataType, &DataDimension, DimensionVector); va_start(ap, Data); if (DataType == CGNS_ENUMV(Character)) (void) va_arg(ap, int); ier = va_arg(ap, cgsize_t *); va_end(ap); #else CGNSDLL void FMNAME(cg_array_read_f, CG_ARRAY_READ_F) (cgint_f *A, void *Data, cgint_f *ier) { #endif *ier = (cgint_f)cg_array_read((int)*A, Data); } /*-----------------------------------------------------------------------*/ #ifdef WIN32_FORTRAN CGNSDLL void __stdcall cg_array_read_as_f(cgint_f *A, CGNS_ENUMT(DataType_t) *type, void *Data, ...) { va_list ap; cgint_f *ier; va_start(ap, Data); if (*type == CGNS_ENUMV(Character)) (void) va_arg(ap, int); ier = va_arg(ap, cgsize_t *); va_end(ap); #else CGNSDLL void FMNAME(cg_array_read_as_f, CG_ARRAY_READ_AS_F) (cgint_f *A, CGNS_ENUMT(DataType_t) *type, void *Data, cgint_f *ier) { #endif *ier = (cgint_f)cg_array_read_as((int)*A, *type, Data); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_array_general_read_f, CG_ARRAY_GENERAL_READ_F) ( cgint_f *A, cgsize_t *s_rmin, cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) *m_type, cgint_f *m_numdim, cgsize_t *m_dimvals, cgsize_t *m_rmin, cgsize_t *m_rmax, void *data, cgint_f *ier) { *ier = (cgint_f)cg_array_general_read( (int)*A, s_rmin, s_rmax, *m_type, (int)*m_numdim, m_dimvals, m_rmin, m_rmax, data); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_nintegrals_f( cgint_f *nintegrals, cgint_f *ier) { int i_nintegrals; *ier = (cgint_f)cg_nintegrals(&i_nintegrals); *nintegrals = (cgint_f)i_nintegrals; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_integral_read_f, CG_INTEGRAL_READ_F) ( cgint_f *IntegralDataIndex, STR_PSTR(IntegralDataName), cgint_f *ier STR_PLEN(IntegralDataName)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; *ier = (cgint_f)cg_integral_read((int)*IntegralDataIndex, c_name); if (!*ier) string_2_F_string(c_name, STR_PTR(IntegralDataName), STR_LEN(IntegralDataName), ier); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_rind_read_f( cgint_f *RindData, cgint_f *ier) { int n, index_dim, i_RindData[6]; index_dim = cgi_posit_index_dim(); *ier = (cgint_f)cg_rind_read(i_RindData); if (*ier) return; for (n = 0; n < 2*index_dim; n++) RindData[n] = (cgint_f)i_RindData[n]; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_ndescriptors_f(cgint_f *ndescriptors, cgint_f *ier) { int i_ndescriptors; *ier = (cgint_f)cg_ndescriptors(&i_ndescriptors); *ndescriptors = (cgint_f)i_ndescriptors; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_descriptor_size_f( cgint_f *descr_no, cgint_f *descr_size, cgint_f *ier) { char *c_descr_text; char descr_name[CGIO_MAX_NAME_LENGTH+1]; *ier = (cgint_f)cg_descriptor_read((int)*descr_no, descr_name, &c_descr_text); if (!*ier) { *descr_size = (cgint_f)strlen(c_descr_text); CGNS_FREE(c_descr_text); } } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_descriptor_read_f, CG_DESCRIPTOR_READ_F) ( cgint_f *descr_no, STR_PSTR(descr_name), STR_PSTR(descr_text), cgint_f *ier STR_PLEN(descr_name) STR_PLEN(descr_text)) { char *c_descr_text; char c_name[CGIO_MAX_NAME_LENGTH+1]; *ier = (cgint_f)cg_descriptor_read((int)*descr_no, c_name, &c_descr_text); if (*ier) return; #if DEBUG_FTOC printf("In cg_descriptor_read_f, descr_no=%d, descr_name='%s', c_descr_text='%s'\n", *descr_no, c_name, c_descr_text); #endif string_2_F_string(c_name, STR_PTR(descr_name), STR_LEN(descr_name), ier); if (!*ier) string_2_F_string(c_descr_text, STR_PTR(descr_text), STR_LEN(descr_text), ier); CGNS_FREE(c_descr_text); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_nunits_f(cgint_f *nunits, cgint_f *ier) { int i_nunits; *ier = (cgint_f)cg_nunits(&i_nunits); *nunits = (cgint_f)i_nunits; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_units_read_f( CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, CGNS_ENUMT(TemperatureUnits_t) *temperature, CGNS_ENUMT(AngleUnits_t) *angle, cgint_f *ier) { CGNS_ENUMT(MassUnits_t) i_mass; CGNS_ENUMT(LengthUnits_t) i_length; CGNS_ENUMT(TimeUnits_t) i_time; CGNS_ENUMT(TemperatureUnits_t) i_temperature; CGNS_ENUMT(AngleUnits_t) i_angle; *ier = (cgint_f)cg_units_read(&i_mass, &i_length, &i_time, &i_temperature, &i_angle); *mass = i_mass; *length = i_length; *time = i_time; *temperature = i_temperature; *angle = i_angle; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_unitsfull_read_f( CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, CGNS_ENUMT(TemperatureUnits_t) *temperature, CGNS_ENUMT(AngleUnits_t) *angle, CGNS_ENUMT(ElectricCurrentUnits_t) *current, CGNS_ENUMT(SubstanceAmountUnits_t) *amount, CGNS_ENUMT(LuminousIntensityUnits_t) *intensity, cgint_f *ier) { CGNS_ENUMT(MassUnits_t) i_mass; CGNS_ENUMT(LengthUnits_t) i_length; CGNS_ENUMT(TimeUnits_t) i_time; CGNS_ENUMT(TemperatureUnits_t) i_temperature; CGNS_ENUMT(AngleUnits_t) i_angle; CGNS_ENUMT(ElectricCurrentUnits_t) i_current; CGNS_ENUMT(SubstanceAmountUnits_t) i_amount; CGNS_ENUMT(LuminousIntensityUnits_t) i_intensity; *ier = (cgint_f)cg_unitsfull_read(&i_mass, &i_length, &i_time, &i_temperature, &i_angle, &i_current, &i_amount, &i_intensity); *mass = i_mass; *length = i_length; *time = i_time; *temperature = i_temperature; *angle = i_angle; *current = i_current; *amount = i_amount; *intensity = i_intensity; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_exponents_info_f(CGNS_ENUMT(DataType_t) *DataType, cgint_f *ier) { CGNS_ENUMT(DataType_t) i_DataType; *ier = (cgint_f)cg_exponents_info(&i_DataType); *DataType = i_DataType; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_nexponents_f(cgint_f*nexps, cgint_f *ier) { int i_nexps; *ier = (cgint_f)cg_nexponents(&i_nexps); *nexps = (cgint_f)i_nexps; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_exponents_read_f, CG_EXPONENTS_READ_F) (void *exponents, cgint_f *ier) { *ier = (cgint_f)cg_exponents_read(exponents); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_expfull_read_f, CG_EXPFULL_READ_F) (void *exponents, cgint_f *ier) { *ier = (cgint_f)cg_expfull_read(exponents); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_conversion_info_f(CGNS_ENUMT(DataType_t) *DataType, cgint_f *ier) { CGNS_ENUMT(DataType_t) i_DataType; *ier = (cgint_f)cg_conversion_info(&i_DataType); *DataType = i_DataType; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_conversion_read_f,CG_CONVERSION_READ_F) (void *ConversionFactors, cgint_f *ier) { *ier = (cgint_f)cg_conversion_read(ConversionFactors); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_dataclass_read_f(CGNS_ENUMT(DataClass_t) *dataclass, cgint_f *ier) { CGNS_ENUMT(DataClass_t) i_dataclass; *ier = (cgint_f)cg_dataclass_read(&i_dataclass); *dataclass = i_dataclass; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_gridlocation_read_f( CGNS_ENUMT(GridLocation_t) *GridLocation, cgint_f *ier) { CGNS_ENUMT(GridLocation_t) i_GridLocation; *ier = (cgint_f)cg_gridlocation_read(&i_GridLocation); *GridLocation = i_GridLocation; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_ordinal_read_f(cgint_f *Ordinal, cgint_f *ier) { int i_Ordinal; *ier = (cgint_f)cg_ordinal_read(&i_Ordinal); *Ordinal = (cgint_f)i_Ordinal; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_npe_f(CGNS_ENUMT(ElementType_t) *type, cgint_f *npe, cgint_f *ier) { int i_npe; *ier = (cgint_f)cg_npe(*type, &i_npe); *npe = (cgint_f)i_npe; } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_is_link_f(cgint_f *path_length, cgint_f *ier) { int i_path_length; *ier = (cgint_f)cg_is_link(&i_path_length); *path_length = (cgint_f)i_path_length; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_link_read_f, CG_LINK_READ_F) ( STR_PSTR(filename), STR_PSTR(link_path), cgint_f *ier STR_PLEN(filename) STR_PLEN(link_path)) { char *f_name, *l_name; *ier = (cgint_f)cg_link_read(&f_name, &l_name); if (*ier) return; string_2_F_string(f_name, STR_PTR(filename), STR_LEN(filename), ier); if (*ier == 0) string_2_F_string(l_name, STR_PTR(link_path), STR_LEN(link_path), ier); CGNS_FREE(f_name); CGNS_FREE(l_name); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_nuser_data_f( cgint_f *nuser_data, cgint_f *ier) { int i_nuser_data; *ier = (cgint_f)cg_nuser_data(&i_nuser_data); *nuser_data = (cgint_f)i_nuser_data; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_user_data_read_f, CG_USER_DATA_READ_F) (cgint_f *index, STR_PSTR(dataname), cgint_f *ier STR_PLEN(dataname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; *ier = (cgint_f)cg_user_data_read((int)*index, c_name); if (*ier == 0) string_2_F_string(c_name, STR_PTR(dataname), STR_LEN(dataname), ier); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Write Multiple path nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_famname_write_f, CG_FAMNAME_WRITE_F) ( STR_PSTR(family_name), cgint_f *ier STR_PLEN(family_name)) { char c_name[(CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH+1]; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(family_name), STR_LEN(family_name), c_name, (CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH, ier); if (*ier == 0) *ier = (cgint_f)cg_famname_write(c_name); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_multifam_write_f, CG_MULTIFAM_WRITE_F) ( STR_PSTR(name), STR_PSTR(family), cgint_f *ier STR_PLEN(name) STR_PLEN(family)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; char c_family[(CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH+1]; string_2_C_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; string_2_C_string(STR_PTR(family), STR_LEN(family), c_family, (CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH, ier); if (*ier) return; *ier = (cgint_f)cg_multifam_write(c_name, c_family); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_convergence_write_f, CG_CONVERGENCE_WRITE_F) ( cgint_f *iterations, STR_PSTR(NormDefinitions), cgint_f *ier STR_PLEN(NormDefinitions)) { char *c_string; int len; len = STR_LEN(NormDefinitions); /* convert Fortran-text-string to a C-string */ c_string = CGNS_NEW(char, len+1); string_2_C_string(STR_PTR(NormDefinitions), len, c_string, len, ier); if (*ier == 0) { #if DEBUG_FTOC printf("In cg_ftoc: c_NormDefinitions = '%s'",c_string); #endif *ier = (cgint_f)cg_convergence_write((int)*iterations, c_string); } CGNS_FREE(c_string); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_state_write_f, CG_STATE_WRITE_F) (STR_PSTR(StateDescription), cgint_f *ier STR_PLEN(StateDescription)) { char *c_string; int len; len = STR_LEN(StateDescription); /* convert Fortran-text-string to a C-string */ c_string = CGNS_NEW(char, len+1); string_2_C_string(STR_PTR(StateDescription), len, c_string, len, ier); if (*ier == 0) { #if DEBUG_FTOC printf("In cg_ftoc: C_StateDescription = '%s'",c_string); #endif *ier = (cgint_f)cg_state_write(c_string); } CGNS_FREE(c_string); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_equationset_write_f(cgint_f *EquationDimension, cgint_f *ier) { #if DEBUG_FTOC printf("In cg_ftoc: EquationDimension=%d\n",*EquationDimension); #endif *ier = (cgint_f)cg_equationset_write((int)*EquationDimension); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_governing_write_f( CGNS_ENUMT(GoverningEquationsType_t) *Equationstype, cgint_f *ier) { *ier = (cgint_f)cg_governing_write(*Equationstype); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_diffusion_write_f( cgint_f *diffusion_model, cgint_f *ier) { int n, index_dim, ndata, i_diffusion_model[6]; index_dim = cgi_posit_index_dim(); if (index_dim == 1) ndata = 1; else if (index_dim == 2) ndata = 3; else if (index_dim == 3) ndata = 6; else { cgi_error("invalid value for IndexDimension"); *ier = (cgint_f)CG_ERROR; return; } for (n = 0; n < ndata; n++) i_diffusion_model[n] = (int)diffusion_model[n]; *ier = (cgint_f)cg_diffusion_write(i_diffusion_model); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_model_write_f, CG_MODEL_WRITE_F) (STR_PSTR(ModelLabel), CGNS_ENUMT(ModelType_t) *ModelType, cgint_f *ier STR_PLEN(ModelLabel)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(ModelLabel), STR_LEN(ModelLabel), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier == 0) *ier = (cgint_f)cg_model_write(c_name, *ModelType); } /*-----------------------------------------------------------------------*/ #ifdef WIN32_FORTRAN CGNSDLL void __stdcall cg_array_write_f(STR_PSTR(ArrayName), CGNS_ENUMT(DataType_t) *DataType, cgint_f *DataDimension, cgsize_t *DimensionVector, void *Data, ...) { va_list ap; cgint_f *ier; char c_name[CGIO_MAX_NAME_LENGTH+1]; va_start(ap, Data); if ((CGNS_ENUMT(DataType_t))*DataType == CGNS_ENUMV(Character)) (void) va_arg(ap, int); ier = va_arg(ap, cgsize_t *); va_end(ap); #else CGNSDLL void FMNAME(cg_array_write_f, CG_ARRAY_WRITE_F) (STR_PSTR(ArrayName), CGNS_ENUMT(DataType_t) *DataType, cgint_f *DataDimension, cgsize_t *DimensionVector, void *Data, cgint_f *ier STR_PLEN(ArrayName)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; #endif /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(ArrayName), STR_LEN(ArrayName), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier == 0) *ier = (cgint_f)cg_array_write(c_name, *DataType, (int)*DataDimension, DimensionVector, Data); } /* CGNSDLL void cg_array_write_f03 (ArrayName, */ /* CGNS_ENUMT(DataType_t) *DataType, cgint_f *DataDimension, cgsize_t *DimensionVector, */ /* void *Data, cgint_f *ier STR_PLEN(ArrayName)) */ /* { */ /* char c_name[CGIO_MAX_NAME_LENGTH+1]; */ /* /\* convert Fortran-text-string to a C-string *\/ */ /* string_2_C_string(STR_PTR(ArrayName), STR_LEN(ArrayName), */ /* c_name, CGIO_MAX_NAME_LENGTH, ier); */ /* if (*ier == 0) */ /* *ier = (cgint_f)cg_array_write(c_name, *DataType, */ /* (int)*DataDimension, DimensionVector, Data); */ /* } */ /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_array_general_write_f, CG_ARRAY_GENERAL_WRITE_F) ( STR_PSTR(arrayname), CGNS_ENUMT(DataType_t) *s_type, cgint_f *s_numdim, cgsize_t *s_dimvals, cgsize_t *s_rmin, cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) *m_type, cgint_f *m_numdim, cgsize_t *m_dimvals, cgsize_t *m_rmin, cgsize_t *m_rmax, void *data, cgint_f *ier STR_PLEN(arrayname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(arrayname), STR_LEN(arrayname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; #if DEBUG_FTOC printf(" arrayname='%s'\n", c_name); #endif *ier = (cgint_f)cg_array_general_write(c_name, *s_type, (int)*s_numdim, s_dimvals, s_rmin, s_rmax, *m_type, (int)*m_numdim, m_dimvals, m_rmin, m_rmax, data); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_integral_write_f, CG_INTEGRAL_WRITE_F) ( STR_PSTR(IntegralDataName), cgint_f *ier STR_PLEN(IntegralDataName)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(IntegralDataName), STR_LEN(IntegralDataName), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier == 0) *ier = (cgint_f)cg_integral_write(c_name); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_rind_write_f(cgint_f *RindData, cgint_f *ier) { int n, index_dim, i_RindData[6]; index_dim = cgi_posit_index_dim(); for (n = 0; n < 2*index_dim; n++) i_RindData[n] = (int)RindData[n]; *ier = (cgint_f)cg_rind_write(i_RindData); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_descriptor_write_f, CG_DESCRIPTOR_WRITE_F) ( STR_PSTR(descr_name), STR_PSTR(descr_text), cgint_f *ier STR_PLEN(descr_name) STR_PLEN(descr_text)) { char *c_descr_text, c_descr_name[CGIO_MAX_NAME_LENGTH+1]; int len; /* On Linux, the string found in STR_PTR(descr_text) is not terminated. Therefore it can be much longer and can't be used as is. The value returned by STR_LEN(descr_text) is correct. So the string can be terminatted properly: char *terminated_descr_text; terminated_descr_text=(char*)malloc(strlen(STR_PTR(descr_text))+1); strcpy(terminated_descr_text,STR_PTR(descr_text)); terminated_descr_text[STR_LEN(descr_text)]='\0'; It's not necessary to do this here since we're always calling get_adf_c_name() which truncates the string to STR_LEN(descr_name) or shorter. */ /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(descr_name), STR_LEN(descr_name), c_descr_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; len = STR_LEN(descr_text); c_descr_text = CGNS_NEW(char, len+1); string_2_C_string(STR_PTR(descr_text), len, c_descr_text, len, ier); if (*ier == 0) { #if DEBUG_FTOC printf("c_descr_name='%s', c_descr_text='%s'\n",c_descr_name, c_descr_text); #endif /* Call C-routine */ *ier = (cgint_f)cg_descriptor_write(c_descr_name, c_descr_text); } CGNS_FREE(c_descr_text); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_units_write_f( CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, CGNS_ENUMT(TemperatureUnits_t) *temperature, CGNS_ENUMT(AngleUnits_t) *angle, cgint_f *ier) { *ier = (cgint_f)cg_units_write(*mass, *length, *time, *temperature, *angle); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_unitsfull_write_f( CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, CGNS_ENUMT(TemperatureUnits_t) *temperature, CGNS_ENUMT(AngleUnits_t) *angle, CGNS_ENUMT(ElectricCurrentUnits_t) *current, CGNS_ENUMT(SubstanceAmountUnits_t) *amount, CGNS_ENUMT(LuminousIntensityUnits_t) *intensity, cgint_f *ier) { *ier = (cgint_f)cg_unitsfull_write(*mass, *length, *time, *temperature, *angle, *current, *amount, *intensity); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_exponents_write_f,CG_EXPONENTS_WRITE_F) ( CGNS_ENUMT(DataType_t)*DataType, void *exponents, cgint_f *ier) { *ier = (cgint_f)cg_exponents_write(*DataType, exponents); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_expfull_write_f, CG_EXPFULL_WRITE_F) ( CGNS_ENUMT(DataType_t) *DataType, void *exponents, cgint_f *ier) { *ier = (cgint_f)cg_expfull_write(*DataType, exponents); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_conversion_write_f, CG_CONVERSION_WRITE_F) ( CGNS_ENUMT(DataType_t) *DataType, void *ConversionFactors, cgint_f *ier) { *ier = (cgint_f)cg_conversion_write(*DataType, ConversionFactors); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_dataclass_write_f( CGNS_ENUMT(DataClass_t) *dataclass, cgint_f *ier) { *ier = (cgint_f)cg_dataclass_write(*dataclass); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_gridlocation_write_f( CGNS_ENUMT(GridLocation_t) *GridLocation, cgint_f *ier) { *ier = (cgint_f)cg_gridlocation_write(*GridLocation); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_ordinal_write_f(cgint_f *Ordinal, cgint_f *ier) { *ier = (cgint_f)cg_ordinal_write((int)*Ordinal); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_link_write_f, CG_LINK_WRITE_F) ( STR_PSTR(nodename), STR_PSTR(filename), STR_PSTR(name_in_file), cgint_f *ier STR_PLEN(nodename) STR_PLEN(filename) STR_PLEN(name_in_file)) { char n_name[CGIO_MAX_NAME_LENGTH+1]; char f_name[CGIO_MAX_FILE_LENGTH+1]; char i_name[CGIO_MAX_LINK_LENGTH+1]; string_2_C_string(STR_PTR(nodename), STR_LEN(nodename), n_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; string_2_C_string(STR_PTR(filename), STR_LEN(filename), f_name, CGIO_MAX_FILE_LENGTH, ier); if (*ier) return; string_2_C_string(STR_PTR(name_in_file), STR_LEN(name_in_file), i_name, CGIO_MAX_LINK_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_link_write(n_name, f_name, i_name); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cg_user_data_write_f, CG_USER_DATA_WRITE_F) ( STR_PSTR(dataname), cgint_f *ier STR_PLEN(dataname)) { char d_name[CGIO_MAX_NAME_LENGTH+1]; string_2_C_string(STR_PTR(dataname), STR_LEN(dataname), d_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier == 0) *ier = (cgint_f)cg_user_data_write(d_name); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * General Delete Function * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_delete_node_f, CG_DELETE_NODE_F) (STR_PSTR(node_name), cgint_f *ier STR_PLEN(node_name)) { /* ici */ char c_name[CGIO_MAX_NAME_LENGTH+1]; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(node_name), STR_LEN(node_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cg_delete_node(c_name); #if DEBUG_FTOC printf("\n Deleting node ='%s'\n", c_name); #endif } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Error Handling Functions * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void FMNAME(cg_get_error_f, CG_GET_ERROR_F) ( STR_PSTR(errmsg) STR_PLEN(errmsg)) { cgint_f ierr; string_2_F_string ((char *)cg_get_error(), STR_PTR(errmsg), STR_LEN(errmsg), &ierr); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_error_exit_f() { cg_error_exit(); } /*-----------------------------------------------------------------------*/ CGNSDLL void cg_error_print_f() { cg_error_print(); } /*-----------------------------------------------------------------------*/ static void exit_on_error(int is_fatal, char *errmsg) { if (is_fatal) { fprintf(stderr, "FATAL ERROR:%s\n", errmsg); exit(1); } } CGNSDLL void cg_exit_on_error_f(cgint_f *flag) { cg_error_handler((int)*flag ? exit_on_error : NULL); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgio_set_dimensions_f_0, CGIO_SET_DIMENSIONS_F_0) ( cgint_f *cgio_num, double *id, STR_PSTR(data_type), cgint_f *ndims, cgsize_t *dims, cgint_f *ier STR_PLEN(data_type) ) { char c_type[CGIO_MAX_DATATYPE_LENGTH+1]; string_2_C_string(STR_PTR(data_type), STR_LEN(data_type), c_type, CGIO_MAX_DATATYPE_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cgio_set_dimensions((int)*cgio_num, *id, c_type, (int)*ndims, dims); } CGNSDLL void FMNAME(cgio_set_dimensions_f_1, CGIO_SET_DIMENSIONS_F_1) ( cgint_f *cgio_num, double *id, STR_PSTR(data_type), cgint_f *ndims, cgsize_t *dims, cgint_f *ier STR_PLEN(data_type) ) { char c_type[CGIO_MAX_DATATYPE_LENGTH+1]; string_2_C_string(STR_PTR(data_type), STR_LEN(data_type), c_type, CGIO_MAX_DATATYPE_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cgio_set_dimensions((int)*cgio_num, *id, c_type, (int)*ndims, dims); } CGNSDLL void cgio_get_dimensions_f_0( cgint_f *cgio_num, double *id, cgint_f *ndims, cgsize_t *dims, cgint_f *ier) { int i_ndims; *ier = (cgint_f)cgio_get_dimensions((int)*cgio_num, *id, &i_ndims, dims); *ndims = (cgint_f)i_ndims; } CGNSDLL void cgio_get_dimensions_f_1( cgint_f *cgio_num, double *id, cgint_f *ndims, cgsize_t *dims, cgint_f *ier) { int i_ndims; *ier = (cgint_f)cgio_get_dimensions((int)*cgio_num, *id, &i_ndims, dims); *ndims = (cgint_f)i_ndims; } #if CG_BUILD_PARALLEL /*====================================================================== * parallel IO interface *======================================================================*/ CGNSDLL void cgp_mpi_comm_f(cgint_f *mpi_comm_f, cgint_f *ier) { MPI_Comm mpi_comm_c; mpi_comm_c = MPI_Comm_f2c((int)*mpi_comm_f); *ier = (cgint_f)cgp_mpi_comm(mpi_comm_c); } CGNSDLL void cgp_mpi_info_f(int *pcg_mpi_info_f, cgint_f *ier) { MPI_Info pcg_mpi_info_c; pcg_mpi_info_c = MPI_Info_f2c((int)*pcg_mpi_info_f); *ier = (cgint_f)cgp_mpi_info(pcg_mpi_info_c); } /*-----------------------------------------------------------------------*/ CGNSDLL void cgp_pio_mode_f(CGNS_ENUMT(PIOmode_t) *mode, cgint_f *ier) { *ier = (cgint_f)cgp_pio_mode(*mode); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_open_f, CGP_OPEN_F) (STR_PSTR(filename), int *mode, cgint_f *fn, cgint_f *ier STR_PLEN(filename)) { int length, i_fn; char *c_name; length = (int) STR_LEN(filename); c_name = CGNS_NEW(char, length+1); string_2_C_string(STR_PTR(filename), STR_LEN(filename), c_name, length, ier); if (*ier == 0) { #if DEBUG_FTOC printf("filename='%s'\n",c_name); #endif *ier = (cgint_f)cgp_open(c_name, *mode, &i_fn); *fn = (cgint_f)i_fn; } CGNS_FREE(c_name); } /*-----------------------------------------------------------------------*/ CGNSDLL void cgp_close_f(cgint_f *fn, cgint_f *ier) { *ier = (cgint_f)cgp_close((int)*fn); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_coord_write_f, CGP_COORD_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, CGNS_ENUMT(DataType_t) *type, STR_PSTR(coordname), cgint_f *C, cgint_f *ier STR_PLEN(coordname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_C; string_2_C_string(STR_PTR(coordname), STR_LEN(coordname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cgp_coord_write((int)*fn, (int)*B, (int)*Z, *type, c_name, &i_C); *C = (cgint_f)i_C; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_coord_write_data_f,CGP_COORD_WRITE_DATA_F)( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *C, cgsize_t *rmin, cgsize_t *rmax, void *data, cgint_f *ier) { *ier = (cgint_f)cgp_coord_write_data((int)*fn, (int)*B, (int)*Z, (int)*C, rmin, rmax, data); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_coord_read_data_f,CGP_COORD_READ_DATA_F)( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *C, cgsize_t *rmin, cgsize_t *rmax, void *data, cgint_f *ier) { *ier = (cgint_f)cgp_coord_read_data((int)*fn, (int)*B, (int)*Z, (int)*C, rmin, rmax, data); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_section_write_f, CGP_SECTION_WRITE_F) ( cgint_f *fn, cgint_f *B, cgint_f *Z, STR_PSTR(section_name), CGNS_ENUMT(ElementType_t)*type, cgsize_t *start, cgsize_t *end, cgint_f *nbndry, cgint_f *S, cgint_f *ier STR_PLEN(section_name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_S; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(section_name), STR_LEN(section_name), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cgp_section_write((int)*fn, (int)*B, (int)*Z, c_name, *type, *start, *end, (int)*nbndry, &i_S); *S = (cgint_f)i_S; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_elements_write_data_f,CGP_ELEMENTS_WRITE_DATA_F)( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *start, cgsize_t *end, cgsize_t *elements, cgint_f *ier) { *ier = (cgint_f)cgp_elements_write_data((int)*fn, (int)*B, (int)*Z, (int)*S, *start, *end, elements); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_elements_read_data_f,CGP_ELEMENTS_READ_DATA_F)( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgsize_t *start, cgsize_t *end, cgsize_t *elements, cgint_f *ier) { *ier = (cgint_f)cgp_elements_read_data((int)*fn, (int)*B, (int)*Z, (int)*S, *start, *end, elements); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_field_write_f, CGP_FIELD_WRITE_F) (cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, CGNS_ENUMT(DataType_t) *type, STR_PSTR(fieldname), cgint_f *F, cgint_f *ier STR_PLEN(fieldname)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_F; string_2_C_string(STR_PTR(fieldname), STR_LEN(fieldname), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cgp_field_write((int)*fn, (int)*B, (int)*Z, (int)*S, *type, c_name, &i_F); *F = (cgint_f)i_F; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_field_write_data_f,CGP_FIELD_WRITE_DATA_F)( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgint_f *F, cgsize_t *rmin, cgsize_t *rmax, void *field_ptr, cgint_f *ier) { *ier = (cgint_f)cgp_field_write_data((int)*fn, (int)*B, (int)*Z, (int)*S, (int)*F, rmin, rmax, field_ptr); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_field_read_data_f,CGP_FIELD_READ_DATA_F)( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgint_f *F, cgsize_t *rmin, cgsize_t *rmax, void *field_ptr, cgint_f *ier) { *ier = (cgint_f)cgp_field_read_data((int)*fn, (int)*B, (int)*Z, (int)*S, (int)*F, rmin, rmax, field_ptr); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_array_write_f, CGP_ARRAY_WRITE_F) (STR_PSTR(ArrayName), CGNS_ENUMT(DataType_t) *DataType, cgint_f *DataDimension, cgsize_t *DimensionVector, cgint_f *A, cgint_f *ier STR_PLEN(ArrayName)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; int i_A; /* convert Fortran-text-string to a C-string */ string_2_C_string(STR_PTR(ArrayName), STR_LEN(ArrayName), c_name, CGIO_MAX_NAME_LENGTH, ier); if (*ier) return; *ier = (cgint_f)cgp_array_write(c_name, *DataType, (int)*DataDimension, DimensionVector, &i_A); *A = (cgint_f)i_A; } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_array_write_data_f, CGP_ARRAY_WRITE_DATA_F) ( cgint_f *A, cgsize_t *rmin, cgsize_t *rmax, void *data, cgint_f *ier) { *ier = (cgint_f)cgp_array_write_data((int)*A, rmin, rmax, data); } /*-----------------------------------------------------------------------*/ CGNSDLL void FMNAME(cgp_array_read_data_f, CGP_ARRAY_READ_DATA_F) ( cgint_f *A, cgsize_t *rmin, cgsize_t *rmax, void *data, cgint_f *ier) { *ier = (cgint_f)cgp_array_read_data((int)*A, rmin, rmax, data); } /*-----------------------------------------------------------------------*/ CGNSDLL void cgp_error_exit_f() { cgp_error_exit(); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * cgp_coord_multi_read_data Function * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cgp_coord_multi_read_data_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *C, cgsize_t *rmin, cgsize_t *rmax, cgint_f *nsets, void *buf[], cgint_f *ier) { int *C_c; int n; if(sizeof(cgsize_t)!=sizeof(int)) { /* type cast C from cgsize_t to an int */ if ((C_c = (int *)malloc(*nsets*sizeof(int)))==NULL) { cgi_error("Error allocating memory..."); *ier = 1; return; } for (n = 0; n < *nsets; n++) { C_c[n] = (int)C[n]; } *ier = (cgint_f)cgp_coord_multi_read_data((int)*fn, (int)*B, (int)*Z, C_c, rmin, rmax, (int)*nsets, buf); free(C_c); } else { *ier = (cgint_f)cgp_coord_multi_read_data((int)*fn, (int)*B, (int)*Z, C, rmin, rmax, (int)*nsets, buf); } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * cgp_coord_multi_write_data Function * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cgp_coord_multi_write_data_f(cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *C, cgsize_t *rmin, cgsize_t *rmax, cgint_f *nsets, const void *buf[], cgint_f *ier) { *ier = (cgint_f)cgp_coord_multi_write_data((int)*fn, (int)*B, (int)*Z, (int*)C, rmin, rmax, (int)*nsets, buf); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * cgp_field_multi_write_data Function * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cgp_field_multi_write_data_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgint_f *F, cgsize_t *rmin, cgsize_t *rmax, cgint_f *nsets, const void *buf[], cgint_f *ier) { int *F_c; int n; if(sizeof(cgsize_t)!=sizeof(int)) { /* type cast F from cgsize_t to an int */ if ((F_c = (int *)malloc(*nsets*sizeof(int)))==NULL) { cgi_error("Error allocating memory..."); *ier = 1; return; } for (n = 0; n < *nsets; n++) { F_c[n] = (int)F[n]; } *ier = cgp_field_multi_write_data((int)*fn, (int)*B, (int)*Z, (int)*S, F_c, rmin, rmax, (int)*nsets, buf); CGNS_FREE(F_c); } else { *ier = cgp_field_multi_write_data((int)*fn, (int)*B, (int)*Z, (int)*S, F, rmin, rmax, (int)*nsets, buf); } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * cgp_field_multi_read_data Function * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cgp_field_multi_read_data_f( cgint_f *fn, cgint_f *B, cgint_f *Z, cgint_f *S, cgint_f *F, cgsize_t *rmin, cgsize_t *rmax, cgint_f *nsets, void *buf[], cgint_f *ier) { int *F_c; int n; if(sizeof(cgsize_t)!=sizeof(int)) { /* type cast F from cgsize_t to an int */ if ((F_c = (int *)malloc(*nsets*sizeof(int)))==NULL) { cgi_error("Error allocating memory..."); *ier = 1; return; } for (n = 0; n < *nsets; n++) { F_c[n] = (int)F[n]; } *ier = (cgint_f)cgp_field_multi_read_data((int)*fn, (int)*B, (int)*Z, (int)*S, F_c, rmin, rmax, (int)*nsets, buf); free(F_c); } else { *ier = (cgint_f)cgp_field_multi_read_data((int)*fn, (int)*B, (int)*Z, (int)*S, F, rmin, rmax, (int)*nsets, buf); } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * cgp_array_multi_write_data Function * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cgp_array_multi_write_data_f( cgint_f *fn, cgint_f *A, cgsize_t *rmin, cgsize_t *rmax, cgint_f *nsets, const void *buf[], cgint_f *ier) { int *A_c; int n; if(sizeof(cgsize_t)!=sizeof(int)) { /* type cast F from cgsize_t to an int */ if ((A_c = (int *)malloc(*nsets*sizeof(int)))==NULL) { cgi_error("Error allocating memory..."); *ier = 1; return; } for (n = 0; n < *nsets; n++) { A_c[n] = (int)A[n]; } *ier = (cgint_f)cgp_array_multi_write_data((int)*fn, A_c, rmin, rmax, (int)*nsets, buf); }else { *ier = (cgint_f)cgp_array_multi_write_data((int)*fn, A, rmin, rmax, (int)*nsets, buf); } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * cgp_array_multi_read_data Function * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL void cgp_array_multi_read_data_f( cgint_f *fn, cgint_f *A, cgsize_t *rmin, cgsize_t *rmax, cgint_f *nsets, void *buf[], cgint_f *ier) { int *A_c; int n; if(sizeof(cgsize_t)!=sizeof(int)) { /* type cast F from cgsize_t to an int */ if ((A_c = (int *)malloc(*nsets*sizeof(int)))==NULL) { cgi_error("Error allocating memory..."); *ier = 1; return; } for (n = 0; n < *nsets; n++) { A_c[n] = (int)A[n]; } *ier = (cgint_f)cgp_array_multi_read_data((int)*fn, A_c, rmin, rmax, (int)*nsets, buf); free(A_c); }else { *ier = (cgint_f)cgp_array_multi_read_data((int)*fn, A, rmin, rmax, (int)*nsets, buf); } } #endif /*CG_BUILD_PARALLEL*/ CGNS-4.5.0/src/cg_hash_types.h.in000066400000000000000000000007221474000356600164450ustar00rootroot00000000000000#ifndef CGNS_HASH_TYPES_H #define CGNS_HASH_TYPES_H #include /* Typedef used by hashmap */ /* Not stored in cgnstypes.h to not leak them */ #define SIZEOF_LONG @SIZEOF_LONG@ #define SIZEOF_VOID_P @SIZEOF_VOID_P@ #if @BUILD64BIT@ typedef int64_t map_ssize_t; typedef uint64_t map_usize_t; #define SIZEOF_MAP_USIZE_T 8 #else typedef int32_t map_ssize_t; typedef uint32_t map_usize_t; #define SIZEOF_MAP_USIZE_T 4 #endif typedef char char_name[33]; #endifCGNS-4.5.0/src/cg_hashmap.c000066400000000000000000000430221474000356600153050ustar00rootroot00000000000000#include "cg_hashmap.h" #include #include #include #include #if defined(_MSC_VER) #include #endif /* The hashmap is unordered. As long as no item is deleted the insertion order is kept */ #define PERTURB_SHIFT 5 #define MAP_SIZE(map) ((map)->table_size) #if SIZEOF_VOID_P > 4 #define MAP_IXSIZE(map) \ (MAP_SIZE(map) <= 0xff ? \ 1 : MAP_SIZE(map) <= 0xffff ? \ 2 : MAP_SIZE(map) <= 0xffffffff ? \ 4 : sizeof(int64_t)) #else #define MAP_IXSIZE(map) \ (MAP_SIZE(map) <= 0xff ? \ 1 : MAP_SIZE(map) <= 0xffff ? \ 2 : sizeof(int32_t)) #endif #define MAP_ENTRIES(map) \ ((cgns_hashmap_entry*)(&((int8_t*)((map)->map_indices))[MAP_SIZE(map) * MAP_IXSIZE(map)])) #define MAP_MASK(map) (((map)->table_size)-1) #define IS_POWER_OF_2(x) (((x) & (x-1)) == 0) /* lookup indices. returns MAPIX_EMPTY, MAPIX_DUMMY, or ix >=0 */ static inline map_ssize_t cgi_hashmap_get_index(const cgns_hashmap_keyobject *keys, map_ssize_t i) { map_ssize_t s = MAP_SIZE(keys); map_ssize_t ix; if (s <= 0xff) { const int8_t *indices = (const int8_t*)(keys->map_indices); ix = indices[i]; } else if (s <= 0xffff) { const int16_t *indices = (const int16_t*)(keys->map_indices); ix = indices[i]; } #if SIZEOF_VOID_P > 4 else if (s > 0xffffffff) { const int64_t *indices = (const int64_t*)(keys->map_indices); ix = indices[i]; } #endif else { const int32_t *indices = (const int32_t*)(keys->map_indices); ix = indices[i]; } assert(ix >= MAPIX_DUMMY); return ix; } /* write to indices. */ static inline void cgi_hashmap_set_index(cgns_hashmap_keyobject *keys, map_ssize_t i, map_ssize_t ix) { map_ssize_t s = MAP_SIZE(keys); assert(ix >= MAPIX_DUMMY); if (s <= 0xff) { int8_t *indices = (int8_t*)(keys->map_indices); assert(ix <= 0x7f); indices[i] = (char)ix; } else if (s <= 0xffff) { int16_t *indices = (int16_t*)(keys->map_indices); assert(ix <= 0x7fff); indices[i] = (int16_t)ix; } #if SIZEOF_VOID_P > 4 else if (s > 0xffffffff) { int64_t *indices = (int64_t*)(keys->map_indices); indices[i] = ix; } #endif else { int32_t *indices = (int32_t*)(keys->map_indices); assert(ix <= 0x7fffffff); indices[i] = (int32_t)ix; } } #if SIZEOF_MAP_USIZE_T == 4 #define _fnvprefix 0x811c9dc5 #define _fnvmult 0x01000193 #elif SIZEOF_MAP_USIZE_T == 8 #define _fnvprefix 0xcbf29ce484222325 #define _fnvmult 0x00000100000001B3 #else #define _fnvprefix 0 #define _fnvmult 0 #endif static map_ssize_t cgi_hash_cstr(const char* a) { const unsigned char* p = (unsigned char *) a; map_ssize_t len; map_usize_t x; map_ssize_t remainder, blocks; union { map_usize_t value; unsigned char bytes[SIZEOF_MAP_USIZE_T]; } block; len = (map_ssize_t) strlen(a); if (len == 0) { return 0; } remainder = len % SIZEOF_MAP_USIZE_T; if (remainder == 0) { remainder = SIZEOF_MAP_USIZE_T; } blocks = (len - remainder) / SIZEOF_MAP_USIZE_T; x = (map_usize_t) _fnvprefix; x ^= (map_usize_t) *p << 7; while (blocks--) { memcpy(block.bytes, p, SIZEOF_MAP_USIZE_T); x = (_fnvmult * x) ^ block.value; p += SIZEOF_MAP_USIZE_T; } /* add remainder */ for (; remainder > 0; remainder--) x = (_fnvmult * x) ^ (map_usize_t)*p++; x ^= (map_usize_t) len; /* no suffix */ if (x == (map_usize_t)-1) x = (map_usize_t)-2; return x; } #define USABLE_FRACTION(n) (((n) << 1)/3) static const unsigned int BitLengthTable[32] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }; unsigned int _bit_length(unsigned long d) { unsigned int d_bits = 0; while (d >= 32) { d_bits += 6; d >>= 6; } d_bits += BitLengthTable[d]; return d_bits; } /* Find the smallest table_size >= minsize. */ static inline map_ssize_t cgi_calculate_keysize(map_ssize_t minsize) { #if SIZEOF_LONG == SIZEOF_VOID_P minsize = (minsize | MAP_MINSIZE) - 1; return 1LL << _bit_length(minsize | (MAP_MINSIZE-1)); #elif defined(_MSC_VER) // On 64bit Windows, sizeof(long) == 4. minsize = (minsize | MAP_MINSIZE) - 1; unsigned long msb; _BitScanReverse64(&msb, (uint64_t)minsize); return 1LL << (msb + 1); #else map_ssize_t size; for (size = MAP_MINSIZE; size < minsize && size > 0; size <<= 1) ; return size; #endif } /* estimate_keysize is reverse function of USABLE_FRACTION. * * This can be used to reserve enough size to insert n entries without * resizing. */ static inline map_ssize_t cgi_estimate_keysize(map_ssize_t n) { return cgi_calculate_keysize((n*3 + 1) / 2); } /* GROWTH_RATE. Growth rate upon hitting maximum load. * Currently set to used*2. * This means that hashtable double in size when growing without deletions, * but have more head room when the number of deletions is on a par with the * number of insertions. * */ #define GROWTH_RATE(d) ((d)->ma_used*2) /* Dirty trick for unsupported flexible array init */ struct _static_hashmapobject { map_ssize_t table_size; map_ssize_t map_usable; map_ssize_t map_nentries; char map_indices[8]; /* we define the size of the array to have a known struct at compile time */ }; /* This immutable, empty cgns_hashmap_keyobject is used for HashMap_Clear() * (which cannot fail and thus can do no allocation). */ static struct _static_hashmapobject empty_keys_struct = { 1, /* table_size */ 0, /* map_usable (immutable) */ 0, /* map_nentries */ {MAPIX_EMPTY, MAPIX_EMPTY, MAPIX_EMPTY, MAPIX_EMPTY, MAPIX_EMPTY, MAPIX_EMPTY, MAPIX_EMPTY, MAPIX_EMPTY}, /* map_indices */ }; #define MAP_EMPTY_KEYS (cgns_hashmap_keyobject *)&empty_keys_struct static cgns_hashmap_keyobject* cgi_new_keys_object(map_ssize_t size) { cgns_hashmap_keyobject *keymap; map_ssize_t es, usable; assert(size >= MAP_MINSIZE); assert(IS_POWER_OF_2(size)); usable = USABLE_FRACTION(size); if (size <= 0xff) { es = 1; } else if (size <= 0xffff) { es = 2; } #if SIZEOF_VOID_P > 4 else if (size <= 0xffffffff) { es = 4; } #endif else { es = sizeof(map_ssize_t); } keymap = malloc(sizeof(cgns_hashmap_keyobject) + es * size + sizeof(cgns_hashmap_entry) * usable); if (keymap == NULL) { return NULL; } keymap->table_size = size; keymap->map_usable = usable; keymap->map_nentries = 0; memset(&keymap->map_indices[0], 0xff, es * size); //memset(&keymap->map_indices[0], MAPIX_EMPTY, es * size); memset(MAP_ENTRIES(keymap), 0, sizeof(cgns_hashmap_entry) * usable); // Set to false the index value; cgns_hashmap_entry* ep = MAP_ENTRIES(keymap); for (map_ssize_t i = 0; i < usable; i++) { ep->me_value = -1; ep++; } return keymap; } /* Consumes a reference to the keys object */ static cgns_hashmap_object * cgi_allocate_hashmap(cgns_hashmap_keyobject *keys) { cgns_hashmap_object *mp; assert(keys != NULL); mp = (cgns_hashmap_object *) malloc(sizeof(cgns_hashmap_object)); if (mp == NULL) { return NULL; } mp->ma_keys = keys; mp->ma_used = 0; return mp; } cgns_hashmap_object * cgi_new_hashmap(void) { return cgi_allocate_hashmap(MAP_EMPTY_KEYS); } cgns_hashmap_object * cgi_new_presized_hashmap(map_ssize_t minused) { const map_ssize_t max_presize = 128 * 1024; map_ssize_t newsize; cgns_hashmap_keyobject *new_keys; if (minused <= USABLE_FRACTION(MAP_MINSIZE)) { return cgi_new_hashmap(); } /* There are no strict guarantee that returned hashmap can contain minused * items without resize. So we create medium size table instead of very * large table. */ if (minused > USABLE_FRACTION(max_presize)) { newsize = max_presize; } else { newsize = cgi_estimate_keysize(minused); } new_keys = cgi_new_keys_object(newsize); if (new_keys == NULL) return NULL; return cgi_allocate_hashmap(new_keys); } /* Search index of hash table from offset of entry table */ static map_ssize_t cgi_index_lookup(cgns_hashmap_keyobject *k, map_ssize_t hash, map_ssize_t index) { size_t mask = MAP_MASK(k); size_t perturb = (size_t)hash; size_t i = (size_t)hash & mask; for (;;) { map_ssize_t ix = cgi_hashmap_get_index(k, i); if (ix == index) { return i; } if (ix == MAPIX_EMPTY) { return MAPIX_EMPTY; } perturb >>= PERTURB_SHIFT; i = mask & (i*5 + perturb + 1); } // Not reachable ... } /* Search index of hash table from hash and name key * It also retrieves the pointed cgns node */ static map_ssize_t cgi_name_lookup(cgns_hashmap_object *mp, const char *key, map_ssize_t hash, map_ssize_t *value_addr) { cgns_hashmap_entry *ep0 = MAP_ENTRIES(mp->ma_keys); // compact storage // size_t mask = MAP_MASK(mp->ma_keys); size_t perturb = (size_t)hash; size_t i = (size_t)hash & mask; for (;;) { map_ssize_t ix = cgi_hashmap_get_index(mp->ma_keys, i); if (ix == MAPIX_EMPTY) { *value_addr = -1; return MAPIX_EMPTY; } if (ix >= 0) { cgns_hashmap_entry *ep = &ep0[ix]; if (ep->me_hash == hash && strcmp(ep->me_key, key) == 0) { *value_addr = ep->me_value; return ix; } } perturb >>= PERTURB_SHIFT; i = mask & (i*5 + perturb + 1); } // unreachable } /* Internal function to find slot for an item from its hash when it is known that the key is not present in the hashtable. */ static map_ssize_t cgi_find_empty_slot(cgns_hashmap_keyobject *keys, map_ssize_t hash) { assert(keys != NULL); if (keys == NULL) { return -1; } const size_t mask = MAP_MASK(keys); size_t i = hash & mask; map_ssize_t ix = cgi_hashmap_get_index(keys, i); for (size_t perturb = hash; ix >= 0;) { perturb >>= PERTURB_SHIFT; i = (i*5 + perturb + 1) & mask; ix = cgi_hashmap_get_index(keys, i); } return i; } /* Internal routine used by cgi_resize_hashmap() to build a hashtable of entries. */ static void cgi_build_indices(cgns_hashmap_keyobject* keys, cgns_hashmap_entry* ep, map_ssize_t n) { size_t mask = (size_t)MAP_SIZE(keys) - 1; for (map_ssize_t ix = 0; ix != n; ix++, ep++) { map_ssize_t hash = ep->me_hash; size_t i = hash & mask; for (size_t perturb = hash; cgi_hashmap_get_index(keys, i) != MAPIX_EMPTY;) { perturb >>= PERTURB_SHIFT; i = mask & (i * 5 + perturb + 1); } cgi_hashmap_set_index(keys, i, ix); } } /* Restructure the table by allocating a new table and reinserting all items again. When entries have been deleted, the new table may actually be smaller than the old one. */ static int cgi_resize_hashmap(cgns_hashmap_object* mp, map_ssize_t newsize) { map_ssize_t numentries; cgns_hashmap_keyobject* oldkeys; cgns_hashmap_entry* oldentries, * newentries; if (newsize <= 0) { //set message with memory error return -1; } assert(IS_POWER_OF_2(newsize)); assert(newsize >= MAP_MINSIZE); oldkeys = mp->ma_keys; /* Allocate a new table. */ mp->ma_keys = cgi_new_keys_object(newsize); if (mp->ma_keys == NULL) { mp->ma_keys = oldkeys; return -1; } // New table must be large enough. assert(mp->ma_keys->map_usable >= mp->ma_used); numentries = mp->ma_used; oldentries = MAP_ENTRIES(oldkeys); newentries = MAP_ENTRIES(mp->ma_keys); if (oldkeys->map_nentries == numentries) { memcpy(newentries, oldentries, numentries * sizeof(cgns_hashmap_entry)); } else { cgns_hashmap_entry* ep = oldentries; for (map_ssize_t i = 0; i < numentries; i++) { while (ep->me_value == -1) ep++; newentries[i].me_hash = ep->me_hash; strcpy(newentries[i].me_key, ep->me_key); newentries[i].me_value = ep->me_value; ep++; } } free(oldkeys); cgi_build_indices(mp->ma_keys, newentries, numentries); mp->ma_keys->map_usable -= numentries; mp->ma_keys->map_nentries = numentries; return 0; } static int cgi_insertion_resize(cgns_hashmap_object *mp) { return cgi_resize_hashmap(mp, cgi_calculate_keysize(GROWTH_RATE(mp))); } /* Internal routine to insert a new item into the table. Used both by the internal resize routine and by the public insert routine. Returns -1 if an error occurred, or 0 on success. */ static int cgi_insert_key(cgns_hashmap_object *mp, const char *key, map_ssize_t hash, map_ssize_t value) { map_ssize_t old_value = -1; map_ssize_t ix = cgi_name_lookup(mp, key, hash, &old_value); if (ix == MAPIX_ERROR) return -1; if (ix == MAPIX_EMPTY) { /* Insert into new slot. */ assert(old_value == -1); if (mp->ma_keys->map_usable <= 0) { /* Need to resize. */ if (cgi_insertion_resize(mp) < 0) return -1; } map_ssize_t hashpos = cgi_find_empty_slot(mp->ma_keys, hash); cgns_hashmap_entry *ep; ep = &MAP_ENTRIES(mp->ma_keys)[mp->ma_keys->map_nentries]; cgi_hashmap_set_index(mp->ma_keys, hashpos, mp->ma_keys->map_nentries); strcpy(ep->me_key, key); ep->me_hash = hash; ep->me_value = value; mp->ma_used++; mp->ma_keys->map_usable--; mp->ma_keys->map_nentries++; assert(mp->ma_keys->map_usable >= 0); return 0; } if (old_value != value) { assert(old_value != -1); MAP_ENTRIES(mp->ma_keys)[ix].me_value = value; } return 0; } // Same to insert but specialized for ma_keys = MAP_EMPTY_KEYS. static int cgi_insert_to_emptymap(cgns_hashmap_object *mp, const char *key, map_ssize_t hash, map_ssize_t value) { assert(mp->ma_keys == MAP_EMPTY_KEYS); cgns_hashmap_keyobject *newkeys = cgi_new_keys_object(MAP_MINSIZE); if (newkeys == NULL) { return -1; } mp->ma_keys = newkeys; size_t hashpos = (size_t)hash & (MAP_MINSIZE-1); cgns_hashmap_entry *ep = MAP_ENTRIES(mp->ma_keys); cgi_hashmap_set_index(mp->ma_keys, hashpos, 0); strcpy(ep->me_key, key); ep->me_hash = hash; ep->me_value = value; mp->ma_used++; mp->ma_keys->map_usable--; mp->ma_keys->map_nentries++; return 0; } map_ssize_t cgi_map_get_item(cgns_hashmap_object *op, const char *key) { map_ssize_t ix; map_ssize_t hash; map_ssize_t value; if (op == NULL) { return -1; } hash = cgi_hash_cstr(key); if (hash == -1) { return -1; } ix = cgi_name_lookup(op, key, hash, &value); if (ix < 0) return -1; return value; } int cgi_map_set_item(cgns_hashmap_object *op, const char *key, map_ssize_t value) { map_ssize_t hash; if (op == NULL) { return -1; } assert(key); assert(value != -1); hash = cgi_hash_cstr(key); if (hash == -1){ return -1; } if (op->ma_keys == MAP_EMPTY_KEYS) { return cgi_insert_to_emptymap(op, key, hash, value); } /* cgi_insert_key() handles any resizing that might be necessary */ return cgi_insert_key(op, key, hash, value); } /* Return 1 if `key` is in hashmap `op`, 0 if not, and -1 on error. */ int cgi_map_contains(cgns_hashmap_object *op, const char *key) { map_ssize_t hash; map_ssize_t ix; map_ssize_t value; hash = cgi_hash_cstr(key); if (hash == -1){ return -1; } ix = cgi_name_lookup(op, key, hash, &value); if (ix == MAPIX_ERROR) return -1; return (ix != MAPIX_EMPTY && value != -1); } void cgi_hashmap_clear(cgns_hashmap_object* op) { cgns_hashmap_keyobject * oldkeys; if (op == NULL) return; oldkeys = op->ma_keys; /* Empty the hashtable... */ op->ma_keys = MAP_EMPTY_KEYS; op->ma_used = 0; free(oldkeys); } int _cg_del_shift_item_known_hash(cgns_hashmap_object* op, const char* key, map_ssize_t hash) { map_ssize_t ix; cgns_hashmap_entry* ep; map_ssize_t old_value; if (op == NULL) { //error bad memory return -1; } assert(key); assert(hash != -1); ix = cgi_name_lookup(op, key, hash, &old_value); if (ix == MAPIX_ERROR) return -1; if (ix == MAPIX_EMPTY || old_value == -1) { // set error bad key return -1; } map_ssize_t hashpos = cgi_index_lookup(op->ma_keys, hash, ix); assert(hashpos >= 0); op->ma_used--; ep = &MAP_ENTRIES(op->ma_keys)[ix]; cgi_hashmap_set_index(op->ma_keys, hashpos, MAPIX_DUMMY);; strcpy(ep->me_key, "\0"); ep->me_value = -1; /* Shift down upper indices */ ep = MAP_ENTRIES(op->ma_keys); for (map_ssize_t i = 0; i < op->ma_keys->map_usable; i++) { if ( ep->me_value > old_value ) { ep->me_value--; } ep++; } return 0; } int cgi_map_del_shift_item(cgns_hashmap_object* op, const char* key) { map_ssize_t hash; assert(key); hash = cgi_hash_cstr(key); if (hash == -1) { return -1; } return _cg_del_shift_item_known_hash(op, key, hash); } CGNS-4.5.0/src/cg_hashmap.h000066400000000000000000000053731474000356600153210ustar00rootroot00000000000000#ifndef CGNS_HASHMAP_H #define CGNS_HASHMAP_H #include "cg_hash_types.h" /* This is a simple hashmap inspired by cpython dict * It maps a char[33] name to its array index. * The indexing struct is compact to be cache friendly. * One of the difficulty is to keep the hash table indices in sync * with the cgns_zone list when there is deletion. */ #define MAP_MINSIZE 8 typedef struct { /* Cached hash code of me_key. */ map_ssize_t me_hash; /* signed integer same size as size_t */ map_ssize_t me_value; /* index of key in mapped vector */ char_name me_key; /* zone name */ } cgns_hashmap_entry; #define MAPIX_EMPTY (-1) #define MAPIX_DUMMY (-2) #define MAPIX_ERROR (-3) struct _hashmapobject { /* Size of the hash table (map_indices). It must be a power of 2. */ map_ssize_t table_size; /* Function to lookup in the hash table (dk_indices): - lookdict_unicode(): specialized to Unicode string keys, comparison of which can never raise an exception; that function can never return DKIX_ERROR. - lookdict_unicode_nodummy(): similar to lookdict_unicode() but further specialized for Unicode string keys that cannot be the value.*/ /* Number of usable entries in map_entries. */ map_ssize_t map_usable; /* Number of used entries in map_entries. */ map_ssize_t map_nentries; /* Actual hash table of map_size entries. It holds indices in map_entries, or MAPIX_EMPTY(-1) or MAPIX_DUMMY(-2). Indices must be: 0 <= indice < USABLE_FRACTION(map_size). The size in bytes of an indice depends on map_size: - 1 byte if map_size <= 0xff (char*) - 2 bytes if map_size <= 0xffff (int16_t*) - 4 bytes if map_size <= 0xffffffff (int32_t*) - 8 bytes otherwise (int64_t*) Dynamically sized, SIZEOF_VOID_P is minimum. */ char map_indices[]; /* char is required to avoid strict aliasing. */ /* "HashMapKeyEntry map_entries[dk_usable];" array follows: see the MAP_ENTRIES() macro */ }; typedef struct _hashmapobject cgns_hashmap_keyobject; typedef struct { /* Number of items in the hashmap */ map_ssize_t ma_used; /* Key and values are stored in a combined continuous struct to be cache friendly. */ cgns_hashmap_keyobject *ma_keys; } cgns_hashmap_object; cgns_hashmap_object* cgi_new_hashmap(void); cgns_hashmap_object* cgi_new_presized_hashmap(map_ssize_t minused); void cgi_hashmap_clear(cgns_hashmap_object* op); map_ssize_t cgi_map_get_item(cgns_hashmap_object* op, const char* key); int cgi_map_set_item(cgns_hashmap_object* op, const char* key, map_ssize_t value); int cgi_map_contains(cgns_hashmap_object* op, const char* key); int cgi_map_del_shift_item(cgns_hashmap_object* op, const char* key); #endif CGNS-4.5.0/src/cg_malloc.c000066400000000000000000000033341474000356600151350ustar00rootroot00000000000000#include #include #include static size_t mem_now = 0; static size_t mem_max = 0; static size_t alloc_calls = 0; static size_t free_calls = 0; void *cgmalloc(size_t bytes) { size_t *data = (size_t *) malloc (bytes + 2 * sizeof(size_t)); if (data) { *data++ = bytes; *data = (size_t)(data + 1); data++; mem_now += bytes; if (mem_max < mem_now) mem_max = mem_now; } alloc_calls++; return (void *)data; } void *cgrealloc(void *olddata, size_t bytes) { size_t *data = (size_t *)olddata; if (data && *(data-1) == (size_t)olddata) { data -= 2; mem_now -= *data; } data = (size_t *) realloc (data, bytes + 2 * sizeof(size_t)); if (data) { *data++ = bytes; *data = (size_t)(data + 1); data++; mem_now += bytes; if (mem_max < mem_now) mem_max = mem_now; } /* alloc_calls++;*/ return (void *)data; } void *cgcalloc(size_t num, size_t bytes) { size_t count = num * bytes; size_t *data = (size_t *) malloc (count + 2 * sizeof(size_t)); if (data) { *data++ = count; *data = (size_t)(data + 1); data++; mem_now += count; if (mem_max < mem_now) mem_max = mem_now; memset(data, 0, count); } alloc_calls++; return (void *)data; } void cgfree(void *freedata) { size_t *data = (size_t *)freedata; if (data && *(data-1) == (size_t)freedata) { data -= 2; mem_now -= *data; free (data); } free_calls++; } size_t cgmemnow(void) {return mem_now;} size_t cgmemmax(void) {return mem_max;} size_t cgalloccalls(void) {return alloc_calls;} size_t cgfreecalls(void) {return free_calls;} CGNS-4.5.0/src/cg_malloc.h000066400000000000000000000007161474000356600151430ustar00rootroot00000000000000#ifndef __CG_MALLOC_H__ #define __CG_MALLOC_H__ #define malloc(S) cgmalloc(S) #define realloc(P,S) cgrealloc(P,S) #define calloc(N,S) cgcalloc(N,S) #define free(P) cgfree(P) extern void *cgmalloc(size_t); extern void *cgrealloc(void *,size_t); extern void *cgcalloc(size_t,size_t); extern void cgfree(void *); extern size_t cgmemnow(void); extern size_t cgmemmax(void); extern size_t cgalloccalls(void); extern size_t cgfreecalls(void); #endif CGNS-4.5.0/src/cgio_ftoc.c000066400000000000000000000472621474000356600151610ustar00rootroot00000000000000/*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ #include #include #include #include #include "fortran_macros.h" #include "cgns_io.h" #ifdef MEM_DEBUG #include "cg_malloc.h" #endif #if defined(_WIN32) && defined(BUILD_DLL) # define CGIODLL __declspec(dllexport) #else # define CGIODLL #endif /*========================================================= * local string conversions *=========================================================*/ static int to_c_string(char *f_str, int f_len, char *c_str, int c_len) { int i, iend; for (iend = f_len-1; iend >= 0; iend--) { if (f_str[iend] != ' ') break; } if (iend >= c_len) iend = c_len - 1; for (i = 0; i <= iend; i++) c_str[i] = f_str[i]; c_str[i] = 0; return i; } /*---------------------------------------------------------*/ static int to_f_string(char *c_str, char *f_str, int f_len) { int i, c_len; c_len = (int)strlen(c_str); if (c_len > f_len) c_len = f_len; for (i = 0; i < c_len; i++) f_str[i] = c_str[i]; while (i < f_len) f_str[i++] = ' '; return f_len; } /*---------------------------------------------------------*/ static char *new_c_string (char *str, int len, cgint_f *ier) { char *c_str; if (len < 1 || str == NULL) { *ier = (cgint_f)CGIO_ERR_NULL_STRING; return NULL; } else if ( len == 2 && strncmp(str, "\0", 2) == 0 ) { *ier = (cgint_f)CGIO_ERR_NULL_STRING; return NULL; } c_str = (char *) malloc (len + 1); if (c_str == NULL) { *ier = (cgint_f)CGIO_ERR_MALLOC; return NULL; } to_c_string (str, len, c_str, len); if (strlen(c_str) < 1) { free (c_str); *ier = (cgint_f)CGIO_ERR_NULL_STRING; return NULL; } *ier = 0; return c_str; } /*========================================================= * paths for searching for linked-to files *=========================================================*/ CGIODLL void FMNAME(cgio_path_add_f, CGIO_PATH_ADD_F) ( STR_PSTR(path), cgint_f *ier STR_PLEN(path)) { char *c_path = new_c_string(STR_PTR(path), STR_LEN(path), ier); if (*ier == 0) { *ier = (cgint_f)cgio_path_add(c_path); free(c_path); } } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_path_delete_f, CGIO_PATH_DELETE_F) ( STR_PSTR(path), cgint_f *ier STR_PLEN(path)) { char *c_path = new_c_string(STR_PTR(path), STR_LEN(path), ier); if (*ier == CGIO_ERR_MALLOC) return; *ier = (cgint_f)cgio_path_delete(c_path); if (c_path) free(c_path); } /*========================================================= * utility routines independent of open files *=========================================================*/ CGIODLL void cgio_is_supported_f( cgsize_t *file_type, cgint_f *ier) { *ier = (cgint_f)cgio_is_supported((int)*file_type); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_check_file_f, CGIO_CHECK_FILE_F) ( STR_PSTR(filename), cgint_f *file_type, cgint_f *ier STR_PLEN(filename)) { int i_file_type; char *c_name = new_c_string(STR_PTR(filename), STR_LEN(filename), ier); if (*ier == 0) { *ier = (cgint_f)cgio_check_file(c_name, &i_file_type); *file_type = (cgint_f)i_file_type; free(c_name); } } /*========================================================= * file operations *=========================================================*/ CGIODLL void FMNAME(cgio_open_file_f, CGIO_OPEN_FILE_F) ( STR_PSTR(filename), cgint_f *file_mode, cgint_f *file_type, cgint_f *cgio_num, cgint_f *ier STR_PLEN(filename)) { int i_cgio_num; char *c_name = new_c_string(STR_PTR(filename), STR_LEN(filename), ier); if (*ier == 0) { *ier = (cgint_f)cgio_open_file(c_name, (int)*file_mode, (int)*file_type, &i_cgio_num); *cgio_num = (cgint_f)i_cgio_num; free(c_name); } } /*---------------------------------------------------------*/ CGIODLL void cgio_close_file_f( cgint_f *cgio_num, cgint_f *ier) { *ier = (cgint_f)cgio_close_file((int)*cgio_num); } /*---------------------------------------------------------*/ CGIODLL void cgio_flush_to_disk_f( cgint_f *cgio_num, cgint_f *ier) { *ier = (cgint_f)cgio_flush_to_disk((int)*cgio_num); } /*========================================================= * file information *=========================================================*/ CGIODLL void FMNAME(cgio_library_version_f, CGIO_LIBRARY_VERSION_F) ( cgint_f *cgio_num, STR_PSTR(version), cgint_f *ier STR_PLEN(version)) { char c_version[CGIO_MAX_VERSION_LENGTH+1]; *ier = (cgint_f)cgio_library_version((int)*cgio_num, c_version); if (*ier == 0) to_f_string(c_version, STR_PTR(version), STR_LEN(version)); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_file_version_f, CGIO_FILE_VERSION_F) ( cgint_f *cgio_num, STR_PSTR(file_version), STR_PSTR(creation_date), STR_PSTR(modified_date), cgint_f *ier STR_PLEN(file_version) STR_PLEN(creation_date) STR_PLEN(modified_date)) { char c_version[CGIO_MAX_VERSION_LENGTH+1]; char c_cdate[CGIO_MAX_VERSION_LENGTH+1]; char c_mdate[CGIO_MAX_VERSION_LENGTH+1]; *ier = (cgint_f)cgio_file_version((int)*cgio_num, c_version, c_cdate, c_mdate); if (*ier == 0) { to_f_string(c_version, STR_PTR(file_version), STR_LEN(file_version)); to_f_string(c_cdate, STR_PTR(creation_date), STR_LEN(creation_date)); to_f_string(c_mdate, STR_PTR(modified_date), STR_LEN(modified_date)); } } /*---------------------------------------------------------*/ CGIODLL void cgio_get_root_id_f( cgint_f *cgio_num, double *rootid, cgint_f *ier) { *ier = (cgint_f)cgio_get_root_id((int)*cgio_num, rootid); } /*---------------------------------------------------------*/ CGIODLL void cgio_get_file_type_f( cgint_f *cgio_num, cgint_f *file_type, cgint_f *ier) { int i_file_type; *ier = (cgint_f)cgio_get_file_type((int)*cgio_num, &i_file_type); *file_type = (cgint_f)i_file_type; } /*========================================================= * error handling *=========================================================*/ CGIODLL void cgio_error_code_f( cgint_f *errcode, cgint_f *file_type) { int i_errcode, i_file_type; cgio_error_code(&i_errcode, &i_file_type); *errcode = (cgint_f)i_errcode; *file_type = (cgint_f)i_file_type; } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_error_message_f,CGIO_ERROR_MESSAGE_F) ( STR_PSTR(errmsg), cgint_f *ier STR_PLEN(errmsg)) { char c_error[CGIO_MAX_ERROR_LENGTH+1]; *ier = (cgint_f)cgio_error_message(c_error); if (*ier == 0) to_f_string(c_error, STR_PTR(errmsg), STR_LEN(errmsg)); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_error_exit_f, CGIO_ERROR_EXIT_F)( STR_PSTR(errmsg) STR_PLEN(errmsg)) { cgint_f ier; char *c_error = new_c_string(STR_PTR(errmsg), STR_LEN(errmsg), &ier); cgio_error_exit(c_error); } /*---------------------------------------------------------*/ CGIODLL void cgio_error_abort_f( cgint_f *abort_flag) { cgio_error_abort((int)*abort_flag); } /*========================================================= * basic node operations *=========================================================*/ CGIODLL void FMNAME(cgio_create_node_f, CGIO_CREATE_NODE_F) ( cgint_f *cgio_num, double *pid, STR_PSTR(name), double *id, cgint_f *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; to_c_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH); *ier = (cgint_f)cgio_create_node((int)*cgio_num, *pid, c_name, id); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_new_node_f, CGIO_NEW_NODE_F) ( cgint_f *cgio_num, double *pid, STR_PSTR(name), STR_PSTR(label), STR_PSTR(data_type), cgint_f *ndims, cgsize_t *dims, void *data, double *id, cgint_f *ier STR_PLEN(name) STR_PLEN(label) STR_PLEN(data_type)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; char c_label[CGIO_MAX_LABEL_LENGTH+1]; char c_dtype[CGIO_MAX_DATATYPE_LENGTH+1]; to_c_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH); to_c_string(STR_PTR(label), STR_LEN(label), c_label, CGIO_MAX_LABEL_LENGTH); to_c_string(STR_PTR(data_type), STR_LEN(data_type), c_dtype, CGIO_MAX_DATATYPE_LENGTH); *ier = (cgint_f)cgio_new_node((int)*cgio_num, *pid, c_name, c_label, c_dtype, (int)*ndims, dims, data, id); } /*---------------------------------------------------------*/ CGIODLL void cgio_delete_node_f( cgint_f *cgio_num, double *pid, double *id, cgint_f *ier) { *ier = (cgint_f)cgio_delete_node((int)*cgio_num, *pid, *id); } /*---------------------------------------------------------*/ CGIODLL void cgio_move_node_f( cgint_f *cgio_num, double *pid, double *id, double *npid, cgint_f *ier) { *ier = (cgint_f)cgio_move_node((int)*cgio_num, *pid, *id, *npid); } /*---------------------------------------------------------*/ CGIODLL void cgio_release_id_f( cgint_f *cgio_num, double *id, cgint_f *ier) { *ier = (cgint_f)cgio_release_id((int)*cgio_num, *id); } /*========================================================= * links *=========================================================*/ CGIODLL void cgio_is_link_f( cgint_f *cgio_num, double *id, cgint_f *link_len, cgint_f *ier) { int i_link_len; *ier = (cgint_f)cgio_is_link((int)*cgio_num, *id, &i_link_len); *link_len = (cgint_f)i_link_len; } /*---------------------------------------------------------*/ CGIODLL void cgio_link_size_f( cgint_f *cgio_num, double *id, cgint_f *file_len, cgint_f *name_len, cgint_f *ier) { int i_file_len, i_name_len; *ier = (cgint_f)cgio_link_size((int)*cgio_num, *id, &i_file_len, &i_name_len); *file_len = (cgint_f)i_file_len; *name_len = (cgint_f)i_name_len; } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_create_link_f, CGIO_CREATE_LINK_F) ( cgint_f *cgio_num, double *pid, STR_PSTR(name), STR_PSTR(filename), STR_PSTR(name_in_file), double *id, cgint_f *ier STR_PLEN(name) STR_PLEN(filename) STR_PLEN(name_in_file)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; char *c_file, *c_link; c_file = new_c_string(STR_PTR(filename), STR_LEN(filename), ier); if (*ier) { if (*ier != CGIO_ERR_NULL_STRING) return; c_file = ""; } c_link = new_c_string(STR_PTR(name_in_file), STR_LEN(name_in_file), ier); if (*ier) { if (*c_file) free(c_file); return; } to_c_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH); *ier = (cgint_f)cgio_create_link((int)*cgio_num, *pid, c_name, c_file, c_link, id); if (*c_file) free(c_file); free(c_link); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_get_link_f, CGIO_GET_LINK_F) ( cgint_f *cgio_num, double *id, STR_PSTR(filename), STR_PSTR(name_in_file), cgint_f *ier STR_PLEN(filename) STR_PLEN(name_in_file)) { char c_file[CGIO_MAX_FILE_LENGTH+1]; char c_link[CGIO_MAX_LINK_LENGTH+1]; *ier = (cgint_f)cgio_get_link((int)*cgio_num, *id, c_file, c_link); if (*ier == 0) { to_f_string(c_file, STR_PTR(filename), STR_LEN(filename)); to_f_string(c_link, STR_PTR(name_in_file), STR_LEN(name_in_file)); } } /*========================================================= * node children *=========================================================*/ CGIODLL void cgio_number_children_f( cgint_f *cgio_num, double *pid, cgint_f *num_children, cgint_f *ier) { int i_num_children; *ier = cgio_number_children(*cgio_num, *pid, &i_num_children); *num_children = (cgint_f)i_num_children; } /*---------------------------------------------------------*/ CGIODLL void cgio_children_ids_f( cgint_f *cgio_num, double *pid, cgint_f *start, cgint_f *max_ret, cgint_f *num_ret, double *ids, cgint_f *ier) { int i_num_ret; *ier = cgio_children_ids((int)*cgio_num, *pid, (int)*start, (int)*max_ret, &i_num_ret, ids); *num_ret = (cgint_f)i_num_ret; } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_children_names_f, CGIO_CHILDREN_NAMES_F) ( cgint_f *cgio_num, double *pid, cgint_f *start, cgint_f *max_ret, cgint_f *name_len, cgint_f *num_ret, STR_PSTR(names), cgint_f *ier STR_PLEN(names)) { int i_num_ret, i_name_len = (int)*name_len; char *c_names; c_names = (char *) malloc ((size_t)*max_ret * (CGIO_MAX_NAME_LENGTH + 1)); if (c_names == NULL) { *ier = (cgint_f)CGIO_ERR_MALLOC; return; } *ier = (cgint_f)cgio_children_names((int)*cgio_num, *pid, (int)*start, (int)*max_ret, CGIO_MAX_NAME_LENGTH + 1, &i_num_ret, c_names); if (*ier == 0) { int n; char *pc = c_names; char *pf = STR_PTR(names); for (n = 0; n < i_num_ret; n++) { to_f_string(pc, pf, i_name_len); pc += (CGIO_MAX_NAME_LENGTH + 1); pf += i_name_len; } *num_ret = (cgint_f)i_num_ret; } free(c_names); } /*========================================================= * read nodes *=========================================================*/ CGIODLL void FMNAME(cgio_get_node_id_f, CGIO_GET_NODE_ID_F) ( cgint_f *cgio_num, double *pid, STR_PSTR(name), double *id, cgint_f *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; to_c_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH); *ier = (cgint_f)cgio_get_node_id((int)*cgio_num, *pid, c_name, id); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_get_name_f, CGIO_GET_NAME_F) ( cgint_f *cgio_num, double *id, STR_PSTR(name), cgint_f *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; *ier = (cgint_f)cgio_get_name((int)*cgio_num, *id, c_name); if (*ier == 0) to_f_string(c_name, STR_PTR(name), STR_LEN(name)); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_get_label_f, CGIO_GET_LABEL_F) ( cgint_f *cgio_num, double *id, STR_PSTR(label), cgint_f *ier STR_PLEN(label)) { char c_label[CGIO_MAX_LABEL_LENGTH+1]; *ier = (cgint_f)cgio_get_label((int)*cgio_num, *id, c_label); if (*ier == 0) to_f_string(c_label, STR_PTR(label), STR_LEN(label)); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_get_data_type_f, CGIO_GET_DATA_TYPE_F) ( cgint_f *cgio_num, double *id, STR_PSTR(data_type), cgint_f *ier STR_PLEN(data_type)) { char c_type[CGIO_MAX_DATATYPE_LENGTH+1]; *ier = (cgint_f)cgio_get_data_type((int)*cgio_num, *id, c_type); if (*ier == 0) to_f_string(c_type, STR_PTR(data_type), STR_LEN(data_type)); } /*---------------------------------------------------------*/ CGIODLL void cgio_get_data_size_f( cgint_f *cgio_num, double *id, cgsize_t *size, cgint_f *ier) { cglong_t data_size; *ier = (cgint_f)cgio_get_data_size((int)*cgio_num, *id, &data_size); *size = (cgsize_t)data_size; } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_read_all_data_type_f, CGIO_READ_ALL_DATA_TYPE_F) ( cgint_f *cgio_num, double *id, STR_PSTR(m_data_type), void *data, cgint_f *ier STR_PLEN(m_data_type)) { char c_dtype[CGIO_MAX_DATATYPE_LENGTH+1]; to_c_string(STR_PTR(m_data_type), STR_LEN(m_data_type), c_dtype, CGIO_MAX_DATATYPE_LENGTH); *ier = (cgint_f)cgio_read_all_data_type((int)*cgio_num, *id, c_dtype, data); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_read_block_data_type_f, CGIO_READ_BLOCK_DATA_TYPE_F) ( cgint_f *cgio_num, double *id, cgsize_t *b_start, cgsize_t *b_end, STR_PSTR(m_data_type), void *data, cgint_f *ier STR_PLEN(m_data_type)) { char c_dtype[CGIO_MAX_DATATYPE_LENGTH+1]; to_c_string(STR_PTR(m_data_type), STR_LEN(m_data_type), c_dtype, CGIO_MAX_DATATYPE_LENGTH); *ier = (cgint_f)cgio_read_block_data_type((int)*cgio_num, *id, *b_start, *b_end, c_dtype, data); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_read_data_type_f, CGIO_READ_DATA_TYPE_F) ( cgint_f *cgio_num, double *id, cgsize_t *s_start, cgsize_t *s_end, cgsize_t *s_stride, STR_PSTR(m_data_type), cgint_f *m_ndims, cgsize_t *m_dims, cgsize_t *m_start, cgsize_t *m_end, cgsize_t *m_stride, void *data, cgint_f *ier STR_PLEN(m_data_type)) { char c_dtype[CGIO_MAX_DATATYPE_LENGTH+1]; to_c_string(STR_PTR(m_data_type), STR_LEN(m_data_type), c_dtype, CGIO_MAX_DATATYPE_LENGTH); *ier = (cgint_f)cgio_read_data_type((int)*cgio_num, *id, s_start, s_end, s_stride, c_dtype, (int)*m_ndims, m_dims, m_start, m_end, m_stride, data); } /*========================================================= * write nodes *=========================================================*/ CGIODLL void FMNAME(cgio_set_name_f, CGIO_SET_NAME_F) ( cgint_f *cgio_num, double *pid, double *id, STR_PSTR(name), cgint_f *ier STR_PLEN(name)) { char c_name[CGIO_MAX_NAME_LENGTH+1]; to_c_string(STR_PTR(name), STR_LEN(name), c_name, CGIO_MAX_NAME_LENGTH); *ier = (cgint_f)cgio_set_name((int)*cgio_num, *pid, *id, c_name); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_set_label_f, CGIO_SET_LABEL_F) ( cgint_f *cgio_num, double *id, STR_PSTR(label), cgint_f *ier STR_PLEN(label)) { char c_label[CGIO_MAX_LABEL_LENGTH+1]; to_c_string(STR_PTR(label), STR_LEN(label), c_label, CGIO_MAX_LABEL_LENGTH); *ier = (cgint_f)cgio_set_label((int)*cgio_num, *id, c_label); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_write_all_data_f, CGIO_WRITE_ALL_DATA_F) ( cgint_f *cgio_num, double *id, void *data, cgint_f *ier) { *ier = (cgint_f)cgio_write_all_data((int)*cgio_num, *id, data); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_write_block_data_f, CGIO_WRITE_BLOCK_DATA_F) ( cgint_f *cgio_num, double *id, cgsize_t *b_start, cgsize_t *b_end, void *data, cgint_f *ier) { *ier = (cgint_f)cgio_write_block_data((int)*cgio_num, *id, *b_start, *b_end, data); } /*---------------------------------------------------------*/ CGIODLL void FMNAME(cgio_write_data_f, CGIO_WRITE_DATA_F) ( cgint_f *cgio_num, double *id, cgsize_t *s_start, cgsize_t *s_end, cgsize_t *s_stride, cgsize_t *m_ndims, cgsize_t *m_dims, cgsize_t *m_start, cgsize_t *m_end, cgsize_t *m_stride, void *data, cgint_f *ier) { *ier = (cgint_f)cgio_write_data((int)*cgio_num, *id, s_start, s_end, s_stride, (int)*m_ndims, m_dims, m_start, m_end, m_stride, data); } #undef CGIODLL CGNS-4.5.0/src/cgio_internal_type.h000066400000000000000000000006461474000356600171030ustar00rootroot00000000000000typedef struct _cgns_io_ctx_t { /* Flag indicating if HDF5 file accesses is PARALLEL or NATIVE */ char hdf5_access[64]; #if CG_BUILD_PARALLEL /* MPI-2 info object */ MPI_Comm pcg_mpi_comm; int pcg_mpi_comm_size; int pcg_mpi_comm_rank; /* flag indicating if mpi_initialized was called */ int pcg_mpi_initialized; MPI_Info pcg_mpi_info; hid_t default_pio_mode; #endif } cgns_io_ctx_t;CGNS-4.5.0/src/cgns-config.cmake.in000066400000000000000000000001511474000356600166470ustar00rootroot00000000000000@PACKAGE_INIT@ include("${CMAKE_CURRENT_LIST_DIR}/cgns-targets.cmake") check_required_components(cgns) CGNS-4.5.0/src/cgnsBuild.defs.in000066400000000000000000000055551474000356600162420ustar00rootroot00000000000000# makefile include for building CGNS code # this file contains the options and libraries used for # building and linking CGNS code, and is intended to be # included in a user's Makefile from the installation #----------------------------------------------------------------------- # CGNS library build options. A 1 indicates that the library # was built with that option, a 0 indicates without # CGNS_DEBUG = debug # CGNS_LEGACY = legacy code (prior to 3.0) # CGNS_SCOPING = scoping of enums # CGNS_64BIT = 64 bit support # CGNS_FORTRAN = Fortran interface # CGNS_PARALLEL = parallel I/O # CGNS_BASESCOPE = Base scope for family and zone reference-to #----------------------------------------------------------------------- CGNS_DEBUG = @BUILDDEBUG@ CGNS_LEGACY = @BUILDLEGACY@ CGNS_SCOPING = @BUILDSCOPE@ CGNS_64BIT = @BUILD64BIT@ CGNS_FORTRAN = @BUILDFORTRAN@ CGNS_PARALLEL = @BUILDPARALLEL@ CGNS_BASESCOPE = @BUILDBASESCOPE@ #----------------------------------------------------------------------- # CGNS_LIBDIR - installation directory for CGNS library # CGNS_INCLUDEDIR - installation directory for CGNS headers #----------------------------------------------------------------------- CGNS_LIBDIR = @LIBDIR@ CGNS_INCLUDEDIR = @INCLUDEDIR@ #----------------------------------------------------------------------- # CGNS_CC - C compiler used to build library # CGNS_CFLAGS - compiler flags used to build library # CGNS_LDFLAGS - any additional linking flags #----------------------------------------------------------------------- CGNS_CC = @CC@ CGNS_CFLAGS = @CFLAGS@ @SYSCFLAGS@ @CFGFLAGS@ CGNS_LDFLAGS = @LDFLAGS@ #----------------------------------------------------------------------- # LIBCGNS - CGNS library name #----------------------------------------------------------------------- CGNS_LIB = $(CGNS_LIBDIR)/@CGNSLIB@ #----------------------------------------------------------------------- # CGNS_HDF5INC - path to HDF5 header files # CGNS_HDF5LIB - HDF5 library # CGNS_SZIPLIB - szip library (if needed) # CGNS_ZLIBLIB - zlib library (if needed) #----------------------------------------------------------------------- CGNS_HDF5INC = @HDF5INC@ CGNS_HDF5LIB = @HDF5LIB@ CGNS_SZIPLIB = @SZIPLIB@ CGNS_ZLIBLIB = @ZLIBLIB@ #----------------------------------------------------------------------- # CGNS_MPIINC - path to MPI header files # CGNS_MPILIBS - MPI libraries #----------------------------------------------------------------------- CGNS_MPIINC = @MPIINC@ CGNS_MPILIBS = @MPILIBS@ #----------------------------------------------------------------------- # CGNS_LINKLIBS contains the list of libraries # with which a CGNS application needs to link #----------------------------------------------------------------------- CGNS_LINKLIBS = $(CGNS_LIB) $(CGNS_HDF5LIB) $(CGNS_SZIPLIB) \ $(CGNS_ZLIBLIB) $(CGNS_MPILIBS) @LIBS@ CGNS-4.5.0/src/cgnsKeywords.h000066400000000000000000001225121474000356600157040ustar00rootroot00000000000000/* @#@#@ $Id: cgnsKeywords.h,v 1.3 2008/07/11 00:25:35 brucewedan Exp $ @#@#@ CHECKSUM: 296864779 40788 @#@#@ (cat cgnsKeywords.h | grep -v '@#@#@' | cksum) */ /*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ /* _____ __ __ _____ ____ _____ _______ _ _ _______ * |_ _| \/ | __ \ / __ \| __ \__ __|/\ | \ | |__ __| * | | | \ / | |__) | | | | |__) | | | / \ | \| | | | * | | | |\/| | ___/| | | | _ / | | / /\ \ | . ` | | | * _| |_| | | | | | |__| | | \ \ | |/ ____ \| |\ | | | * |_____|_| |_|_| \____/|_| \_\ |_/_/ \_\_| \_| |_| * * ------------------- DEVELOPER'S NOTES --------------------------- * * (1) If a new keyword is introduced into this file then the same keyword * needs to be added to cgns_f.F90 in order to maintain Fortran * compatibility. * */ #ifndef CGNSLIB_KEYWORDS_H #define CGNSLIB_KEYWORDS_H /* THIS HEADER CAN BE READ BY ANY C LANGUAGE PRE-PROCESSOR ENUMERATES DEFINITIONS ARE DECLARED, IN THE CASE YOU DO NOT WANT THESE DEFINITIONS (e.g. you compile Fortran) THEN YOU HAVE TO UNSET THE __CGNS_ENUMS__ #undef __CGNS_ENUMS__ BY DEFAULT YOU WANT TO DECLARE THESE ENUMERATES #define __CGNS_ENUMS__ */ #define __CGNS_ENUMS__ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * VERSION NUMBER * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define CGNS_VERSION 4500 #define CGNS_DOTVERS 4.50 #define CGNS_COMPATVERSION 2540 #define CGNS_COMPATDOTVERS 2.54 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * modes for cgns file * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * modes for cgns file * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define CG_MODE_READ 0 #define CG_MODE_WRITE 1 #define CG_MODE_MODIFY 2 /* function return codes */ #define CG_OK 0 #define CG_ERROR 1 #define CG_NODE_NOT_FOUND 2 #define CG_INCORRECT_PATH 3 #define CG_NO_INDEX_DIM 4 /* Null and UserDefined enums */ #define CG_Null 0 #define CG_UserDefined 1 /* max goto depth */ #define CG_MAX_GOTO_DEPTH 20 /* configuration options */ #define CG_CONFIG_ERROR 1 #define CG_CONFIG_COMPRESS 2 #define CG_CONFIG_SET_PATH 3 #define CG_CONFIG_ADD_PATH 4 #define CG_CONFIG_FILE_TYPE 5 /* The Null and the UserDefined string constants are always the same, whatever enumerate you consider. */ #define CG_Null_s "Null" #define CG_UserDefined_s "Userdefined" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Dimensional Units * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Mass ---*/ #ifdef __CGNS_ENUMS__ typedef enum { MassUnitsNull, MassUnitsUserDefined, Kilogram, Gram, Slug, PoundMass } MassUnits_t; #endif #define NofValidMassUnits 6 #define Kilogram_s "Kilogram" #define Gram_s "Gram" #define Slug_s "Slug" #define PoundMass_s "PoundMass" #define Meter_s "Meter" /* Length ---*/ #ifdef __CGNS_ENUMS__ typedef enum { LengthUnitsNull, LengthUnitsUserDefined, Meter, Centimeter, Millimeter, Foot, Inch } LengthUnits_t; #endif #define NofValidLengthUnits 7 #define Centimeter_s "Centimeter" #define Millimeter_s "Millimeter" #define Foot_s "Foot" #define Inch_s "Inch" /* Mass ---*/ #ifdef __CGNS_ENUMS__ typedef enum { TimeUnitsNull, TimeUnitsUserDefined, Second } TimeUnits_t; #endif #define NofValidTimeUnits 3 #define Second_s "Second" /* Temperature ---*/ #ifdef __CGNS_ENUMS__ typedef enum { TemperatureUnitsNull, TemperatureUnitsUserDefined, Kelvin, Celsius, Rankine, Fahrenheit } TemperatureUnits_t; #endif #define NofValidTemperatureUnits 6 #define Kelvin_s "Kelvin" #define Celsius_s "Celsius" #define Rankine_s "Rankine" #define Fahrenheit_s "Fahrenheit" /* Angle ---*/ #ifdef __CGNS_ENUMS__ typedef enum { AngleUnitsNull, AngleUnitsUserDefined, Degree, Radian } AngleUnits_t; #endif #define NofValidAngleUnits 4 #define Degree_s "Degree" #define Radian_s "Radian" /* ElectricCurrent ---*/ #ifdef __CGNS_ENUMS__ typedef enum { ElectricCurrentUnitsNull, ElectricCurrentUnitsUserDefined, Ampere, Abampere, Statampere, Edison, auCurrent } ElectricCurrentUnits_t; #endif #define NofValidElectricCurrentUnits 7 #define Ampere_s "Ampere" #define Abampere_s "Abampere" #define Statampere_s "Statampere" #define Edison_s "Edison" #define auCurrent_s "auCurrent" /* SubstanceAmount ---*/ #ifdef __CGNS_ENUMS__ typedef enum { SubstanceAmountUnitsNull, SubstanceAmountUnitsUserDefined, Mole, Entities, StandardCubicFoot, StandardCubicMeter } SubstanceAmountUnits_t; #endif #define NofValidSubstanceAmountUnits 6 #define Mole_s "Mole" #define Entities_s "Entities" #define StandardCubicFoot_s "StandardCubicFoot" #define StandardCubicMeter_s "StandardCubicMeter" /* LuminousIntensity ---*/ #ifdef __CGNS_ENUMS__ typedef enum { LuminousIntensityUnitsNull, LuminousIntensityUnitsUserDefined, Candela, Candle, Carcel, Hefner, Violle } LuminousIntensityUnits_t; #endif #define NofValidLuminousIntensityUnits 7 #define Candela_s "Candela" #define Candle_s "Candle" #define Carcel_s "Carcel" #define Hefner_s "Hefner" #define Violle_s "Violle" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Data Class * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { DataClassNull, DataClassUserDefined, Dimensional, NormalizedByDimensional, NormalizedByUnknownDimensional, NondimensionalParameter, DimensionlessConstant } DataClass_t; #endif #define NofValidDataClass 7 #define Dimensional_s "Dimensional" #define NormalizedByDimensional_s "NormalizedByDimensional" #define NormalizedByUnknownDimensional_s "NormalizedByUnknownDimensional" #define NondimensionalParameter_s "NondimensionalParameter" #define DimensionlessConstant_s "DimensionlessConstant" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Grid Location \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { GridLocationNull, GridLocationUserDefined, Vertex, CellCenter, FaceCenter, IFaceCenter, JFaceCenter, KFaceCenter, EdgeCenter } GridLocation_t; #endif #define NofValidGridLocation 9 #define Vertex_s "Vertex" #define CellCenter_s "CellCenter" #define FaceCenter_s "FaceCenter" #define IFaceCenter_s "IFaceCenter" #define JFaceCenter_s "JFaceCenter" #define KFaceCenter_s "KFaceCenter" #define EdgeCenter_s "EdgeCenter" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * BCData Types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { BCDataTypeNull, BCDataTypeUserDefined, Dirichlet, Neumann } BCDataType_t; #endif #define NofValidBCDataTypes 4 #define Dirichlet_s "Dirichlet" #define Neumann_s "Neumann" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Grid Connectivity Types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { GridConnectivityTypeNull, GridConnectivityTypeUserDefined, Overset, Abutting, Abutting1to1 } GridConnectivityType_t; #endif #define NofValidGridConnectivityTypes 5 #define Overset_s "Overset" #define Abutting_s "Abutting" #define Abutting1to1_s "Abutting1to1" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Point Set Types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { PointSetTypeNull, PointSetTypeUserDefined, PointList, PointListDonor, PointRange, PointRangeDonor, ElementRange, ElementList, CellListDonor } PointSetType_t; #endif #define NofValidPointSetTypes 9 #define PointList_s "PointList" #define PointListDonor_s "PointListDonor" #define PointRange_s "PointRange" #define PointRangeDonor_s "PointRangeDonor" #define ElementRange_s "ElementRange" #define ElementList_s "ElementList" #define CellListDonor_s "CellListDonor" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Governing Equations and Physical Models Types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { GoverningEquationsNull, GoverningEquationsUserDefined, FullPotential, Euler, NSLaminar, NSTurbulent, NSLaminarIncompressible, NSTurbulentIncompressible } GoverningEquationsType_t; #endif #define NofValidGoverningEquationsTypes 8 #define FullPotential_s "FullPotential" #define Euler_s "Euler" #define NSLaminar_s "NSLaminar" #define NSTurbulent_s "NSTurbulent" #define NSLaminarIncompressible_s "NSLaminarIncompressible" #define NSTurbulentIncompressible_s "NSTurbulentIncompressible" /* Any model type will accept both ModelTypeNull and ModelTypeUserDefined. ** The following models will accept these values as valid... ** ** GasModel_t: Ideal, VanderWaals, CaloricallyPerfect, ThermallyPerfect, ** ConstantDensity, RedlichKwong ** ** ViscosityModel_t: Constant, PowerLaw, SutherlandLaw ** ** ThermalConductivityModel_t: PowerLaw, SutherlandLaw, ConstantPrandtl ** ** TurbulenceModel_t: Algebraic_BaldwinLomax, Algebraic_CebeciSmith, ** HalfEquation_JohnsonKing, OneEquation_BaldwinBarth, ** OneEquation_SpalartAllmaras, TwoEquation_JonesLaunder, ** TwoEquation_MenterSST,TwoEquation_Wilcox ** ** TurbulenceClosure_t: EddyViscosity, ReynoldsStress, ReynoldsStressAlgebraic ** ** ThermalRelaxationModel_t: Frozen, ThermalEquilib, ThermalNonequilib ** ** ChemicalKineticsModel_t: Frozen, ChemicalEquilibCurveFit, ** ChemicalEquilibMinimization, ChemicalNonequilib ** ** EMElectricFieldModel_t: Voltage, Interpolated, Constant, Frozen ** ** EMMagneticFieldModel_t: Interpolated, Constant, Frozen ** ** EMConductivityModel_t: Constant, Frozen, Equilibrium_LinRessler, ** Chemistry_LinRessler */ #ifdef __CGNS_ENUMS__ typedef enum { ModelTypeNull, ModelTypeUserDefined, Ideal, VanderWaals, Constant, PowerLaw, SutherlandLaw, ConstantPrandtl, EddyViscosity, ReynoldsStress, ReynoldsStressAlgebraic, Algebraic_BaldwinLomax, Algebraic_CebeciSmith, HalfEquation_JohnsonKing, OneEquation_BaldwinBarth, OneEquation_SpalartAllmaras, TwoEquation_JonesLaunder, TwoEquation_MenterSST, TwoEquation_Wilcox, CaloricallyPerfect, ThermallyPerfect, ConstantDensity, RedlichKwong, Frozen, ThermalEquilib, ThermalNonequilib, ChemicalEquilibCurveFit, ChemicalEquilibMinimization, ChemicalNonequilib, EMElectricField, EMMagneticField, EMConductivity, Voltage, Interpolated, Equilibrium_LinRessler, Chemistry_LinRessler } ModelType_t; #endif #define NofValidModelTypes 36 #define Ideal_s "Ideal" #define VanderWaals_s "VanderWaals" #define Constant_s "Constant" #define PowerLaw_s "PowerLaw" #define SutherlandLaw_s "SutherlandLaw" #define ConstantPrandtl_s "ConstantPrandtl" #define EddyViscosity_s "EddyViscosity" #define ReynoldsStress_s "ReynoldsStress" #define Algebraic_s "Algebraic" #define BaldwinLomax_s "BaldwinLomax" #define ReynoldsStressAlgebraic_s "ReynoldsStressAlgebraic" #define Algebraic_CebeciSmith_s "Algebraic_CebeciSmith" #define HalfEquation_JohnsonKing_s "HalfEquation_JohnsonKing" #define OneEquation_BaldwinBarth_s "OneEquation_BaldwinBarth" #define OneEquation_SpalartAllmaras_s "OneEquation_SpalartAllmaras" #define TwoEquation_JonesLaunder_s "TwoEquation_JonesLaunder" #define TwoEquation_MenterSST_s "TwoEquation_MenterSST" #define TwoEquation_Wilcox_s "TwoEquation_Wilcox" #define CaloricallyPerfect_s "CaloricallyPerfect" #define ThermallyPerfect_s "ThermallyPerfect" #define ConstantDensity_s "ConstantDensity" #define RedlichKwong_s "RedlichKwong" #define Frozen_s "Frozen" #define ThermalEquilib_s "ThermalEquilib" #define ThermalNonequilib_s "ThermalNonequilib" #define ChemicalEquilibCurveFit_s "ChemicalEquilibCurveFit" #define ChemicalEquilibMinimization_s "ChemicalEquilibMinimization" #define ChemicalNonequilib_s "ChemicalNonequilib" #define EMElectricField_s "EMElectricField" #define EMMagneticField_s "EMMagneticField" #define EMConductivity_s "EMConductivity" #define Voltage_s "Voltage" #define Interpolated_s "Interpolated" #define Equilibrium_LinRessler_s "Equilibrium_LinRessler" #define Chemistry_LinRessler_s "Chemistry_LinRessler" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Boundary Condition Types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { BCTypeNull, BCTypeUserDefined, BCAxisymmetricWedge, BCDegenerateLine, BCDegeneratePoint, BCDirichlet, BCExtrapolate, BCFarfield, BCGeneral, BCInflow, BCInflowSubsonic, BCInflowSupersonic, BCNeumann, BCOutflow, BCOutflowSubsonic, BCOutflowSupersonic, BCSymmetryPlane, BCSymmetryPolar, BCTunnelInflow, BCTunnelOutflow, BCWall, BCWallInviscid, BCWallViscous, BCWallViscousHeatFlux, BCWallViscousIsothermal, FamilySpecified } BCType_t; #endif #define NofValidBCTypes 26 #define BCAxisymmetricWedge_s "BCAxisymmetricWedge" #define BCDegenerateLine_s "BCDegenerateLine" #define BCDegeneratePoint_s "BCDegeneratePoint" #define BCDirichlet_s "BCDirichlet" #define BCExtrapolate_s "BCExtrapolate" #define BCFarfield_s "BCFarfield" #define BCGeneral_s "BCGeneral" #define BCInflow_s "BCInflow" #define BCInflowSubsonic_s "BCInflowSubsonic" #define BCInflowSupersonic_s "BCInflowSupersonic" #define BCNeumann_s "BCNeumann" #define BCOutflow_s "BCOutflow" #define BCOutflowSubsonic_s "BCOutflowSubsonic" #define BCOutflowSupersonic_s "BCOutflowSupersonic" #define BCSymmetryPlane_s "BCSymmetryPlane" #define BCSymmetryPolar_s "BCSymmetryPolar" #define BCTunnelInflow_s "BCTunnelInflow" #define BCTunnelOutflow_s "BCTunnelOutflow" #define BCWall_s "BCWall" #define BCWallInviscid_s "BCWallInviscid" #define BCWallViscous_s "BCWallViscous" #define BCWallViscousHeatFlux_s "BCWallViscousHeatFlux" #define BCWallViscousIsothermal_s "BCWallViscousIsothermal" #define FamilySpecified_s "FamilySpecified" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Data types: Can not add data types and stay forward compatible * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { DataTypeNull, DataTypeUserDefined, Integer, RealSingle, RealDouble, Character, LongInteger, ComplexSingle, ComplexDouble } DataType_t; #endif #define NofValidDataTypes 9 #define Integer_s "Integer" #define RealSingle_s "RealSingle" #define RealDouble_s "RealDouble" #define Character_s "Character" #define LongInteger_s "LongInteger" #define ComplexSingle_s "ComplexSingle" #define ComplexDouble_s "ComplexDouble" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Element types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { ElementTypeNull, ElementTypeUserDefined, /* 0, 1, */ NODE, BAR_2, BAR_3, /* 2, 3, 4, */ TRI_3, TRI_6, /* 5, 6, */ QUAD_4, QUAD_8, QUAD_9, /* 7, 8, 9, */ TETRA_4, TETRA_10, /* 10, 11, */ PYRA_5, PYRA_14, /* 12, 13, */ PENTA_6, PENTA_15, PENTA_18, /* 14, 15, 16, */ HEXA_8, HEXA_20, HEXA_27, /* 17, 18, 19, */ MIXED, PYRA_13, NGON_n, NFACE_n /* 20, 21, 22, 23*/ } ElementType_t; #endif #define NofValidElementTypes 24 #define NODE_s "NODE" #define BAR_2_s "BAR_2" #define BAR_3_s "BAR_3" #define TRI_3_s "TRI_3" #define TRI_6_s "TRI_6" #define QUAD_4_s "QUAD_4" #define QUAD_8_s "QUAD_8" #define QUAD_9_s "QUAD_9" #define TETRA_4_s "TETRA_4" #define TETRA_10_s "TETRA_10" #define PYRA_5_s "PYRA_5" #define PYRA_14_s "PYRA_14" #define PENTA_6_s "PENTA_6" #define PENTA_15_s "PENTA_15" #define PENTA_18_s "PENTA_18" #define HEXA_8_s "HEXA_8" #define HEXA_20_s "HEXA_20" #define HEXA_27_s "HEXA_27" #define MIXED_s "MIXED" #define PYRA_13_s "PYRA_13" #define NGON_n_s "NGON_n" #define NFACE_n_s "NFACE_n" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Zone types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { ZoneTypeNull, ZoneTypeUserDefined, Structured, Unstructured } ZoneType_t; #endif #define NofValidZoneTypes 4 #define Structured_s "Structured" #define Unstructured_s "Unstructured" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Rigid Grid Motion types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { RigidGridMotionTypeNull, RigidGridMotionTypeUserDefined, ConstantRate, VariableRate } RigidGridMotionType_t; #endif #define NofValidRigidGridMotionTypes 4 #define ConstantRate_s "ConstantRate" #define VariableRate_s "VariableRate" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Arbitrary Grid Motion types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { ArbitraryGridMotionTypeNull, ArbitraryGridMotionTypeUserDefined, NonDeformingGrid, DeformingGrid } ArbitraryGridMotionType_t; #endif #define NofValidArbitraryGridMotionTypes 4 #define NonDeformingGrid_s "NonDeformingGrid" #define DeformingGrid_s "DeformingGrid" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Simulation types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { SimulationTypeNull, SimulationTypeUserDefined, TimeAccurate, NonTimeAccurate } SimulationType_t; #endif #define NofValidSimulationTypes 4 #define TimeAccurate_s "TimeAccurate" #define NonTimeAccurate_s "NonTimeAccurate" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * BC Property types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { WallFunctionTypeNull, WallFunctionTypeUserDefined, Generic } WallFunctionType_t; #endif #define NofValidWallFunctionTypes 3 #define Generic_s "Generic" #ifdef __CGNS_ENUMS__ typedef enum { AreaTypeNull, AreaTypeUserDefined, BleedArea, CaptureArea } AreaType_t; #endif #define NofValidAreaTypes 4 #define BleedArea_s "BleedArea" #define CaptureArea_s "CaptureArea" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Grid Connectivity Property types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifdef __CGNS_ENUMS__ typedef enum { AverageInterfaceTypeNull, AverageInterfaceTypeUserDefined, AverageAll, AverageCircumferential, AverageRadial, AverageI, AverageJ, AverageK } AverageInterfaceType_t; #endif #define NofValidAverageInterfaceTypes 8 #define AverageAll_s "AverageAll" #define AverageCircumferential_s "AverageCircumferential" #define AverageRadial_s "AverageRadial" #define AverageI_s "AverageI" #define AverageJ_s "AverageJ" #define AverageK_s "AverageK" /* The strings defined below are node names or node name patterns */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Coordinate system * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define CoordinateX_s "CoordinateX" #define CoordinateY_s "CoordinateY" #define CoordinateZ_s "CoordinateZ" #define CoordinateR_s "CoordinateR" #define CoordinateTheta_s "CoordinateTheta" #define CoordinatePhi_s "CoordinatePhi" #define CoordinateNormal_s "CoordinateNormal" #define CoordinateTangential_s "CoordinateTangential" #define CoordinateXi_s "CoordinateXi" #define CoordinateEta_s "CoordinateEta" #define CoordinateZeta_s "CoordinateZeta" #define CoordinateTransform_s "CoordinateTransform" #define InterpolantsDonor_s "InterpolantsDonor" #define ElementConnectivity_s "ElementConnectivity" #define ParentData_s "ParentData" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * FlowSolution Quantities * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Patterns --- */ #define VectorX_ps "%sX" #define VectorY_ps "%sY" #define VectorZ_ps "%sZ" #define VectorTheta_ps "%sTheta" #define VectorPhi_ps "%sPhi" #define VectorMagnitude_ps "%sMagnitude" #define VectorNormal_ps "%sNormal" #define VectorTangential_ps "%sTangential" #define Potential_s "Potential" #define StreamFunction_s "StreamFunction" #define Density_s "Density" #define Pressure_s "Pressure" #define Temperature_s "Temperature" #define EnergyInternal_s "EnergyInternal" #define Enthalpy_s "Enthalpy" #define Entropy_s "Entropy" #define EntropyApprox_s "EntropyApprox" #define DensityStagnation_s "DensityStagnation" #define PressureStagnation_s "PressureStagnation" #define TemperatureStagnation_s "TemperatureStagnation" #define EnergyStagnation_s "EnergyStagnation" #define EnthalpyStagnation_s "EnthalpyStagnation" #define EnergyStagnationDensity_s "EnergyStagnationDensity" #define VelocityX_s "VelocityX" #define VelocityY_s "VelocityY" #define VelocityZ_s "VelocityZ" #define VelocityR_s "VelocityR" #define VelocityTheta_s "VelocityTheta" #define VelocityPhi_s "VelocityPhi" #define VelocityMagnitude_s "VelocityMagnitude" #define VelocityNormal_s "VelocityNormal" #define VelocityTangential_s "VelocityTangential" #define VelocitySound_s "VelocitySound" #define VelocitySoundStagnation_s "VelocitySoundStagnation" #define MomentumX_s "MomentumX" #define MomentumY_s "MomentumY" #define MomentumZ_s "MomentumZ" #define MomentumMagnitude_s "MomentumMagnitude" #define RotatingVelocityX_s "RotatingVelocityX" #define RotatingVelocityY_s "RotatingVelocityY" #define RotatingVelocityZ_s "RotatingVelocityZ" #define RotatingMomentumX_s "RotatingMomentumX" #define RotatingMomentumY_s "RotatingMomentumY" #define RotatingMomentumZ_s "RotatingMomentumZ" #define RotatingVelocityMagnitude_s "RotatingVelocityMagnitude" #define RotatingPressureStagnation_s "RotatingPressureStagnation" #define RotatingEnergyStagnation_s "RotatingEnergyStagnation" #define RotatingEnergyStagnationDensity_s "RotatingEnergyStagnationDensity" #define RotatingEnthalpyStagnation_s "RotatingEnthalpyStagnation" #define EnergyKinetic_s "EnergyKinetic" #define PressureDynamic_s "PressureDynamic" #define SoundIntensityDB_s "SoundIntensityDB" #define SoundIntensity_s "SoundIntensity" #define VorticityX_s "VorticityX" #define VorticityY_s "VorticityY" #define VorticityZ_s "VorticityZ" #define VorticityMagnitude_s "VorticityMagnitude" #define SkinFrictionX_s "SkinFrictionX" #define SkinFrictionY_s "SkinFrictionY" #define SkinFrictionZ_s "SkinFrictionZ" #define SkinFrictionMagnitude_s "SkinFrictionMagnitude" #define VelocityAngleX_s "VelocityAngleX" #define VelocityAngleY_s "VelocityAngleY" #define VelocityAngleZ_s "VelocityAngleZ" #define VelocityUnitVectorX_s "VelocityUnitVectorX" #define VelocityUnitVectorY_s "VelocityUnitVectorY" #define VelocityUnitVectorZ_s "VelocityUnitVectorZ" #define MassFlow_s "MassFlow" #define ViscosityKinematic_s "ViscosityKinematic" #define ViscosityMolecular_s "ViscosityMolecular" #define ViscosityEddyDynamic_s "ViscosityEddyDynamic" #define ViscosityEddy_s "ViscosityEddy" #define ThermalConductivity_s "ThermalConductivity" #define PowerLawExponent_s "PowerLawExponent" #define SutherlandLawConstant_s "SutherlandLawConstant" #define TemperatureReference_s "TemperatureReference" #define ViscosityMolecularReference_s "ViscosityMolecularReference" #define ThermalConductivityReference_s "ThermalConductivityReference" #define IdealGasConstant_s "IdealGasConstant" #define SpecificHeatPressure_s "SpecificHeatPressure" #define SpecificHeatVolume_s "SpecificHeatVolume" #define ReynoldsStressXX_s "ReynoldsStressXX" #define ReynoldsStressXY_s "ReynoldsStressXY" #define ReynoldsStressXZ_s "ReynoldsStressXZ" #define ReynoldsStressYY_s "ReynoldsStressYY" #define ReynoldsStressYZ_s "ReynoldsStressYZ" #define ReynoldsStressZZ_s "ReynoldsStressZZ" #define LengthReference_s "LengthReference" #define MolecularWeight_s "MolecularWeight" #define MolecularWeight_ps "MolecularWeight%s" #define HeatOfFormation_s "HeatOfFormation" #define HeatOfFormation_ps "HeatOfFormation%s" #define FuelAirRatio_s "FuelAirRatio" #define ReferenceTemperatureHOF_s "ReferenceTemperatureHOF" #define MassFraction_s "MassFraction" #define MassFraction_ps "MassFraction%s" #define LaminarViscosity_s "LaminarViscosity" #define LaminarViscosity_ps "LaminarViscosity%s" #define ThermalConductivity_ps "ThermalConductivity%s" #define EnthalpyEnergyRatio_s "EnthalpyEnergyRatio" #define CompressibilityFactor_s "CompressibilityFactor" #define VibrationalElectronEnergy_s "VibrationalElectronEnergy" #define VibrationalElectronTemperature_s "VibrationalElectronTemperature" #define SpeciesDensity_s "SpeciesDensity" #define SpeciesDensity_ps "SpeciesDensity%s" #define MoleFraction_s "MoleFraction" #define MoleFraction_ps "MoleFraction%s" #define ElectricFieldX_s "ElectricFieldX" #define ElectricFieldY_s "ElectricFieldY" #define ElectricFieldZ_s "ElectricFieldZ" #define MagneticFieldX_s "MagneticFieldX" #define MagneticFieldY_s "MagneticFieldY" #define MagneticFieldZ_s "MagneticFieldZ" #define CurrentDensityX_s "CurrentDensityX" #define CurrentDensityY_s "CurrentDensityY" #define CurrentDensityZ_s "CurrentDensityZ" #define LorentzForceX_s "LorentzForceX" #define LorentzForceY_s "LorentzForceY" #define LorentzForceZ_s "LorentzForceZ" #define ElectricConductivity_s "ElectricConductivity" #define JouleHeating_s "JouleHeating" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Typical Turbulence Models * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define TurbulentDistance_s "TurbulentDistance" #define TurbulentEnergyKinetic_s "TurbulentEnergyKinetic" #define TurbulentDissipation_s "TurbulentDissipation" #define TurbulentDissipationRate_s "TurbulentDissipationRate" #define TurbulentBBReynolds_s "TurbulentBBReynolds" #define TurbulentSANuTilde_s "TurbulentSANuTilde" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Nondimensional Parameters * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define Mach_s "Mach" #define Mach_Velocity_s "Mach_Velocity" #define Mach_VelocitySound_s "Mach_VelocitySound" #define Reynolds_s "Reynolds" #define Reynolds_Velocity_s "Reynolds_Velocity" #define Reynolds_Length_s "Reynolds_Length" #define Reynolds_ViscosityKinematic_s "Reynolds_ViscosityKinematic" #define Prandtl_s "Prandtl" #define Prandtl_ThermalConductivity_s "Prandtl_ThermalConductivity" #define Prandtl_ViscosityMolecular_s "Prandtl_ViscosityMolecular" #define Prandtl_SpecificHeatPressure_s "Prandtl_SpecificHeatPressure" #define PrandtlTurbulent_s "PrandtlTurbulent" #define SpecificHeatRatio_s "SpecificHeatRatio" #define SpecificHeatRatio_Pressure_s "SpecificHeatRatio_Pressure" #define SpecificHeatRatio_Volume_s "SpecificHeatRatio_Volume" #define CoefPressure_s "CoefPressure" #define CoefSkinFrictionX_s "CoefSkinFrictionX" #define CoefSkinFrictionY_s "CoefSkinFrictionY" #define CoefSkinFrictionZ_s "CoefSkinFrictionZ" #define Coef_PressureDynamic_s "Coef_PressureDynamic" #define Coef_PressureReference_s "Coef_PressureReference" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Characteristics and Riemann invariant * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define Vorticity_s "Vorticity" #define Acoustic_s "Acoustic" #define RiemannInvariantPlus_s "RiemannInvariantPlus" #define RiemannInvariantMinus_s "RiemannInvariantMinus" #define CharacteristicEntropy_s "CharacteristicEntropy" #define CharacteristicVorticity1_s "CharacteristicVorticity1" #define CharacteristicVorticity2_s "CharacteristicVorticity2" #define CharacteristicAcousticPlus_s "CharacteristicAcousticPlus" #define CharacteristicAcousticMinus_s "CharacteristicAcousticMinus" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Forces and Moments * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define ForceX_s "ForceX" #define ForceY_s "ForceY" #define ForceZ_s "ForceZ" #define ForceR_s "ForceR" #define ForceTheta_s "ForceTheta" #define ForcePhi_s "ForcePhi" #define Lift_s "Lift" #define Drag_s "Drag" #define MomentX_s "MomentX" #define MomentY_s "MomentY" #define MomentZ_s "MomentZ" #define MomentR_s "MomentR" #define MomentTheta_s "MomentTheta" #define MomentPhi_s "MomentPhi" #define MomentXi_s "MomentXi" #define MomentEta_s "MomentEta" #define MomentZeta_s "MomentZeta" #define Moment_CenterX_s "Moment_CenterX" #define Moment_CenterY_s "Moment_CenterY" #define Moment_CenterZ_s "Moment_CenterZ" #define CoefLift_s "CoefLift" #define CoefDrag_s "CoefDrag" #define CoefMomentX_s "CoefMomentX" #define CoefMomentY_s "CoefMomentY" #define CoefMomentZ_s "CoefMomentZ" #define CoefMomentR_s "CoefMomentR" #define CoefMomentTheta_s "CoefMomentTheta" #define CoefMomentPhi_s "CoefMomentPhi" #define CoefMomentXi_s "CoefMomentXi" #define CoefMomentEta_s "CoefMomentEta" #define CoefMomentZeta_s "CoefMomentZeta" #define Coef_PressureDynamic_s "Coef_PressureDynamic" #define Coef_Area_s "Coef_Area" #define Coef_Length_s "Coef_Length" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Time dependent flow * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define TimeValues_s "TimeValues" #define IterationValues_s "IterationValues" #define NumberOfZones_s "NumberOfZones" #define NumberOfFamilies_s "NumberOfFamilies" #define ZonePointers_s "ZonePointers" #define FamilyPointers_s "FamilyPointers" #define RigidGridMotionPointers_s "RigidGridMotionPointers" #define ArbitraryGridMotionPointers_s "ArbitraryGridMotionPointers" #define GridCoordinatesPointers_s "GridCoordinatesPointers" #define FlowSolutionPointers_s "FlowSolutionPointers" #define OriginLocation_s "OriginLocation" #define RigidRotationAngle_s "RigidRotationAngle" #define RigidVelocity_s "RigidVelocity" #define RigidRotationRate_s "RigidRotationRate" #define GridVelocityX_s "GridVelocityX" #define GridVelocityY_s "GridVelocityY" #define GridVelocityZ_s "GridVelocityZ" #define GridVelocityR_s "GridVelocityR" #define GridVelocityTheta_s "GridVelocityTheta" #define GridVelocityPhi_s "GridVelocityPhi" #define GridVelocityXi_s "GridVelocityXi" #define GridVelocityEta_s "GridVelocityEta" #define GridVelocityZeta_s "GridVelocityZeta" /* The strings defined below are type names used for node labels */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Types as strings * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define ArbitraryGridMotion_ts "ArbitraryGridMotion_t" #define Area_ts "Area_t" #define AverageInterface_ts "AverageInterface_t" #define Axisymmetry_ts "Axisymmetry_t" #define BCDataSet_ts "BCDataSet_t" #define BCData_ts "BCData_t" #define BCProperty_ts "BCProperty_t" #define BC_ts "BC_t" #define BaseIterativeData_ts "BaseIterativeData_t" #define CGNSBase_ts "CGNSBase_t" #define CGNSLibraryVersion_ts "CGNSLibraryVersion_t" #define ChemicalKineticsModel_ts "ChemicalKineticsModel_t" #define ConvergenceHistory_ts "ConvergenceHistory_t" #define DataArray_ts "DataArray_t" #define DataClass_ts "DataClass_t" #define DataConversion_ts "DataConversion_t" #define Descriptor_ts "Descriptor_t" #define DimensionalExponents_ts "DimensionalExponents_t" #define DimensionalUnits_ts "DimensionalUnits_t" #define DiscreteData_ts "DiscreteData_t" #define Elements_ts "Elements_t" #define FamilyBC_ts "FamilyBC_t" #define FamilyName_ts "FamilyName_t" #define Family_ts "Family_t" #define FlowEquationSet_ts "FlowEquationSet_t" #define FlowSolution_ts "FlowSolution_t" #define GasModel_ts "GasModel_t" #define GeometryEntity_ts "GeometryEntity_t" #define GeometryFile_ts "GeometryFile_t" #define GeometryFormat_ts "GeometryFormat_t" #define GeometryReference_ts "GeometryReference_t" #define GoverningEquations_ts "GoverningEquations_t" #define Gravity_ts "Gravity_t" #define GridConnectivity1to1_ts "GridConnectivity1to1_t" #define GridConnectivityProperty_ts "GridConnectivityProperty_t" #define GridConnectivityType_ts "GridConnectivityType_t" #define GridConnectivity_ts "GridConnectivity_t" #define GridCoordinates_ts "GridCoordinates_t" #define GridLocation_ts "GridLocation_t" #define IndexArray_ts "IndexArray_t" #define IndexRange_ts "IndexRange_t" #define IntegralData_ts "IntegralData_t" #define InwardNormalList_ts "InwardNormalList_t" #define Ordinal_ts "Ordinal_t" #define OversetHoles_ts "OversetHoles_t" #define Periodic_ts "Periodic_t" #define ReferenceState_ts "ReferenceState_t" #define RigidGridMotion_ts "RigidGridMotion_t" #define Rind_ts "Rind_t" #define RotatingCoordinates_ts "RotatingCoordinates_t" #define SimulationType_ts "SimulationType_t" #define ThermalConductivityModel_ts "ThermalConductivityModel_t" #define ThermalRelaxationModel_ts "ThermalRelaxationModel_t" #define TurbulenceClosure_ts "TurbulenceClosure_t" #define TurbulenceModel_ts "TurbulenceModel_t" #define UserDefinedData_ts "UserDefinedData_t" #define ViscosityModel_ts "ViscosityModel_t" #define WallFunction_ts "WallFunction_t" #define ZoneBC_ts "ZoneBC_t" #define ZoneGridConnectivity_ts "ZoneGridConnectivity_t" #define ZoneIterativeData_ts "ZoneIterativeData_t" #define ZoneType_ts "ZoneType_t" #define Zone_ts "Zone_t" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * No line after this comment - * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #endif CGNS-4.5.0/src/cgns_error.c000066400000000000000000000076431474000356600153670ustar00rootroot00000000000000/*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ /** * \defgroup ErrorHandling Error Handling **/ #include #include #include #include "cgnslib.h" #include "cgns_header.h" #include "cgns_io.h" void (*cgns_error_handler)(int, char *) = 0; char cgns_error_mess[200] = "no CGNS error reported"; CGNSDLL void cgi_error(const char *format, ...) { va_list arg; va_start(arg, format); vsnprintf(cgns_error_mess, 200, format, arg); va_end(arg); if (cgns_error_handler) (*cgns_error_handler)(1, cgns_error_mess); } CGNSDLL void cgi_warning(const char *format, ...) { va_list arg; va_start(arg, format); if (cgns_error_handler) { char warning_msg[200]; vsnprintf(warning_msg, 200, format, arg); (*cgns_error_handler)(0, warning_msg); } else { fprintf(stdout,"*** Warning:"); vfprintf(stdout,format,arg); fprintf(stdout," ***\n"); } va_end(arg); } /** * \ingroup ErrorHandling * * \brief If an error occurs during the execution of a CGNS library function, * signified by a non-zero value of the error status variable \p ier, an error * message may be retrieved using the function cg_get_error(). * * \return The error message */ const char *cg_get_error() { return cgns_error_mess; } /** * \ingroup ErrorHandling * * \brief Print the error message and stop the execution of the program * * \note In C, you may define a function to be called automatically in the case of a * warning or error using the cg_configure() routine. The function is of the form * \code void err_func(int is_error, char *errmsg) \endcode and will be called whenever an error * or warning occurs. The first argument, \p is_error, will be 0 for warning messages, * 1 for error messages, and -1 if the program is going to terminate * (i.e., a call to cg_error_exit()). The second argument is the error or warning message. * */ void cg_error_exit() { if (cgns_error_handler) (*cgns_error_handler)(-1, cgns_error_mess); else fprintf(stderr,"%s\n",cgns_error_mess); cgio_cleanup(); exit(1); } /** * \ingroup ErrorHandling * * \brief Print the error message and continue execution of the program * * \note In C, you may define a function to be called automatically in the case of a * warning or error using the cg_configure() routine. The function is of the form * \code void err_func(int is_error, char *errmsg) \endcode and will be called whenever an error * or warning occurs. The first argument, \p is_error, will be 0 for warning messages, * 1 for error messages, and -1 if the program is going to terminate * (i.e., a call to cg_error_exit()). The second argument is the error or warning message. * */ void cg_error_print() { fprintf(stderr,"%s\n",cgns_error_mess); } CGNSDLL void cg_io_error (const char *funcname) { char errmsg[CGIO_MAX_ERROR_LENGTH+1]; cgio_error_message(errmsg); cgi_error("%s:%s", funcname, errmsg); } CGNS-4.5.0/src/cgns_f.F90000066400000000000000000012020561474000356600145730ustar00rootroot00000000000000!------------------------------------------------------------------------- !This software is provided 'as-is', without any express or implied warranty. !In no event will the authors be held liable for any damages arising from !the use of this software. ! !Permission is granted to anyone to use this software for any purpose, !including commercial applications, and to alter it and redistribute it !freely, subject to the following restrictions: ! !1. The origin of this software must not be misrepresented; you must not ! claim that you wrote the original software. If you use this software ! in a product, an acknowledgment in the product documentation would be ! appreciated but is not required. ! !2. Altered source versions must be plainly marked as such, and must not ! be misrepresented as being the original software. ! !3. This notice may not be removed or altered from any source distribution. !------------------------------------------------------------------------- ! _____ _____ _ _ _____ ! / ____/ ____| \ | |/ ____| ! | | | | __| \| | (___ ! | | | | |_ | . ` |\___ \ ! | |___| |__| | |\ |____) | ! \_____\_____|_| \_|_____/ ! ! PURPOSE: ! Provides a module for the Fortran wrapper interfaces and CGNS ! constant parameters. ! ! ! KNOWN ISSUES: ! Routines passing an argument to a C API argument of type ! void * do not have explicit interfaces. They are the routines which ! are commented out. ! MODULE cgns USE ISO_C_BINDING, ONLY : C_INT, C_FLOAT, C_DOUBLE, C_LONG_LONG, C_CHAR, C_PTR, & C_NULL_CHAR, C_NULL_PTR, C_LOC, C_ASSOCIATED, C_F_POINTER IMPLICIT NONE #include "cgnstypes_f03.h" !These definitions are needed for Windows DLLs !DEC$ IF DEFINED(WINNT) !DEC$ ATTRIBUTES REFERENCE, C, VARYING :: cg_goto_f !DEC$ ATTRIBUTES REFERENCE, C, VARYING :: cg_array_read_f !DEC$ ATTRIBUTES REFERENCE, C, VARYING :: cg_array_read_as_f !DEC$ ATTRIBUTES REFERENCE, C, VARYING :: cg_array_write_f !DEC$ ENDIF #if CG_BUILD_64BIT_F # if HAVE_FORTRAN_2003 INTEGER, PARAMETER :: CGSIZE_T = C_LONG_LONG INTEGER, PARAMETER :: CGID_T = C_DOUBLE INTEGER, PARAMETER :: CGLONG_T = C_LONG_LONG # else INTEGER, PARAMETER :: cgint_kind = SELECTED_INT_KIND(15) ! should map to INTEGER*8 on most modern processors INTEGER, PARAMETER :: cgdouble_kind = SELECTED_REAL_KIND(10) ! should map to REAL*8 on most modern processors INTEGER, PARAMETER :: CGSIZE_T = cgint_kind INTEGER, PARAMETER :: CGID_T = cgdouble_kind INTEGER, PARAMETER :: CGLONG_T = cgint_kind # endif LOGICAL, PARAMETER :: CG_BUILD_64BIT = .TRUE. #else # if HAVE_FORTRAN_2003 INTEGER, PARAMETER :: CGSIZE_T = C_INT INTEGER, PARAMETER :: CGID_T = C_DOUBLE INTEGER, PARAMETER :: CGLONG_T = C_LONG_LONG # else INTEGER, PARAMETER :: cgint_kind = SELECTED_INT_KIND(5) ! should map to INTEGER*4 on most modern processors INTEGER, PARAMETER :: cglong_kind = SELECTED_INT_KIND(15) ! should map to INTEGER*8 on most modern processors INTEGER, PARAMETER :: cgdouble_kind = SELECTED_REAL_KIND(10) ! should map to REAL*8 on most modern processors INTEGER, PARAMETER :: CGSIZE_T = cgint_kind INTEGER, PARAMETER :: CGID_T = cgdouble_kind INTEGER, PARAMETER :: CGLONG_T = cglong_kind # endif LOGICAL, PARAMETER :: CG_BUILD_64BIT = .FALSE. #endif !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: CGSIZE_T !DEC$ATTRIBUTES DLLEXPORT :: CGID_T !DEC$ATTRIBUTES DLLEXPORT :: CGLONG_T !DEC$ATTRIBUTES DLLEXPORT :: CG_BUILD_64BIT !DEC$endif INTEGER, PARAMETER, PRIVATE :: MAX_LEN = 32 PRIVATE :: C_F_string_chars PRIVATE :: C_F_string_ptr INTERFACE cgio_set_dimensions_f SUBROUTINE cgio_set_dimensions_f_0(cgio_num, id, data_type, ndims, dims, ier) ! BIND(C, NAME="cgio_set_dimensions_f_0") IMPORT :: CGSIZE_T, C_DOUBLE, C_CHAR IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id CHARACTER(KIND=C_CHAR, LEN=*) :: data_type INTEGER :: ndims INTEGER(CGSIZE_T) :: dims INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_set_dimensions_f_0 SUBROUTINE cgio_set_dimensions_f_1(cgio_num, id, data_type, ndims, dims, ier) ! BIND(C, NAME="cgio_set_dimensions_f_1") IMPORT :: CGSIZE_T, C_DOUBLE, C_CHAR IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id CHARACTER(KIND=C_CHAR, LEN=*) :: data_type INTEGER :: ndims INTEGER(CGSIZE_T), DIMENSION(*) :: dims INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_set_dimensions_f_1 END INTERFACE INTERFACE cgio_get_dimensions_f SUBROUTINE cgio_get_dimensions_f_0(cgio_num, id, ndims, dims, ier) BIND(C, NAME="cgio_get_dimensions_f_0") IMPORT :: C_DOUBLE, CGSIZE_T IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id INTEGER :: ndims INTEGER(CGSIZE_T) :: dims INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_dimensions_f_0 SUBROUTINE cgio_get_dimensions_f_1(cgio_num, id, ndims, dims, ier) BIND(C, NAME="cgio_get_dimensions_f_1") IMPORT :: C_DOUBLE, CGSIZE_T IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id INTEGER :: ndims INTEGER(CGSIZE_T), DIMENSION(*) :: dims INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_dimensions_f_1 END INTERFACE ! Fortran version of cgnslib.h ! !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* modes for cgns file * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * INTEGER(C_INT), PARAMETER :: CG_MODE_READ = 0 INTEGER(C_INT), PARAMETER :: CG_MODE_WRITE = 1 INTEGER(C_INT), PARAMETER :: CG_MODE_MODIFY = 2 ! file open modes (found in cgns_io.h) INTEGER(C_INT), PARAMETER :: CGIO_MODE_READ = 0 INTEGER(C_INT), PARAMETER :: CGIO_MODE_WRITE = 1 INTEGER(C_INT), PARAMETER :: CGIO_MODE_MODIFY = 2 ! database file types (found in cgns_io.h) INTEGER(C_INT), PARAMETER :: CGIO_FILE_NONE = 0 INTEGER(C_INT), PARAMETER :: CGIO_FILE_ADF = 1 INTEGER(C_INT), PARAMETER :: CGIO_FILE_HDF5 = 2 INTEGER(C_INT), PARAMETER :: CGIO_FILE_ADF2 = 3 !* legacy code support INTEGER(C_INT) MODE_READ, MODE_WRITE, MODE_MODIFY PARAMETER (MODE_READ = 0) PARAMETER (MODE_WRITE = 1) PARAMETER (MODE_MODIFY = 2) !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: CG_MODE_READ !DEC$ATTRIBUTES DLLEXPORT :: CG_MODE_WRITE !DEC$ATTRIBUTES DLLEXPORT :: CG_MODE_MODIFY !DEC$ATTRIBUTES DLLEXPORT :: CGIO_MODE_READ !DEC$ATTRIBUTES DLLEXPORT :: CGIO_MODE_WRITE !DEC$ATTRIBUTES DLLEXPORT :: CGIO_MODE_MODIFY !DEC$ATTRIBUTES DLLEXPORT :: CGIO_FILE_NONE !DEC$ATTRIBUTES DLLEXPORT :: CGIO_FILE_ADF !DEC$ATTRIBUTES DLLEXPORT :: CGIO_FILE_HDF5 !DEC$ATTRIBUTES DLLEXPORT :: CGIO_FILE_ADF2 !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* file types (found in cgnslib.h) * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * INTEGER(C_INT), PARAMETER :: CG_FILE_NONE = 0 INTEGER(C_INT), PARAMETER :: CG_FILE_ADF = 1 INTEGER(C_INT), PARAMETER :: CG_FILE_HDF5 = 2 INTEGER(C_INT), PARAMETER :: CG_FILE_ADF2 = 3 !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: CG_FILE_NONE !DEC$ATTRIBUTES DLLEXPORT :: CG_FILE_ADF !DEC$ATTRIBUTES DLLEXPORT :: CG_FILE_HDF5 !DEC$ATTRIBUTES DLLEXPORT :: CG_FILE_ADF2 !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* some error code (found in cgnslib.h) * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * INTEGER(C_INT), PARAMETER :: CG_OK = 0 INTEGER(C_INT), PARAMETER :: CG_ERROR = 1 INTEGER(C_INT), PARAMETER :: CG_NODE_NOT_FOUND = 2 INTEGER(C_INT), PARAMETER :: CG_INCORRECT_PATH = 3 INTEGER(C_INT), PARAMETER :: CG_CG_NO_INDEX_DIM = 4 !* legacy code support INTEGER(C_INT) ALL_OK, ERROR, NODE_NOT_FOUND, INCORRECT_PATH PARAMETER (ALL_OK = 0) PARAMETER (ERROR = 1) PARAMETER (NODE_NOT_FOUND = 2) PARAMETER (INCORRECT_PATH = 3) !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: CG_OK !DEC$ATTRIBUTES DLLEXPORT :: CG_ERROR !DEC$ATTRIBUTES DLLEXPORT :: CG_NODE_NOT_FOUND !DEC$ATTRIBUTES DLLEXPORT :: CG_INCORRECT_PATH !DEC$ATTRIBUTES DLLEXPORT :: CG_CG_NO_INDEX_DIM !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Configuration options (found in cgnslib.h) * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * INTEGER, PARAMETER :: CG_CONFIG_ERROR = 1 INTEGER, PARAMETER :: CG_CONFIG_COMPRESS = 2 INTEGER, PARAMETER :: CG_CONFIG_SET_PATH = 3 INTEGER, PARAMETER :: CG_CONFIG_ADD_PATH = 4 INTEGER, PARAMETER :: CG_CONFIG_FILE_TYPE = 5 INTEGER, PARAMETER :: CG_CONFIG_RIND_INDEX = 6 ! Fortran length of names for variables is limited to 31 characters INTEGER, PARAMETER :: CG_CONFIG_HDF5_COMPRESS = 201 INTEGER, PARAMETER :: CG_CONFIG_HDF5_MPI_COMM = 202 INTEGER, PARAMETER :: CG_CONFIG_HDF5_DISKLESS = 203 INTEGER, PARAMETER :: CG_CONFIG_HDF5_DISKLESS_INCR = 204 INTEGER, PARAMETER :: CG_CONFIG_HDF5_DISKLESS_WRITE = 205 INTEGER, PARAMETER :: CG_CONFIG_HDF5_ALIGNMENT = 206 INTEGER, PARAMETER :: CG_CONFIG_HDF5_MD_BLOCK_SIZE = 207 INTEGER, PARAMETER :: CG_CONFIG_HDF5_BUFFER = 208 INTEGER, PARAMETER :: CG_CONFIG_HDF5_SIEVE_BUF_SIZE = 209 INTEGER, PARAMETER :: CG_CONFIG_HDF5_ELINK_CACHE_SIZE = 210 INTEGER, PARAMETER :: CG_CONFIG_RESET = 1000 INTEGER, PARAMETER :: CG_CONFIG_RESET_HDF5 = 1 INTEGER, PARAMETER :: CG_CONFIG_RIND_ZERO = 0 INTEGER, PARAMETER :: CG_CONFIG_RIND_CORE = 1 !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_ERROR !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_COMPRESS !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_SET_PATH !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_ADD_PATH !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_FILE_TYPE !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_RIND_INDEX !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_COMPRESS !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_MPI_COMM !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_DISKLESS !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_DISKLESS_INCR !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_DISKLESS_WRITE !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_ALIGNMENT !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_MD_BLOCK_SIZE !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_BUFFER !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_SIEVE_BUF_SIZE !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_HDF5_ELINK_CACHE_SIZE !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_RESET !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_RESET_HDF5 !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_RIND_ZERO !DEC$ATTRIBUTES DLLEXPORT :: CG_CONFIG_RIND_CORE !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Parallel CGNS parameters * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * ENUM, BIND(C) ENUMERATOR :: CGP_INDEPENDENT = 0 ENUMERATOR :: CGP_COLLECTIVE = 1 END ENUM !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Dimensional Units (found in cgnslib.h) * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * INTEGER(C_INT), PARAMETER :: CG_Null = 0 INTEGER(C_INT), PARAMETER :: CG_UserDefined = 1 !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: CG_Null !DEC$ATTRIBUTES DLLEXPORT :: CG_UserDefined !DEC$endif CHARACTER(LEN=MAX_LEN) :: MassUnitsName(0:5) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(MassUnitsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(MassUnitsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Kilogram) = 2 ENUMERATOR :: CGNS_ENUMV(Gram) = 3 ENUMERATOR :: CGNS_ENUMV(Slug) = 4 ENUMERATOR :: CGNS_ENUMV(PoundMass) = 5 END ENUM CHARACTER(LEN=MAX_LEN) :: LengthUnitsName(0:6) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(LengthUnitsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(LengthUnitsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Meter) = 2 ENUMERATOR :: CGNS_ENUMV(Centimeter) = 3 ENUMERATOR :: CGNS_ENUMV(Millimeter) = 4 ENUMERATOR :: CGNS_ENUMV(Foot) = 5 ENUMERATOR :: CGNS_ENUMV(Inch) = 6 END ENUM CHARACTER(LEN=MAX_LEN) :: TimeUnitsName(0:2) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(TimeUnitsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(TimeUnitsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Second) = 2 END ENUM CHARACTER(LEN=MAX_LEN) :: TemperatureUnitsName(0:5) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(TemperatureUnitsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(TemperatureUnitsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Kelvin) = 2 ENUMERATOR :: CGNS_ENUMV(Celsius) = 3 ENUMERATOR :: CGNS_ENUMV(Rankine) = 4 ENUMERATOR :: CGNS_ENUMV(Fahrenheit) = 5 END ENUM CHARACTER(LEN=MAX_LEN) :: AngleUnitsName(0:3) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(AngleUnitsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(AngleUnitsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Degree) = 2 ENUMERATOR :: CGNS_ENUMV(Radian) = 3 END ENUM CHARACTER(LEN=MAX_LEN) :: ElectricCurrentUnitsName(0:6) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(ElectricCurrentUnitsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(ElectricCurrentUnitsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Ampere) = 2 ENUMERATOR :: CGNS_ENUMV(Abampere) = 3 ENUMERATOR :: CGNS_ENUMV(Statampere) = 4 ENUMERATOR :: CGNS_ENUMV(Edison) = 5 ENUMERATOR :: CGNS_ENUMV(auCurrent) = 6 END ENUM CHARACTER(LEN=MAX_LEN) :: SubstanceAmountUnitsName(0:5) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(SubstanceAmountUnitsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(SubstanceAmountUnitsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Mole) = 2 ENUMERATOR :: CGNS_ENUMV(Entities) = 3 ENUMERATOR :: CGNS_ENUMV(StandardCubicFoot) = 4 ENUMERATOR :: CGNS_ENUMV(StandardCubicMeter) = 5 END ENUM CHARACTER(LEN=MAX_LEN) :: LuminousIntensityUnitsName(0:6) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(LuminousIntensityUnitsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(LuminousIntensityUnitsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Candela) = 2 ENUMERATOR :: CGNS_ENUMV(Candle) = 3 ENUMERATOR :: CGNS_ENUMV(Carcel) = 4 ENUMERATOR :: CGNS_ENUMV(Hefner) = 5 ENUMERATOR :: CGNS_ENUMV(Violle) = 6 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: MassUnitsName !DEC$ATTRIBUTES DLLEXPORT :: LengthUnitsName !DEC$ATTRIBUTES DLLEXPORT :: TimeUnitsName !DEC$ATTRIBUTES DLLEXPORT :: TemperatureUnitsName !DEC$ATTRIBUTES DLLEXPORT :: AngleUnitsName !DEC$ATTRIBUTES DLLEXPORT :: ElectricCurrentUnitsName !DEC$ATTRIBUTES DLLEXPORT :: SubstanceAmountUnitsName !DEC$ATTRIBUTES DLLEXPORT :: LuminousIntensityUnitsName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Data Class (found in cgnslib.h * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: DataClassName(0:6) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(DataClassNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(DataClassUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Dimensional) = 2 ENUMERATOR :: CGNS_ENUMV(NormalizedByDimensional) = 3 ENUMERATOR :: CGNS_ENUMV(NormalizedByUnknownDimensional) = 4 ENUMERATOR :: CGNS_ENUMV(NondimensionalParameter) = 5 ENUMERATOR :: CGNS_ENUMV(DimensionlessConstant) = 6 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: DataClassName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Grid Location * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: GridLocationName(0:8) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(GridLocationNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(GridLocationUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Vertex) = 2 ENUMERATOR :: CGNS_ENUMV(CellCenter) = 3 ENUMERATOR :: CGNS_ENUMV(FaceCenter) = 4 ENUMERATOR :: CGNS_ENUMV(IFaceCenter) = 5 ENUMERATOR :: CGNS_ENUMV(JFaceCenter) = 6 ENUMERATOR :: CGNS_ENUMV(KFaceCenter) = 7 ENUMERATOR :: CGNS_ENUMV(EdgeCenter) = 8 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: GridLocationName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Grid Connectivity Types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: GridConnectivityTypeName(0:4) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(GridConnectivityTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(GridConnectivityTypeUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Overset) = 2 ENUMERATOR :: CGNS_ENUMV(Abutting) = 3 ENUMERATOR :: CGNS_ENUMV(Abutting1to1) = 4 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: GridConnectivityTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Point Set Types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: PointSetTypeName(0:8) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(PointSetTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(PointSetTypeUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(PointList) = 2 ENUMERATOR :: CGNS_ENUMV(PointListDonor) = 3 ENUMERATOR :: CGNS_ENUMV(PointRange) = 4 ENUMERATOR :: CGNS_ENUMV(PointRangeDonor) = 5 ENUMERATOR :: CGNS_ENUMV(ElementRange) = 6 ENUMERATOR :: CGNS_ENUMV(ElementList) = 7 ENUMERATOR :: CGNS_ENUMV(CellListDonor) = 8 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: PointSetTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Governing Equations and Physical Models Types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: GoverningEquationsTypeName(0:7) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(GoverningEquationsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(GoverningEquationsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(FullPotential) = 2 ENUMERATOR :: CGNS_ENUMV(Euler) = 3 ENUMERATOR :: CGNS_ENUMV(NSLaminar) = 4 ENUMERATOR :: CGNS_ENUMV(NSTurbulent) = 5 ENUMERATOR :: CGNS_ENUMV(NSLaminarIncompressible) = 6 ENUMERATOR :: CGNS_ENUMV(NSTurbulentIncompressible) = 7 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: GoverningEquationsTypeName !DEC$endif !** Any model type will accept both ModelTypeNull and ModelTypeUserDefined. !** The following models will accept these values as valid... !** !** GasModel_t: Ideal, VanderWaals, CaloricallyPerfect, ThermallyPerfect, !** ConstantDensity, RedlichKwong !** !** ViscosityModel_t: Constant, PowerLaw, SutherlandLaw !** !** ThermalConductivityModel_t: PowerLaw, SutherlandLaw, ConstantPrandtl !** !** TurbulenceModel_t: Algebraic_BaldwinLomax, Algebraic_CebeciSmith, !** HalfEquation_JohnsonKing, OneEquation_BaldwinBarth, !** OneEquation_SpalartAllmaras, TwoEquation_JonesLaunder, !** TwoEquation_MenterSST,TwoEquation_Wilcox !** !** TurbulenceClosure_t: EddyViscosity, ReynoldsStress, !** ReynoldsStressAlgebraic !** !** ThermalRelaxationModel_t: Frozen, ThermalEquilib, ThermalNonequilib !** !** ChemicalKineticsModel_t: Frozen, ChemicalEquilibCurveFit, !** ChemicalEquilibMinimization, ChemicalNonequilib !** !** EMElectricFieldModel_t: Voltage, Interpolated, Constant, Frozen !** !** EMMagneticFieldModel_t: Interpolated, Constant, Frozen !** !** EMConductivityModel_t: Constant, Frozen, Equilibrium_LinRessler, !** Chemistry_LinRessler CHARACTER(LEN=MAX_LEN) :: ModelTypeName(0:35) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(ModelTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(ModelTypeUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Ideal) = 2 ENUMERATOR :: CGNS_ENUMV(VanderWaals) = 3 ENUMERATOR :: CGNS_ENUMV(Constant) = 4 ENUMERATOR :: CGNS_ENUMV(PowerLaw) = 5 ENUMERATOR :: CGNS_ENUMV(SutherlandLaw) = 6 ENUMERATOR :: CGNS_ENUMV(ConstantPrandtl) = 7 ENUMERATOR :: CGNS_ENUMV(EddyViscosity) = 8 ENUMERATOR :: CGNS_ENUMV(ReynoldsStress) = 9 ENUMERATOR :: CGNS_ENUMV(ReynoldsStressAlgebraic) = 10 ENUMERATOR :: CGNS_ENUMV(Algebraic_BaldwinLomax) = 11 ENUMERATOR :: CGNS_ENUMV(Algebraic_CebeciSmith) = 12 ENUMERATOR :: CGNS_ENUMV(HalfEquation_JohnsonKing) = 13 ENUMERATOR :: CGNS_ENUMV(OneEquation_BaldwinBarth) = 14 ENUMERATOR :: CGNS_ENUMV(OneEquation_SpalartAllmaras) = 15 ENUMERATOR :: CGNS_ENUMV(TwoEquation_JonesLaunder) = 16 ENUMERATOR :: CGNS_ENUMV(TwoEquation_MenterSST) = 17 ENUMERATOR :: CGNS_ENUMV(TwoEquation_Wilcox) = 18 ENUMERATOR :: CGNS_ENUMV(CaloricallyPerfect) = 19 ENUMERATOR :: CGNS_ENUMV(ThermallyPerfect) = 20 ENUMERATOR :: CGNS_ENUMV(ConstantDensity) = 21 ENUMERATOR :: CGNS_ENUMV(RedlichKwong) = 22 ENUMERATOR :: CGNS_ENUMV(Frozen) = 23 ENUMERATOR :: CGNS_ENUMV(ThermalEquilib) = 24 ENUMERATOR :: CGNS_ENUMV(ThermalNonequilib) = 25 ENUMERATOR :: CGNS_ENUMV(ChemicalEquilibCurveFit) = 26 ENUMERATOR :: CGNS_ENUMV(ChemicalEquilibMinimization) = 27 ENUMERATOR :: CGNS_ENUMV(ChemicalNonequilib) = 28 ENUMERATOR :: CGNS_ENUMV(EMElectricField) = 29 ENUMERATOR :: CGNS_ENUMV(EMMagneticField) = 30 ENUMERATOR :: CGNS_ENUMV(EMConductivity) = 31 ENUMERATOR :: CGNS_ENUMV(Voltage) = 32 ENUMERATOR :: CGNS_ENUMV(Interpolated) = 33 ENUMERATOR :: CGNS_ENUMV(Equilibrium_LinRessler) = 34 ENUMERATOR :: CGNS_ENUMV(Chemistry_LinRessler) = 35 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: ModelTypeName !DEC$endif CHARACTER(LEN=MAX_LEN) :: ParticleGoverningEquationsTypeName(0:4) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(ParticleGoverningEquationsNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(ParticleGoverningEquationsUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(DEM) = 2 ENUMERATOR :: CGNS_ENUMV(DSMC) = 3 ENUMERATOR :: CGNS_ENUMV(SPH) = 4 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: ParticleGoverningEquationsTypeName !DEC$endif !** Any particle model type will accept both ParticleModelTypeNull and ParticleModelTypeUserDefined. !** The following particle models will accept these values as valid... !** !** ParticleCollisionModelType_t: Linear, NonLinear, HardSphere, SoftSphere, !** LinearSpringDashpot, Pair, HertzMindlin, HertzKuwabaraKono, ORourke, !** Stochastic, NonStochastic, NTC !** !** ParticleBreakupModel_t: KelvinHelmholtz, KelvinHelmholtzACT, RayleighTaylor, !** KelvinHelmholtzRayleighTaylor, TAB, ETAB, LISA, SHF, PilchErdman, ReitzDiwakar !** !** ParticleForceModel_t: Sphere, NonShpere, Tracer, BeetstraVanDerHoefKuipers, !** Ergun, CliftGrace, Gidaspow, HaiderLevenspiel, PlessisMasliyah, !** SyamlalOBrien, SaffmanMei, TennetiGargSubramaniam, Tomiyama, Stokes, !** StokesCunningham, WenYu !** !** ParticleWallInteractionModel_t: Linear, NonLinear, HardSphere, SoftSphere, !** LinearSpringDashpot, BaiGosman, Pair, HertzMindlin, HertzKuwabaraKono, Khunke, !** ORourke, Stochastic, NonStochastic, NTC !** !** ParticlePhaseChangeModel_t: Boil, Condense, Flash, Nucleate, Chiang, Frossling, FuchsKnudsen CHARACTER(LEN=MAX_LEN) :: ParticleModelTypeName(0:49) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(ParticleModelTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(ParticleModelTypeUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Linear) = 2 ENUMERATOR :: CGNS_ENUMV(NonLinear) = 3 ENUMERATOR :: CGNS_ENUMV(HardSphere) = 4 ENUMERATOR :: CGNS_ENUMV(SoftSphere) = 5 ENUMERATOR :: CGNS_ENUMV(LinearSpringDashpot) = 6 ENUMERATOR :: CGNS_ENUMV(Pair) = 7 ENUMERATOR :: CGNS_ENUMV(HertzMindlin) = 8 ENUMERATOR :: CGNS_ENUMV(HertzKuwabaraKono) = 9 ENUMERATOR :: CGNS_ENUMV(ORourke) = 10 ENUMERATOR :: CGNS_ENUMV(Stochastic) = 11 ENUMERATOR :: CGNS_ENUMV(NonStochastic) = 12 ENUMERATOR :: CGNS_ENUMV(NTC) = 13 ENUMERATOR :: CGNS_ENUMV(KelvinHelmholtz) = 14 ENUMERATOR :: CGNS_ENUMV(KelvinHelmholtzACT) = 15 ENUMERATOR :: CGNS_ENUMV(RayleighTaylor) = 16 ENUMERATOR :: CGNS_ENUMV(KelvinHelmholtzRayleighTaylor) = 17 ENUMERATOR :: CGNS_ENUMV(ReitzKHRT) = 18 ENUMERATOR :: CGNS_ENUMV(TAB) = 19 ENUMERATOR :: CGNS_ENUMV(ETAB) = 20 ENUMERATOR :: CGNS_ENUMV(LISA) = 21 ENUMERATOR :: CGNS_ENUMV(SHF) = 22 ENUMERATOR :: CGNS_ENUMV(PilchErdman) = 23 ENUMERATOR :: CGNS_ENUMV(ReitzDiwakar) = 24 ENUMERATOR :: CGNS_ENUMV(Sphere) = 25 ENUMERATOR :: CGNS_ENUMV(NonShpere) = 26 ENUMERATOR :: CGNS_ENUMV(Tracer) = 27 ENUMERATOR :: CGNS_ENUMV(BeetstraVanDerHoefKuipers) = 28 ENUMERATOR :: CGNS_ENUMV(Ergun) = 29 ENUMERATOR :: CGNS_ENUMV(CliftGrace) = 30 ENUMERATOR :: CGNS_ENUMV(Gidaspow) = 31 ENUMERATOR :: CGNS_ENUMV(HaiderLevenspiel) = 32 ENUMERATOR :: CGNS_ENUMV(PlessisMasliyah) = 33 ENUMERATOR :: CGNS_ENUMV(SyamlalOBrien) = 34 ENUMERATOR :: CGNS_ENUMV(SaffmanMei) = 35 ENUMERATOR :: CGNS_ENUMV(TennetiGargSubramaniam) = 36 ENUMERATOR :: CGNS_ENUMV(Tomiyama) = 37 ENUMERATOR :: CGNS_ENUMV(Stokes) = 38 ENUMERATOR :: CGNS_ENUMV(StokesCunningham) = 39 ENUMERATOR :: CGNS_ENUMV(WenYu) = 40 ENUMERATOR :: CGNS_ENUMV(BaiGosman) = 41 ENUMERATOR :: CGNS_ENUMV(Khunke) = 42 ENUMERATOR :: CGNS_ENUMV(Boil) = 43 ENUMERATOR :: CGNS_ENUMV(Condense) = 44 ENUMERATOR :: CGNS_ENUMV(Flash) = 45 ENUMERATOR :: CGNS_ENUMV(Nucleate) = 46 ENUMERATOR :: CGNS_ENUMV(Chiang) = 47 ENUMERATOR :: CGNS_ENUMV(Frossling) = 48 ENUMERATOR :: CGNS_ENUMV(FuchsKnudsen) = 49 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: ParticleModelTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Boundary Condition Types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: BCTypeName(0:25) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(BCTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(BCTypeUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(BCAxisymmetricWedge) = 2 ENUMERATOR :: CGNS_ENUMV(BCDegenerateLine) = 3 ENUMERATOR :: CGNS_ENUMV(BCDegeneratePoint) = 4 ENUMERATOR :: CGNS_ENUMV(BCDirichlet) = 5 ENUMERATOR :: CGNS_ENUMV(BCExtrapolate) = 6 ENUMERATOR :: CGNS_ENUMV(BCFarfield) = 7 ENUMERATOR :: CGNS_ENUMV(BCGeneral) = 8 ENUMERATOR :: CGNS_ENUMV(BCInflow) = 9 ENUMERATOR :: CGNS_ENUMV(BCInflowSubsonic) = 10 ENUMERATOR :: CGNS_ENUMV(BCInflowSupersonic) = 11 ENUMERATOR :: CGNS_ENUMV(BCNeumann) = 12 ENUMERATOR :: CGNS_ENUMV(BCOutflow) = 13 ENUMERATOR :: CGNS_ENUMV(BCOutflowSubsonic) = 14 ENUMERATOR :: CGNS_ENUMV(BCOutflowSupersonic) = 15 ENUMERATOR :: CGNS_ENUMV(BCSymmetryPlane) = 16 ENUMERATOR :: CGNS_ENUMV(BCSymmetryPolar) = 17 ENUMERATOR :: CGNS_ENUMV(BCTunnelInflow) = 18 ENUMERATOR :: CGNS_ENUMV(BCTunnelOutflow) = 19 ENUMERATOR :: CGNS_ENUMV(BCWall) = 20 ENUMERATOR :: CGNS_ENUMV(BCWallInviscid) = 21 ENUMERATOR :: CGNS_ENUMV(BCWallViscous) = 22 ENUMERATOR :: CGNS_ENUMV(BCWallViscousHeatFlux) = 23 ENUMERATOR :: CGNS_ENUMV(BCWallViscousIsothermal) = 24 ENUMERATOR :: CGNS_ENUMV(FamilySpecified) = 25 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: BCTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Data types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: DataTypeName(0:8) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(DataTypeNull) ENUMERATOR :: CGNS_ENUMV(DataTypeUserDefined) ENUMERATOR :: CGNS_ENUMV(Integer) ENUMERATOR :: CGNS_ENUMV(RealSingle) ENUMERATOR :: CGNS_ENUMV(RealDouble) ENUMERATOR :: CGNS_ENUMV(Character) ENUMERATOR :: CGNS_ENUMV(LongInteger) ENUMERATOR :: CGNS_ENUMV(ComplexSingle) ENUMERATOR :: CGNS_ENUMV(ComplexDouble) END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: DataTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* BCData_t types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: BCDataTypeName(0:3) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(BCDataTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(BCDataTypeUserDefined) = CG_UserDefined ENUMERATOR :: CGNS_ENUMV(Dirichlet) = 2 ENUMERATOR :: CGNS_ENUMV(Neumann) = 3 END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: BCDataTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Element types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: ElementTypeName(0:56) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(ElementTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(ElementTypeUserDefined) ENUMERATOR :: CGNS_ENUMV(NODE) ENUMERATOR :: CGNS_ENUMV(BAR_2) ENUMERATOR :: CGNS_ENUMV(BAR_3) ENUMERATOR :: CGNS_ENUMV(TRI_3) ENUMERATOR :: CGNS_ENUMV(TRI_6) ENUMERATOR :: CGNS_ENUMV(QUAD_4) ENUMERATOR :: CGNS_ENUMV(QUAD_8) ENUMERATOR :: CGNS_ENUMV(QUAD_9) ENUMERATOR :: CGNS_ENUMV(TETRA_4) ENUMERATOR :: CGNS_ENUMV(TETRA_10) ENUMERATOR :: CGNS_ENUMV(PYRA_5) ENUMERATOR :: CGNS_ENUMV(PYRA_14) ENUMERATOR :: CGNS_ENUMV(PENTA_6) ENUMERATOR :: CGNS_ENUMV(PENTA_15) ENUMERATOR :: CGNS_ENUMV(PENTA_18) ENUMERATOR :: CGNS_ENUMV(HEXA_8) ENUMERATOR :: CGNS_ENUMV(HEXA_20) ENUMERATOR :: CGNS_ENUMV(HEXA_27) ENUMERATOR :: CGNS_ENUMV(MIXED) ENUMERATOR :: CGNS_ENUMV(PYRA_13) ENUMERATOR :: CGNS_ENUMV(NGON_n) ENUMERATOR :: CGNS_ENUMV(NFACE_n) ENUMERATOR :: CGNS_ENUMV(BAR_4) ENUMERATOR :: CGNS_ENUMV(TRI_9) ENUMERATOR :: CGNS_ENUMV(TRI_10) ENUMERATOR :: CGNS_ENUMV(QUAD_12) ENUMERATOR :: CGNS_ENUMV(QUAD_16) ENUMERATOR :: CGNS_ENUMV(TETRA_16) ENUMERATOR :: CGNS_ENUMV(TETRA_20) ENUMERATOR :: CGNS_ENUMV(PYRA_21) ENUMERATOR :: CGNS_ENUMV(PYRA_29) ENUMERATOR :: CGNS_ENUMV(PYRA_30) ENUMERATOR :: CGNS_ENUMV(PENTA_24) ENUMERATOR :: CGNS_ENUMV(PENTA_38) ENUMERATOR :: CGNS_ENUMV(PENTA_40) ENUMERATOR :: CGNS_ENUMV(HEXA_32) ENUMERATOR :: CGNS_ENUMV(HEXA_56) ENUMERATOR :: CGNS_ENUMV(HEXA_64) ENUMERATOR :: CGNS_ENUMV(BAR_5) ENUMERATOR :: CGNS_ENUMV(TRI_12) ENUMERATOR :: CGNS_ENUMV(TRI_15) ENUMERATOR :: CGNS_ENUMV(QUAD_P4_16) ENUMERATOR :: CGNS_ENUMV(QUAD_25) ENUMERATOR :: CGNS_ENUMV(TETRA_22) ENUMERATOR :: CGNS_ENUMV(TETRA_34) ENUMERATOR :: CGNS_ENUMV(TETRA_35) ENUMERATOR :: CGNS_ENUMV(PYRA_P4_29) ENUMERATOR :: CGNS_ENUMV(PYRA_50) ENUMERATOR :: CGNS_ENUMV(PYRA_55) ENUMERATOR :: CGNS_ENUMV(PENTA_33) ENUMERATOR :: CGNS_ENUMV(PENTA_66) ENUMERATOR :: CGNS_ENUMV(PENTA_75) ENUMERATOR :: CGNS_ENUMV(HEXA_44) ENUMERATOR :: CGNS_ENUMV(HEXA_98) ENUMERATOR :: CGNS_ENUMV(HEXA_125) END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: ElementTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Zone types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: ZoneTypeName(0:3) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(ZoneTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(ZoneTypeUserDefined) ENUMERATOR :: CGNS_ENUMV(Structured) ENUMERATOR :: CGNS_ENUMV(Unstructured) END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: ZoneTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Rigid Grid Motion types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: RigidGridMotionTypeName(0:3) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(RigidGridMotionTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(RigidGridMotionTypeUserDefined) ENUMERATOR :: CGNS_ENUMV(ConstantRate) ENUMERATOR :: CGNS_ENUMV(VariableRate) END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: RigidGridMotionTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Arbitrary Grid Motion types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: ArbitraryGridMotionTypeName(0:3) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(ArbitraryGridMotionTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(ArbitraryGridMotionTypeUserDefined) ENUMERATOR :: CGNS_ENUMV(NonDeformingGrid) ENUMERATOR :: CGNS_ENUMV(DeformingGrid) END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: ArbitraryGridMotionTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Simulation type * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: SimulationTypeName(0:3) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(SimulationTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(SimulationTypeUserDefined) ENUMERATOR :: CGNS_ENUMV(TimeAccurate) ENUMERATOR :: CGNS_ENUMV(NonTimeAccurate) END ENUM !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: SimulationTypeName !DEC$endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* BC Property types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: WallFunctionTypeName(0:2) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(WallFunctionTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(WallFunctionTypeUserDefined) ENUMERATOR :: CGNS_ENUMV(Generic) END ENUM CHARACTER(LEN=MAX_LEN) :: AreaTypeName(0:3) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(AreaTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(AreaTypeUserDefined) ENUMERATOR :: CGNS_ENUMV(BleedArea) ENUMERATOR :: CGNS_ENUMV(CaptureArea) END ENUM !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Grid Connectivity Property types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * CHARACTER(LEN=MAX_LEN) :: AverageInterfaceTypeName(0:7) ENUM, BIND(C) ENUMERATOR :: CGNS_ENUMV(AverageInterfaceTypeNull) = CG_Null ENUMERATOR :: CGNS_ENUMV(AverageInterfaceTypeUserDefined) ENUMERATOR :: CGNS_ENUMV(AverageAll) ENUMERATOR :: CGNS_ENUMV(AverageCircumferential) ENUMERATOR :: CGNS_ENUMV(AverageRadial) ENUMERATOR :: CGNS_ENUMV(AverageI) ENUMERATOR :: CGNS_ENUMV(AverageJ) ENUMERATOR :: CGNS_ENUMV(AverageK) END ENUM ! For portability to Linux Absoft, all data statements were moved after the ! variables and parameters declarations !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Dimensional Units * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA MassUnitsName /'Null','UserDefined','Kilogram','Gram', & 'Slug','PoundMass'/ DATA LengthUnitsName / 'Null', 'UserDefined', & 'Meter','Centimeter','Millimeter','Foot','Inch'/ DATA TimeUnitsName /'Null','UserDefined','Second'/ DATA TemperatureUnitsName /'Null','UserDefined', & 'Kelvin','Celsius','Rankine','Fahrenheit'/ DATA AngleUnitsName /'Null','UserDefined','Degree','Radian'/ DATA ElectricCurrentUnitsName /'Null', 'UserDefined', 'Ampere', & 'Abampere', 'Statampere', 'Edison', 'a.u.'/ DATA SubstanceAmountUnitsName /'Null', 'UserDefined', 'Mole', & 'Entities', 'StandardCubicFoot', 'StandardCubicMeter'/ DATA LuminousIntensityUnitsName /'Null', 'UserDefined', & 'Candela', 'Candle', 'Carcel', 'Hefner', 'Violle'/ !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Data Class * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA DataClassName / 'Null','UserDefined', & 'Dimensional','NormalizedByDimensional', & 'NormalizedByUnknownDimensional', & 'NondimensionalParameter','DimensionlessConstant'/ !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Grid Location * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA GridLocationName / 'Null','UserDefined', & 'Vertex','CellCenter','FaceCenter','IFaceCenter', & 'JFaceCenter','KFaceCenter','EdgeCenter' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Grid Connectivity Types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA GridConnectivityTypeName / 'Null','UserDefined', & 'Overset','Abutting','Abutting1to1'/ !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Point Set Types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA PointSetTypeName / 'Null','UserDefined', & 'PointList','PointListDonor', & 'PointRange','PointRangeDonor', & 'ElementRange','ElementList','CellListDonor'/ !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Governing Equations and Physical Models Types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA GoverningEquationsTypeName / 'Null','UserDefined', & 'FullPotential','Euler', 'NSLaminar', 'NSTurbulent', & 'NSLaminarIncompressible', 'NSTurbulentIncompressible'/ DATA ModelTypeName / 'Null','UserDefined', & 'Ideal','VanderWaals', 'Constant','PowerLaw', & 'SutherlandLaw','ConstantPrandtl','EddyViscosity', & 'ReynoldsStress','ReynoldsStressAlgebraic', & 'Algebraic_BaldwinLomax','Algebraic_CebeciSmith', & 'HalfEquation_JohnsonKing','OneEquation_BaldwinBarth', & 'OneEquation_SpalartAllmaras','TwoEquation_JonesLaunder', & 'TwoEquation_MenterSST','TwoEquation_Wilcox', & 'CaloricallyPerfect', 'ThermallyPerfect', & 'ConstantDensity', 'RedlichKwong', 'Frozen', & 'ThermalEquilib', 'ThermalNonequilib', & 'ChemicalEquilibCurveFit', 'ChemicalEquilibMinimization', & 'ChemicalNonequilib', 'EMElectricField', & 'EMMagneticField', 'EMConductivity', 'Voltage', & 'Interpolated', 'Equilibrium_LinRessler', & 'Chemistry_LinRessler'/ DATA ParticleGoverningEquationsTypeName / 'Null','UserDefined', & 'DEM','DSMC', 'SPH' / DATA ParticleModelTypeName / 'Null', 'UserDefined', & 'Linear', 'NonLinear', 'HardSphere', 'SoftSphere', & 'LinearSpringDashpot', 'Pair', 'HertzMindlin', & 'HertzKuwabaraKono', 'ORourke', 'Stochastic', 'NonStochastic', & 'NTC', 'KelvinHelmholtz', 'KelvinHelmholtzACT', 'RayleighTaylor', & 'KelvinHelmholtzRayleighTaylor', 'ReitzKHRT', 'TAB', 'ETAB', & 'LISA', 'SHF', 'PilchErdman', 'ReitzDiwakar', 'Sphere', 'NonShpere', & 'Tracer', 'BeetstraVanDerHoefKuipers', 'Ergun', 'CliftGrace', & 'Gidaspow', 'HaiderLevenspiel', 'PlessisMasliyah', & 'SyamlalOBrien', 'SaffmanMei', 'TennetiGargSubramaniam', 'Tomiyama', & 'Stokes', 'StokesCunningham', 'WenYu', 'BaiGosman', 'Kunkhe', & 'Boil', 'Condense', 'Flash' , 'Nucleate', 'Chiang', 'Frossling', & 'FuchsKnudsen'/ !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Boundary Condition Types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA BCTypeName / 'Null','UserDefined', & 'BCAxisymmetricWedge','BCDegenerateLine', & 'BCDegeneratePoint','BCDirichlet','BCExtrapolate', & 'BCFarfield','BCGeneral','BCInflow','BCInflowSubsonic', & 'BCInflowSupersonic','BCNeumann','BCOutflow', & 'BCOutflowSubsonic','BCOutflowSupersonic', & 'BCSymmetryPlane','BCSymmetryPolar','BCTunnelInflow', & 'BCTunnelOutflow','BCWall','BCWallInviscid', & 'BCWallViscous','BCWallViscousHeatFlux', & 'BCWallViscousIsothermal','FamilySpecified' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Data types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA DataTypeName / 'Null','UserDefined', & 'Integer','RealSingle','RealDouble','Character', & 'LongInteger','ComplexSingle','ComplexDouble' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* BCData_t types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA BCDataTypeName / 'Null','UserDefined', & 'Dirichlet', 'Neumann' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Element types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA ElementTypeName / 'Null','UserDefined', & 'NODE', 'BAR_2', 'BAR_3', 'TRI_3', 'TRI_6', & 'QUAD_4', 'QUAD_8', 'QUAD_9', 'TETRA_4', 'TETRA_10', & 'PYRA_5', 'PYRA_14', 'PENTA_6', 'PENTA_15', & 'PENTA_18', 'HEXA_8', 'HEXA_20', 'HEXA_27', 'MIXED', & 'PYRA_13', 'NGON_n', 'NFACE_n', & 'BAR_4', 'TRI_9', 'TRI_10', & 'QUAD_12', 'QUAD_16', & 'TETRA_16', 'TETRA_20', & 'PYRA_21', 'PYRA_29', 'PYRA_30', & 'PENTA_24', 'PENTA_38', 'PENTA_40', & 'HEXA_32', 'HEXA_56', 'HEXA_64', & 'BAR_5', 'TRI_12', 'TRI_15', & 'QUAD_P4_16', 'QUAD_25', & 'TETRA_22', 'TETRA_34', 'TETRA_35', & 'PYRA_P4_29', 'PYRA_50', 'PYRA_55', & 'PENTA_33', 'PENTA_66', 'PENTA_75', & 'HEXA_44', 'HEXA_98', 'HEXA_125' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Zone types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA ZoneTypeName / 'Null','UserDefined', & 'Structured', 'Unstructured' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Rigid Grid Motion types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA RigidGridMotionTypeName / 'Null','UserDefined', & 'ConstantRate', 'VariableRate' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Arbitrary Grid Motion types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA ArbitraryGridMotionTypeName / 'Null','UserDefined', & 'NonDeformingGrid', 'DeformingGrid' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Simulation type * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA SimulationTypeName / 'Null','UserDefined', & 'TimeAccurate', 'NonTimeAccurate' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* BC Property types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA WallFunctionTypeName / 'Null','UserDefined',& 'Generic' / DATA AreaTypeName / 'Null','UserDefined', & 'BleedArea', 'CaptureArea' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* Grid Connectivity Property types * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * DATA AverageInterfaceTypeName / 'Null','UserDefined', & 'AverageAll', 'AverageCircumferential', 'AverageRadial', & 'AverageI', 'AverageJ', 'AverageK' / !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* ENUMTYPE FOR FORTRAN FUNCTIONS * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * INTEGER, PARAMETER :: cgenum_t = KIND(CGP_INDEPENDENT) !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* INTERFACES FOR THE FORTRAN FUNCTIONS * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * INTERFACE INTEGER(C_INT) FUNCTION cg_is_cgns(filename, file_type) BIND(C,NAME="cg_is_cgns") USE ISO_C_BINDING IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: filename INTEGER(C_INT), INTENT(OUT) :: file_type END FUNCTION cg_is_cgns INTEGER(C_INT) FUNCTION cg_open(filename, mode, fn) BIND(C,NAME="cg_open") USE ISO_C_BINDING IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: filename INTEGER(C_INT), INTENT(IN), VALUE :: mode INTEGER(C_INT), INTENT(OUT) :: fn END FUNCTION cg_open END INTERFACE ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write GridCoordinates_t/DataArray_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if HAVE_FORTRAN_2008 INTERFACE cg_coord_read_f SUBROUTINE cg_coord_read_c_double (fn, B, Z, coordname, TYPE, rmin, rmax, coord, ier) !BIND(C, NAME="cg_coord_read_c_double") IMPORT :: c_char, cgenum_t, CGSIZE_T, c_double IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: coordname INTEGER(cgenum_t) :: TYPE INTEGER(CGSIZE_T) :: rmin INTEGER(CGSIZE_T) :: rmax REAL(C_DOUBLE), DIMENSION(*) :: coord INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_coord_read_c_double SUBROUTINE cg_coord_read_c_float (fn, B, Z, coordname, TYPE, rmin, rmax, coord, ier) !BIND(C, NAME="cg_coord_read_c_float") IMPORT :: c_char, cgenum_t, CGSIZE_T, c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: coordname INTEGER(cgenum_t) :: TYPE INTEGER(CGSIZE_T) :: rmin INTEGER(CGSIZE_T) :: rmax REAL(C_FLOAT), DIMENSION(*) :: coord INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_coord_read_c_float SUBROUTINE cg_coord_read_f03 (fn, B, Z, coordname, TYPE, rmin, rmax, coord, ier) BIND(C, NAME="cg_coord_read_f03") IMPORT :: c_char, cgenum_t, CGSIZE_T, c_ptr IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: coordname INTEGER(cgenum_t) :: TYPE INTEGER(CGSIZE_T) :: rmin INTEGER(CGSIZE_T) :: rmax TYPE(C_PTR), VALUE :: coord INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_coord_read_f03 END INTERFACE #endif INTERFACE !!$ SUBROUTINE cg_coord_write_f(fn, B, Z, TYPE, coordname, coord, C, ier) BIND(C, NAME="") !!$ IMPORT :: c_char, cgenum_t, c_ptr !!$ IMPLICIT NONE !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER(cgenum_t) :: TYPE !!$ CHARACTER(KIND=C_CHAR), DIMENSION(*) :: coordname !!$ TYPE(C_PTR), VALUE :: coord !!$ INTEGER :: C !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_coord_write_f !!$ SUBROUTINE cg_coord_partial_write_f( fn, B, Z, TYPE, coordname, rmin, rmax, coord, C, ier) BIND(C, NAME="") !!$ IMPORT :: c_char, cgenum_t, CGSIZE_T, c_ptr !!$ IMPLICIT NONE !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER(cgenum_t) :: TYPE !!$ CHARACTER(KIND=C_CHAR), DIMENSION(*) :: coordname !!$ INTEGER(CGSIZE_T) :: rmin !!$ INTEGER(CGSIZE_T) :: rmax !!$ TYPE(C_PTR) :: coord !!$ INTEGER :: C !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_coord_partial_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write Elements_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_section_read_f(fn, B, Z, E, section_name, TYPE, start, END, nbndry, & parent_flag, ier) !BIND(C, NAME="cg_section_read_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: E CHARACTER(KIND=C_CHAR), DIMENSION(*) :: section_name INTEGER(cgenum_t) :: TYPE INTEGER(CGSIZE_T) ::start INTEGER(CGSIZE_T) ::END INTEGER :: nbndry INTEGER :: parent_flag INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_section_read_f !!$!!$ SUBROUTINE cg_elements_read_f(fn, B, Z, E, elements, parent_data, ier) BIND(C, NAME="cg_elements_read_f") !!$ IMPORT :: CGSIZE_T !!$ IMPLICIT NONE !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: E !!$ INTEGER(CGSIZE_T), DIMENSION(*) :: elements !!$ INTEGER(CGSIZE_T), DIMENSION(*) :: parent_data !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_elements_read_f !!$ SUBROUTINE cg_elementdatasize_f(fn, B, Z, E, ElementDataSize, ier) BIND(C, NAME="cg_elementdatasize_f") IMPORT :: CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: E INTEGER(CGSIZE_T) :: ElementDataSize INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_elementdatasize_f SUBROUTINE cg_elementpartialsize_f(fn, B, Z, E, start, END, ElementDataSize, ier) BIND(C, NAME="cg_elementpartialsize_f") IMPORT :: CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: E INTEGER(CGSIZE_T) :: start INTEGER(CGSIZE_T) :: END INTEGER(CGSIZE_T) :: ElementDataSize INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_elementpartialsize_f !!$!!$ SUBROUTINE cg_section_write_f(fn, B, Z, section_name, TYPE, start, END, nbndry, elements, S, ier) !BIND(C, NAME="cg_section_write_f") !!$ IMPORT :: c_char, cgenum_t, CGSIZE_T !!$ IMPLICIT NONE !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ CHARACTER(KIND=C_CHAR), DIMENSION(*) :: section_name !!$ INTEGER(cgenum_t) :: TYPE !!$ INTEGER(CGSIZE_T) :: start !!$ INTEGER(CGSIZE_T) :: END !!$ INTEGER :: nbndry !!$ INTEGER(CGSIZE_T), DIMENSION() :: elements !!$ INTEGER :: S !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_section_write_f !!$ !!$!!$ SUBROUTINE cg_parent_data_write_f(fn, B, Z, S, parent_data, ier) BIND(C, NAME="cg_parent_data_write_f") !!$ IMPORT :: CGSIZE_T !!$ IMPLICIT NONE !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: S !!$ INTEGER(CGSIZE_T), DIMENSION(*) :: parent_data !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_parent_data_write_f !!$ SUBROUTINE cg_section_partial_write_f( fn, B, Z, section_name, TYPE, start, END, & nbndry, S, ier) !BIND(C, NAME="cg_section_partial_write_f") IMPORT :: c_char, CGSIZE_T, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: section_name INTEGER(cgenum_t) ::TYPE INTEGER(CGSIZE_T) ::start INTEGER(CGSIZE_T) ::END INTEGER :: nbndry INTEGER :: S INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_section_partial_write_f !!$!!$ SUBROUTINE cg_elements_partial_write_f(fn, B, Z, S, rmin, rmax, elements, ier) & !!$ BIND(C, NAME="cg_elements_partial_write_f") !!$ IMPORT :: CGSIZE_T !!$ IMPLICIT NONE !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: S !!$ INTEGER(CGSIZE_T) :: rmin !!$ INTEGER(CGSIZE_T) :: rmax !!$ INTEGER(CGSIZE_T), DIMENSION(*) :: elements !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_elements_partial_write_f !!$ !!$!!$ SUBROUTINE cg_parent_data_partial_write_f(fn, B, Z, S, rmin, rmax, parent_data, ier) & !!$ BIND(C, NAME="cg_parent_data_partial_write_f") !!$ IMPORT :: CGSIZE_T !!$ IMPLICIT NONE !!$ !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: S !!$ INTEGER(CGSIZE_T) :: rmin !!$ INTEGER(CGSIZE_T) :: rmax !!$ INTEGER(CGSIZE_T), DIMENSION(*) :: parent_data !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_parent_data_partial_write_f !!$!!$ !!$!!$ SUBROUTINE cg_elements_partial_read_f(fn, B, Z, S, rmin, rmax, elements, parent, ier) & !!$ BIND(C, NAME="cg_elements_partial_read_f") !!$ IMPORT :: CGSIZE_T !!$ IMPLICIT NONE !!$ !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: S !!$ INTEGER(CGSIZE_T) ::rmin !!$ INTEGER(CGSIZE_T) ::rmax !!$ INTEGER(CGSIZE_T), DIMENSION(*) :: elements !!$ INTEGER(CGSIZE_T), DIMENSION(*) :: parent !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_elements_partial_read_f !!$ ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write FlowSolution_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_nsols_f(fn, B, Z, nsols, ier) BIND(C, NAME="cg_nsols_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: nsols INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nsols_f SUBROUTINE cg_sol_info_f(fn, B, Z, S, solname, location, ier) !BIND(C, NAME="cg_sol_info_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S CHARACTER(KIND=C_CHAR), DIMENSION(*) :: solname INTEGER(cgenum_t) :: location INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_sol_info_f SUBROUTINE cg_sol_id_f(fn, B, Z, S, sol_id, ier) BIND(C, NAME="cg_sol_id_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S REAL(C_DOUBLE) :: sol_id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_sol_id_f SUBROUTINE cg_sol_write_f(fn, B, Z, solname, location, S, ier) !BIND(C, NAME="cg_sol_write_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: solname INTEGER(cgenum_t) :: location INTEGER :: S INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_sol_write_f SUBROUTINE cg_sol_size_f(fn, B, Z, S, ndim, dims, ier) BIND(C, NAME="cg_sol_size_f") IMPORT :: CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S INTEGER :: ndim INTEGER(CGSIZE_T), DIMENSION(*) :: dims INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_sol_size_f SUBROUTINE cg_sol_ptset_info_f( fn, B, Z, S, ptype, npnts, ier) BIND(C, NAME="cg_sol_ptset_info_f") IMPORT :: cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S INTEGER(cgenum_t) :: ptype INTEGER(CGSIZE_T) :: npnts INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_sol_ptset_info_f SUBROUTINE cg_sol_ptset_read_f(fn, B, Z, S, pnts, ier) BIND(C, NAME="cg_sol_ptset_read_f") IMPORT :: CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S INTEGER(CGSIZE_T) ::pnts INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_sol_ptset_read_f SUBROUTINE cg_sol_ptset_write_f(fn, B, Z, name, location, ptype, npnts, pnts, S, ier) !BIND(C, NAME="cg_sol_ptset_write_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name INTEGER(cgenum_t) :: location INTEGER(cgenum_t) :: ptype INTEGER(CGSIZE_T) :: npnts INTEGER(CGSIZE_T) :: pnts INTEGER :: S INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_sol_ptset_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write solution DataArray_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_nfields_f(fn, B, Z, S, nfields, ier) BIND(C, NAME="cg_nfields_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S INTEGER :: nfields INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nfields_f SUBROUTINE cg_field_info_f(fn, B, Z, S, F, TYPE, fieldname, ier) !BIND(C, NAME="cg_field_info_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S INTEGER :: F INTEGER(cgenum_t) :: TYPE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: fieldname INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_field_info_f !!$INTERFACE !!$ SUBROUTINE cg_field_read_f(fn, B, Z, S, fieldname), TYPE, rmin, rmax, field_ptr, ier) BIND(C, NAME="") !!$ INTEGER :: fn !!$ INTEGER :: B, !!$ INTEGER :: Z !!$ INTEGER :: S, CHARACTER(KIND=C_CHAR), DIMENSION(*) :: fieldname), INTEGER(cgenum_t) :: TYPE !!$ INTEGER(CGSIZE_T) ::rmin, !!$ INTEGER(CGSIZE_T) ::rmax !!$ void *field_ptr, !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_field_read_f !!$END INTERFACE SUBROUTINE cg_field_id_f(fn, B, Z, S, F, field_id, ier) !BIND(C, NAME="cg_field_id_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S INTEGER :: F REAL(C_DOUBLE) :: field_id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_field_id_f !!$ SUBROUTINE cg_field_write_f(fn, B, Z, S, TYPE, fieldname, field_ptr, F, ier) BIND(C, NAME="") !!$ INTEGER :: fn !!$ INTEGER :: B, !!$ INTEGER :: Z !!$ INTEGER :: S !!$ INTEGER(cgenum_t) :: TYPE !!$ CHARACTER(KIND=C_CHAR), DIMENSION(*) :: fieldname !!$ void *field_ptr, !!$ INTEGER :: F !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_field_write_f !!$ SUBROUTINE cg_field_partial_write_f) (fn, B, Z, S, TYPE, fieldname, rmin, rmax, void *field_ptr, F, ier) BIND(C, NAME="") !!$ INTEGER :: fn, !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: S, INTEGER(cgenum_t) :: TYPE !!$ CHARACTER(KIND=C_CHAR), DIMENSION(*) :: fieldname !!$ INTEGER(CGSIZE_T) :: rmin !!$ INTEGER(CGSIZE_T) :: rmax !!$ void *field_ptr !!$ INTEGER :: F !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_field_partial_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write ZoneSubRegion_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_nsubregs_f(fn, B, Z, nsubreg, ier) BIND(C, NAME="cg_nsubregs_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: nsubreg INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nsubregs_f SUBROUTINE cg_subreg_info_f(fn, B, Z, S, regname, DIMENSION, & location, ptset_type, npnts, bcname_len, gcname_len, ier) !BIND(C, NAME="cg_subreg_info_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S CHARACTER(KIND=C_CHAR), DIMENSION(*) :: regname INTEGER :: DIMENSION INTEGER(cgenum_t) :: location INTEGER(cgenum_t) :: ptset_type INTEGER(CGSIZE_T) ::npnts INTEGER :: bcname_len INTEGER :: gcname_len INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_subreg_info_f SUBROUTINE cg_subreg_ptset_read_f( fn, B, Z, S, pnts, ier) BIND(C, NAME="cg_subreg_ptset_read_f") IMPORT :: CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S INTEGER(CGSIZE_T), DIMENSION(*) :: pnts INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_subreg_ptset_read_f SUBROUTINE cg_subreg_bcname_read_f( fn, B, Z, S, bcname, ier) !BIND(C, NAME="cg_subreg_bcname_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S CHARACTER(KIND=C_CHAR), DIMENSION(*) :: bcname INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_subreg_bcname_read_f SUBROUTINE cg_subreg_gcname_read_f(fn, B, Z, S, gcname, ier) !BIND(C, NAME="cg_subreg_gcname_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S CHARACTER(KIND=C_CHAR), DIMENSION(*) :: gcname INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_subreg_gcname_read_f SUBROUTINE cg_subreg_ptset_write_f(fn, B, Z, regname, DIMENSION, location, ptset_type, npnts, & pnts, S, ier) !BIND(C, NAME="cg_subreg_ptset_write_f") IMPORT :: cgenum_t, c_char, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: regname INTEGER :: DIMENSION INTEGER(cgenum_t) :: location INTEGER(cgenum_t) :: ptset_type INTEGER(CGSIZE_T) :: npnts INTEGER(CGSIZE_T), DIMENSION(*) :: pnts INTEGER :: S INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_subreg_ptset_write_f SUBROUTINE cg_subreg_bcname_write_f( fn, B, Z, regname, DIMENSION, bcname, S, ier) !BIND(C, NAME="cg_subreg_bcname_write_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: regname INTEGER :: DIMENSION CHARACTER(KIND=C_CHAR), DIMENSION(*) :: bcname INTEGER :: S INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_subreg_bcname_write_f SUBROUTINE cg_subreg_gcname_write_f( fn, B, Z, regname, DIMENSION, gcname, S, ier) !BIND(C, NAME="cg_subreg_gcname_write_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: regname INTEGER :: DIMENSION CHARACTER(KIND=C_CHAR), DIMENSION(*) :: gcname INTEGER :: S INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_subreg_gcname_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write ZoneGridConnectivity_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_nzconns_f(fn, B, Z, nzconns, ier) BIND(C, NAME="cg_nzconns_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: nzconns INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nzconns_f SUBROUTINE cg_zconn_read_f(fn, B, Z, C, name, ier) !BIND(C, NAME="cg_zconn_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: C CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_zconn_read_f SUBROUTINE cg_zconn_write_f(fn, B, Z, name, C, ier) !BIND(C, NAME="cg_zconn_write_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name INTEGER :: C INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_zconn_write_f SUBROUTINE cg_zconn_get_f(fn, B, Z, C, ier) BIND(C, NAME="cg_zconn_get_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: C INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_zconn_get_f SUBROUTINE cg_zconn_set_f(fn, B, Z, C, ier) BIND(C, NAME="cg_zconn_set_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: C INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_zconn_set_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write OversetHoles_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_nholes_f(fn, B, Z, nholes, ier) BIND(C, NAME="cg_nholes_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: nholes INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nholes_f SUBROUTINE cg_hole_info_f(fn, B, Z, I, holename, location, ptset_type, nptsets, npnts, ier) !BIND(C, NAME="cg_hole_info_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I CHARACTER(KIND=C_CHAR), DIMENSION(*) :: holename INTEGER(cgenum_t) :: location INTEGER(cgenum_t) :: ptset_type INTEGER(CGSIZE_T) :: nptsets INTEGER(CGSIZE_T) :: npnts INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_hole_info_f SUBROUTINE cg_hole_read_f(fn, B, Z, I, pnts, ier) BIND(C, NAME="cg_hole_read_f") IMPORT :: CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I INTEGER(CGSIZE_T), DIMENSION(*) :: pnts INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_hole_read_f SUBROUTINE cg_hole_id_f(fn, B, Z, I, hole_id, ier) BIND(C, NAME="cg_hole_id_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I REAL(C_DOUBLE) :: hole_id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_hole_id_f SUBROUTINE cg_hole_write_f(fn, B, Z, holename, location, ptset_type, nptsets, npnts, & pnts, I, ier) !BIND(C, NAME="cg_hole_write_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: holename INTEGER(cgenum_t) :: location INTEGER(cgenum_t) :: ptset_type INTEGER :: nptsets INTEGER(CGSIZE_T) :: npnts INTEGER(CGSIZE_T), DIMENSION(*) :: pnts INTEGER :: I INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_hole_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write GridConnectivity_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_nconns_f(fn, B, Z, nconns, ier) BIND(C, NAME="cg_nconns_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: nconns INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nconns_f SUBROUTINE cg_conn_info_f(fn, B, Z, I, connectname, location, & TYPE, ptset_type, npnts, donorname, donor_zonetype, donor_ptset_type, & donor_datatype, ndata_donor, ier) !BIND(C, NAME="cg_conn_info_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I CHARACTER(KIND=C_CHAR), DIMENSION(*) :: connectname INTEGER(cgenum_t) :: location INTEGER(cgenum_t) :: TYPE INTEGER(cgenum_t) :: ptset_type INTEGER(CGSIZE_T) :: npnts CHARACTER(KIND=C_CHAR), DIMENSION(*) :: donorname INTEGER(cgenum_t) :: donor_zonetype INTEGER(cgenum_t) :: donor_ptset_type INTEGER(cgenum_t) :: donor_datatype INTEGER(CGSIZE_T) :: ndata_donor INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_info_f SUBROUTINE cg_conn_read_f(fn, B, Z, I, pnts, donor_datatype, donor_data, ier) BIND(C, NAME="cg_conn_read_f") IMPORT :: cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I INTEGER(CGSIZE_T), DIMENSION(*) :: pnts INTEGER(cgenum_t) :: donor_datatype INTEGER(CGSIZE_T), DIMENSION(*) :: donor_data INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_read_f SUBROUTINE cg_conn_read_short_f(fn, B, Z, I, pnts, ier) BIND(C, NAME="cg_conn_read_short_f") IMPORT :: CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I INTEGER(CGSIZE_T) ::pnts INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_read_short_f SUBROUTINE cg_conn_id_f(fn, B, Z, I, conn_id, ier) BIND(C, NAME="cg_conn_id_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I REAL(C_DOUBLE) :: conn_id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_id_f SUBROUTINE cg_conn_write_f(fn, B, Z, connectname, location, TYPE, ptset_type, & npnts, pnts, donorname, donor_zonetype, donor_ptset_type, & donor_datatype, ndata_donor, donor_data, I, ier) !BIND(C, NAME="cg_conn_write_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: connectname INTEGER(cgenum_t) :: location INTEGER(cgenum_t) :: TYPE INTEGER(cgenum_t) :: ptset_type INTEGER(CGSIZE_T) :: npnts INTEGER(CGSIZE_T), DIMENSION(*) :: pnts CHARACTER(KIND=C_CHAR), DIMENSION(*) :: donorname INTEGER(cgenum_t) :: donor_zonetype INTEGER(cgenum_t) :: donor_ptset_type INTEGER(cgenum_t) :: donor_datatype INTEGER(CGSIZE_T) :: ndata_donor INTEGER(CGSIZE_T), DIMENSION(*) :: donor_data INTEGER :: I INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_write_f SUBROUTINE cg_conn_write_short_f(fn, B, Z, connectname, location, & TYPE, ptset_type, npnts, pnts, donorname, I, ier) !BIND(C, NAME="cg_conn_write_short_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: connectname INTEGER(cgenum_t) :: location INTEGER(cgenum_t) :: TYPE INTEGER(cgenum_t) :: ptset_type INTEGER(CGSIZE_T) :: npnts INTEGER(CGSIZE_T) :: pnts CHARACTER(KIND=C_CHAR), DIMENSION(*) :: donorname INTEGER :: I INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_write_short_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write GridConnectivity1to1_t Nodes in a zone * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_n1to1_f(fn, B, Z, n1to1, ier) BIND(C, NAME="cg_n1to1_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: n1to1 INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_n1to1_f SUBROUTINE cg_1to1_read_f(fn, B, Z, I, connectname, donorname, & range, donor_range, transform, ier) !BIND(C, NAME="cg_1to1_read_f") IMPORT :: c_char, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I CHARACTER(KIND=C_CHAR), DIMENSION(*) :: connectname CHARACTER(KIND=C_CHAR), DIMENSION(*) :: donorname INTEGER(CGSIZE_T), DIMENSION(*) :: range INTEGER(CGSIZE_T), DIMENSION(*) :: donor_range INTEGER, DIMENSION(*) :: transform INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_1to1_read_f SUBROUTINE cg_1to1_id_f(fn, B, Z, I, one21_id, ier) !BIND(C, NAME="cg_1to1_id_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I REAL(C_DOUBLE) :: one21_id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_1to1_id_f SUBROUTINE cg_1to1_write_f(fn, B, Z, connectname, donorname, range, & donor_range, transform, I, ier) !BIND(C, NAME="cg_1to1_write_f") IMPORT :: c_char, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: connectname CHARACTER(KIND=C_CHAR), DIMENSION(*) :: donorname INTEGER(CGSIZE_T), DIMENSION(*) :: range INTEGER(CGSIZE_T), DIMENSION(*) :: donor_range INTEGER, DIMENSION(*) :: transform INTEGER :: I INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_1to1_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read all GridConnectivity1to1_t Nodes of a base * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_n1to1_global_f(fn, B, n1to1_global, ier) BIND(C, NAME="cg_n1to1_global_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: n1to1_global INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_n1to1_global_f SUBROUTINE cg_1to1_read_global_f(fn, B, connectname, zonename, donorname, & range, donor_range, transform, ier) !BIND(C, NAME="cg_1to1_read_global_f") IMPORT :: c_char, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B CHARACTER(KIND=C_CHAR), DIMENSION(*) :: connectname CHARACTER(KIND=C_CHAR), DIMENSION(*) :: zonename CHARACTER(KIND=C_CHAR), DIMENSION(*) :: donorname INTEGER(CGSIZE_T), DIMENSION(*) :: range INTEGER(CGSIZE_T), DIMENSION(*) :: donor_range INTEGER, DIMENSION(*) :: transform INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_1to1_read_global_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write BC_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_nbocos_f(fn, B, Z, nbocos, ier) BIND(C, NAME="cg_nbocos_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: nbocos INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nbocos_f SUBROUTINE cg_boco_info_f(fn, B, Z, BC, boconame, bocotype, & ptset_type, npnts, NormalIndex, & NormalListSize, NormalDataType, ndataset, ier) !BIND(C, NAME="cg_boco_info_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC CHARACTER(KIND=C_CHAR), DIMENSION(*) :: boconame INTEGER(cgenum_t) :: bocotype INTEGER(cgenum_t) :: ptset_type INTEGER(CGSIZE_T) :: npnts INTEGER, DIMENSION(*) :: NormalIndex INTEGER(CGSIZE_T) :: NormalListSize INTEGER(cgenum_t) :: NormalDataType INTEGER :: ndataset INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_boco_info_f !!$ INTERFACE !!$ SUBROUTINE cg_boco_read_f(fn, B, Z, BC, pnts, NormalList, ier) BIND(C, NAME="") !!$ IMPORT :: CGSIZE_T !!$ IMPLICIT NONE !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: BC !!$ INTEGER(CGSIZE_T) :: pnts !!$ void *NormalList !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_boco_read_f !!$ END INTERFACE SUBROUTINE cg_boco_id_f(fn, B, Z, BC, boco_id, ier) BIND(C, NAME="cg_boco_id_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC REAL(C_DOUBLE) :: boco_id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_boco_id_f SUBROUTINE cg_boco_write_f(fn, B, Z, boconame, bocotype, ptset_type, npnts, pnts, BC, ier) !BIND(C, NAME="cg_boco_write_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: boconame INTEGER(cgenum_t) :: bocotype INTEGER(cgenum_t) :: ptset_type INTEGER(CGSIZE_T) :: npnts INTEGER(CGSIZE_T), DIMENSION(*) :: pnts INTEGER :: BC INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_boco_write_f !!$ SUBROUTINE cg_boco_normal_write_f( fn, B, Z, BC, NormalIndex, NormalListFlag, !!$ NormalDataType, NormalList, ier) BIND(C, NAME="") !!$ !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: BC, !!$ INTEGER(CGSIZE_T) ::NormalIndex !!$ INTEGER :: NormalListFlag, !!$ INTEGER(cgenum_t) :: NormalDataType !!$ ! void *NormalList, !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_boco_normal_write_f SUBROUTINE cg_boco_gridlocation_read_f(fn, B, Z, BC, location, ier) BIND(C, NAME="cg_boco_gridlocation_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC INTEGER(cgenum_t) :: location INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_boco_gridlocation_read_f SUBROUTINE cg_boco_gridlocation_write_f( fn, B, Z, BC, location, ier) BIND(C, NAME="cg_boco_gridlocation_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC INTEGER(cgenum_t) :: location INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_boco_gridlocation_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write BCProperty_t/WallFunction_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_bc_wallfunction_read_f(fn, B, Z, BC, WallFunctionType, ier) BIND(C, NAME="cg_bc_wallfunction_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC INTEGER(cgenum_t) :: WallFunctionType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_bc_wallfunction_read_f SUBROUTINE cg_bc_wallfunction_write_f(fn, B, Z, BC, WallFunctionType, ier) BIND(C, NAME="cg_bc_wallfunction_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC INTEGER(cgenum_t) :: WallFunctionType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_bc_wallfunction_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write BCProperty_t/Area_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_bc_area_read_f(fn, B, Z, BC, AreaType, SurfaceArea, RegionName, ier) !BIND(C, NAME="cg_bc_area_read_f") IMPORT :: c_char, cgenum_t, c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC INTEGER(cgenum_t) :: AreaType REAL(C_FLOAT) :: SurfaceArea CHARACTER(KIND=C_CHAR), DIMENSION(*) :: RegionName INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_bc_area_read_f SUBROUTINE cg_bc_area_write_f(fn, B, Z, BC, AreaType, SurfaceArea, RegionName, ier) !BIND(C, NAME="cg_bc_area_write_f") IMPORT :: c_char, cgenum_t, c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC INTEGER(cgenum_t) :: AreaType REAL(C_FLOAT) :: SurfaceArea CHARACTER(KIND=C_CHAR), DIMENSION(*) :: RegionName INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_bc_area_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write GridConnectivityProperty_t/Periodic_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_conn_periodic_read_f(fn, B, Z, I, RotationCenter, RotationAngle, Translation, ier) & BIND(C, NAME="cg_conn_periodic_read_f") IMPORT :: c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I REAL(C_FLOAT), DIMENSION(*) :: RotationCenter REAL(C_FLOAT), DIMENSION(*) :: RotationAngle REAL(C_FLOAT), DIMENSION(*) :: Translation INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_periodic_read_f SUBROUTINE cg_conn_periodic_write_f( fn, B, Z, I, RotationCenter, RotationAngle, Translation, ier) & BIND(C, NAME="cg_conn_periodic_write_f") IMPORT :: c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I REAL(C_FLOAT), DIMENSION(*) :: RotationCenter REAL(C_FLOAT), DIMENSION(*) :: RotationAngle REAL(C_FLOAT), DIMENSION(*) :: Translation INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_periodic_write_f SUBROUTINE cg_1to1_periodic_read_f(fn, B, Z, I, RotationCenter, RotationAngle, Translation, ier) & BIND(C, NAME="cg_1to1_periodic_read_f") IMPORT :: c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I REAL(C_FLOAT), DIMENSION(*) :: RotationCenter REAL(C_FLOAT), DIMENSION(*) :: RotationAngle REAL(C_FLOAT), DIMENSION(*) :: Translation INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_1to1_periodic_read_f SUBROUTINE cg_1to1_periodic_write_f(fn, B, Z, I, RotationCenter, RotationAngle, Translation, ier) & BIND(C, NAME="cg_1to1_periodic_write_f") IMPORT :: c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I REAL(C_FLOAT), DIMENSION(*) :: RotationCenter REAL(C_FLOAT), DIMENSION(*) :: RotationAngle REAL(C_FLOAT), DIMENSION(*) :: Translation INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_1to1_periodic_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write GridConnectivityProperty_t/AverageInterface_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_conn_average_read_f(fn, B, Z, I, AverageInterfaceType, ier) & BIND(C, NAME="cg_conn_average_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I INTEGER(cgenum_t) :: AverageInterfaceType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_average_read_f SUBROUTINE cg_conn_average_write_f(fn, B, Z, I, AverageInterfaceType, ier) & BIND(C, NAME="cg_conn_average_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I INTEGER(cgenum_t) :: AverageInterfaceType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conn_average_write_f SUBROUTINE cg_1to1_average_read_f(fn, B, Z, I, AverageInterfaceType, ier) & BIND(C, NAME="cg_1to1_average_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I INTEGER(cgenum_t) :: AverageInterfaceType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_1to1_average_read_f SUBROUTINE cg_1to1_average_write_f(fn, B, Z, I,AverageInterfaceType, ier) BIND(C, NAME="cg_1to1_average_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: I INTEGER(cgenum_t) :: AverageInterfaceType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_1to1_average_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write BCDataSet_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_dataset_read_f(fn, B, Z, BC, DSet, Dataset_name, BCType, DirichletFlag, & NeumannFlag, ier) !BIND(C, NAME="cg_dataset_read_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC INTEGER :: DSet CHARACTER(KIND=C_CHAR), DIMENSION(*) :: Dataset_name INTEGER(cgenum_t) :: BCType INTEGER :: DirichletFlag INTEGER :: NeumannFlag INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_dataset_read_f SUBROUTINE cg_dataset_write_f(fn, B, Z, BC, Dataset_name,BCType, Dset, ier) !BIND(C, NAME="cg_dataset_write_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC CHARACTER(KIND=C_CHAR), DIMENSION(*) :: Dataset_name INTEGER(cgenum_t) :: BCType INTEGER :: Dset INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_dataset_write_f SUBROUTINE cg_bcdataset_write_f(Dataset_name, BCType, BCDataType, ier) !BIND(C, NAME="cg_bcdataset_write_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: Dataset_name INTEGER(cgenum_t) :: BCType INTEGER(cgenum_t) :: BCDataType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_bcdataset_write_f SUBROUTINE cg_bcdataset_info_f(ndataset, ier) BIND(C, NAME="cg_bcdataset_info_f") IMPLICIT NONE INTEGER :: ndataset INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_bcdataset_info_f SUBROUTINE cg_bcdataset_read_f(index, Dataset_name, BCType, & DirichletFlag, NeumannFlag,ier) !BIND(C, NAME="cg_bcdataset_read_f") IMPORT :: c_char, cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER ::index CHARACTER(KIND=C_CHAR), DIMENSION(*) :: Dataset_name INTEGER(cgenum_t) :: BCType INTEGER :: DirichletFlag INTEGER :: NeumannFlag INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_bcdataset_read_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write BCData_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_bcdata_write_f(fn, B, Z, BC, Dset, BCDataType, ier) BIND(C, NAME="cg_bcdata_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: BC INTEGER :: Dset INTEGER(cgenum_t) :: BCDataType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_bcdata_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write RigidGridMotion_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_n_rigid_motions_f(fn, B, Z, n_rigid_motions, ier) BIND(C, NAME="cg_n_rigid_motions_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: n_rigid_motions INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_n_rigid_motions_f SUBROUTINE cg_rigid_motion_read_f(fn, B, Z, R, rmotion_name, TYPE, ier) !BIND(C, NAME="cg_rigid_motion_read_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: R CHARACTER(KIND=C_CHAR), DIMENSION(*) :: rmotion_name INTEGER(cgenum_t) :: TYPE INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_rigid_motion_read_f SUBROUTINE cg_rigid_motion_write_f(fn, B, Z, rmotion_name, TYPE, R, ier) !BIND(C, NAME="cg_rigid_motion_write_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: rmotion_name INTEGER(cgenum_t) :: TYPE INTEGER :: R INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_rigid_motion_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write ArbitraryGridMotion_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_n_arbitrary_motions_f( fn, B, Z, n_arbitrary_motions, ier) BIND(C, NAME="cg_n_arbitrary_motions_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: n_arbitrary_motions INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_n_arbitrary_motions_f SUBROUTINE cg_arbitrary_motion_read_f(fn, B, Z, A, amotion_name, TYPE, ier) !BIND(C, NAME="cg_arbitrary_motion_read_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: A CHARACTER(KIND=C_CHAR), DIMENSION(*) :: amotion_name INTEGER(cgenum_t) :: TYPE INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_arbitrary_motion_read_f SUBROUTINE cg_arbitrary_motion_write_f(fn, B, Z, amotion_name, TYPE, A, ier) !BIND(C, NAME="cg_arbitrary_motion_write_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: amotion_name INTEGER(cgenum_t) :: TYPE INTEGER :: A INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_arbitrary_motion_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write GridCoordinates_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_ngrids_f(fn, B, Z, ngrids, ier) BIND(C, NAME="cg_ngrids_f") IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: ngrids INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_ngrids_f SUBROUTINE cg_grid_read_f(fn, B, Z, G, gridname, ier) ! BIND(C, NAME="cg_grid_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: G CHARACTER(KIND=C_CHAR), DIMENSION(*) :: gridname INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_grid_read_f SUBROUTINE cg_grid_write_f(fn, B, Z, gridname, G, ier) !BIND(C, NAME="cg_grid_write_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: gridname INTEGER :: G INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_grid_write_f !!$ SUBROUTINE cg_grid_bounding_box_read_f(fn, B, Z, G, datatype, array, ier) ! BIND(C, NAME="cg_grid_bounding_box_read_f") !!$ IMPORT :: cgenum_t !!$ IMPLICIT NONE !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: G !!$ INTEGER(cgenum_t), INTENT(IN) :: datatype !!$ TYPE(*), DIMENSION(*) :: array !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_grid_bounding_box_read_f !!$!!$ SUBROUTINE cg_grid_bounding_box_write_f(fn, B, Z, G, datatype, array, ier) !BIND(C, NAME="cg_grid_bounding_box_write_f") !!$ IMPORT :: cgenum_t, c_ptr !!$ IMPLICIT NONE !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: G !!$ INTEGER(cgenum_t), INTENT(IN) :: datatype !!$ void *array !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_grid_bounding_box_write_f !!$ ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write SimulationType_t Node * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_simulation_type_read_f(fn, B, TYPE, ier) BIND(C, NAME="cg_simulation_type_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER(cgenum_t) :: TYPE INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_simulation_type_read_f SUBROUTINE cg_simulation_type_write_f(fn, B, TYPE, ier) BIND(C, NAME="cg_simulation_type_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER(cgenum_t) :: TYPE INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_simulation_type_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write BaseIterativeData_t Node * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_biter_read_f(fn, B, bitername, nsteps, ier) !BIND(C, NAME="cg_biter_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B CHARACTER(KIND=C_CHAR), DIMENSION(*) :: bitername INTEGER :: nsteps INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_biter_read_f SUBROUTINE cg_biter_write_f(fn, B, bitername, nsteps, ier) !BIND(C, NAME="cg_biter_write_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B CHARACTER(KIND=C_CHAR), DIMENSION(*) :: bitername INTEGER :: nsteps INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_biter_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write ZoneIterativeData_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_ziter_read_f(fn, B, Z, zitername, ier) !BIND(C, NAME="cg_ziter_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: zitername INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_ziter_read_f SUBROUTINE cg_ziter_write_f(fn, B, Z, zitername, ier) !BIND(C, NAME="cg_ziter_write_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: zitername INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_ziter_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write Gravity_t Node * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_gravity_read_f(fn, B, gravity_vector, ier) BIND(C, NAME="cg_gravity_read_f") IMPORT :: c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B REAL(C_FLOAT), DIMENSION(*) :: gravity_vector INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_gravity_read_f SUBROUTINE cg_gravity_write_f(fn, B, gravity_vector, ier) BIND(C, NAME="cg_gravity_write_f") IMPORT :: c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B REAL(C_FLOAT), DIMENSION(*) :: gravity_vector INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_gravity_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write Axisymmetry_t Node * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_axisym_read_f(fn, B, ref_point, axis, ier) BIND(C, NAME="cg_axisym_read_f") IMPORT :: c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B REAL(C_FLOAT), DIMENSION(*) :: ref_point REAL(C_FLOAT), DIMENSION(*) :: axis INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_axisym_read_f SUBROUTINE cg_axisym_write_f(fn, B, ref_point, axis, ier) BIND(C, NAME="cg_axisym_write_f") IMPORT :: c_float IMPLICIT NONE INTEGER :: fn INTEGER :: B REAL(C_FLOAT), DIMENSION(*) :: ref_point REAL(C_FLOAT), DIMENSION(*) :: axis INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_axisym_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write RotatingCoordinates_t Node * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_rotating_read_f(rot_rate, rot_center, ier) BIND(C, NAME="cg_rotating_read_f") IMPORT :: c_float IMPLICIT NONE REAL(C_FLOAT), DIMENSION(*) :: rot_rate REAL(C_FLOAT), DIMENSION(*) :: rot_center INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_rotating_read_f SUBROUTINE cg_rotating_write_f(rot_rate, rot_center, ier) BIND(C, NAME="cg_rotating_write_f") IMPORT :: c_float IMPLICIT NONE REAL(C_FLOAT), DIMENSION(*) :: rot_rate REAL(C_FLOAT), DIMENSION(*) :: rot_center INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_rotating_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read and write IndexArray/Range_t Nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_ptset_info_f(ptset_type, npnts, ier) BIND(C, NAME="cg_ptset_info_f") IMPORT :: cgenum_t, CGSIZE_T IMPLICIT NONE INTEGER(cgenum_t) :: ptset_type INTEGER(CGSIZE_T) :: npnts INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_ptset_info_f !!$!!$ SUBROUTINE cg_ptset_read_f(pnts, ier) BIND(C, NAME="cg_ptset_read_f") !!$ IMPORT :: cgenum_t, CGSIZE_T !!$ IMPLICIT NONE !!$ INTEGER(CGSIZE_T), DIMENSION(*) :: pnts !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_ptset_read_f !!$ !!$!!$ SUBROUTINE cg_ptset_write_f(ptset_type, npnts, pnts, ier) BIND(C, NAME="cg_ptset_write_f") !!$ IMPORT :: cgenum_t, CGSIZE_T !!$ IMPLICIT NONE !!$ INTEGER(cgenum_t) :: ptset_type !!$ INTEGER(CGSIZE_T) :: npnts !!$ INTEGER(CGSIZE_T), DIMENSION() :: pnts !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_ptset_write_f !!$ ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Go - To Function * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Read Multiple path nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_famname_read_f(famname, ier) !BIND(C, NAME="cg_famname_read_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: famname INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_famname_read_f SUBROUTINE cg_nmultifam_f(nfam, ier) BIND(C, NAME="cg_nmultifam_f") IMPLICIT NONE INTEGER :: nfam INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nmultifam_f SUBROUTINE cg_multifam_read_f(N,name, family, ier) !BIND(C, NAME="cg_multifam_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: N CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name CHARACTER(KIND=C_CHAR), DIMENSION(*) :: family INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_multifam_read_f SUBROUTINE cg_convergence_read_f(iterations, NormDefinitions, ier) !BIND(C, NAME="cg_convergence_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: iterations CHARACTER(KIND=C_CHAR), DIMENSION(*) :: NormDefinitions INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_convergence_read_f SUBROUTINE cg_state_size_f(size, ier) !BIND(C, NAME="cg_state_size_f") IMPLICIT NONE INTEGER :: size INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_state_size_f SUBROUTINE cg_state_read_f(StateDescription, ier) !BIND(C, NAME="cg_state_read_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: StateDescription INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_state_read_f SUBROUTINE cg_equationset_read_f(EquationDimension, GoverningEquationsFlag, & GasModelFlag, ViscosityModelFlag, ThermalConductivityModelFlag, & TurbulenceClosureFlag, TurbulenceModelFlag, ier) BIND(C, NAME="cg_equationset_read_f") IMPLICIT NONE INTEGER :: EquationDimension INTEGER :: GoverningEquationsFlag INTEGER :: GasModelFlag INTEGER :: ViscosityModelFlag INTEGER :: ThermalConductivityModelFlag INTEGER :: TurbulenceClosureFlag INTEGER :: TurbulenceModelFlag INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_equationset_read_f SUBROUTINE cg_equationset_chemistry_read_f(ThermalRelaxationFlag, ChemicalKineticsFlag, ier) & BIND(C, NAME="cg_equationset_chemistry_read_f") IMPLICIT NONE INTEGER :: ThermalRelaxationFlag INTEGER :: ChemicalKineticsFlag INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_equationset_chemistry_read_f SUBROUTINE cg_equationset_elecmagn_read_f(ElecFldModelFlag, MagnFldModelFlag, & ConductivityModelFlag, ier) BIND(C, NAME="cg_equationset_elecmagn_read_f") IMPLICIT NONE INTEGER :: ElecFldModelFlag INTEGER :: MagnFldModelFlag INTEGER :: ConductivityModelFlag INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_equationset_elecmagn_read_f SUBROUTINE cg_governing_read_f(EquationsType, ier) BIND(C, NAME="cg_governing_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: EquationsType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_governing_read_f SUBROUTINE cg_diffusion_read_f(diffusion_model, ier) BIND(C, NAME="cg_diffusion_read_f") IMPLICIT NONE INTEGER, DIMENSION(*) :: diffusion_model INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_diffusion_read_f SUBROUTINE cg_model_read_f(ModelLabel, ModelType, ier) !BIND(C, NAME="cg_model_read_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: ModelLabel INTEGER(cgenum_t) :: ModelType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_model_read_f SUBROUTINE cg_nintegrals_f(nintegrals, ier) BIND(C, NAME="cg_nintegrals_f") IMPLICIT NONE INTEGER :: nintegrals INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nintegrals_f SUBROUTINE cg_integral_read_f(IntegralDataIndex, IntegralDataName,ier) !BIND(C, NAME="cg_integral_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: IntegralDataIndex CHARACTER(KIND=C_CHAR), DIMENSION(*) :: IntegralDataName INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_integral_read_f SUBROUTINE cg_rind_read_f(RindData, ier) BIND(C, NAME="cg_rind_read_f") IMPLICIT NONE INTEGER, DIMENSION(*) :: RindData INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_rind_read_f SUBROUTINE cg_ndescriptors_f(ndescriptors, ier) BIND(C, NAME="cg_ndescriptors_f") IMPLICIT NONE INTEGER :: ndescriptors INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_ndescriptors_f SUBROUTINE cg_descriptor_size_f(descr_no, descr_size, ier) BIND(C, NAME="cg_descriptor_size_f") IMPLICIT NONE INTEGER :: descr_no INTEGER :: descr_size INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_descriptor_size_f SUBROUTINE cg_descriptor_read_f(descr_no, descr_name, descr_text, ier) !BIND(C, NAME="cg_descriptor_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: descr_no CHARACTER(KIND=C_CHAR), DIMENSION(*) :: descr_name CHARACTER(KIND=C_CHAR), DIMENSION(*) :: descr_text INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_descriptor_read_f SUBROUTINE cg_nunits_f(nunits, ier) BIND(C, NAME="cg_nunits_f") IMPLICIT NONE INTEGER :: nunits INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nunits_f SUBROUTINE cg_units_read_f(mass, length, time, temperature, angle, ier) BIND(C, NAME="cg_units_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: mass INTEGER(cgenum_t) :: length INTEGER(cgenum_t) :: time INTEGER(cgenum_t) :: temperature INTEGER(cgenum_t) :: angle INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_units_read_f SUBROUTINE cg_unitsfull_read_f(mass, length, time, temperature, angle, current, & amount, intensity, ier) BIND(C, NAME="cg_unitsfull_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: mass INTEGER(cgenum_t) :: length INTEGER(cgenum_t) :: time INTEGER(cgenum_t) :: temperature INTEGER(cgenum_t) :: angle INTEGER(cgenum_t) :: current INTEGER(cgenum_t) :: amount INTEGER(cgenum_t) :: intensity INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_unitsfull_read_f SUBROUTINE cg_exponents_info_f(DataType, ier) BIND(C, NAME="cg_exponents_info_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: DataType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_exponents_info_f SUBROUTINE cg_nexponents_f(nexps, ier) BIND(C, NAME="cg_nexponents_f") IMPLICIT NONE INTEGER :: nexps INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nexponents_f !!$ SUBROUTINE cg_exponents_read_f(void *exponents, ier) BIND(C, NAME="") !!$ void *exponents !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_exponents_read_f !!$ SUBROUTINE cg_expfull_read_f(exponents, ier) BIND(C, NAME="") !!$ void *exponents, !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_expfull_read_f SUBROUTINE cg_conversion_info_f(DataType, ier) BIND(C, NAME="cg_conversion_info_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: DataType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_conversion_info_f !!$ SUBROUTINE cg_conversion_read_f(ConversionFactors, ier) BIND(C, NAME="") !!$ void *ConversionFactors, !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_conversion_read_f SUBROUTINE cg_dataclass_read_f(dataclass, ier) BIND(C, NAME="cg_dataclass_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: dataclass INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_dataclass_read_f SUBROUTINE cg_gridlocation_read_f(GridLocation, ier) BIND(C, NAME="cg_gridlocation_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: GridLocation INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_gridlocation_read_f SUBROUTINE cg_ordinal_read_f(Ordinal, ier) BIND(C, NAME="cg_ordinal_read_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER :: Ordinal INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_ordinal_read_f SUBROUTINE cg_npe_f(TYPE,npe, ier) BIND(C, NAME="cg_npe_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: TYPE INTEGER :: npe INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_npe_f SUBROUTINE cg_is_link_f(path_length, ier) BIND(C, NAME="cg_is_link_f") IMPLICIT NONE INTEGER :: path_length INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_is_link_f SUBROUTINE cg_link_read_f(filename, link_path, ier) !BIND(C, NAME="cg_link_read_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: filename CHARACTER(KIND=C_CHAR), DIMENSION(*) :: link_path INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_link_read_f SUBROUTINE cg_nuser_data_f(nuser_data, ier) BIND(C, NAME="cg_nuser_data_f") IMPLICIT NONE INTEGER :: nuser_data INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_nuser_data_f SUBROUTINE cg_user_data_read_f(index,dataname, ier) !BIND(C, NAME="cg_user_data_read_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: index CHARACTER(KIND=C_CHAR), DIMENSION(*) :: dataname INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_user_data_read_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Write Multiple path nodes * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_famname_write_f(family_name, ier) !BIND(C, NAME="cg_famname_write_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: family_name INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_famname_write_f SUBROUTINE cg_multifam_write_f(name, family, ier) !BIND(C, NAME="cg_multifam_write_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name CHARACTER(KIND=C_CHAR), DIMENSION(*) :: family INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_multifam_write_f SUBROUTINE cg_convergence_write_f(iterations, NormDefinitions, ier) !BIND(C, NAME="cg_convergence_write_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: iterations CHARACTER(KIND=C_CHAR), DIMENSION(*) :: NormDefinitions INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_convergence_write_f SUBROUTINE cg_state_write_f(StateDescription, ier) !BIND(C, NAME="cg_state_write_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: StateDescription INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_state_write_f SUBROUTINE cg_equationset_write_f(EquationDimension, ier) BIND(C, NAME="cg_equationset_write_f") IMPLICIT NONE INTEGER :: EquationDimension INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_equationset_write_f SUBROUTINE cg_governing_write_f(Equationstype, ier) BIND(C, NAME="cg_governing_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: Equationstype INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_governing_write_f SUBROUTINE cg_diffusion_write_f(diffusion_model, ier) BIND(C, NAME="cg_diffusion_write_f") IMPLICIT NONE INTEGER, DIMENSION(*) :: diffusion_model INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_diffusion_write_f SUBROUTINE cg_model_write_f(ModelLabel, ModelType, ier) !BIND(C, NAME="cg_model_write_f") IMPORT :: c_char, cgenum_t IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: ModelLabel INTEGER(cgenum_t) :: ModelType INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_model_write_f !!$ SUBROUTINE cg_array_write_f03(ArrayName, DataType, DataDimension, DimensionVector, DATA, ier) & !!$ BIND(C, NAME="cg_array_write_f03") !!$ IMPORT :: c_char, cgenum_t, cgsize_t, c_ptr !!$ CHARACTER(KIND=C_CHAR), DIMENSION(*) :: ArrayName !!$ INTEGER(cgenum_t) :: DataType !!$ INTEGER :: DataDimension !!$ INTEGER(cgsize_t), DIMENSION(*) :: DimensionVector !!$ TYPE(C_PTR), VALUE :: Data !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_array_write_f03 SUBROUTINE cg_integral_write_f(IntegralDataName, ier) !BIND(C, NAME="cg_integral_write_f") IMPORT :: c_char CHARACTER(KIND=C_CHAR), DIMENSION(*) :: IntegralDataName INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_integral_write_f SUBROUTINE cg_rind_write_f(RindData, ier) BIND(C, NAME="cg_rind_write_f") IMPLICIT NONE INTEGER, DIMENSION(*) :: RindData INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_rind_write_f SUBROUTINE cg_descriptor_write_f(descr_name, descr_text, ier) !BIND(C, NAME="cg_descriptor_write_f") IMPORT :: c_char CHARACTER(KIND=C_CHAR), DIMENSION(*) :: descr_name CHARACTER(KIND=C_CHAR), DIMENSION(*) :: descr_text INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_descriptor_write_f SUBROUTINE cg_units_write_f(mass, length, time, temperature, angle, ier) BIND(C, NAME="cg_units_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: mass INTEGER(cgenum_t) :: length INTEGER(cgenum_t) :: time INTEGER(cgenum_t) :: temperature INTEGER(cgenum_t) :: angle INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_units_write_f SUBROUTINE cg_unitsfull_write_f(mass, length, time, temperature, angle, current, & amount, intensity, ier) BIND(C, NAME="cg_unitsfull_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: mass INTEGER(cgenum_t) :: length INTEGER(cgenum_t) :: time INTEGER(cgenum_t) :: temperature INTEGER(cgenum_t) :: angle INTEGER(cgenum_t) :: current INTEGER(cgenum_t) :: amount INTEGER(cgenum_t) :: intensity INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_unitsfull_write_f !!$ SUBROUTINE cg_exponents_write_f(DataType, void *exponents, ier) BIND(C, NAME="") !!$ !!$ INTEGER(cgenum_t) :: DataType_t)*DataType, void *exponents, !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_exponents_write_f !!$ SUBROUTINE cg_expfull_write_f(DataType, void *exponents, ier) BIND(C, NAME="") !!$ INTEGER(cgenum_t) :: DataType !!$ void *exponents, !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_expfull_write_f !!$ SUBROUTINE cg_conversion_write_f( DataType, ConversionFactors, ier) BIND(C, NAME="") !!$ INTEGER(cgenum_t) :: DataType !!$ void *ConversionFactors !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cg_conversion_write_f SUBROUTINE cg_dataclass_write_f(dataclass, ier) BIND(C, NAME="cg_dataclass_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: dataclass INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_dataclass_write_f SUBROUTINE cg_gridlocation_write_f(GridLocation, ier) BIND(C, NAME="cg_gridlocation_write_f") IMPORT :: cgenum_t IMPLICIT NONE INTEGER(cgenum_t) :: GridLocation INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_gridlocation_write_f SUBROUTINE cg_ordinal_write_f(Ordinal, ier) BIND(C, NAME="cg_ordinal_write_f") IMPLICIT NONE INTEGER :: Ordinal INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_ordinal_write_f SUBROUTINE cg_link_write_f(nodename, filename, name_in_file, ier) !BIND(C, NAME="cg_link_write_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: nodename CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: filename CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name_in_file INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_link_write_f SUBROUTINE cg_user_data_write_f(dataname, ier) ! BIND(C, NAME="cg_user_data_write_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: dataname INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_user_data_write_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! General Delete Function * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_delete_node_f(node_name, ier) !BIND(C, NAME="cg_delete_node_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: node_name INTEGER, INTENT(OUT) :: ier END SUBROUTINE cg_delete_node_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ ! Error Handling Functions * ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ SUBROUTINE cg_get_error_f(errmsg) !BIND(C, NAME="cg_get_error_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: errmsg END SUBROUTINE cg_get_error_f SUBROUTINE cg_error_exit_f() BIND(C, NAME="cg_error_exit_f") IMPLICIT NONE END SUBROUTINE cg_error_exit_f SUBROUTINE cg_error_print_f() BIND(C, NAME="cg_error_print_f") IMPLICIT NONE END SUBROUTINE cg_error_print_f SUBROUTINE cg_exit_on_error_f(flag) BIND(C, NAME="cg_exit_on_error_f") IMPLICIT NONE INTEGER :: flag END SUBROUTINE cg_exit_on_error_f #if CG_BUILD_PARALLEL_F !====================================================================== ! parallel IO interface !====================================================================== SUBROUTINE cgp_mpi_comm_f( mpi_comm_f, ier) BIND(C, NAME="cgp_mpi_comm_f") IMPLICIT NONE INTEGER :: mpi_comm_f INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgp_mpi_comm_f SUBROUTINE cgp_pio_mode_f( mode, ier) BIND(C, NAME="cgp_pio_mode_f") IMPORT :: C_INT IMPLICIT NONE INTEGER(C_INT) :: mode INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgp_pio_mode_f SUBROUTINE cgp_open_f(filename, mode, fn, ier) !BIND(C, NAME="cgp_open_f") IMPORT :: C_CHAR, C_INT IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: filename INTEGER(C_INT) :: mode INTEGER :: fn INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgp_open_f SUBROUTINE cgp_close_f(fn, ier) BIND(C, NAME="cgp_close_f") IMPLICIT NONE INTEGER, INTENT(IN) :: fn INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgp_close_f SUBROUTINE cgp_coord_write_f(fn, B, Z, type, coordname, C, ier) !BIND(C, NAME="cgp_coord_write_f") IMPORT :: cgenum_t, c_char IMPLICIT NONE INTEGER, INTENT(IN) :: fn INTEGER, INTENT(IN) :: B INTEGER, INTENT(IN) :: Z INTEGER(cgenum_t), INTENT(IN) :: type CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: coordname INTEGER, INTENT(IN) :: C INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgp_coord_write_f !!$ SUBROUTINE cgp_coord_write_data_f(fn, B, Z, C, !!$ CGSIZE_T *rmin, CGSIZE_T *rmax, void *data, ier) BIND(C, NAME="") !!$ !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: C, !!$ INTEGER(CGSIZE_T) :: rmin, INTEGER(CGSIZE_T) :: rmax, void *DATA, !!$ INTEGER, INTENT(OUT) :: ier !!$END SUBROUTINE cgp_coord_write_data_f !!$ !!$ SUBROUTINE cgp_coord_read_data_f( !!$ fn, B, Z, C, !!$ CGSIZE_T *rmin, CGSIZE_T *rmax, void *data, ier) BIND(C, NAME="") !!$ !!$ INTEGER :: fn !!$ INTEGER :: B !!$ INTEGER :: Z !!$ INTEGER :: C, !!$ INTEGER(CGSIZE_T) :: rmin, INTEGER(CGSIZE_T) :: rmax, void *data, !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE !!$ SUBROUTINE cgp_section_write_f( fn, B, Z, section_name, & TYPE,start,END, nbndry, S, ier) !BIND(C, NAME="cgp_section_write_f") IMPORT :: cgenum_t, cgsize_t, c_char IMPLICIT NONE INTEGER, INTENT(IN) :: fn INTEGER, INTENT(IN) :: B INTEGER, INTENT(IN) :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: section_name INTEGER(cgenum_t) :: TYPE INTEGER(CGSIZE_T), INTENT(IN) :: start INTEGER(CGSIZE_T), INTENT(IN) :: END INTEGER, INTENT(IN) :: nbndry INTEGER, INTENT(OUT) :: S INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgp_section_write_f !!$!!$ SUBROUTINE cgp_elements_write_data_f( fn, B, Z, S, CGSIZE_T *start, & !!$ CGSIZE_T *END, CGSIZE_T *elements, ier) BIND(C, NAME="cgp_elements_write_data_f") !!$ IMPORT :: cgsize_t !!$ IMPLICIT NONE !!$ IMPLICIT NONE !!$ INTEGER, INTENT(IN) :: fn !!$ INTEGER, INTENT(IN) :: B !!$ INTEGER, INTENT(IN) :: Z !!$ INTEGER, INTENT(IN) :: S !!$ INTEGER(CGSIZE_T), INTENT(IN) :: start !!$ INTEGER(CGSIZE_T), INTENT(IN) :: end !!$ INTEGER(CGSIZE_T) , INTENT(IN) :: elements !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cgp_elements_write_data_f !!$ !!$ !!$!!$ SUBROUTINE cgp_elements_read_data_f(fn, B, Z, S, start, & !!$ end, elements, ier) BIND(C, NAME="cgp_elements_read_data_f") !!$ IMPORT :: cgsize_t !!$ IMPLICIT NONE !!$ INTEGER, INTENT(IN) :: fn !!$ INTEGER, INTENT(IN) :: B !!$ INTEGER, INTENT(IN) :: Z !!$ INTEGER, INTENT(IN) :: S !!$ INTEGER(CGSIZE_T), INTENT(IN) :: start !!$ INTEGER(CGSIZE_T), INTENT(IN) :: end !!$ INTEGER(CGSIZE_T) :: elements !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cgp_elements_read_data_f !!$ SUBROUTINE cgp_field_write_f(fn, B, Z, S, TYPE, fieldname, F, ier)! BIND(C, NAME="cgp_field_write_f") IMPORT :: cgenum_t, c_char IMPLICIT NONE INTEGER :: fn INTEGER :: B INTEGER :: Z INTEGER :: S INTEGER(cgenum_t) :: type CHARACTER(KIND=C_CHAR), DIMENSION(*) :: fieldname INTEGER :: F INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgp_field_write_f SUBROUTINE cgp_error_exit_f() BIND(C, NAME="cgp_error_exit_f") IMPLICIT NONE END SUBROUTINE cgp_error_exit_f SUBROUTINE cgp_mpi_info_f(pcg_mpi_info_f, ier) BIND(C,NAME="cgp_mpi_info_f") IMPORT :: C_INT IMPLICIT NONE INTEGER(C_INT), INTENT(IN) :: pcg_mpi_info_f INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgp_mpi_info_f SUBROUTINE cgp_coord_multi_read_data_f(fn, B, Z, C, rmin, rmax, nsets, & buf, ier) BIND(C, NAME="cgp_coord_multi_read_data_f") IMPORT :: C_INT, C_PTR, CGSIZE_T IMPLICIT NONE INTEGER(C_INT) :: fn INTEGER(C_INT) :: B INTEGER(C_INT) :: Z INTEGER(C_INT), DIMENSION(*) :: C INTEGER(CGSIZE_T), DIMENSION(*) :: rmin INTEGER(CGSIZE_T), DIMENSION(*) :: rmax INTEGER(C_INT) :: nsets TYPE(C_PTR), DIMENSION(*) :: buf INTEGER :: ier END SUBROUTINE cgp_coord_multi_read_data_f SUBROUTINE cgp_coord_multi_write_data_f(fn, B, Z, C, rmin, rmax, nsets, & buf, ier) BIND(C, NAME="cgp_coord_multi_write_data_f") IMPORT :: C_INT, C_PTR, CGSIZE_T IMPLICIT NONE INTEGER(C_INT) :: fn INTEGER(C_INT) :: B INTEGER(C_INT) :: Z INTEGER(C_INT), DIMENSION(*) :: C INTEGER(CGSIZE_T), DIMENSION(*) :: rmin INTEGER(CGSIZE_T), DIMENSION(*) :: rmax INTEGER(C_INT) :: nsets TYPE(C_PTR), DIMENSION(*) :: buf INTEGER :: ier END SUBROUTINE cgp_coord_multi_write_data_f SUBROUTINE cgp_field_multi_read_data_f(fn, B, Z, S, F, rmin, rmax, nsets, & buf, ier) BIND(C, NAME="cgp_field_multi_read_data_f") IMPORT :: C_INT, C_PTR, CGSIZE_T IMPLICIT NONE INTEGER(C_INT) :: fn INTEGER(C_INT) :: B INTEGER(C_INT) :: Z INTEGER(C_INT) :: S INTEGER(C_INT), DIMENSION(*) :: F INTEGER(CGSIZE_T), DIMENSION(*) :: rmin INTEGER(CGSIZE_T), DIMENSION(*) :: rmax INTEGER(C_INT) :: nsets TYPE(C_PTR), DIMENSION(*) :: buf INTEGER :: ier END SUBROUTINE cgp_field_multi_read_data_f SUBROUTINE cgp_field_multi_write_data_f(fn, B, Z, S, F, rmin, rmax, nsets, & buf, ier) BIND(C, NAME="cgp_field_multi_write_data_f") IMPORT :: C_INT, C_PTR, CGSIZE_T IMPLICIT NONE INTEGER(C_INT) :: fn INTEGER(C_INT) :: B INTEGER(C_INT) :: Z INTEGER(C_INT) :: S INTEGER(C_INT), DIMENSION(*) :: F INTEGER(CGSIZE_T), DIMENSION(*) :: rmin INTEGER(CGSIZE_T), DIMENSION(*) :: rmax INTEGER(C_INT) :: nsets TYPE(C_PTR), DIMENSION(*) :: buf INTEGER :: ier END SUBROUTINE cgp_field_multi_write_data_f SUBROUTINE cgp_array_multi_read_data_f(fn, A, rmin, rmax, nsets, & buf, ier) BIND(C, NAME="cgp_array_multi_read_data_f") IMPORT :: C_INT, C_PTR, CGSIZE_T IMPLICIT NONE INTEGER(C_INT) :: fn INTEGER(C_INT), DIMENSION(*) :: A INTEGER(CGSIZE_T), DIMENSION(*) :: rmin INTEGER(CGSIZE_T), DIMENSION(*) :: rmax INTEGER(C_INT) :: nsets TYPE(C_PTR), DIMENSION(*) :: buf INTEGER :: ier END SUBROUTINE cgp_array_multi_read_data_f SUBROUTINE cgp_array_multi_write_data_f(fn, A, rmin, rmax, nsets, & buf, ier) BIND(C, NAME="cgp_array_multi_write_data_f") IMPORT :: C_INT, C_PTR, CGSIZE_T IMPLICIT NONE INTEGER(C_INT) :: fn INTEGER(C_INT), DIMENSION(*) :: A INTEGER(CGSIZE_T), DIMENSION(*) :: rmin INTEGER(CGSIZE_T), DIMENSION(*) :: rmax INTEGER(C_INT) :: nsets TYPE(C_PTR), DIMENSION(*) :: buf INTEGER :: ier END SUBROUTINE cgp_array_multi_write_data_f #endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* INTERFACES FOR THE C FUNCTIONS * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !!$!!$ INTEGER(C_INT) FUNCTION cgp_open(filename, mode, fn) BIND(C, name="cgp_open") !!$ IMPORT :: c_int, c_char !!$ IMPLICIT NONE !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: filename !!$ INTEGER(C_INT), INTENT(IN), VALUE :: mode !!$ INTEGER(C_INT), INTENT(OUT) :: fn !!$ END FUNCTION cgp_open !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_pio_mode(mode) BIND(C, name="cgp_pio_mode") !!$ USE ISO_C_BINDING !!$ INTEGER(KIND(CGP_COLLECTIVE)), INTENT(IN), VALUE :: mode !!$ END FUNCTION cgp_pio_mode !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cg_base_write(fn, basename, cell_dim, phys_dim, B) BIND(C, name="cg_base_write") !!$ USE ISO_C_BINDING !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: basename !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: cell_dim !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: phys_dim !!$ INTEGER(C_INT) , INTENT(OUT) :: B !!$ END FUNCTION cg_base_write !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cg_zone_write(fn, B, zonename, nijk, itype, Z) BIND(C, name="cg_zone_write") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: zonename !!$ INTEGER(CGSIZE_T), DIMENSION(*), INTENT(IN) :: nijk !!$ INTEGER(KIND(CGP_COLLECTIVE)), INTENT(IN), VALUE :: itype !!$ INTEGER(C_INT) , INTENT(OUT) :: Z !!$ END FUNCTION cg_zone_write !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cg_base_read(fn, B, basename, cell_dim, phys_dim) BIND(C, name="cg_base_read") !!$ USE ISO_C_BINDING !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(OUT) :: basename !!$ INTEGER(C_INT) , INTENT(OUT) :: cell_dim !!$ INTEGER(C_INT) , INTENT(OUT) :: phys_dim !!$ END FUNCTION cg_base_read !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cg_zone_read(fn, B, Z, zonename, nijk) !BIND(C, name="cg_zone_read") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(OUT) :: zonename !!$ INTEGER(CGSIZE_T), DIMENSION(*), INTENT(OUT) :: nijk !!$ END FUNCTION cg_zone_read !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_coord_write(fn, B, Z, itype, coordname, C) BIND(C, name="cgp_coord_write") !!$ USE ISO_C_BINDING !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ INTEGER(KIND(CGP_INDEPENDENT)), INTENT(IN), VALUE :: itype !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: coordname !!$ INTEGER(C_INT) , INTENT(OUT) :: C !!$ END FUNCTION cgp_coord_write !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_coord_write_data(fn, B, Z, C, rmin, rmax, coords) BIND(C, name="cgp_coord_write_data") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: C !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmin !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmax !!$ TYPE(C_PTR), VALUE :: coords !!$ END FUNCTION cgp_coord_write_data !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_field_write(fn, B, Z, S, itype, fieldname, F) BIND(C, name="cgp_field_write") !!$ USE ISO_C_BINDING !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: S !!$ INTEGER(KIND(CGP_INDEPENDENT)), INTENT(IN), VALUE :: itype !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: fieldname !!$ INTEGER(C_INT) , INTENT(OUT) :: F !!$ END FUNCTION cgp_field_write !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_field_write_data(fn, B, Z, S, F, rmin, rmax, data) BIND(C, name="cgp_field_write_data") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: S !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: F !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmin !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmax !!$ TYPE(C_PTR), VALUE :: data !!$ END FUNCTION cgp_field_write_data !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_field_read_data(fn, B, Z, S, F, rmin, rmax, data) BIND(C, name="cgp_field_read_data") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: S !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: F !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmin !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmax !!$ TYPE(C_PTR), VALUE :: data !!$ END FUNCTION cgp_field_read_data !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_coord_read_data(fn, B, Z, C, rmin, rmax, coords) BIND(C, name="cgp_coord_read_data") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: C !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmin !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmax !!$ TYPE(C_PTR), VALUE :: coords !!$ END FUNCTION cgp_coord_read_data !!$!!$ !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_section_write(fn,B,Z,sectionname,itype,start,end,nbndry,S) BIND(C, name="cgp_section_write") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: sectionname !!$ INTEGER(KIND(CGP_INDEPENDENT)), INTENT(IN), VALUE :: itype !!$ INTEGER(CGSIZE_T), INTENT(IN), VALUE :: start !!$ INTEGER(CGSIZE_T), INTENT(IN), VALUE :: end !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: nbndry !!$ INTEGER(C_INT) , INTENT(OUT) :: S !!$ END FUNCTION cgp_section_write !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_array_write(arrayname,itype,DataDimension,DimensionVector,A) BIND(C, name="cgp_array_write") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: arrayname !!$ INTEGER(KIND(CGP_INDEPENDENT)), INTENT(IN), VALUE :: itype !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: DataDimension !!$ INTEGER(CGSIZE_T), DIMENSION(1:DataDimension), INTENT(IN) :: DimensionVector !!$ INTEGER(C_INT) , INTENT(OUT) :: A !!$ END FUNCTION cgp_array_write !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_array_write_data(A, rmin, rmax, data) BIND(C, name="cgp_array_write_data") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: A !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmin !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmax !!$ TYPE(C_PTR), VALUE :: data !!$ END FUNCTION cgp_array_write_data !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_elements_write_data(fn,B,Z,S,emin,emax,elements) BIND(C, name="cgp_elements_write_data") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: S !!$ INTEGER(CGSIZE_T), INTENT(IN), VALUE :: emin !!$ INTEGER(CGSIZE_T), INTENT(IN), VALUE :: emax !!$ TYPE(C_PTR), VALUE :: elements !!$ END FUNCTION cgp_elements_write_data !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_elements_read_data(fn,B,Z,S,start,end,elements) BIND(C, name="cgp_elements_read_data") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: S !!$ INTEGER(CGSIZE_T), INTENT(IN), VALUE :: start !!$ INTEGER(CGSIZE_T), INTENT(IN), VALUE :: end !!$ TYPE(C_PTR), VALUE :: elements !!$ END FUNCTION cgp_elements_read_data !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_array_read_data(A, rmin, rmax, data) BIND(C, name="cgp_array_read_data") !!$ USE ISO_C_BINDING !!$ IMPORT :: CGSIZE_T !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: A !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmin !!$ INTEGER(CGSIZE_T), INTENT(IN) :: rmax !!$ TYPE(C_PTR), VALUE :: data !!$ END FUNCTION cgp_array_read_data !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cg_sol_write(fn,B,Z,solname,location,S) BIND(C, name="cg_sol_write") !!$ USE ISO_C_BINDING !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: fn !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: B !!$ INTEGER(C_INT) , INTENT(IN), VALUE :: Z !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: solname !!$ INTEGER(KIND(CGP_INDEPENDENT)), INTENT(IN), VALUE :: location !!$ INTEGER(C_INT) , INTENT(OUT) :: S !!$ END FUNCTION cg_sol_write !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_error_exit() BIND(C, name="cgp_error_exit") !!$ USE ISO_C_BINDING !!$ END FUNCTION cgp_error_exit !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_close(fn) BIND(C, name="cgp_close") !!$ USE ISO_C_BINDING !!$ INTEGER(C_INT), INTENT(IN), VALUE :: fn !!$ END FUNCTION cgp_close !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_queue_set(use_queue) BIND(C, name="cgp_queue_set") !!$ USE ISO_C_BINDING !!$ INTEGER(C_INT), INTENT(IN), VALUE :: use_queue !!$ END FUNCTION cgp_queue_set !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cgp_queue_flush() BIND(C, name="cgp_queue_flush") !!$ USE ISO_C_BINDING !!$ END FUNCTION cgp_queue_flush !!$!!$ !!$!!$ INTEGER(C_INT) FUNCTION cg_user_data_write(UserDataName) BIND(C, name="cg_user_data_write") !!$ USE ISO_C_BINDING !!$ CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: UserDataName !!$ END FUNCTION cg_user_data_write !!$ #if HAVE_FORTRAN_2008TS ! THE FOLLOWING CODE ONLY WORKS FOR COMPILERS HAVING F2008 STANDARD EXTENSION: ! TS 29113 Further Interoperability of FORTRAN with C WG5/N1942 ! The number of optional parameters should be set to ! CG_MAX_GOTO_DEPTH, which is currently set to 20. INTEGER(C_INT) FUNCTION cg_gorel(fn, & UserDataName1, i1, UserDataName2, i2, & UserDataName3, i3, UserDataName4, i4, & UserDataName5, i5, UserDataName6, i6, & UserDataName7, i7, UserDataName8, i8, & UserDataName9, i9, UserDataName10, i10, & UserDataName11, i11, UserDataName12, i12, & UserDataName13, i13, UserDataName14, i14, & UserDataName15, i15, UserDataName16, i16, & UserDataName17, i17, UserDataName18, i18, & UserDataName19, i19, UserDataName20, i20, & end) BIND(C, name="cg_gorel_f08") USE ISO_C_BINDING INTEGER(C_INT) , INTENT(IN), VALUE :: fn CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN), OPTIONAL :: UserDataName1,UserDataName2, & UserDataName3,UserDataName4,UserDataName5,UserDataName6,UserDataName7,UserDataName8, & UserDataName9,UserDataName10,UserDataName11,UserDataName12,UserDataName13,UserDataName14, & UserDataName15,UserDataName16,UserDataName17,UserDataName18,UserDataName19,UserDataName20 INTEGER(C_INT), INTENT(IN), OPTIONAL :: i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16, & i17, i18, i19, i20 CHARACTER(C_CHAR), DIMENSION(3), INTENT(IN), OPTIONAL :: end END FUNCTION cg_gorel ! The number of optional parameters should be set to ! CG_MAX_GOTO_DEPTH, which is currently set to 20. INTEGER(C_INT) FUNCTION cg_goto(fn, B, & UserDataName1, i1, UserDataName2, i2, & UserDataName3, i3, UserDataName4, i4, & UserDataName5, i5, UserDataName6, i6, & UserDataName7, i7, UserDataName8, i8, & UserDataName9, i9, UserDataName10, i10, & UserDataName11, i11, UserDataName12, i12, & UserDataName13, i13, UserDataName14, i14, & UserDataName15, i15, UserDataName16, i16, & UserDataName17, i17, UserDataName18, i18, & UserDataName19, i19, UserDataName20, i20, & end) BIND(C, name="cg_goto_f08") USE ISO_C_BINDING INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B CHARACTER(C_CHAR), DIMENSION(*), OPTIONAL :: UserDataName1,UserDataName2, & UserDataName3,UserDataName4,UserDataName5,UserDataName6,UserDataName7,UserDataName8, & UserDataName9,UserDataName10,UserDataName11,UserDataName12,UserDataName13,UserDataName14, & UserDataName15,UserDataName16,UserDataName17,UserDataName18,UserDataName19,UserDataName20, end INTEGER(C_INT), OPTIONAL :: i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16,i17,i18,i19,i20 END FUNCTION cg_goto INTEGER(C_INT) FUNCTION cg_golist(fn, B, depth, label, num) BIND(C, name="cg_golist") USE ISO_C_BINDING INTEGER(C_INT) , INTENT(IN), VALUE :: fn INTEGER(C_INT) , INTENT(IN), VALUE :: B INTEGER(C_INT) , INTENT(IN), VALUE :: depth TYPE(C_PTR), DIMENSION(*), INTENT(IN) :: label INTEGER(C_INT), DIMENSION(*), INTENT(IN) :: num END FUNCTION cg_golist #endif END INTERFACE INTERFACE cg_get_type MODULE PROCEDURE cg_get_type_c_int MODULE PROCEDURE cg_get_type_c_long_long MODULE PROCEDURE cg_get_type_c_float MODULE PROCEDURE cg_get_type_c_double END INTERFACE INTERFACE cg_configure_f ! DO NOT CHANGE THE ORDER OF THE FOLLOWING INTERFACES, AS IT RESULTS IN ! THE WRONG INTERFACE BEING CALLED WITH GNU FORTRAN ON macOS. MODULE PROCEDURE cg_configure_funptr MODULE PROCEDURE cg_configure_ptr END INTERFACE #if CG_BUILD_PARALLEL_F INTERFACE cgp_particle_coord_write_data_f MODULE PROCEDURE cgp_particle_coord_write_data_f0 MODULE PROCEDURE cgp_particle_coord_write_data_f1 END INTERFACE PRIVATE cgp_particle_coord_write_data_f0, cgp_particle_coord_write_data_f1 INTERFACE cgp_particle_coord_read_data_f MODULE PROCEDURE cgp_particle_coord_read_data_f0 MODULE PROCEDURE cgp_particle_coord_read_data_f1 END INTERFACE PRIVATE cgp_particle_coord_read_data_f0, cgp_particle_coord_read_data_f1 INTERFACE cgp_particle_coord_general_write_data_f MODULE PROCEDURE cgp_particle_coord_general_write_data_f0 MODULE PROCEDURE cgp_particle_coord_general_write_data_f1 ENDINTERFACE PRIVATE cgp_particle_coord_general_write_data_f0, cgp_particle_coord_general_write_data_f1 INTERFACE cgp_particle_coord_general_read_data_f MODULE PROCEDURE cgp_particle_coord_general_read_data_f0 MODULE PROCEDURE cgp_particle_coord_general_read_data_f1 END INTERFACE PRIVATE cgp_particle_coord_general_read_data_f0, cgp_particle_coord_general_read_data_f1 INTERFACE cgp_particle_field_write_data_f MODULE PROCEDURE cgp_particle_field_write_data_f0 MODULE PROCEDURE cgp_particle_field_write_data_f1 END INTERFACE PRIVATE cgp_particle_field_write_data_f0, cgp_particle_field_write_data_f1 INTERFACE cgp_particle_field_read_data_f MODULE PROCEDURE cgp_particle_field_read_data_f0 MODULE PROCEDURE cgp_particle_field_read_data_f1 END INTERFACE PRIVATE cgp_particle_field_read_data_f0, cgp_particle_field_read_data_f1 INTERFACE cgp_particle_field_general_write_data_f MODULE PROCEDURE cgp_particle_field_general_write_data_f0 MODULE PROCEDURE cgp_particle_field_general_write_data_f1 END INTERFACE PRIVATE cgp_particle_field_general_write_data_f0, cgp_particle_field_general_write_data_f1 INTERFACE cgp_particle_field_general_read_data_f MODULE PROCEDURE cgp_particle_field_general_read_data_f0 MODULE PROCEDURE cgp_particle_field_general_read_data_f1 END INTERFACE PRIVATE cgp_particle_field_general_read_data_f0, cgp_particle_field_general_read_data_f1 INTERFACE cgp_particle_coord_multi_write_data_f MODULE PROCEDURE cgp_particle_coord_multi_write_data_f0 MODULE PROCEDURE cgp_particle_coord_multi_write_data_f1 END INTERFACE PRIVATE cgp_particle_coord_multi_write_data_f0, cgp_particle_coord_multi_write_data_f1 INTERFACE cgp_particle_coord_multi_read_data_f MODULE PROCEDURE cgp_particle_coord_multi_read_data_f0 MODULE PROCEDURE cgp_particle_coord_multi_read_data_f1 END INTERFACE PRIVATE cgp_particle_coord_multi_read_data_f0, cgp_particle_coord_multi_read_data_f1 INTERFACE cgp_particle_field_multi_write_data_f MODULE PROCEDURE cgp_particle_field_multi_write_data_f0 MODULE PROCEDURE cgp_particle_field_multi_write_data_f1 END INTERFACE PRIVATE cgp_particle_field_multi_write_data_f0, cgp_particle_field_multi_write_data_f1 INTERFACE cgp_particle_field_multi_read_data_f MODULE PROCEDURE cgp_particle_field_multi_read_data_f0 MODULE PROCEDURE cgp_particle_field_multi_read_data_f1 END INTERFACE PRIVATE cgp_particle_field_multi_read_data_f0, cgp_particle_field_multi_read_data_f1 #endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * !* INTERFACES FOR THE CGIO FORTRAN FUNCTIONS * !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * INTERFACE !*========================================================= !* paths for searching for linked-to files !*========================================================= SUBROUTINE cgio_path_add_f(path, ier) ! BIND(C,NAME="cgio_path_add_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: path INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_path_add_f !*--------------------------------------------------------- SUBROUTINE cgio_path_delete_f(path, ier) ! BIND(C,NAME="cgio_path_delete_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: path INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_path_delete_f !*========================================================= !* utility routines independent of open files !*========================================================= SUBROUTINE cgio_is_supported_f(file_type, ier) BIND(C,NAME="cgio_is_supported_f") IMPORT :: CGSIZE_T IMPLICIT NONE INTEGER(CGSIZE_T) :: file_type INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_is_supported_f !*--------------------------------------------------------- SUBROUTINE cgio_check_file_f(filename, file_type, ier) !BIND(C,NAME="cgio_check_file_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: filename INTEGER :: file_type INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_check_file_f !*========================================================= !* file operations !*========================================================= SUBROUTINE cgio_open_file_f(filename, file_mode, file_type, cgio_num, ier) ! BIND(C,NAME="cgio_open_file_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: filename INTEGER :: file_mode INTEGER :: file_type INTEGER :: cgio_num INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_open_file_f !*--------------------------------------------------------- SUBROUTINE cgio_close_file_f(cgio_num, ier) BIND(C,NAME="cgio_close_file_f") IMPLICIT NONE INTEGER :: cgio_num INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_close_file_f !*--------------------------------------------------------- SUBROUTINE cgio_flush_to_disk_f(cgio_num, ier) BIND(C,NAME="cgio_flush_to_disk_f") IMPLICIT NONE INTEGER :: cgio_num INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_flush_to_disk_f !*========================================================= !* file information !*========================================================= SUBROUTINE cgio_library_version_f(cgio_num, version, ier) ! BIND(C,NAME="cgio_library_version_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: cgio_num CHARACTER(KIND=C_CHAR), DIMENSION(*) :: version INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_library_version_f !*--------------------------------------------------------- SUBROUTINE cgio_file_version_f(cgio_num, file_version, creation_date, modified_date, ier) ! BIND(C,NAME="cgio_file_version_f") IMPORT :: c_char IMPLICIT NONE INTEGER :: cgio_num CHARACTER(KIND=C_CHAR), DIMENSION(*) :: file_version CHARACTER(KIND=C_CHAR), DIMENSION(*) :: creation_date CHARACTER(KIND=C_CHAR), DIMENSION(*) :: modified_date INTEGER, INTENT(OUT) :: ier END SUBROUTINE !*--------------------------------------------------------- SUBROUTINE cgio_get_root_id_f(cgio_num, rootid, ier) BIND(C,NAME="cgio_get_root_id_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: cgio_num REAL(c_double) :: rootid INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_root_id_f !*--------------------------------------------------------- SUBROUTINE cgio_get_file_type_f(cgio_num, file_type, ier) BIND(C,NAME="cgio_get_file_type_f") IMPLICIT NONE INTEGER :: cgio_num INTEGER :: file_type INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_file_type_f !*========================================================= !* error handling !*========================================================= SUBROUTINE cgio_error_code_f(errcode, file_type) BIND(C,NAME="cgio_error_code_f") IMPLICIT NONE INTEGER :: errcode INTEGER :: file_type END SUBROUTINE cgio_error_code_f !*--------------------------------------------------------- SUBROUTINE cgio_error_message_f(errmsg, ier) ! BIND(C,NAME="cgio_error_message_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: errmsg INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_error_message_f !*--------------------------------------------------------- SUBROUTINE cgio_error_exit_f(errmsg) ! BIND(C,NAME="cgio_error_exit_f") IMPORT :: c_char IMPLICIT NONE CHARACTER(KIND=C_CHAR), DIMENSION(*) :: errmsg END SUBROUTINE cgio_error_exit_f !*--------------------------------------------------------- SUBROUTINE cgio_error_abort_f(abort_flag) BIND(C,NAME="cgio_error_abort_f") IMPLICIT NONE INTEGER :: abort_flag END SUBROUTINE cgio_error_abort_f !*========================================================= !* basic node operations !*========================================================= SUBROUTINE cgio_create_node_f(cgio_num, pid, name, id, ier) ! BIND(C,NAME="cgio_create_node_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: pid CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name REAL(C_DOUBLE) :: id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_create_node_f !*--------------------------------------------------------- !!$!!$ SUBROUTINE cgio_new_node_f(cgio_num, pid, name, label, data_type, ndims, dims, DATA, id, ier) BIND(C,NAME="") !!$ IMPORT :: c_char, c_double !!$ IMPLICIT NONE !!$ INTEGER :: cgio_num !!$ REAL(C_DOUBLE) :: pid !!$ CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name !!$ CHARACTER(KIND=C_CHAR), DIMENSION(*) :: label !!$ CHARACTER(KIND=C_CHAR), DIMENSION(*) :: data_type !!$ INTEGER :: ndims !!$ INTEGER(CGSIZE_T), DIMENSION(*) :: dims !!$ TYPE(C_PTR) :: DATA !!$ REAL(C_DOUBLE) :: id !!$ INTEGER, INTENT(OUT) :: ier !!$ END SUBROUTINE cgio_new_node_f !!$ !*--------------------------------------------------------- SUBROUTINE cgio_delete_node_f(cgio_num, pid, id, ier) BIND(C,NAME="cgio_delete_node_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: pid REAL(C_DOUBLE) :: id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_delete_node_f !*--------------------------------------------------------- SUBROUTINE cgio_move_node_f(cgio_num, pid, id, npid, ier) BIND(C,NAME="cgio_move_node_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: pid REAL(C_DOUBLE) :: id REAL(C_DOUBLE) :: npid INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_move_node_f !*--------------------------------------------------------- SUBROUTINE cgio_release_id_f(cgio_num, id, ier) BIND(C,NAME="cgio_release_id_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_release_id_f !*========================================================= !* links !*========================================================= SUBROUTINE cgio_is_link_f(cgio_num, id, link_len, ier) BIND(C,NAME="cgio_is_link_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id INTEGER :: link_len INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_is_link_f !*--------------------------------------------------------- SUBROUTINE cgio_link_size_f(cgio_num, id, file_len, name_len, ier) BIND(C,NAME="cgio_link_size_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id INTEGER :: file_len INTEGER :: name_len INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_link_size_f !*--------------------------------------------------------- SUBROUTINE cgio_create_link_f(cgio_num, pid, name, filename, name_in_file, id, ier) ! BIND(C,NAME="cgio_create_link_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: pid CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name CHARACTER(KIND=C_CHAR), DIMENSION(*) :: filename CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name_in_file REAL(C_DOUBLE) :: id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_create_link_f !*--------------------------------------------------------- SUBROUTINE cgio_get_link_f(cgio_num, id, filename, name_in_file, ier) ! BIND(C,NAME="cgio_get_link_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id CHARACTER(KIND=C_CHAR), DIMENSION(*) :: filename CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name_in_file INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_link_f !*========================================================= !* node children !*========================================================= SUBROUTINE cgio_number_children_f(cgio_num, pid, num_children, ier) & BIND(C,NAME="cgio_number_children_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: pid INTEGER :: num_children INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_number_children_f !*--------------------------------------------------------- SUBROUTINE cgio_children_ids_f(cgio_num, pid, start, max_ret, num_ret, ids, ier) & BIND(C,NAME="cgio_children_ids_f") IMPORT :: c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: pid INTEGER :: start INTEGER :: max_ret INTEGER :: num_ret REAL(C_DOUBLE) :: ids INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_children_ids_f !*--------------------------------------------------------- SUBROUTINE cgio_children_names_f(cgio_num, pid, start, max_ret, name_len, & num_ret, names, ier) !BIND(C,NAME="cgio_children_names_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: pid INTEGER :: start INTEGER :: max_ret INTEGER :: name_len INTEGER :: num_ret CHARACTER(KIND=C_CHAR), DIMENSION(*) :: names INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_children_names_f !*========================================================= !* read nodes !*========================================================= SUBROUTINE cgio_get_node_id_f(cgio_num, pid, name, id, ier) !BIND(C,NAME="cgio_get_node_id_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: pid CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name REAL(C_DOUBLE) :: id INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_node_id_f !*--------------------------------------------------------- SUBROUTINE cgio_get_name_f(cgio_num, id, name, ier) !BIND(C,NAME="cgio_get_name_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_name_f !*--------------------------------------------------------- SUBROUTINE cgio_get_label_f(cgio_num, id, label, ier) !BIND(C,NAME="cgio_get_label_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id CHARACTER(KIND=C_CHAR), DIMENSION(*) :: label INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_label_f !*--------------------------------------------------------- SUBROUTINE cgio_get_data_type_f(cgio_num, id, data_type, ier) !BIND(C,NAME="cgio_get_data_type_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id CHARACTER(KIND=C_CHAR), DIMENSION(*) :: data_type INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_data_type_f !*--------------------------------------------------------- SUBROUTINE cgio_get_data_size_f(cgio_num, id, size, ier) BIND(C,NAME="cgio_get_data_size_f") IMPORT :: c_double, cgsize_t IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id INTEGER(CGSIZE_T) :: size INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_get_data_size_f !*========================================================= !* write nodes !*========================================================= SUBROUTINE cgio_set_name_f(cgio_num, pid, id, name, ier) !BIND(C,NAME="cgio_set_name_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: pid REAL(C_DOUBLE) :: id CHARACTER(KIND=C_CHAR), DIMENSION(*) :: name INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_set_name_f !*--------------------------------------------------------- SUBROUTINE cgio_set_label_f(cgio_num, id, label, ier) !BIND(C,NAME="cgio_set_label_f") IMPORT :: c_char, c_double IMPLICIT NONE INTEGER :: cgio_num REAL(C_DOUBLE) :: id CHARACTER(KIND=C_CHAR), DIMENSION(*) :: label INTEGER, INTENT(OUT) :: ier END SUBROUTINE cgio_set_label_f !*--------------------------------------------------------- !!$!!$ SUBROUTINE cgio_write_all_data_f( !!$ cgint_f *cgio_num, double *id, void *data, cgint_f *ier) BIND(C,NAME="") !!$ !*--------------------------------------------------------- !!$!!$ SUBROUTINE cgio_write_block_data_f( !!$ cgint_f *cgio_num, double *id, cgsize_t *b_start, cgsize_t *b_end, !!$ void *data, cgint_f *ier) BIND(C,NAME="") !!$ !!$ !*--------------------------------------------------------- !!$!!$ SUBROUTINE cgio_write_data_f( !!$ cgint_f *cgio_num, double *id, cgsize_t *s_start, cgsize_t *s_end, !!$ cgsize_t *s_stride, cgsize_t *m_ndims, cgsize_t *m_dims, cgsize_t *m_start, !!$ cgsize_t *m_end, cgsize_t *m_stride, void *data, cgint_f *ier) BIND(C,NAME="") !!$ !!$ END INTERFACE #if CG_BUILD_PARALLEL_F INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_coord_write_data(fn, B, P, C, rmin, rmax, coords) & BIND(C, name="cgp_particle_coord_write_data") IMPORT :: C_INT, C_PTR IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: C TYPE(C_PTR), VALUE :: rmin TYPE(C_PTR), VALUE :: rmax TYPE(C_PTR), VALUE :: coords END FUNCTION cgp_particle_coord_write_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_coord_read_data(fn, B, P, C, rmin, rmax, coords) & BIND(C, name="cgp_particle_coord_read_data") IMPORT :: C_INT, C_PTR IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: C TYPE(C_PTR), VALUE :: rmin TYPE(C_PTR), VALUE :: rmax TYPE(C_PTR), VALUE :: coords END FUNCTION cgp_particle_coord_read_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_coord_general_write_data(fn, B, P, C, rmin, rmax, & m_type, m_numdim, m_arg_dimvals, m_rmin, m_rmax, & coords) BIND(C, name="cgp_particle_coord_general_write_data") IMPORT :: C_INT, C_PTR, CGSIZE_T, CGENUM_T IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: C TYPE(C_PTR), VALUE :: rmin TYPE(C_PTR), VALUE :: rmax INTEGER(CGENUM_T), VALUE :: m_type INTEGER(CGSIZE_T), VALUE :: m_numdim TYPE(C_PTR), VALUE :: m_arg_dimvals TYPE(C_PTR), VALUE :: m_rmin TYPE(C_PTR), VALUE :: m_rmax TYPE(C_PTR), VALUE :: coords END FUNCTION cgp_particle_coord_general_write_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_field_write_data(fn, B, P, S, F, rmin, rmax, DATA) & BIND(C, name="cgp_particle_field_write_data") IMPORT :: C_INT, C_PTR IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: S INTEGER(C_INT), VALUE :: F TYPE(C_PTR), VALUE :: rmin TYPE(C_PTR), VALUE :: rmax TYPE(C_PTR), VALUE :: data END FUNCTION cgp_particle_field_write_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_field_general_write_data(fn, B, P, S, F, rmin, rmax, & m_type, m_numdim, m_arg_dimvals, m_rmin, m_rmax, & field) BIND(C, name="cgp_particle_field_general_write_data") IMPORT :: C_INT, C_PTR, CGSIZE_T, CGENUM_T IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: S INTEGER(C_INT), VALUE :: F TYPE(C_PTR), VALUE :: rmin TYPE(C_PTR), VALUE :: rmax INTEGER(CGENUM_T), VALUE :: m_type INTEGER(CGSIZE_T), VALUE :: m_numdim TYPE(C_PTR), VALUE :: m_arg_dimvals TYPE(C_PTR), VALUE :: m_rmin TYPE(C_PTR), VALUE :: m_rmax TYPE(C_PTR), VALUE :: field END FUNCTION cgp_particle_field_general_write_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_field_read_data(fn, B, P, S, F, rmin, rmax, data) & BIND(C, name="cgp_particle_field_read_data") IMPORT :: C_INT, C_PTR IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: S INTEGER(C_INT), VALUE :: F TYPE(C_PTR), VALUE :: rmin TYPE(C_PTR), VALUE :: rmax TYPE(C_PTR), VALUE :: data END FUNCTION cgp_particle_field_read_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_field_general_read_data(fn, B, P, S, F, rmin, rmax, & m_type, m_numdim, m_arg_dimvals, m_rmin, m_rmax, & field) BIND(C, name="cgp_particle_field_general_read_data") IMPORT :: C_INT, C_PTR, CGSIZE_T, CGENUM_T IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: S INTEGER(C_INT), VALUE :: F TYPE(C_PTR), VALUE :: rmin TYPE(C_PTR), VALUE :: rmax INTEGER(CGENUM_T), VALUE :: m_type INTEGER(CGSIZE_T), VALUE :: m_numdim TYPE(C_PTR), VALUE :: m_arg_dimvals TYPE(C_PTR), VALUE :: m_rmin TYPE(C_PTR), VALUE :: m_rmax TYPE(C_PTR), VALUE :: field END FUNCTION cgp_particle_field_general_read_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_coord_general_read_data(fn, B, P, C, rmin, rmax, & m_type, m_numdim, m_arg_dimvals, m_rmin, m_rmax, & coords) BIND(C, name="cgp_particle_coord_general_read_data") IMPORT :: C_INT, C_PTR, CGSIZE_T, CGENUM_T IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: C TYPE(C_PTR), VALUE :: rmin TYPE(C_PTR), VALUE :: rmax INTEGER(CGENUM_T), VALUE :: m_type INTEGER(CGSIZE_T), VALUE :: m_numdim TYPE(C_PTR), VALUE :: m_arg_dimvals TYPE(C_PTR), VALUE :: m_rmin TYPE(C_PTR), VALUE :: m_rmax TYPE(C_PTR), VALUE :: coords END FUNCTION cgp_particle_coord_general_read_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_coord_multi_write_data(fn, B, P, C, rmin, rmax, & nsets, buf) BIND(C, NAME="cgp_particle_coord_multi_write_data") IMPORT :: C_INT, C_PTR IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), DIMENSION(*) :: C TYPE(C_PTR) , VALUE :: rmin TYPE(C_PTR) , VALUE :: rmax INTEGER(C_INT), VALUE :: nsets TYPE(C_PTR), DIMENSION(*) :: buf END FUNCTION cgp_particle_coord_multi_write_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_coord_multi_read_data(fn, B, P, C, rmin, rmax, & nsets, buf) BIND(C, NAME="cgp_particle_coord_multi_read_data") IMPORT :: C_INT, C_PTR IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), DIMENSION(*) :: C TYPE(C_PTR) , VALUE :: rmin TYPE(C_PTR) , VALUE :: rmax INTEGER(C_INT), VALUE :: nsets TYPE(C_PTR), DIMENSION(*) :: buf END FUNCTION cgp_particle_coord_multi_read_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_field_multi_write_data(fn, B, P, S, F, rmin, rmax, & nsets, buf) BIND(C, NAME="cgp_particle_field_multi_write_data") IMPORT :: C_INT, C_PTR IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: S INTEGER(C_INT), DIMENSION(*) :: F TYPE(C_PTR) , VALUE :: rmin TYPE(C_PTR) , VALUE :: rmax INTEGER(C_INT), VALUE :: nsets TYPE(C_PTR), DIMENSION(*) :: buf END FUNCTION cgp_particle_field_multi_write_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_particle_field_multi_read_data(fn, B, P, S, F, rmin, rmax, & nsets, buf) BIND(C, NAME="cgp_particle_field_multi_read_data") IMPORT :: C_INT, C_PTR IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: P INTEGER(C_INT), VALUE :: S INTEGER(C_INT), DIMENSION(*) :: F TYPE(C_PTR) , VALUE :: rmin TYPE(C_PTR) , VALUE :: rmax INTEGER(C_INT), VALUE :: nsets TYPE(C_PTR), DIMENSION(*) :: buf END FUNCTION cgp_particle_field_multi_read_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_ptlist_write_data(file_number, rmin, rmax, points) BIND(C, NAME="cgp_ptlist_write_data") IMPORT :: C_INT, C_PTR, CGSIZE_T IMPLICIT NONE INTEGER(C_INT) , VALUE :: file_number INTEGER(CGSIZE_T), VALUE :: rmin INTEGER(CGSIZE_T), VALUE :: rmax TYPE(C_PTR) , VALUE :: points END FUNCTION cgp_ptlist_write_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_ptlist_read_data(file_number, rmin, rmax, points) BIND(C, NAME="cgp_ptlist_read_data") IMPORT :: C_INT, C_PTR, CGSIZE_T IMPLICIT NONE INTEGER(C_INT) , VALUE :: file_number INTEGER(CGSIZE_T), VALUE :: rmin INTEGER(CGSIZE_T), VALUE :: rmax TYPE(C_PTR) , VALUE :: points END FUNCTION cgp_ptlist_read_data END INTERFACE INTERFACE INTEGER(C_INT) FUNCTION cgp_parent_data_write(file_number, B, Z, S, rmin, rmax, parents) BIND(C, NAME="cgp_parent_data_write") IMPORT :: C_INT, C_PTR, CGSIZE_T IMPLICIT NONE INTEGER(C_INT), VALUE :: file_number INTEGER(C_INT), VALUE :: B INTEGER(C_INT), VALUE :: Z INTEGER(C_INT), VALUE :: S INTEGER(CGSIZE_T), VALUE :: rmin INTEGER(CGSIZE_T), VALUE :: rmax TYPE(C_PTR) , VALUE :: parents END FUNCTION cgp_parent_data_write END INTERFACE #endif PRIVATE cg_configure_ptr, cg_configure_funptr PRIVATE cg_get_type_c_int, cg_get_type_c_long_long, cg_get_type_c_float, cg_get_type_c_double CONTAINS #if CG_BUILD_PARALLEL_F SUBROUTINE cgp_poly_section_write_f(fn, B , Z, sectionname, type, start, end, maxoffset, nbndry, S, ier) IMPLICIT NONE INTEGER, INTENT(IN) :: fn INTEGER, INTENT(IN) :: B INTEGER, INTENT(IN) :: Z CHARACTER(LEN=*), INTENT(IN) :: sectionname INTEGER(cgenum_t), INTENT(IN) :: type INTEGER(cgsize_t), INTENT(IN) :: start INTEGER(cgsize_t), INTENT(IN) :: end INTEGER(cgsize_t), INTENT(IN) :: maxoffset INTEGER, INTENT(IN) :: nbndry INTEGER, INTENT(OUT) :: S INTEGER, INTENT(OUT) :: ier CHARACTER(LEN=LEN_TRIM(sectionname)+1,KIND=C_CHAR) :: c_name INTEGER(c_int) :: c_S INTERFACE INTEGER(c_int) FUNCTION cgp_poly_section_write(fn, B , Z, sectionname, type, start, end, maxoffset, nbndry, S) & BIND(C, name="cgp_poly_section_write") IMPORT :: c_int, c_char, cgsize_t, cgenum_t IMPLICIT NONE INTEGER(c_int), VALUE :: fn INTEGER(c_int), VALUE :: B INTEGER(c_int), VALUE :: Z CHARACTER(KIND=C_CHAR), DIMENSION(*) :: sectionname INTEGER(cgenum_t), VALUE :: type INTEGER(cgsize_t), VALUE :: start INTEGER(cgsize_t), VALUE :: end INTEGER(cgsize_t), VALUE :: maxoffset INTEGER(c_int), VALUE :: nbndry INTEGER(c_int) :: S END FUNCTION cgp_poly_section_write END INTERFACE c_name = TRIM(sectionname)//C_NULL_CHAR ier = INT(cgp_poly_section_write(INT(fn, c_int), INT(B, c_int), INT(Z, c_int), c_name, type, start, end, maxoffset, & INT(nbndry, c_int), c_S)) S = INT(c_S) END SUBROUTINE cgp_poly_section_write_f SUBROUTINE cgp_poly_elements_write_data_f(fn, B , Z, S, start, end, elements, offsets, ier) IMPLICIT NONE INTEGER, INTENT(IN) :: fn INTEGER, INTENT(IN) :: B INTEGER, INTENT(IN) :: Z INTEGER, INTENT(IN) :: S INTEGER(cgsize_t), INTENT(IN) :: start INTEGER(cgsize_t), INTENT(IN) :: end INTEGER(cgsize_t), INTENT(IN), TARGET :: elements(:) INTEGER(cgsize_t), INTENT(IN), TARGET :: offsets(:) INTEGER, INTENT(OUT) :: ier TYPE(c_ptr) :: c_elements TYPE(c_ptr) :: c_offsets INTERFACE INTEGER(c_int) FUNCTION cgp_poly_elements_write_data(fn, B , Z, S, start, end, elements, offsets) & BIND(C, name="cgp_poly_elements_write_data") IMPORT :: c_int, c_ptr, cgsize_t IMPLICIT NONE INTEGER(c_int), VALUE :: fn INTEGER(c_int), VALUE :: B INTEGER(c_int), VALUE :: Z INTEGER(c_int), VALUE :: S INTEGER(cgsize_t), VALUE :: start INTEGER(cgsize_t), VALUE :: end TYPE(c_ptr), VALUE :: elements TYPE(c_ptr), VALUE :: offsets END FUNCTION cgp_poly_elements_write_data END INTERFACE c_elements = C_NULL_PTR c_offsets = C_NULL_PTR IF (end >= start) THEN c_elements = C_LOC(elements) c_offsets = C_LOC(offsets) END IF ier = INT(cgp_poly_elements_write_data(INT(fn, c_int), INT(B, c_int), INT(Z, c_int), INT(S, c_int), start, end, & c_elements, c_offsets)) END SUBROUTINE cgp_poly_elements_write_data_f #endif !> @ingroup CGNSFile !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_open_f !DEC$endif SUBROUTINE cg_open_f(filename, mode, fn, ier) IMPLICIT NONE CHARACTER(*), INTENT(IN) :: filename INTEGER, INTENT(IN) :: mode INTEGER, INTENT(OUT) :: fn INTEGER, INTENT(OUT) :: ier INTEGER(C_INT) :: i_fn ier = INT(cg_open(TRIM(filename)//C_NULL_CHAR, INT(mode, C_INT), i_fn)) fn = INT(i_fn) END SUBROUTINE cg_open_f !> @ingroup CGNSFile !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_is_cgns_f !DEC$endif SUBROUTINE cg_is_cgns_f(filename, file_type, ier) IMPLICIT NONE CHARACTER(*), INTENT(IN) :: filename INTEGER, INTENT(OUT) :: file_type INTEGER, INTENT(OUT) :: ier INTEGER(C_INT) :: i_file_type ier = INT(cg_is_cgns(TRIM(filename)//C_NULL_CHAR, i_file_type)) file_type = INT(i_file_type) END SUBROUTINE cg_is_cgns_f !> @ingroup CGNSFile !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_version_f !DEC$endif SUBROUTINE cg_version_f(fn, FileVersion, ier) IMPLICIT NONE INTEGER :: fn REAL(C_FLOAT) :: FileVersion INTEGER, INTENT(OUT) :: ier INTERFACE INTEGER(C_INT) FUNCTION cg_version(fn, FileVersion) BIND(C, name="cg_version") IMPORT ::C_INT, C_FLOAT IMPLICIT NONE INTEGER(C_INT), VALUE, INTENT(IN) :: fn REAL(C_FLOAT) :: FileVersion END FUNCTION cg_version END INTERFACE ier = INT(cg_version(INT(fn, C_INT), FileVersion)) END SUBROUTINE cg_version_f !> @ingroup CGNSFile !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_precision_f !DEC$endif SUBROUTINE cg_precision_f(fn, PRECISION, ier) IMPLICIT NONE INTEGER :: fn INTEGER :: PRECISION INTEGER, INTENT(OUT) :: ier INTEGER(C_INT) :: i_precision INTERFACE INTEGER(C_INT) FUNCTION cg_precision(fn, precision) BIND(C, name="cg_precision") IMPORT ::C_INT IMPLICIT NONE INTEGER(C_INT), VALUE, INTENT(IN) :: fn INTEGER(C_INT), INTENT(OUT) :: precision END FUNCTION cg_precision END INTERFACE ier = INT(cg_precision(INT(fn, C_INT), i_precision)) PRECISION = INT(i_precision) END SUBROUTINE cg_precision_f !> @ingroup CGNSFile !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_close_f !DEC$endif SUBROUTINE cg_close_f(fn, ier) IMPLICIT NONE INTEGER :: fn INTEGER, INTENT(OUT) :: ier INTERFACE INTEGER(C_INT) FUNCTION cg_close(fn) BIND(C, name="cg_close") IMPORT ::C_INT IMPLICIT NONE INTEGER(C_INT), VALUE, INTENT(IN) :: fn END FUNCTION cg_close END INTERFACE ier = INT(cg_close(INT(fn, C_INT))) END SUBROUTINE cg_close_f !> @ingroup CGNSFile !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_save_as_f !DEC$endif SUBROUTINE cg_save_as_f(fn, filename, file_type, follow_links, ier) IMPLICIT NONE INTEGER :: fn CHARACTER(*), INTENT(IN) :: filename INTEGER :: file_type INTEGER :: follow_links INTEGER, INTENT(OUT) :: ier CHARACTER(LEN=LEN_TRIM(filename)+1, kind=C_CHAR) :: c_name INTERFACE INTEGER(C_INT) FUNCTION cg_save_as(fn, filename, file_type, follow_links) BIND(C, name="cg_save_as") IMPORT ::C_INT, C_CHAR IMPLICIT NONE INTEGER(C_INT), VALUE, INTENT(IN) :: fn CHARACTER(LEN=1, kind=C_CHAR), DIMENSION(*), INTENT(IN) :: filename INTEGER(C_INT), VALUE, INTENT(IN) :: file_type INTEGER(C_INT), VALUE, INTENT(IN) :: follow_links END FUNCTION cg_save_as END INTERFACE c_name = TRIM(filename)//C_NULL_CHAR ier = INT(cg_save_as(INT(fn, C_INT), c_name, INT(file_type, C_INT), INT(follow_links, C_INT))) END SUBROUTINE cg_save_as_f !> @ingroup CGNSFile !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_set_file_type_f !DEC$endif SUBROUTINE cg_set_file_type_f(ft, ier) IMPLICIT NONE INTEGER :: ft INTEGER, INTENT(OUT) :: ier INTERFACE INTEGER(C_INT) FUNCTION cg_set_file_type(ft) BIND(C, name="cg_set_file_type") IMPORT ::C_INT IMPLICIT NONE INTEGER(C_INT), VALUE, INTENT(IN) :: ft END FUNCTION cg_set_file_type END INTERFACE ier = INT(cg_set_file_type(INT(ft, C_INT))) END SUBROUTINE cg_set_file_type_f !> @ingroup CGNSFile !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_get_file_type_f !DEC$endif SUBROUTINE cg_get_file_type_f(fn, ft, ier) IMPLICIT NONE INTEGER :: fn INTEGER :: ft INTEGER, INTENT(OUT) :: ier INTEGER(C_INT) :: i_ft INTERFACE INTEGER(C_INT) FUNCTION cg_get_file_type(fn, ft) BIND(C, name="cg_get_file_type") IMPORT ::C_INT IMPLICIT NONE INTEGER(C_INT), VALUE, INTENT(IN) :: fn INTEGER(C_INT), INTENT(OUT) :: ft END FUNCTION cg_get_file_type END INTERFACE ier = INT(cg_get_file_type(INT(fn, C_INT), i_ft)) ft = INT(i_ft) END SUBROUTINE cg_get_file_type_f !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_set_compress_f !DEC$endif SUBROUTINE cg_set_compress_f(cmpr, ier) IMPLICIT NONE INTEGER :: cmpr INTEGER, INTENT(OUT) :: ier INTERFACE INTEGER(C_INT) FUNCTION cg_set_compress(cmpr) BIND(C, name="cg_set_compress") IMPORT ::C_INT IMPLICIT NONE INTEGER(C_INT), VALUE, INTENT(IN) :: cmpr END FUNCTION cg_set_compress END INTERFACE ier = INT(cg_set_compress(INT(cmpr))) END SUBROUTINE cg_set_compress_f !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_get_compress_f !DEC$endif SUBROUTINE cg_get_compress_f(cmpr, ier) INTEGER :: cmpr INTEGER(C_INT) :: i_cmpr INTEGER, INTENT(OUT) :: ier INTERFACE INTEGER(C_INT) FUNCTION cg_get_compress(cmpr) BIND(C, name="cg_get_compress") IMPORT ::C_INT IMPLICIT NONE INTEGER(C_INT), INTENT(OUT) :: cmpr END FUNCTION cg_get_compress END INTERFACE ier = INT(cg_get_compress(i_cmpr)) cmpr = INT(i_cmpr) END SUBROUTINE cg_get_compress_f !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_set_path_f !DEC$endif SUBROUTINE cg_set_path_f(pathname, ier) USE ISO_C_BINDING IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: pathname INTEGER, INTENT(OUT) :: ier CHARACTER(LEN=LEN_TRIM(pathname)+1, kind=C_CHAR) :: c_name INTERFACE INTEGER(C_INT) FUNCTION cg_set_path(pth) BIND(C, name="cg_set_path") IMPORT ::C_INT, C_CHAR IMPLICIT NONE CHARACTER(LEN=1, kind=C_CHAR), DIMENSION(*), INTENT(IN) :: pth END FUNCTION cg_set_path END INTERFACE c_name = TRIM(pathname)//C_NULL_CHAR ier = INT(cg_set_path(c_name)) END SUBROUTINE cg_set_path_f !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_add_path_f !DEC$endif SUBROUTINE cg_add_path_f(pathname, ier) USE ISO_C_BINDING IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: pathname INTEGER, INTENT(OUT) :: ier CHARACTER(LEN=LEN_TRIM(pathname)+1, kind=C_CHAR) :: c_name INTERFACE INTEGER(C_INT) FUNCTION cg_add_path(pth) BIND(C, name="cg_add_path") IMPORT ::C_INT, C_CHAR IMPLICIT NONE CHARACTER(LEN=1, kind=C_CHAR), DIMENSION(*), INTENT(IN) :: pth END FUNCTION cg_add_path END INTERFACE c_name = TRIM(pathname)//C_NULL_CHAR ier = INT(cg_add_path(c_name)) END SUBROUTINE cg_add_path_f !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_get_cgio_f !DEC$endif SUBROUTINE cg_get_cgio_f(fn, cgio_num, ier) IMPLICIT NONE INTEGER :: fn INTEGER :: cgio_num INTEGER, INTENT(OUT) :: ier INTEGER(C_INT) i_cgio_num INTERFACE INTEGER(C_INT) FUNCTION cg_get_cgio(fn, cgio_num) BIND(C, name="cg_get_cgio") IMPORT ::C_INT IMPLICIT NONE INTEGER(C_INT), VALUE, INTENT(IN) :: fn INTEGER(C_INT) :: cgio_num END FUNCTION cg_get_cgio END INTERFACE ier = INT(cg_get_cgio(INT(fn, C_INT), i_cgio_num)) cgio_num = INT(i_cgio_num) END SUBROUTINE cg_get_cgio_f !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_root_id_f !DEC$endif SUBROUTINE cg_root_id_f(fn, rootid, ier) IMPLICIT NONE INTEGER :: fn REAL(C_DOUBLE) :: rootid INTEGER, INTENT(OUT) :: ier INTERFACE INTEGER(C_INT) FUNCTION cg_root_id(fn, rootid) BIND(C, name="cg_root_id") IMPORT ::C_INT, C_DOUBLE IMPLICIT NONE INTEGER(C_INT), VALUE, INTENT(IN) :: fn REAL(C_DOUBLE) :: rootid END FUNCTION cg_root_id END INTERFACE ier = INT(cg_root_id(INT(fn, C_INT), rootid)) END SUBROUTINE cg_root_id_f !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_set_rind_zero_f !DEC$endif SUBROUTINE cg_set_rind_zero_f(ier) IMPLICIT NONE INTEGER, INTENT(OUT) :: ier INTEGER(C_INT), TARGET :: value value = CG_CONFIG_RIND_ZERO call cg_configure_f(CG_CONFIG_RIND_INDEX, C_LOC(value), ier) END SUBROUTINE cg_set_rind_zero_f !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_set_rind_core_f !DEC$endif SUBROUTINE cg_set_rind_core_f(ier) IMPLICIT NONE INTEGER, INTENT(OUT) :: ier INTEGER(C_INT), TARGET :: value value = CG_CONFIG_RIND_CORE call cg_configure_f(CG_CONFIG_RIND_INDEX, C_LOC(value), ier) END SUBROUTINE cg_set_rind_core_f ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Read and write CGNSBase_t Nodes ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !DEC$if defined(BUILD_CGNS_DLL) !DEC$ATTRIBUTES DLLEXPORT :: cg_nbases_f !DEC$endif SUBROUTINE cg_nbases_f(fn, nbases, ier) IMPLICIT NONE INTEGER, INTENT(IN) :: fn INTEGER, INTENT(OUT) :: nbases INTEGER, INTENT(OUT) :: ier INTEGER(C_INT) :: c_nbases INTERFACE INTEGER(C_INT) FUNCTION cg_nbases(fn, nbases) BIND(C, name="cg_nbases") IMPORT ::C_INT IMPLICIT NONE INTEGER(C_INT), VALUE :: fn INTEGER(C_INT) :: nbases END FUNCTION cg_nbases END INTERFACE ier = INT(cg_nbases(INT(fn, C_INT), c_nbases)) nbases = INT(c_nbases) END SUBROUTINE cg_nbases_f ! Copy a C string ptr, to a Fortran string. subroutine C_F_string_ptr(C_string, F_string) type(C_ptr), intent(in) :: C_string character(len=*), intent(out) :: F_string character(len=1,kind=C_char), dimension(:), pointer :: p_chars integer :: i if (.not. C_associated(C_string)) then F_string = ' ' else call C_F_pointer(C_string,p_chars,[huge(0)]) i=1 do while(p_chars(i)/=C_NULL_CHAR .and. i<=len(F_string)) F_string(i:i) = p_chars(i) i=i+1 end do if (i /* included for definition of HUGE */ #include "cgnstypes.h" #include "cgns_io.h" #include "cg_hashmap.h" typedef char char_33[33]; #ifdef CG_BUILD_BASESCOPE typedef char char_66[66]; /* 32 + '/' + 32 + '\0' */ #else typedef char char_66[33]; /* 32 + '\0' (caller's malloc compat issues) */ #endif typedef char char_md[CG_MAX_GOTO_DEPTH*33+1]; /* ('/'+ 32)*MAX_GOTO_DEPTH + '\0' (FAMILY TREE) */ typedef char const cchar_33[33]; typedef cgsize_t cgsize6_t[6]; typedef int cgint3_t[3]; #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) #define CGNS_DELETE_SHIFT(nchild, child, func_free) {\ for (n=0; nnchild && strcmp(parent->child[n].name,node_name); n++);\ if (n==parent->nchild) {\ cgi_error("Error in cg_delete: Can't find node '%s'",node_name);\ return 1;\ }\ func_free(&parent->child[n]);\ for (m=n+1; mnchild; m++) parent->child[m-1] = parent->child[m];\ if (--parent->nchild == 0) {\ free(parent->child);\ parent->child=0;\ }\ } #define CGNS_DELETE_CHILD(child, func_free) {\ if (parent->child) {\ func_free(parent->child);\ free(parent->child);\ }\ parent->child = 0;\ } #define ADDRESS4MULTIPLE(parent_type, nchild, child, child_type) {\ parent_type *parent = (parent_type *)posit->posit;\ child = 0;\ if (local_mode == CG_MODE_WRITE) {\ for (n=0; nnchild && strcmp(parent->child[n].name,given_name);n++);\ if (n==parent->nchild) {\ if (parent->nchild==0) parent->child = CGNS_NEW(child_type, 1);\ else parent->child = CGNS_RENEW(child_type,parent->nchild+1, parent->child);\ child = &parent->child[parent->nchild];\ parent->nchild++;\ } else {\ if (cg->mode == CG_MODE_WRITE || allow_dup) error1=1;\ if (cg->mode != CG_MODE_WRITE || allow_dup) {\ parent_id = parent->id;\ child= &(parent->child[n]);\ }\ }\ } else if (local_mode == CG_MODE_READ) {\ if (given_no > parent->nchild || given_no<=0) error2=1;\ else child = &parent->child[given_no-1];\ }\ } #define ADDRESS4SINGLE_ALLOC(parent_type, child) {\ parent_type *parent = (parent_type *)posit->posit;\ child = &parent->child;\ parent_id = parent->id;\ } #define ADDRESS4SINGLE(parent_type, child, child_type, size) {\ parent_type *parent = (parent_type *)posit->posit;\ if (local_mode==CG_MODE_WRITE) {\ if (parent->child==0) parent->child = CGNS_NEW(child_type, size);\ else {\ if (cg->mode == CG_MODE_WRITE) error1=1;\ else parent_id = parent->id;\ }\ }\ child = parent->child;\ } #define NDESCRIPTOR(parent_type) {\ parent_type *parent = (parent_type *)posit->posit;\ (*ndescriptors)= parent->ndescr;\ } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Macros, moved from cgnslib.h * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define CGNS_NEW(type,size) (type *)cgi_malloc((size_t)(size),sizeof(type)) #define CGNS_RENEW(type,size,old) (type *)cgi_realloc(old,(size_t)(size)*sizeof(type)) #define CGNS_FREE(data) free(data); #define INVALID_ENUM(E,EMAX) ((int)(E)<0 || (int)(E)>=(EMAX)) #define DEBUG_FILE 0 #define DEBUG_BASE 0 #define DEBUG_ZONE 0 #define DEBUG_SORT 0 #define DEBUG_ARRAY 0 #define DEBUG_SOL 0 #define DEBUG_HOLE 0 #define DEBUG_CONN 0 #define DEBUG_1TO1 0 #define DEBUG_BOCO 0 #define DEBUG_GOTO 0 #define DEBUG_FTOC 0 #define DEBUG_VERSION 0 #define DEBUG_LINKS 0 #define SKIP_DATA 0 #define READ_DATA 1 #define CG_MODE_CLOSED 99 /* flag for parallel reading or parallel writing */ typedef enum { CGI_Read, CGI_Write } cgi_rw; /* * Internal Structures: */ /* Note that the link information held in these structs are only needed ** until the CGNS file is written. At that point the ADF link mechanism ** takes over and reading/modifying linked nodes is transparent to this ** API. */ typedef struct { char *filename; /* filename to use for the link; empty if within file */ char *name_in_file; /* path of the node which the link will point to */ } cgns_link; /* V2.1 */ typedef struct { /* Descriptor_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ char *text; /* Copy of Descriptor data */ } cgns_descr; /* CPEX 0033 */ typedef struct { double id; char_33 name; char_md family; /* ** FAMILY TREE ** */ } cgns_famname; typedef struct { /* DimensionalUnits_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int nunits; /* number of units (5 or 8) */ CGNS_ENUMT(MassUnits_t) mass; CGNS_ENUMT(LengthUnits_t) length; CGNS_ENUMT(TimeUnits_t) time; CGNS_ENUMT(TemperatureUnits_t) temperature; CGNS_ENUMT(AngleUnits_t) angle; CGNS_ENUMT(ElectricCurrentUnits_t) current; CGNS_ENUMT(SubstanceAmountUnits_t) amount; CGNS_ENUMT(LuminousIntensityUnits_t) intensity; } cgns_units; typedef struct { /* DimensionalExponents_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ char_33 data_type; /* type of data */ void *data; /* MassExponent, LengthExponent, TimeExponent, TemperatureExponent, AngleExponent */ /* ElecCurrentExponent, MoleExponent, LumIntensityExponent */ int nexps; /* number of exponents written */ } cgns_exponent; typedef struct { /* DataConversion_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ char_33 data_type; /* type of data */ void *data; /* ConversionScale, ConversionOffset */ } cgns_conversion; typedef struct { /* DataArray_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ char_33 data_type; /* type of data */ int data_dim; /* number of dimensions */ cgsize_t dim_vals[12]; /* Size in each dimension */ void *data; /* data */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ cgns_exponent *exponents;/* ptrs to in-memory copy of exponents */ cgns_conversion *convert;/* ptrs to in-memory copy of convert */ cgsize_t range[2]; /* index range for currently stored data*/ } cgns_array; typedef struct { /* IndexArray/Range_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ CGNS_ENUMT(PointSetType_t) type; /* PointList, PointRange, ... */ char_33 data_type; /* type of data */ cgsize_t npts; /* number of points to define the patch */ cgsize_t size_of_patch; /* nr of nodes or elements in patch */ void *data; /* data (only loaded in MODE_MODIFY */ } cgns_ptset; /* when version mismatch) */ typedef struct cgns_user_data_s /* UserDefinedData_t Node */ { char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* No of DataArray_t nodes */ cgns_array *array; /* ptrs to in-mem. copy of Data Arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ CGNS_ENUMT(GridLocation_t) location;/* Grid location where data is recorded */ char_md family_name; /* Family name */ /* ** FAMILY TREE ** */ int ordinal; /* option to specify a rank */ cgns_ptset *ptset; /* PointList, PointRange */ int nuser_data; /* number of user defined data nodes */ struct cgns_user_data_s *user_data; /* User defined data. */ /* CPEX 0034 */ int nfamname; cgns_famname *famname; } cgns_user_data; /* V2.1 */ typedef struct { /* IntegralData_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* number of data arrays */ cgns_array *array; /* ptrs to in-memory copies of data_arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_integral; typedef struct { /* DiscreteData_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ cgns_ptset *ptset; /* PointList, PointRange */ CGNS_ENUMT(GridLocation_t) location;/* Grid location where data is recorded*/ int *rind_planes; /* No. of rind-planes on each zone face */ int narrays; /* number of data arrays */ cgns_array *array; /* ptrs to in-memory copies of data_arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_discrete; typedef struct { /* ConvergenceHistory_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int iterations; /* no of iterations */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ cgns_descr *NormDefinitions; /* Document the norms */ int narrays; /* number of data arrays */ cgns_array *array; /* ptrs to in-memory copies of data_arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_converg; typedef struct { /* ReferenceState_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ cgns_descr *StateDescription;/* ReferenceStateDescription */ int narrays; /* number of data arrays */ cgns_array *array; /* ptrs to in-memory copies of data_arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_state; typedef struct { /* Gravity_t node */ /* V2.2 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* should be 0 or 1 */ cgns_array *vector; /* ptrs to in-memory copy of GravityVector */ CGNS_ENUMT(DataClass_t)data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_gravity; typedef struct { /* Axisymmetry_t node */ /* V2.2 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* should be 2, 3 or 4 */ cgns_array *array; /* ptrs to in-memory copy of data arrays*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_axisym; typedef struct { /* RotatingCoordinates_t node */ /* V2.2 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* should be 2, 3 or 4 */ cgns_array *array; /* ptrs to in-memory copy of data arrays*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_rotating; typedef struct { /* WallFunction_t node */ /* V2.2 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(WallFunctionType_t) type;/* Type of wall function */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_bcwall; typedef struct { /* Area_t node */ /* V2.2 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(AreaType_t) type; /* type of area */ int narrays; /* should be 2 */ cgns_array *array; /* ptrs to in-memory copy of data arrays*/ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_bcarea; typedef struct { /* BCProperty_t node */ /* V2.2 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ cgns_bcwall *bcwall; /* ptrs to in-memory copy of bcwall */ cgns_bcarea *bcarea; /* ptrs to in-memory copy of bcarea */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_bprop; typedef struct { /* Periodic_t node */ /* V2.2 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* should be 3 */ cgns_array *array; /* ptrs to in-memory copy of data arrays*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_cperio; typedef struct { /* AverageInterface_t node */ /* V2.2 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(AverageInterfaceType_t) type; /* type of interface */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_caverage; typedef struct { /* GridConnectivityProperty_t */ /* V2.2 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ cgns_cperio *cperio; /* ptrs to in-memory copy of cperio */ cgns_caverage *caverage;/* ptrs to in-memory copy of caverage */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_cprop; typedef struct { /* xxx Model_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ CGNS_ENUMT(ModelType_t) type; int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* No of DataArray_t nodes */ cgns_array *array; /* ptrs to in-mem. copy of Data Arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int *diffusion_model; /* only for turbulence model. */ int dim_vals; /* dim. value for diffusion_model */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_model; typedef struct { /* xxx ParticleModel_t node */ /* CPEX 0046 V4.5 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ CGNS_ENUMT(ParticleModelType_t) type; int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* No of DataArray_t nodes */ cgns_array *array; /* ptrs to in-mem. copy of Data Arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int dim_vals; /* dim. value for diffusion_model */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_pmodel; typedef struct { /* GoverningEquations_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ CGNS_ENUMT(GoverningEquationsType_t) type; int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int *diffusion_model; int dim_vals; /* dim. value for diffusion_model */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_governing; typedef struct { /* FlowEquationSet_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int equation_dim; /* dimensionality of the governing equations */ cgns_governing *governing; /* ptrs to in-mem. copy of GoverningEquations */ cgns_model *gas; /* ptrs to in-mem. copy of GasModel */ cgns_model *visc; /* ptrs to in-mem. copy of ViscosityM. */ cgns_model *conduct; /* ptrs to in-mem. copy of ThermalCond. */ cgns_model *closure; /* ptrs to in-mem. copy of Turb.Closure */ cgns_model *turbulence; /* ptrs to in-mem. copy of TurbulenceM. */ cgns_model *relaxation; /* ptrs to in-mem. copy of ThermalRelaxation . */ cgns_model *chemkin; /* ptrs to in-mem. copy of ChemicalKinetics. */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ cgns_model *elecfield; /* ptrs to in-mem. copy of EMElecFieldM. */ cgns_model *magnfield; /* ptrs to in-mem. copy of EMMagneticFieldM. */ cgns_model *emconduct; /* ptrs to in-mem. copy of EMConductivityM. */ } cgns_equations; typedef struct { /* ParticleGoverningEquations_t node */ /* CPEX 0046 V4.5 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ CGNS_ENUMT(ParticleGoverningEquationsType_t) type; int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_pgoverning; typedef struct { /* ParticleEquationSet_t Node */ /* CPEX 0046 V4.5 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int equation_dim; /* dimensionality of the governing equations */ cgns_pgoverning *governing; /* ptrs to in-mem. copy of ParticleGoverningEquations */ cgns_pmodel *collision; /* ptrs to in-mem. copy of ParticleCollisionM. */ cgns_pmodel *breakup; /* ptrs to in-mem. copy of ParticleBreakupM. */ cgns_pmodel *force; /* ptrs to in-mem. copy of ParticleForceM. */ cgns_pmodel *wallinteract; /* ptrs to in-mem. copy of ParticleWallInteractionM. */ cgns_pmodel *phasechange; /* ptrs to in-mem. copy of ParticlePhaseChnageM. */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* ptrs to in-memory copy of units */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_pequations; typedef struct { /* BCData_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* no. of global data arrays */ cgns_array *array; /* ptrs to in-mem. copy of local data */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_bcdata; typedef struct { /* BCDataSet_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(BCType_t) type;/* type of boco */ cgns_bcdata *dirichlet; /* ptrs to in-mem. copy of DirichletData*/ cgns_bcdata *neumann; /* ptrs to in-mem. copy of NeumannData */ cgns_state *state; /* ptrs to in-memory copies of Ref.state*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ CGNS_ENUMT(GridLocation_t) location;/* Grid location where data is recorded */ cgns_ptset *ptset; /* PointList, PointRange */ } cgns_dataset; typedef struct { /* Elements_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(ElementType_t) el_type; /* element type */ int el_bound; /* nr of bound. el. if sorted, else 0 */ cgsize_t range[2]; /* index of first and last element */ int *rind_planes; /* No. of rind-elements */ cgns_array *connect; /* ElementConnectivity */ cgns_array *connect_offset; /* ElementStartOffset */ cgns_array *parelem; /* ParentElements */ cgns_array *parface; /* ParentElementsPosition */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_section; typedef struct { /* BC_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(GridLocation_t) location;/* Grid location */ CGNS_ENUMT(BCType_t) type; /* type of boco */ cgns_ptset *ptset; /* PointList, PointRange */ char_md family_name; /* Family name for the bound. patch */ /* ** FAMILY TREE ** */ int *Nindex; /* Inward Normal Index */ double index_id; /* ADF ID number of InwardNormalIndex */ cgns_array *normal; /* Inward Normal List */ int ndataset; /* no of BCDataSet nodes */ cgns_dataset *dataset; /* ptrs to in-mem. copy of BCDataSet */ cgns_bprop *bprop; /* ptrs to in-mem. copy of BCProperty_t */ /* V2.2 */ cgns_state *state; /* ptrs to in-memory copies of Ref.state*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int ordinal; /* option to define a rank */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ /* CPEX 0034 */ int nfamname; cgns_famname *famname; } cgns_boco; typedef struct { /* ZoneBC_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int nbocos; /* number of BC_t nodes */ cgns_boco *boco; /* ptrs to in-memory copies of bocos */ cgns_state *state; /* ptrs to in-memory copies of Ref.state*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_zboco; typedef struct { /* OversetHoles_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(GridLocation_t) location;/* Grid location */ int nptsets; /* Number of point-sets */ cgns_ptset *ptset; /* any no of PointList and/or PointRange*/ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_hole; typedef struct { /* GridConnectivity_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(GridConnectivityType_t) type; /*Overset, Abutting or Abutting1to1*/ CGNS_ENUMT(GridLocation_t) location;/* Grid location */ cgns_ptset ptset; /* PointList or PointRange */ cgns_ptset dptset; /* PointListDonor or CellListDonor */ int narrays; /* should be 0 or 1 */ cgns_array *interpolants;/* InterpolantsDonor */ char_66 donor; /* donor name */ cgns_cprop *cprop; /* ptrs to in-memory copies of cprop */ /* V2.2 */ int ordinal; /* option to specify a rank */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_conn; typedef struct { /* GridConnectivity1to1_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int *transform; /* short form of transformation matrix */ cgns_ptset ptset; /* PointRange */ cgns_ptset dptset; /* PointRangeDonor */ char_md donor; /* donor name */ int ordinal; /* option to specify a rank */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ cgns_cprop *cprop; /* ptrs to in-memory copies of cprop */ } cgns_1to1; typedef struct { /* ZoneGridConnectivity_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int n1to1; /* number of GridConnectivity1to1 nodes */ cgns_1to1 *one21; /* ptrs to in-memory copies of one21 */ int nconns; /* number of GridConnectivity_t nodes */ cgns_conn *conn; /* ptrs to in-memory copies of conns */ int nholes; /* number of OversetHoles_t nodes */ cgns_hole *hole; /* ptrs to in-memory copies of holes */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_zconn; typedef struct { /* FlowSolution_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ cgns_ptset *ptset; /* PointList, PointRange */ CGNS_ENUMT(GridLocation_t) location;/* Grid location type */ int *rind_planes; /* No. of rind-planes on each zone face */ int nfields; /* number of flow solution arrays */ cgns_array *field; /* ptrs to in-memory copies of sol.field*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_sol; typedef struct { /* GridCoordinates_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int *rind_planes; /* No. of rind-planes on each zone face */ int ncoords; /* number of coordinates arrays */ cgns_array *coord; /* ptrs to in-mem. copy of coord-arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_zcoor; typedef struct { /* RigidGridMotion_t node */ /* V2.0 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(RigidGridMotionType_t) type; /* type of rigid motion */ int narrays; /* no. of data arrays */ cgns_array *array; /* ptrs to in-mem. copy of local data */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_rmotion; typedef struct { /* ArbitraryGridMotion_t node */ /* V2.0 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(ArbitraryGridMotionType_t) type;/* type of arbitrary motion */ CGNS_ENUMT(GridLocation_t) location;/* Grid location type */ int *rind_planes; /* No. of rind-planes on each zone face */ int narrays; /* no. of data arrays */ cgns_array *array; /* ptrs to in-mem. copy of misc. arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_amotion; typedef struct { /* ZoneIterativeData_t node */ /* V2.0 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* no. of data arrays */ cgns_array *array; /* ptrs to in-mem. copy of misc. arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_ziter; typedef struct { /* BaseIterativeData_t node */ /* V2.0 */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int nsteps; /* NumberOfSteps */ int narrays; /* no. of data arrays */ cgns_array *array; /* ptrs to in-mem. copy of misc. arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_biter; typedef struct { /* ZoneSubRegion_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int reg_dim; /* nr of indices to specify a node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int narrays; /* no. of data arrays */ cgns_array *array; /* ptrs to in-mem. copy of misc. arrays */ cgns_ptset *ptset; /* PointList, PointRange */ cgns_descr *bcname; /* BC_t node name */ cgns_descr *gcname; /* GridConnectivity node name */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ CGNS_ENUMT(GridLocation_t) location;/* Grid location where data is recorded */ char_md family_name; /* Family name */ /* ** FAMILY TREE ** */ int *rind_planes; /* No. of rind-planes on each zone face */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ /* CPEX 0034 */ int nfamname; cgns_famname *famname; } cgns_subreg; typedef struct { /* Zone_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ CGNS_ENUMT(ZoneType_t) type; /* Structured or Unstructured */ int index_dim; /* nr of indices to specify a node */ cgsize_t *nijk; /* size of zone in vertex and cells */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int nzcoor; /* no of GridCoordinates_t nodes */ /* V2.0 */ cgns_zcoor *zcoor; /* ptrs to in-memory copies of coords */ int nsections; /* no of Elements_t nodes */ cgns_section *section; /* ptrs to in-memory copies of section */ char_md family_name; /* family name of the unstr. zone */ /* ** FAMILY TREE ** */ int nsols; /* number of FlowSolution_t nodes */ cgns_sol *sol; /* ptrs to in-memory copies of sols */ int ndiscrete; /* number of DiscreteData_t nodes */ cgns_discrete *discrete;/* ptrs to in-memory copy of discrete */ int nintegrals; /* number of IntegralData_t nodes */ cgns_integral *integral;/* ptrs to in-memory copy of integral */ /* version 3.2 - multiple ZoneGridConnectivity_t */ int active_zconn; /* currently active zconn */ int nzconn; /* no of ZoneGridConnectivity_t nodes */ cgns_zconn *zconn; /* ptrs to in-mem. copy of ZoneGridConn.*/ cgns_zboco *zboco; /* ptrs to in-memory copies of ZoneBC */ cgns_state *state; /* ptrs to in-memory copies of Ref.state*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ cgns_equations *equations;/* ptrs to in-mem. copy of FlowEqu. */ cgns_converg *converg; /* ptrs to in-mem. copy of Conv.Hist. */ int ordinal; /* option to assign a rank */ int nrmotions; /* number of RigidGridMotion_t nodes */ /* V2.0 */ cgns_rmotion *rmotion; /* ptrs to in-mem. copy of RigidGridMot.*/ /* V2.0 */ int namotions; /* number of ArbitraryGridMotion_t nodes*/ /* V2.0 */ cgns_amotion *amotion; /* ptrs to in-mem. copy of Arb.GridMot. */ /* V2.0 */ cgns_ziter *ziter; /* ptrs to in-mem. copies of ZoneIter. */ /* V2.0 */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ cgns_rotating *rotating;/* ptrs to in-memory copy of Rot. Coord.*/ /* V2.2 */ /* version 3.2 */ int nsubreg; /* num subregions */ cgns_subreg *subreg; /* subregion ptrs */ /* CPEX 0034 */ int nfamname; cgns_famname *famname; } cgns_zone; typedef struct { /* */ char_33 name; /* name of Geometry part */ double id; /* ADF ID */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ } cgns_part; typedef struct { /* GeometryReference_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ char *file; /* name of geometry file */ char_33 format; /* name of geometry format */ int npart; /* number of geo. entities */ cgns_part *part; /* list of geometry entities */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ } cgns_geo; typedef struct { /* FamilyBC_t node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ CGNS_ENUMT(BCType_t) type;/* type of boco */ int ndataset; /* no of BCDataSet nodes */ cgns_dataset *dataset; /* ptrs to in-mem. copy of BCDataSet */ } cgns_fambc; typedef struct cgns_family_s { /* Family_t node */ char_33 name; /* Family name & name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ /* V2.1 */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int nfambc; /* number of FamilyBC_t nodes */ cgns_fambc *fambc; /* FamilyBC */ int ngeos; /* no of GeometryReference_t nodes */ cgns_geo *geo; /* Geometry reference */ int ordinal; /* option to assign a rank */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ cgns_rotating *rotating;/* ptrs to in-memory copy of Rot. Coord.*/ /* CPEX 0033 */ int nfamname; cgns_famname *famname; /* ** FAMILY TREE ** */ int nfamilies; struct cgns_family_s* family; } cgns_family; typedef struct { /* ParticleCoordinates_t node */ /* CPEX 0046 V4.5*/ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int ncoords; /* number of coordinates arrays */ cgns_array *coord; /* ptrs to in-mem. copy of coord-arrays */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_pcoor; typedef struct { /* ParticleSolution_t node */ /* CPEX 0046 V4.5*/ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ cgns_ptset *ptset; /* PointList, PointRange */ int nfields; /* number of particle solution arrays */ cgns_array *field; /* ptrs to in-memory copies of sol.field*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ } cgns_psol; typedef struct { /* ParticleZone_t node */ /* CPEX 0046 V4.5*/ char_33 name; /* Particle zone name and name of ADF node */ double id; /* ADF ID number (address) of node */ cgsize_t nparticles; /* number of particles in this node */ int npcoor; /* number of ParticleCoordinate_t nodes */ cgns_pcoor *pcoor; /* ptrs to in-memory copies of pcoor */ cgns_link *link; /* link information */ int in_link; /* set if child of a linked node */ int nfamname; /* number of AdditionalFamily_t nodes */ cgns_famname *famname; /* ptrs to in-memory copies of famnames */ /* FAMILY TREE */ char_md family_name; /* Family_t node name */ cgns_state *state; /* ptrs to in-memory copies of Ref.state*/ int nsols; /* number of ParticleSolution_t nodes */ cgns_psol *sol; /* ptrs to in-memory copies of sols */ int ndescr; /* number of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_pequations *equations;/* ptrs to in-mem. copy of ParticleEqu. */ cgns_units *units; /* Dimensional Units */ int nintegrals; /* number of IntegralData_t nodes */ cgns_integral *integral; /* ptrs to in-memory copy of integral */ cgns_ziter *piter; /* ptrs to in-mem. copies of ParticleIter. */ int nuser_data; /* number of user defined data nodes */ cgns_user_data *user_data; /* User defined data. */ }cgns_pzone; typedef struct { /* CGNSBase_t Node */ char_33 name; /* name of ADF node */ double id; /* ADF ID number (address) of node */ int cell_dim; /* highest cell dimension */ int phys_dim; /* nr of coordinates to specify a node */ int ndescr; /* no of Descriptor_t nodes */ cgns_descr *descr; /* ptrs to in-memory copy of descr */ int nzones; /* number of zones in base */ cgns_zone *zone; /* ptrs to in-memory copies of zones */ cgns_hashmap_object *zonemap; /* hashmap to check for duplicate zone names */ int nfamilies; /* number of families */ cgns_family *family; /* ptrs to in-memory copies of families */ cgns_state *state; /* ptrs to in-memory copies of Ref.state*/ CGNS_ENUMT(DataClass_t) data_class; /* Class of data */ cgns_units *units; /* Dimensional Units */ cgns_equations *equations; /* ptrs to in-mem. copy of FlowEqu. */ cgns_pequations *pequations; /* ptr to in-mem. copy of ParticleEqu. */ /* V4.5*/ cgns_converg *converg; /* ptrs to in-mem. copy of Conv.Hist. */ int nintegrals; /* no of IntegralData_t nodes */ cgns_integral *integral;/* ptrs to in-mem. copy of integral data*/ cgns_biter *biter; /* ptrs to in-mem. copy of BaseIter. */ /* V2.0 */ CGNS_ENUMT(SimulationType_t) type; /* Simulation type */ /* V2.0 */ double type_id; /* ADF ID number of SimulationType_t */ /* V2.0 */ int nuser_data; /* number of user defined data nodes */ /* V2.1 */ cgns_user_data *user_data; /* User defined data. */ /* V2.1 */ cgns_gravity *gravity; /* ptrs to in-memory copy of gravity */ /* V2.2 */ cgns_axisym *axisym; /* ptrs to in-memory copy of Axisymmetry*/ /* V2.2 */ cgns_rotating *rotating;/* ptrs to in-memory copy of Rot. Coord.*/ /* V2.2 */ int npzones; /* number of ParticleZone_t nodes */ /* V4.5 */ cgns_pzone *pzone; /* ptrs to in-memory copy of ParticleZone_t nodes */ /* V4.5 */ cgns_hashmap_object *pzonemap; /* hashmap to check duplicate particle zone names */ /* V4.5 */ } cgns_base; typedef struct { char *filename; /* name of file */ int filetype; /* type of file */ int version; /* version of the CGNS file * 1000 */ int cgio; /* index of I/O control */ double rootid; /* root ID of file */ int mode; /* reading or writing */ int file_number; /* external identifier */ int deleted; /* number of deleted nodes */ int added; /* number of added nodes */ char_33 dtb_version; /* ADF Database Version */ char_33 creation_date; /* creation date of the file */ char_33 modify_date; /* last modification date of the file */ char_33 adf_lib_version;/* ADF Library Version */ int nbases; /* number of bases in the file */ cgns_base *base; /* ptrs to in-memory copies of bases */ } cgns_file; typedef struct { void *posit; char label[33]; int index; double id; } cgns_posit; #ifdef __cplusplus extern "C" { #endif /* * Extern variables */ extern cgns_file *cgns_files; extern cgns_file *cg; /* current file */ extern int n_cgns_files; extern int file_number_offset; extern int CGNSLibVersion; /* CGNSLib Version number */ /* goto stuff */ extern cgns_posit *posit; extern int posit_file, posit_base, posit_zone; extern int posit_depth; extern cgns_posit posit_stack[CG_MAX_GOTO_DEPTH+1]; /* * Internal Functions */ CGNSDLL void *cgi_malloc(size_t cnt,size_t size); CGNSDLL void *cgi_realloc(void *old,size_t bytes); /* retrieve addresses of nodes who may have children */ CGNSDLL cgns_file *cgi_get_file (int file_number); CGNSDLL cgns_base *cgi_get_base (cgns_file *cg, int B); CGNSDLL cgns_zone *cgi_get_zone (cgns_file *cg, int B, int Z); CGNSDLL cgns_family *cgi_get_family (cgns_file *cg, int B, int F); CGNSDLL cgns_biter *cgi_get_biter (cgns_file *cg, int B); CGNSDLL cgns_gravity *cgi_get_gravity(cgns_file *cg, int B); CGNSDLL cgns_axisym *cgi_get_axisym (cgns_file *cg, int B); CGNSDLL cgns_ziter *cgi_get_ziter (cgns_file *cg, int B, int Z); CGNSDLL cgns_zcoor *cgi_get_zcoor (cgns_file *cg, int B, int Z, int C); CGNSDLL cgns_zcoor *cgi_get_zcoorGC(cgns_file *cg, int B, int Z); CGNSDLL cgns_section *cgi_get_section(cgns_file *cg, int B, int Z, int S); CGNSDLL cgns_sol *cgi_get_sol (cgns_file *cg, int B, int Z, int S); CGNSDLL cgns_array *cgi_get_field (cgns_file *cg, int B, int Z, int S, int F); CGNSDLL cgns_zconn *cgi_get_zconnZC(cgns_file *cg, int B, int Z, int C); CGNSDLL cgns_zconn *cgi_get_zconn (cgns_file *cg, int B, int Z); CGNSDLL cgns_hole *cgi_get_hole (cgns_file *cg, int B, int Z, int J); CGNSDLL cgns_conn *cgi_get_conn (cgns_file *cg, int B, int Z, int J); CGNSDLL cgns_1to1 *cgi_get_1to1 (cgns_file *cg, int B, int Z, int J); CGNSDLL cgns_zboco *cgi_get_zboco (cgns_file *cg, int B, int Z); CGNSDLL cgns_boco *cgi_get_boco (cgns_file *cg, int B, int Z, int BC); CGNSDLL cgns_dataset *cgi_get_dataset(cgns_file *cg, int B, int Z, int BC, int DSet); CGNSDLL cgns_bcdata *cgi_get_bcdata (cgns_file *cg, int B, int Z, int BC, int Dset, CGNS_ENUMT(BCDataType_t) type); CGNSDLL cgns_model *cgi_get_model (cgns_file *cg, int B, int Z, char *model); CGNSDLL cgns_state *cgi_get_state (cgns_file *cg, int B, int Z, int P, int ZBC, int BC, int Dset); CGNSDLL cgns_converg *cgi_get_converg(cgns_file *cg, int B, int Z); CGNSDLL cgns_equations *cgi_get_equations(cgns_file *cg, int B, int Z); CGNSDLL cgns_governing *cgi_get_governing(cgns_file *cg, int B, int Z); CGNSDLL cgns_integral *cgi_get_integral (cgns_file *cg, int B, int Z, int N); CGNSDLL cgns_discrete *cgi_get_discrete (cgns_file *cg, int B, int Z, int D); CGNSDLL cgns_rmotion *cgi_get_rmotion (cgns_file *cg, int B, int Z, int R); CGNSDLL cgns_amotion *cgi_get_amotion (cgns_file *cg, int B, int Z, int R); CGNSDLL cgns_rotating *cgi_get_rotating (cgns_file *cg, int B, int Z); CGNSDLL cgns_bprop *cgi_get_bprop (cgns_file *cg, int B, int Z, int BC); CGNSDLL cgns_cprop *cgi_get_cprop (cgns_file *cg, int B, int Z, int J); CGNSDLL cgns_subreg *cgi_get_subreg (cgns_file *cg, int B, int Z, int S); CGNSDLL cgns_pzone *cgi_get_particle (cgns_file *cg, int B, int P); CGNSDLL cgns_pcoor *cgi_get_particle_pcoor (cgns_file *cg, int B, int P, int C); CGNSDLL cgns_pcoor *cgi_get_particle_pcoorPC (cgns_file* cg, int B, int P); CGNSDLL cgns_psol *cgi_get_particle_sol (cgns_file *cg, int B, int P, int S); CGNSDLL cgns_array *cgi_get_particle_field (cgns_file *cg, int B, int P, int S, int F); CGNSDLL cgns_ziter *cgi_get_piter (cgns_file *cg, int B, int P); CGNSDLL cgns_pgoverning *cgi_get_particle_governing(cgns_file *cg, int B, int P); CGNSDLL cgns_pequations *cgi_get_particle_equations(cgns_file *cg, int B, int P); /* find position lead by the goto function */ CGNSDLL int cgi_update_posit(int cnt, int *index, char **label); CGNSDLL int cgi_set_posit(int fn, int B, int n, int *index, char **label); CGNSDLL int cgi_posit_id(double *posit_id); CGNSDLL cgns_posit *cgi_get_posit(void); CGNSDLL int cgi_posit_index_dim(void); /* retrieve memory address of multiple patch children knowing their parent label (posit_label) and their parent memory address (posit) */ cgns_descr *cgi_descr_address(int local_mode, int descr_no, char const *descr_name, int *ier); CGNS_ENUMT(DataClass_t) *cgi_dataclass_address(int local_mode, int *ier); cgns_units *cgi_units_address(int local_mode, int *ier); int *cgi_ordinal_address(int local_mode, int *ier); int *cgi_rind_address(int local_mode, int *ier); CGNS_ENUMT(GridLocation_t) *cgi_location_address(int local_mode, int *ier); cgns_conversion *cgi_conversion_address(int local_mode, int *ier); cgns_exponent *cgi_exponent_address(int local_mode, int *ier); cgns_integral *cgi_integral_address(int local_mode, int integral_no, char const *integral_name, int *ier); cgns_equations *cgi_equations_address(int local_mode, int *ier); cgns_state *cgi_state_address(int local_mode, int *ier); cgns_converg *cgi_converg_address(int local_mode, int *ier); cgns_governing *cgi_governing_address(int local_mode, int *ier); int *cgi_diffusion_address(int local_mode, int *ier); cgns_array *cgi_array_address(int local_mode, int allow_dup, int array_no, char const *array_name, int* have_dup, int *ier); cgns_model *cgi_model_address(int local_mode, char const *ModelLabel, int *ier); char *cgi_famname_address(int local_mode, int *ier); cgns_famname *cgi_multfam_address(int mode, int num, char const *name, int *ier); cgns_user_data *cgi_user_data_address(int local_mode, int given_no, char const *given_name, int *ier); cgns_family *cgi_family_address(int local_node, int given_no, char const *given_name, int *ier); /* ** FAMILY TREE ** */ cgns_rotating *cgi_rotating_address(int local_mode, int *ier); cgns_ptset *cgi_ptset_address(int local_mode, int *ier); cgns_dataset * cgi_bcdataset_address(int local_mode, int given_no, char const *given_name, int *ier); cgns_pequations *cgi_particle_equations_address(int local_mode, int *ier); cgns_pgoverning *cgi_particle_governing_address(int local_mode, int *ier); cgns_pmodel *cgi_particle_model_address(int local_mode, char const *ModelLabel, int *ier); /* read CGNS file into internal database */ int cgi_read(void); int cgi_read_base(cgns_base *base); int cgi_read_zone(cgns_zone *zone); int cgi_read_zonetype(double parent_id, char_33 parent_name, CGNS_ENUMT(ZoneType_t) *type); int cgi_read_family(cgns_family *family); int cgi_read_family_dataset(int in_link, double parent_id, int *ndataset, cgns_dataset **dataset); int cgi_read_family_name(int in_link, double parent_id, char_33 parent_name, char_md family_name); /** FAMILY TREE **/ int cgi_read_array(cgns_array *array, char *parent_label, double parent_id); int cgi_read_section(int in_link, double parent_id, int *nsections, cgns_section **section); int cgi_read_hole(cgns_hole *hole); int cgi_read_conn(cgns_conn *conn); int cgi_read_1to1(cgns_1to1 *one21); int cgi_read_one_ptset(int linked, double parent_id, cgns_ptset **ptset); int cgi_read_ptset(double parent_id, cgns_ptset *ptset); int cgi_read_string(double id, char_33 name, char **string_data); int cgi_read_boco(cgns_boco *boco); int cgi_read_location(double parent_id, char_33 parent_name, CGNS_ENUMT(GridLocation_t) *location); int cgi_read_state(int in_link, double parent_id, cgns_state **state); int cgi_read_converg(int in_link, double parent_id, cgns_converg **converg); int cgi_read_units(int in_link, double parent_id, cgns_units **units); int cgi_read_equations(int in_link, double parent_id, cgns_equations **equations); int cgi_read_model(int in_link, double parent_id, char *label, cgns_model **model); int cgi_read_conversion(int in_link, double parent_id, cgns_conversion **convert); int cgi_read_exponents(int in_link, double parent_id, cgns_exponent **exponents); int cgi_read_integral(int in_link, double parent_id, int *nintegrals, cgns_integral **integral); int cgi_read_discrete(int in_link, double parent_id, int *ndiscrete, cgns_discrete **discrete); int cgi_read_sol(int in_link, double parent_id, int *nsols, cgns_sol **sol); int cgi_read_zcoor(int in_link, double parent_id, int *nzcoor, cgns_zcoor **zcoor); int cgi_read_zconn(int in_link, double parent_id, int *nzconn, cgns_zconn **zconn); int cgi_read_zboco(int in_link, double parent_id, cgns_zboco **zboco); int cgi_read_dataset(int in_link, double parent_id, int *ndataset, cgns_dataset **dataset); int cgi_read_bcdata(cgns_bcdata *bcdata); int cgi_read_rind(double parent_id, int **rind_planes); int cgi_read_ordinal(double parent_id, int *ordinal); int cgi_read_DDD(int in_link, double parent_id, int *ndescr, cgns_descr **descr, CGNS_ENUMT(DataClass_t) *data_class, cgns_units **units); int cgi_read_rmotion(int in_link, double parent_id, int *nrmotions, cgns_rmotion **rmotion); int cgi_read_amotion(int in_link, double parent_id, int *namotions, cgns_amotion **amotion); int cgi_read_simulation(double parent_id, CGNS_ENUMT(SimulationType_t) *type, double *type_id); int cgi_read_biter(int in_link, double parent_id, cgns_biter **biter); int cgi_read_ziter(int in_link, double parent_id, cgns_ziter **ziter); int cgi_read_gravity(int in_link, double parent_id, cgns_gravity **gravity); int cgi_read_axisym(int in_link, double parent_id, cgns_axisym **axisym); int cgi_read_rotating(int in_link, double parent_id, cgns_rotating **rotating); int cgi_read_bprop(int in_link, double parent_id, cgns_bprop **bprop); int cgi_read_cprop(int in_link, double parent_id, cgns_cprop **cprop); int cgi_read_user_data(int in_link, double parent_id, int *nuser_data, cgns_user_data **user_data); int cgi_read_subregion(int in_link, double parent_id, int *nsubreg, cgns_subreg **subreg); cgns_link *cgi_read_link(double node_id); CGNSDLL int cgi_datasize(int ndim, cgsize_t *dims, CGNS_ENUMT(GridLocation_t) location, int *rind_planes, cgsize_t *DataSize); int cgi_read_node(double node_id, char_33 name, char_33 data_type, int *ndim, cgsize_t *dim_vals, void **data, int data_flag); int cgi_read_node_data(double node_id, char_33 data_type, int* ndim, cgsize_t* dim_vals, void** data); CGNSDLL int cgi_get_nodes(double parent_id, char *label, int *nnodes, double **id); int cgi_read_particle(cgns_pzone *pzone); int cgi_read_particle_sol(int in_link, double parent_id, int *nsols, cgns_psol **sol); int cgi_read_particle_pcoor(int in_link, double parent_id, int *npcoor, cgns_pcoor **pcoor); int cgi_read_piter(int in_link, double parent_id, cgns_ziter **piter); int cgi_read_particle_model(int in_link, double parent_id, char *label, cgns_pmodel **model); int cgi_read_particle_equations(int in_link, double parent_id, cgns_pequations **equations); /* write ADF file from internal database */ int cgi_write(int file_number); int cgi_write_zone(double parent_id, cgns_zone *zone); int cgi_write_family(double parent_id, cgns_family *family); int cgi_write_zcoor(double parent_id, cgns_zcoor *zcoor); int cgi_write_section(double parent_id, cgns_section *section); int cgi_write_sol(double parent_id, cgns_sol *sol); int cgi_write_zconn(double parent_id, cgns_zconn *zconn); int cgi_write_1to1(double parent_id, cgns_1to1 *one21); int cgi_write_conns(double parent_id, cgns_conn *conn); int cgi_write_holes(double parent_id, cgns_hole *hole); int cgi_write_zboco(double parent_id, cgns_zboco *zboco); int cgi_write_boco(double parent_id, cgns_boco *boco); int cgi_write_dataset(double parent_id, const char *label, cgns_dataset *dataset); int cgi_write_bcdata(double bcdata_id, cgns_bcdata *bcdata); int cgi_write_ptset(double id, char *name, cgns_ptset *ptset, int ndim, void *ptset_ptr); int cgi_write_equations(double parent_id, cgns_equations *equations); int cgi_write_model(double parent_id, cgns_model *model); int cgi_write_state(double parent_id, cgns_state *state); int cgi_write_converg(double parent_id, cgns_converg *converg); int cgi_write_discrete(double parent_id, cgns_discrete *discrete); int cgi_write_integral(double parent_id, cgns_integral *integral); CGNSDLL int cgi_write_array(double parent_id, cgns_array *array); int cgi_write_rind(double parent_id, int *rind_planes, int idim); int cgi_write_units(double parent_id, cgns_units *units); int cgi_write_exponents(double parent_id, cgns_exponent *exponents); CGNSDLL int cgi_write_dataclass(double parent_id, CGNS_ENUMT(DataClass_t) data_class); int cgi_write_descr(double parent_id, cgns_descr *descr); CGNSDLL int cgi_write_ordinal(double parent_id, int ordinal); int cgi_write_rmotion(double parent_id, cgns_rmotion *rmotion); int cgi_write_amotion(double parent_id, cgns_amotion *amotion); int cgi_write_biter(double parent_id, cgns_biter *biter); int cgi_write_ziter(double parent_id, cgns_ziter *ziter); int cgi_write_gravity(double parent_id, cgns_gravity *gravity); int cgi_write_axisym(double parent_id, cgns_axisym *axisym); int cgi_write_rotating(double parent_id, cgns_rotating *rotating); int cgi_write_bprop(double parent_id, cgns_bprop *bprop); int cgi_write_cprop(double parent_id, cgns_cprop *cprop); int cgi_write_user_data(double parent_id, cgns_user_data *user_data); int cgi_write_link(double parent_id, char *name, cgns_link *link, double *node_id); int cgi_write_particle(double parent_id, cgns_pzone *pzone); int cgi_write_pcoor(double parent_id, cgns_pcoor *pcoor); int cgi_write_particle_sol(double parent_id, cgns_psol *sol); int cgi_write_piter(double parent_id, cgns_ziter *piter); int cgi_write_particle_equations(double parent_id, cgns_pequations *equations); int cgi_write_particle_model(double parent_id, cgns_pmodel *model); CGNSDLL int cgi_new_node(double parent_id, char const *name, char const *label, double *node_id, char const *data_type, int ndim, cgsize_t const *dim_vals, void const *data); int cgi_new_node_partial(double parent_id, char const *name, char const *label, double *node_id, char const *data_type, int numdim, cgsize_t const *dims, cgsize_t const *s_start, cgsize_t const *s_end, int m_numdim, cgsize_t const *m_dims, cgsize_t const *m_start, cgsize_t const *m_end, void const *data); int cgi_move_node(double old_id, double node_id, double new_id, cchar_33 node_name); int cgi_delete_node (double parent_id, double node_id); /* general array reading and writing */ int cgi_array_general_verify_range(const cgi_rw op_rw, const void* rind_index, const int* rind_planes, const int s_numdim, const cgsize_t *s_dimvals, const cgsize_t *rmin, const cgsize_t *rmax, const int m_numdim, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, cgsize_t *s_rmin, cgsize_t *s_rmax, cgsize_t *stride, int *s_access_full_range, int *m_access_full_range, cgsize_t *numpt); int cgi_array_general_read(const cgns_array *array, const void* rind_index, const int *rind_planes, const int s_numdim, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, const int m_numdim, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void* data); int cgi_array_general_write(double p_id, int *p_narraylist, cgns_array **p_arraylist, const char *const arrayname, const void* rind_index, const int* rind_planes, CGNS_ENUMT(DataType_t) s_type, const int s_numdim, const cgsize_t *s_dimvals, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, const int m_numdim, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, const void* data, int *A); /* error handling */ CGNSDLL void cgi_error(const char *format, ...); CGNSDLL void cgi_warning(const char *format, ...); CGNSDLL void cg_io_error(const char *routine_name); /* retrieve list number from list name */ int cgi_GridLocation(char *GridLocationName, CGNS_ENUMT(GridLocation_t) *type); int cgi_GridConnectivityType(char *GridConnectivityName, CGNS_ENUMT(GridConnectivityType_t) *type); int cgi_PointSetType(char *PointSetName, CGNS_ENUMT(PointSetType_t) *type); int cgi_BCType(char *BCName, CGNS_ENUMT(BCType_t) *type); int cgi_DataClass(char *Name, CGNS_ENUMT(DataClass_t) *data_class); int cgi_MassUnits(char *Name, CGNS_ENUMT(MassUnits_t) *mass_unit); int cgi_LengthUnits(char *Name, CGNS_ENUMT(LengthUnits_t) *length_unit); int cgi_TimeUnits(char *Name, CGNS_ENUMT(TimeUnits_t) *time_unit); int cgi_TemperatureUnits(char *Name, CGNS_ENUMT(TemperatureUnits_t) *temperature_unit); int cgi_AngleUnits(char *Name, CGNS_ENUMT(AngleUnits_t) *angle_unit); int cgi_ElectricCurrentUnits(char *Name, CGNS_ENUMT(ElectricCurrentUnits_t) *unit); int cgi_SubstanceAmountUnits(char *Name, CGNS_ENUMT(SubstanceAmountUnits_t) *unit); int cgi_LuminousIntensityUnits(char *Name, CGNS_ENUMT(LuminousIntensityUnits_t) *unit); int cgi_GoverningEquationsType(char *Name, CGNS_ENUMT(GoverningEquationsType_t) *type); int cgi_ModelType(char *Name, CGNS_ENUMT(ModelType_t) *type); int cgi_ParticleModelType(char *Name, CGNS_ENUMT(ParticleModelType_t) *type); int cgi_ZoneType(char *Name, CGNS_ENUMT(ZoneType_t) *type); int cgi_RigidGridMotionType(char *Name, CGNS_ENUMT(RigidGridMotionType_t) *type); int cgi_ArbitraryGridMotionType(char *Name, CGNS_ENUMT(ArbitraryGridMotionType_t) *type); int cgi_SimulationType(char *Name, CGNS_ENUMT(SimulationType_t) *type); int cgi_WallFunctionType(char *Name, CGNS_ENUMT(WallFunctionType_t) *type); int cgi_AreaType(char *Name, CGNS_ENUMT(AreaType_t) *type); int cgi_AverageInterfaceType(char *Name, CGNS_ENUMT(AverageInterfaceType_t) *type); int cgi_ParticleGoverningEquationsType(char *Name, CGNS_ENUMT(ParticleGoverningEquationsType_t) *type); int cgi_zone_no(cgns_base *base, char *zonename, int *zone_no); /* miscellaneous */ int cgi_sort_names(int n, double *ids); size_t size_of(const char_33 adf_type); char *type_of(char_33 data_type); int cgi_check_strlen(char const * string); int cgi_check_strlen_x2(char const *string); int cgi_check_mode(char const * filename, int file_mode, int mode_wanted); const char *cgi_adf_datatype(CGNS_ENUMT(DataType_t) type); CGNSDLL CGNS_ENUMT(DataType_t) cgi_datatype(const char *adf_type); int cgi_check_dimensions(int ndims, cglong_t *dims); int cgi_check_location(int dim, CGNS_ENUMT(ZoneType_t) type, CGNS_ENUMT(GridLocation_t) loc); CGNSDLL int cgi_read_int_data(double id, char_33 data_type, cgsize_t cnt, cgsize_t *data); int cgi_read_offset_data_type(double id, char const *data_type, cgsize_t start, cgsize_t end, char const *to_type, void *to_data); int cgi_convert_data(cgsize_t cnt, CGNS_ENUMT(DataType_t) from_type, const void *from_data, CGNS_ENUMT(DataType_t) to_type, void *to_data); int cgi_add_czone(char_33 zonename, cgsize6_t range, cgsize6_t donor_range, int idim, int *ndouble, char_33 **Dzonename, cgsize6_t **Drange, cgsize6_t **Ddonor_range); void cgi_array_print(char *routine, cgns_array *array); cgsize_t cgi_element_data_size(CGNS_ENUMT(ElementType_t) type, cgsize_t nelems, const cgsize_t *connect, const cgsize_t *connect_offset); /* free memory */ void cgi_free_file(cgns_file *cg); void cgi_free_base(cgns_base *base); void cgi_free_zone(cgns_zone *zone); void cgi_free_family(cgns_family *family); void cgi_free_fambc(cgns_fambc *fambc); void cgi_free_famname(cgns_famname *famname); void cgi_free_geo(cgns_geo *geo); void cgi_free_part(cgns_part *part); void cgi_free_zcoor(cgns_zcoor *zcoor); void cgi_free_section(cgns_section *section); void cgi_free_zboco(cgns_zboco *zboco); void cgi_free_zconn(cgns_zconn *zconn); void cgi_free_sol(cgns_sol *sol); void cgi_free_1to1(cgns_1to1 *one21); void cgi_free_hole(cgns_hole *hole); void cgi_free_conn(cgns_conn *conn); void cgi_free_boco(cgns_boco *boco); void cgi_free_dataset(cgns_dataset *dataset); void cgi_free_bcdata(cgns_bcdata *bcdata); void cgi_free_ptset(cgns_ptset *ptset); void cgi_free_equations(cgns_equations *equations); void cgi_free_governing(cgns_governing *governing); void cgi_free_model(cgns_model *model); void cgi_free_state(cgns_state *state); void cgi_free_converg(cgns_converg *converg); void cgi_free_discrete(cgns_discrete *discrete); void cgi_free_integral(cgns_integral *integral); void cgi_free_array(cgns_array *array); void cgi_free_convert(cgns_conversion *convert); void cgi_free_exponents(cgns_exponent *exponents); void cgi_free_units(cgns_units *units); void cgi_free_descr(cgns_descr *descr); void cgi_free_rmotion(cgns_rmotion *rmotion); void cgi_free_amotion(cgns_amotion *amotion); void cgi_free_biter(cgns_biter *biter); void cgi_free_ziter(cgns_ziter *ziter); void cgi_free_gravity(cgns_gravity *gravity); void cgi_free_axisym(cgns_axisym *axisym); void cgi_free_rotating(cgns_rotating *rotating); void cgi_free_bprop(cgns_bprop *bprop); void cgi_free_bcwall(cgns_bcwall *bcwall); void cgi_free_bcarea(cgns_bcarea *bcarea); void cgi_free_cprop(cgns_cprop *cprop); void cgi_free_cperio(cgns_cperio *cperio); void cgi_free_caverage(cgns_caverage *caverage); void cgi_free_user_data(cgns_user_data *user_data); void cgi_free_subreg(cgns_subreg *subreg); void cgi_free_particle(cgns_pzone *pzone); void cgi_free_pcoor(cgns_pcoor *pcoor); void cgi_free_psol(cgns_psol *sol); void cgi_free_particle_model(cgns_pmodel *model); void cgi_free_particle_equations(cgns_pequations *equations); void cgi_free_particle_governing(cgns_pgoverning *governing); #ifdef __cplusplus } #endif #endif CGNS-4.5.0/src/cgns_internals.c000066400000000000000000023266031474000356600162370ustar00rootroot00000000000000/*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ #include #include #include #include #include #if !defined(_WIN32) || defined(__NUTC__) #include #endif #include "cgnsconfig.h" #include "cgnslib.h" #include "cgns_header.h" #include "cgns_io.h" #include "cg_hashmap.h" #ifdef MEM_DEBUG #include "cg_malloc.h" #endif #if CG_BUILD_HDF5 #include "adfh/ADFH.h" #include "hdf5.h" #endif #if CG_BUILD_COMPLEX_C99_EXT #include #undef I #if defined(_MSC_VER) #define cg_complex_float _Fcomplex #define cg_complex_double _Dcomplex #define __real__(c) c._Val[0] #define __imag__(c) c._Val[1] #else #define cg_complex_float float _Complex #define cg_complex_double double _Complex #endif #endif #define CGNS_NAN(x) (!((x) < HUGE_VAL && (x) > -HUGE_VAL)) /* Flag for contiguous (0) or compact storage (1) */ extern int HDF5storage_type; /*********************************************************************** * global variable definitions ***********************************************************************/ int Idim; /* current IndexDimension */ int Cdim; /* current CellDimension */ int Pdim; /* current PhysicalDimension */ cgsize_t CurrentDim[9]; /* current vertex, cell & bnd zone size*/ cgsize_t CurrentParticleSize; /* current size of ParticleZone_t node */ CGNS_ENUMT( ZoneType_t ) CurrentZoneType; /* current zone type */ int NumberOfSteps; /* Number of steps */ /*----- the goto stack -----*/ int posit_depth = 0; cgns_posit posit_stack[CG_MAX_GOTO_DEPTH+1]; /***********************************************************************\ * Internal functions * \***********************************************************************/ void *cgi_malloc(size_t cnt, size_t size) { void *buf = calloc(cnt, size); if (buf == NULL) { cgi_error("calloc failed for %zu values of size %zu", cnt, size); exit (1); } return buf; } void *cgi_realloc(void *oldbuf, size_t bytes) { void *buf = realloc(oldbuf, bytes); if (buf == NULL) { cgi_error("realloc failed for %zu bytes", bytes); exit (1); } return buf; } /***********************************************************************\ * Read CGNS file and store in internal data structures * \***********************************************************************/ int cgi_read() { int b; double *id; /* get number of CGNSBase_t nodes and their ID */ if (cgi_get_nodes(cg->rootid, "CGNSBase_t", &cg->nbases, &id)) return CG_ERROR; if (cg->nbases==0) return CG_OK; cg->base = CGNS_NEW(cgns_base,cg->nbases); for (b=0; bnbases; b++) cg->base[b].id = id[b]; CGNS_FREE(id); /* read and save CGNSBase_t data */ for (b=0; bnbases; b++) if (cgi_read_base(&cg->base[b])) return CG_ERROR; return CG_OK; } /* helpers to parse CGNSBase_t node */ typedef enum { LabelNull_t, LabelFamily_t, LabelReferenceState_t, LabelGravity_t, LabelAxisymmetry_t, LabelRotatingCoordinates_t, LabelConvergenceHistory_t, LabelDescriptor_t, LabelDataClass_t, LabelDimensionalUnits_t, LabelFlowEquationSet_t, LabelIntegralData_t, LabelSimulationType_t, LabelBaseIterativeData_t, LabelUserDefinedData_t, LabelZone_t, LabelParticleZone_t, LabelParticleEquationSet_t } BaseLabel_t; #define NofBaseLabel 18 static int get_base_label_type_as_enum(const char* nodelabel) { if (0 == strcmp(nodelabel, "Zone_t")) { return LabelZone_t; } else if (0 == strcmp(nodelabel, "Family_t")) { return LabelFamily_t; } else if (0 == strcmp(nodelabel, "ReferenceState_t")) { return LabelReferenceState_t; } else if (0 == strcmp(nodelabel, "Gravity_t")) { return LabelGravity_t; } else if (0 == strcmp(nodelabel, "Axisymmetry_t")) { return LabelAxisymmetry_t; } else if (0 == strcmp(nodelabel, "RotatingCoordinates_t")) { return LabelRotatingCoordinates_t; } else if (0 == strcmp(nodelabel, "ConvergenceHistory_t")) { return LabelConvergenceHistory_t; } else if (0 == strcmp(nodelabel, "Descriptor_t")) { return LabelDescriptor_t; } else if (0 == strcmp(nodelabel, "DataClass_t")) { return LabelDataClass_t; } else if (0 == strcmp(nodelabel, "DimensionalUnits_t")) { return LabelDimensionalUnits_t; } else if (0 == strcmp(nodelabel, "FlowEquationSet_t")) { return LabelFlowEquationSet_t; } else if (0 == strcmp(nodelabel, "IntegralData_t")) { return LabelIntegralData_t; } else if (0 == strcmp(nodelabel, "SimulationType_t")) { return LabelSimulationType_t; } else if (0 == strcmp(nodelabel, "BaseIterativeData_t")) { return LabelBaseIterativeData_t; } else if (0 == strcmp(nodelabel, "UserDefinedData_t")) { return LabelUserDefinedData_t; } else if (0 == strcmp(nodelabel, "ParticleZone_t")) { return LabelParticleZone_t; } else if (0 == strcmp(nodelabel, "ParticleEquationSet_t")) { return LabelParticleEquationSet_t; } else { return LabelNull_t; } } typedef struct _childnode { double id; int type; char_33 name; } _childnode_t; static int sort_childnode_names(const void* v1, const void* v2) { _childnode_t* p1 = (_childnode_t*)v1; _childnode_t* p2 = (_childnode_t*)v2; return (strcmp(p1->name, p2->name)); } int cgi_read_all_base_children(double base_id, int* nnodes, _childnode_t** childnodes) { int nid, n, nchildren, len; char nodelabel[CGIO_MAX_NAME_LENGTH + 1]; double* idlist; _childnode_t* childlist; *nnodes = 0; if (cgio_number_children(cg->cgio, base_id, &nchildren)) { cg_io_error("cgio_number_children"); return CG_ERROR; } if (nchildren < 1) return CG_OK; idlist = CGNS_NEW(double, nchildren); if (cgio_children_ids(cg->cgio, base_id, 1, nchildren, &len, idlist)) { cg_io_error("cgio_children_ids"); return CG_ERROR; } if (len != nchildren) { CGNS_FREE(idlist); cgi_error("mismatch in number of base children and child IDs read"); return CG_ERROR; } childlist = CGNS_NEW(_childnode_t, nchildren); nid = 0; for (nid = 0, n = 0; n < nchildren; n++) { /* Get the node label */ if (cgio_get_label(cg->cgio, idlist[n], nodelabel)) { cg_io_error("cgio_get_label"); return CG_ERROR; } childlist[n].type = get_base_label_type_as_enum(nodelabel); if (childlist[n].type != LabelNull_t) { childlist[nid].id = idlist[n]; if (nid < n) { childlist[nid].type = childlist[n].type; } /* Get also the node name */ if (cgio_get_name(cg->cgio, idlist[n], childlist[nid].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } nid++; } else { cgio_release_id(cg->cgio, idlist[n]); } } CGNS_FREE(idlist); if (nid > 0) { *childnodes = childlist; *nnodes = nid; } else { CGNS_FREE(childlist); } return CG_OK; } int cgi_read_equations_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_equations** equations); int cgi_read_particle_equations_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_pequations** equations); int cgi_read_state_from_list(int in_link, const _childnode_t* nodelist, int nnodes, cgns_state** state); int cgi_read_gravity_from_list(int in_link, const _childnode_t* nodelist, const int nnodes, cgns_gravity** gravity); int cgi_read_axisym_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_axisym** axisym); int cgi_read_rotating_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_rotating** rotating); int cgi_read_converg_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_converg** converg); int cgi_read_integral_from_list(int in_link, _childnode_t* nodelist, int nnodes, int* nintegrals, cgns_integral** integral); int cgi_read_DDD_from_list(int in_link, _childnode_t* nodebylabel[NofBaseLabel], int ndescr, int ndata_class, int ndimensional_units, cgns_descr** descr, CGNS_ENUMV(DataClass_t)* data_class, cgns_units** units); int cgi_read_simulation_from_list(_childnode_t* nodelist, int nnodes, CGNS_ENUMT(SimulationType_t)* type, double* type_id); int cgi_read_biter_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_biter** biter); int cgi_read_user_data_from_list(int in_link, _childnode_t* nodelist, int nnodes, int* nuser_data, cgns_user_data** user_data); /* end of helpers */ #define call_base_func(error) \ if (error) { \ for (m = 0; m < NofBaseLabel; m++) { \ if (childbylabel[m] == NULL) continue; \ CGNS_FREE(childbylabel[m]) \ } \ return CG_ERROR; \ } int cgi_read_base(cgns_base *base) { char_33 data_type; int ndim, *index; int n, m; void *vdata; cgsize_t dim_vals[12]; int nchildren; _childnode_t* childlist = NULL; int nchildbylabel[NofBaseLabel]; _childnode_t* childbylabel[NofBaseLabel]; for (n = 0; n < NofBaseLabel; n++) { childbylabel[n] = NULL; nchildbylabel[n] = 0; } /* Read CGNSBase_t Node */ if (cgi_read_node(base->id, base->name, data_type, &ndim, dim_vals, &vdata, READ_DATA)) { cgi_error("Error reading base"); return CG_ERROR; } index = (int *)vdata; /* check data type */ if (strcmp(data_type,"I4")!=0) { cgi_error("Unexpected data type for dimension data of base %s='%s'", base->name, data_type); return CG_ERROR; } if ((cg->version==1050 && (ndim != 1 || dim_vals[0]!=1)) || (cg->version >= 1100 && (ndim != 1 || dim_vals[0]!=2))) { cgi_error("Wrong definition of Base Dimensions."); return CG_ERROR; } if (cg->version == 1050) { /* old multiblock format */ base->cell_dim = base->phys_dim = index[0]; } else { base->cell_dim = index[0]; base->phys_dim = index[1]; } CGNS_FREE(vdata); if (base->cell_dim<1 || base->cell_dim>3) { cgi_error("Invalid value for base cell dimension (=%d)", base->cell_dim); return CG_ERROR; } if (base->phys_dim<1 || base->phys_dim>3) { cgi_error("Invalid value for base physical dimension(=%d)", base->phys_dim); return CG_ERROR; } /* set Global variable */ Cdim = base->cell_dim; Pdim = base->phys_dim; /* update version */ if (cg->mode == CG_MODE_MODIFY && cg->version < 1100) { dim_vals[0] = 2; if (cgio_set_dimensions(cg->cgio, base->id, "I4", 1, dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } dim_vals[0] = base->cell_dim; dim_vals[1] = base->phys_dim; if (cgio_write_all_data(cg->cgio, base->id, dim_vals)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } } if (cgi_read_all_base_children(base->id, &nchildren, &childlist)) return CG_ERROR; /* we now have all ids with label and name */ /* store them by label */ for (n = 0; n < nchildren; n++) { nchildbylabel[childlist[n].type]++; } for (n = 0; n < NofBaseLabel; n++) { if (nchildbylabel[n] == 0) continue; childbylabel[n] = CGNS_NEW(_childnode_t, nchildbylabel[n]); nchildbylabel[n] = 0; } for (n = 0; n < nchildren; n++) { memcpy((void *)&(childbylabel[childlist[n].type][nchildbylabel[childlist[n].type]]), ((void *)&childlist[n]), sizeof(_childnode_t)); nchildbylabel[childlist[n].type] ++; } CGNS_FREE(childlist); /* now consume the childbylabel array for each label */ /* Family_t */ /* -- FAMILY TREE -- */ base->nfamilies = nchildbylabel[LabelFamily_t]; if (base->nfamilies > 0) { /* read & save families */ base->family = CGNS_NEW(cgns_family, base->nfamilies); for (n=0; nnfamilies; n++) { base->family[n].id = childbylabel[LabelFamily_t][n].id; base->family[n].link = cgi_read_link(childbylabel[LabelFamily_t][n].id); base->family[n].in_link = 0; call_base_func(cgi_read_family(&base->family[n])) } } /* ReferenceState_t */ call_base_func(cgi_read_state_from_list(0, childbylabel[LabelReferenceState_t], nchildbylabel[LabelReferenceState_t], &base->state)) /* Gravity_t */ call_base_func(cgi_read_gravity_from_list(0, childbylabel[LabelGravity_t], nchildbylabel[LabelGravity_t], &base->gravity)) /* Axisymmetry_t */ call_base_func(cgi_read_axisym_from_list(0, childbylabel[LabelAxisymmetry_t], nchildbylabel[LabelAxisymmetry_t], &base->axisym)) /* RotatingCoordinates_t */ call_base_func(cgi_read_rotating_from_list(0, childbylabel[LabelRotatingCoordinates_t], nchildbylabel[LabelRotatingCoordinates_t], &base->rotating)) /* ConvergenceHistory_t */ call_base_func(cgi_read_converg_from_list(0, childbylabel[LabelConvergenceHistory_t], nchildbylabel[LabelConvergenceHistory_t], &base->converg)) /* Descriptor_t, DataClass_t, DimensionalUnits_t */ base->ndescr = nchildbylabel[LabelDescriptor_t]; call_base_func(cgi_read_DDD_from_list(0, childbylabel, nchildbylabel[LabelDescriptor_t], nchildbylabel[LabelDataClass_t], nchildbylabel[LabelDimensionalUnits_t], &base->descr, &base->data_class, &base->units)) /* FlowEquationSet_t */ call_base_func(cgi_read_equations_from_list(0, childbylabel[LabelFlowEquationSet_t], nchildbylabel[LabelFlowEquationSet_t], &base->equations)) /* ParticleEquationSet_t */ call_base_func(cgi_read_particle_equations_from_list(0, childbylabel[LabelParticleEquationSet_t], nchildbylabel[LabelParticleEquationSet_t], &base->pequations)) /* IntegralData_t */ call_base_func(cgi_read_integral_from_list(0, childbylabel[LabelIntegralData_t], nchildbylabel[LabelIntegralData_t], &base->nintegrals, &base->integral)) /* SimulationType_t */ call_base_func(cgi_read_simulation_from_list(childbylabel[LabelSimulationType_t], nchildbylabel[LabelSimulationType_t], &base->type, &base->type_id)) /* BaseIterativeData_t */ call_base_func(cgi_read_biter_from_list(0, childbylabel[LabelBaseIterativeData_t], nchildbylabel[LabelBaseIterativeData_t], &base->biter)) /* UserDefinedData_t */ call_base_func(cgi_read_user_data_from_list(0, childbylabel[LabelUserDefinedData_t], nchildbylabel[LabelUserDefinedData_t], &base->nuser_data, &base->user_data)) /* Zone_t (depends on NumberOfSteps) */ childlist = childbylabel[LabelZone_t]; base->nzones = nchildbylabel[LabelZone_t]; if (base->nzones>0) { /* Order zones alpha-numerically */ qsort(childlist, base->nzones, sizeof(_childnode_t), sort_childnode_names); /* populate zones in sorted order */ base->zone = CGNS_NEW(cgns_zone, base->nzones); for (n=0; nnzones; n++) { base->zone[n].id = childlist[n].id; base->zone[n].link = cgi_read_link(childlist[n].id); base->zone[n].in_link = 0; strcpy(base->zone[n].name, childlist[n].name); } } /* ParticleZone_t (depends on NumberOfSteps) */ childlist = childbylabel[LabelParticleZone_t]; base->npzones = nchildbylabel[LabelParticleZone_t]; if (base->npzones>0) { /* Order particle zone names alpha-numerically */ qsort(childlist, base->npzones, sizeof(_childnode_t), sort_childnode_names); /* populate particle zones in sorted order */ base->pzone = CGNS_NEW(cgns_pzone, base->npzones); for (n=0; nnpzones; n++) { base->pzone[n].id = childlist[n].id; base->pzone[n].link = cgi_read_link(childlist[n].id); base->pzone[n].in_link = 0; strcpy(base->pzone[n].name, childlist[n].name); } } for (m = 0; m < NofBaseLabel; m++) { if (childbylabel[m] == NULL) continue; CGNS_FREE(childbylabel[m]) } /* read zones */ for (n = 0; n < base->nzones; n++) { if (cgi_read_zone(&base->zone[n])) return CG_ERROR; } /* read particle zones */ for (n = 0; n < base->npzones; n++) { if (cgi_read_particle(&base->pzone[n])) return CG_ERROR; } return CG_OK; } int cgi_read_zone(cgns_zone *zone) { int n, ndim; int in_link = zone->link ? 1 : zone->in_link; char_33 data_type; void *vdata; double *id; cgsize_t dim_vals[12]; /* Zone_t, assume zone->name is already read */ if (cgi_read_node_data(zone->id, data_type, &ndim, dim_vals, &vdata)) { cgi_error("Error reading node Zone_t"); return CG_ERROR; } /* verify data read */ if (ndim!=2) { cgi_error("Wrong number of dimension for a Zone_t node"); return CG_ERROR; } /* ZoneType_t */ if (cgi_read_zonetype(zone->id, zone->name, &zone->type)) return CG_ERROR; /* Set IndexDimension of zone */ if (zone->type==CGNS_ENUMV(Structured)) zone->index_dim=Cdim; else zone->index_dim=1; /* save Global Variable Idim */ Idim = zone->index_dim; if (dim_vals[0]!=zone->index_dim || ((cg->version==1050 && dim_vals[1]!=2) || (cg->version>=1100 && dim_vals[1]!=3))) { cgi_error("Wrong number of dimension values for Zone_t %s",zone->name); return CG_ERROR; } /* allocate memory to record zone size */ zone->nijk=CGNS_NEW(cgsize_t, zone->index_dim*3); if (0 == strcmp(data_type, "I8")) { cglong_t *mesh_dim = (cglong_t *)vdata; #if CG_SIZEOF_SIZE == 32 /*if (cgi_check_dimensions(zone->index_dim, mesh_dim)) return CG_ERROR;*/ /* Modified by zbhfut , 2017-11-09 For unstructured mesh, mesh_dim = {nnode,nelem}, the multiply product of mesh_dim may be exceed the limit of 32-bit integer. We don't need check the product actually but the component of mesh_dim. */ if (zone->type == CGNS_ENUMV(Structured)) { if (cgi_check_dimensions(zone->index_dim, mesh_dim)) return 1; } else{ for (n=0; nindex_dim; ++n) { if (mesh_dim[n] > CG_MAX_INT32) { cgi_error("array size exceeds that for a 32-bit integer"); return 1; } } } #endif for (n=0; nindex_dim; n++) { zone->nijk[n] = (cgsize_t)mesh_dim[n]; zone->nijk[n+Idim] = (cgsize_t)mesh_dim[n+Idim]; if (cg->version==1050) zone->nijk[n+2*Idim] = (cgsize_t)0; else zone->nijk[n+2*Idim] = (cgsize_t)mesh_dim[n+2*Idim]; } } else if (0 == strcmp(data_type, "I4")) { int *mesh_dim = (int *)vdata; for (n=0; nindex_dim; n++) { zone->nijk[n] = (cgsize_t)mesh_dim[n]; zone->nijk[n+Idim] = (cgsize_t)mesh_dim[n+Idim]; if (cg->version==1050) zone->nijk[n+2*Idim] = (cgsize_t)0; else zone->nijk[n+2*Idim] = (cgsize_t)mesh_dim[n+2*Idim]; } } else { cgi_error("Unsupported data type for Zone_t node %s= %s", zone->name, data_type); return CG_ERROR; } CGNS_FREE(vdata); /* save Global Variables */ for (n=0; nnijk[n]; CurrentZoneType = zone->type; /* verify data */ if (zone->type==CGNS_ENUMV(Structured)) { for (n=0; nindex_dim; n++) { if (zone->nijk[n] <=0 || zone->nijk[n]!=zone->nijk[n+Idim]+1) { cgi_error("Invalid structured zone dimensions"); return CG_ERROR; } } } else { if (zone->nijk[0]<0 || zone->nijk[1]<0 || zone->nijk[2]>zone->nijk[0]) { cgi_error("Invalid unstructured zone dimensions"); return CG_ERROR; } } /* update version */ if (cg->mode == CG_MODE_MODIFY && cg->version < 1100 && !in_link) { dim_vals[0] = zone->index_dim; dim_vals[1] = 3; if (cgio_set_dimensions(cg->cgio, zone->id, CG_SIZE_DATATYPE, 2, dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } if (cgio_write_all_data(cg->cgio, zone->id, zone->nijk)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } } /* GridCoordinates_t */ if (cgi_read_zcoor(in_link, zone->id, &zone->nzcoor, &zone->zcoor)) return CG_ERROR; /* Elements_t: Only for Unstructured zones */ if (cgi_read_section(in_link, zone->id, &zone->nsections, &zone->section)) return CG_ERROR; if (zone->type==CGNS_ENUMV( Structured ) && zone->nsections!=0) { cgi_error("Elements_t nodes is valid only for unstructured zones"); return CG_ERROR; } /* FamilyName_t */ /* -- FAMILY TREE -- */ if (cgi_read_family_name(in_link, zone->id, zone->name, zone->family_name)) return CG_ERROR; /* CPEX 0034 */ /* -- FAMILY TREE -- */ if (cgi_get_nodes(zone->id, "AdditionalFamilyName_t", &zone->nfamname, &id)) return CG_ERROR; if (zone->nfamname > 0) { char *fam; zone->famname = CGNS_NEW(cgns_famname, zone->nfamname); for (n = 0; n < zone->nfamname; n++) { zone->famname[n].id = id[n]; if (cgi_read_string(id[n], zone->famname[n].name, &fam)) return CG_ERROR; strncpy(zone->famname[n].family, fam, (CG_MAX_GOTO_DEPTH*(CGIO_MAX_NAME_LENGTH+1))); CGNS_FREE(fam); } CGNS_FREE(id); } /* FlowSolution_t */ if (cgi_read_sol(in_link, zone->id, &zone->nsols, &zone->sol)) return CG_ERROR; /* ZoneGridConnectivity_t */ if (cgi_read_zconn(in_link, zone->id, &zone->nzconn, &zone->zconn)) return CG_ERROR; /* ZoneBC_t */ if (cgi_read_zboco(in_link, zone->id, &zone->zboco)) return CG_ERROR; /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(in_link, zone->id, &zone->ndescr, &zone->descr, &zone->data_class, &zone->units)) return CG_ERROR; /* DiscreteData_t */ if (cgi_read_discrete(in_link, zone->id, &zone->ndiscrete, &zone->discrete)) return CG_ERROR; /* IntegralData_t */ if (cgi_read_integral(in_link, zone->id, &zone->nintegrals, &zone->integral)) return CG_ERROR; /* ReferenceState_t */ if (cgi_read_state(in_link, zone->id, &zone->state)) return CG_ERROR; /* ConvergenceHistory_t */ if (cgi_read_converg(in_link, zone->id, &zone->converg)) return CG_ERROR; /* FlowEquationSet_t */ if (cgi_read_equations(in_link, zone->id, &zone->equations)) return CG_ERROR; /* Ordinal_t */ if (cgi_read_ordinal(zone->id, &zone->ordinal)) return CG_ERROR; /* RigidGridMotion_t */ if (cgi_read_rmotion(in_link, zone->id, &zone->nrmotions, &zone->rmotion)) return CG_ERROR; /* ArbitraryGridMotion_t */ if (cgi_read_amotion(in_link, zone->id, &zone->namotions, &zone->amotion)) return CG_ERROR; /* ZoneIterativeData_t can only exist if BaseIterativeData_t exist because it depends on it */ if (NumberOfSteps) { if (cgi_read_ziter(in_link, zone->id, &zone->ziter)) return CG_ERROR; } else zone->ziter = 0; /* UserDefinedData_t */ if (cgi_read_user_data(in_link, zone->id, &zone->nuser_data, &zone->user_data)) return CG_ERROR; /* RotatingCoordinates_t */ if (cgi_read_rotating(in_link, zone->id, &zone->rotating)) return CG_ERROR; /* ZoneSubRegion_t */ if (cgi_read_subregion(in_link, zone->id, &zone->nsubreg, &zone->subreg)) return CG_ERROR; return CG_OK; } int cgi_read_family(cgns_family *family) /* ** FAMILY TREE ** */ { int n, linked, in_link = family->link ? 1 : family->in_link; double *id; char *boconame; /* Family name */ if (cgio_get_name(cg->cgio, family->id, family->name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* CPEX 0033 */ if (cgi_get_nodes(family->id, "FamilyName_t", &family->nfamname, &id)) return CG_ERROR; if (family->nfamname > 0) { char *fam; family->famname = CGNS_NEW(cgns_famname, family->nfamname); for (n = 0; n < family->nfamname; n++) { family->famname[n].id = id[n]; if (cgi_read_string(id[n], family->famname[n].name, &fam)) return CG_ERROR; strncpy(family->famname[n].family, fam,(CG_MAX_GOTO_DEPTH*(CGIO_MAX_NAME_LENGTH+1))); CGNS_FREE(fam); } CGNS_FREE(id); } /* FamilyBC_t */ if (cgi_get_nodes(family->id, "FamilyBC_t", &family->nfambc, &id)) return CG_ERROR; if (family->nfambc>0) { family->fambc = CGNS_NEW(cgns_fambc, family->nfambc); for (n=0; nnfambc; n++) { family->fambc[n].id = id[n]; family->fambc[n].link = cgi_read_link(id[n]); family->fambc[n].in_link = in_link; if (cgi_read_string(id[n], family->fambc[n].name, &boconame)) return CG_ERROR; /* get BCType */ if (cgi_BCType(boconame, &family->fambc[n].type)) return CG_ERROR; CGNS_FREE(boconame); /* FamilyBCDataSet_t */ linked = family->fambc[n].link ? 1 : in_link; if (cgi_read_family_dataset(linked, family->fambc[n].id, &family->fambc[n].ndataset, &family->fambc[n].dataset)) return CG_ERROR; } CGNS_FREE(id); } /* GeometryReference_t */ if (cgi_get_nodes(family->id, "GeometryReference_t", &family->ngeos, &id)) return CG_ERROR; if (family->ngeos>0) { family->geo = CGNS_NEW(cgns_geo, family->ngeos); for (n=0; nngeos; n++) { family->geo[n].id = id[n]; family->geo[n].link = cgi_read_link(id[n]); family->geo[n].in_link = in_link; /* GeometryReference Name */ if (cgio_get_name(cg->cgio, family->geo[n].id, family->geo[n].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* UserDefinedData_t */ linked = family->geo[n].link ? 1 : in_link; if (cgi_read_user_data(linked, family->geo[n].id, &family->geo[n].nuser_data, &family->geo[n].user_data)) return CG_ERROR; } CGNS_FREE(id); } /* GeometryReference_t Children */ for (n=0; nngeos; n++) { int i, flag; char_33 dummy_name; cgns_geo *geo = &family->geo[n]; /* Descriptor_t */ if (cgi_get_nodes(geo->id, "Descriptor_t", &geo->ndescr, &id)) return CG_ERROR; if (geo->ndescr>0) { geo->descr = CGNS_NEW(cgns_descr, geo->ndescr); for (i=0; indescr; i++) { geo->descr[i].id = id[i]; geo->descr[i].link = cgi_read_link(id[i]); geo->descr[i].in_link = in_link; if (cgi_read_string(id[i], geo->descr[i].name, &geo->descr[i].text)) return CG_ERROR; } CGNS_FREE(id); } /* GeometryFile_t */ if (cgi_get_nodes(geo->id, "GeometryFile_t", &flag, &id)) return CG_ERROR; if (flag==1) { if (cgi_read_string(id[0], dummy_name, &geo->file)) return CG_ERROR; } else { cgi_error("Incorrect definition of GeometryFile_t"); return CG_ERROR; } if (flag) CGNS_FREE(id); /* GeometryFormat_t */ if (cgi_get_nodes(geo->id, "GeometryFormat_t", &flag, &id)) return CG_ERROR; if (flag==1) { char *geoformat; if (cgi_read_string(id[0], dummy_name, &geoformat)) return CG_ERROR; if (strlen(geoformat)>32) { cgi_error("Geometry File Format is limited to 32 characters"); return CG_ERROR; } else strcpy(geo->format, geoformat); CGNS_FREE(geoformat); } else { cgi_error("Incorrect definition of GeometryFormat_t"); return CG_ERROR; } if (flag) CGNS_FREE(id); /* GeometryEntity_t */ if (cgi_get_nodes(geo->id, "GeometryEntity_t", &geo->npart, &id)) return CG_ERROR; if (geo->npart>0) { geo->part = CGNS_NEW(cgns_part, geo->npart); for (i=0; inpart; i++) { geo->part[i].id = id[i]; geo->part[i].link = cgi_read_link(id[i]); geo->part[i].in_link = in_link; if (cgio_get_name(cg->cgio, id[i], geo->part[i].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } } CGNS_FREE(id); } } /* loop through ngeos */ /* Descriptor_t under Family_t */ if (cgi_get_nodes(family->id, "Descriptor_t", &family->ndescr, &id)) return CG_ERROR; if (family->ndescr>0) { family->descr = CGNS_NEW(cgns_descr, family->ndescr); for (n=0; nndescr; n++) { family->descr[n].id = id[n]; family->descr[n].link = cgi_read_link(id[n]); family->descr[n].in_link = in_link; if (cgi_read_string(id[n], family->descr[n].name, &family->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* Family_t */ /* ** FAMILY TREE ** */ if (cgi_get_nodes(family->id, "Family_t", &family->nfamilies, &id)) return CG_ERROR; if (family->nfamilies>0) { /* read & save families */ family->family = CGNS_NEW(cgns_family, family->nfamilies); for (n=0; nnfamilies; n++) { family->family[n].id = id[n]; family->family[n].link = cgi_read_link(id[n]); family->family[n].in_link = 0; if (cgi_read_family(&family->family[n])) return CG_ERROR; } CGNS_FREE(id); } /* Ordinal_t */ if (cgi_read_ordinal(family->id, &family->ordinal)) return CG_ERROR; /* UserDefinedData_t */ if (cgi_read_user_data(in_link, family->id, &family->nuser_data, &family->user_data)) return CG_ERROR; /* RotatingCoordinates_t */ if (cgi_read_rotating(in_link, family->id, &family->rotating)) return CG_ERROR; return CG_OK; } int cgi_read_family_dataset(int in_link, double parent_id, int *ndataset, cgns_dataset **pdataset) { int n, i, nnod, linked; double *id, *ids; char_33 name; char *string_data; int modified = 0; cgns_dataset *dataset; /* FamilyBCDataSet_t */ if (cgi_get_nodes(parent_id, "FamilyBCDataSet_t", ndataset, &id)) return CG_ERROR; /* if not found, check for BCDataSet_t (pre 3.1.3) */ if (*ndataset <= 0) { if (cgi_get_nodes(parent_id, "BCDataSet_t", ndataset, &id)) return CG_ERROR; modified = (cg->filetype != CG_FILE_ADF2); } if (*ndataset <= 0) { *pdataset = NULL; return CG_OK; } dataset = CGNS_NEW(cgns_dataset, (*ndataset)); *pdataset = dataset; for (n = 0; n < *ndataset; n++) { dataset[n].id = id[n]; dataset[n].link = cgi_read_link(id[n]); dataset[n].in_link = in_link; linked = dataset[n].link ? 1 : in_link; if (cgi_read_string(dataset[n].id, dataset[n].name, &string_data) || cgi_BCType(string_data, &dataset[n].type)) return CG_ERROR; CGNS_FREE(string_data); /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, dataset[n].id, &dataset[n].ndescr, &dataset[n].descr, &dataset[n].data_class, &dataset[n].units)) return CG_ERROR; /* ReferenceState_t */ if (cgi_read_state(linked, dataset[n].id, &dataset[n].state)) return CG_ERROR; /* BCData_t */ dataset[n].dirichlet = dataset[n].neumann = NULL; if (cgi_get_nodes(dataset[n].id, "BCData_t", &nnod, &ids)) return CG_ERROR; if (nnod > 0) { for (i = 0; i < nnod; i++) { /* Name */ if (cgio_get_name(cg->cgio, ids[i], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "DirichletData")==0) { if (dataset[n].dirichlet!=0) { cgi_error("Dirichet Data defined more than once..."); return CG_ERROR; } dataset[n].dirichlet=CGNS_NEW(cgns_bcdata, 1); dataset[n].dirichlet->id = ids[i]; dataset[n].dirichlet->link = cgi_read_link(ids[i]); dataset[n].dirichlet->in_link = linked; strcpy(dataset[n].dirichlet->name,"DirichletData"); if (cgi_read_bcdata(dataset[n].dirichlet)) return CG_ERROR; } else if (strcmp(name, "NeumannData")==0) { if (dataset[n].neumann!=0) { cgi_error("Neumann Data defined more than once..."); return CG_ERROR; } dataset[n].neumann=CGNS_NEW(cgns_bcdata, 1); dataset[n].neumann->id = ids[i]; dataset[n].neumann->link = cgi_read_link(ids[i]); dataset[n].neumann->in_link = linked; strcpy(dataset[n].neumann->name,"NeumannData"); if (cgi_read_bcdata(dataset[n].neumann)) return CG_ERROR; } } CGNS_FREE(ids); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, dataset[n].id, &dataset[n].nuser_data, &dataset[n].user_data)) return CG_ERROR; /* fix label if needed */ if (modified && !linked && cg->mode == CG_MODE_MODIFY) { if (cgio_set_label(cg->cgio, id[n], "FamilyBCDataSet_t")) { cg_io_error("cgio_set_label"); return CG_ERROR; } } } CGNS_FREE(id); return CG_OK; } /* ** FAMILY TREE ** */ int cgi_read_family_name(int in_link, double parent_id, char_33 parent_name, char_md family_name) { int fam_flag; double *id; char_33 NodeName; char *FamilyName=0; /* allocated in cgi_read_node */ family_name[0]='\0'; if (cgi_get_nodes(parent_id, "FamilyName_t", &fam_flag, &id)) return CG_ERROR; if (fam_flag==1) { if (cg->version>1200) { /* FamilyName in data field of the ADF node */ if (cgi_read_string(id[0], NodeName, &FamilyName)) return CG_ERROR; if (strlen(FamilyName) > (CG_MAX_GOTO_DEPTH*(CGIO_MAX_NAME_LENGTH+1))) { FamilyName[(CG_MAX_GOTO_DEPTH*(CGIO_MAX_NAME_LENGTH+1))]='\0'; /* ** FAMILY TREE ** */ } strcpy(family_name, FamilyName); if (FamilyName) CGNS_FREE(FamilyName); } else { /* FamilyName is the ADF node name */ if (cgio_get_name(cg->cgio, id[0], family_name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* update version */ if (cg->mode == CG_MODE_MODIFY && !in_link) { double dummy_id; cgsize_t len = (cgsize_t)strlen(family_name); if (cgi_delete_node(parent_id, id[0])) return CG_ERROR; if (cgi_new_node(parent_id, "FamilyName", "FamilyName_t", &dummy_id, "C1", 1, &len, (void *)family_name)) return CG_ERROR; } } CGNS_FREE(id); } else if (fam_flag<0 || fam_flag>1) { cgi_error("Family name defined incorrectly under '%s',",parent_name); return CG_ERROR; } return CG_OK; } int cgi_read_zcoor(int in_link, double parent_id, int *nzcoor, cgns_zcoor **zcoor) { double *idg, *id; int g, z, n, linked; cgsize_t DataSize[3]; if (cgi_get_nodes(parent_id, "GridCoordinates_t", nzcoor, &idg)) return CG_ERROR; if ((*nzcoor)<=0) return CG_OK; zcoor[0] = CGNS_NEW(cgns_zcoor, (*nzcoor)); for (g=0; g<(*nzcoor); g++) { zcoor[0][g].id = idg[g]; zcoor[0][g].link = cgi_read_link(idg[g]); zcoor[0][g].in_link = in_link; linked = zcoor[0][g].link ? 1 : in_link; /* Name */ if (cgio_get_name(cg->cgio, zcoor[0][g].id, zcoor[0][g].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* Rind Planes */ if (cgi_read_rind(zcoor[0][g].id, &zcoor[0][g].rind_planes)) return CG_ERROR; /* Assume that the coordinates are always at the node */ if (cgi_datasize(Idim, CurrentDim, CGNS_ENUMV(Vertex), zcoor[0][g].rind_planes, DataSize)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(zcoor[0][g].id, "DataArray_t", &zcoor[0][g].ncoords, &id)) return CG_ERROR; if (zcoor[0][g].ncoords > 0) { zcoor[0][g].coord = CGNS_NEW(cgns_array, zcoor[0][g].ncoords); for (z=0; zversion < 3100) { if (cg->version < 3000) { if (el_type > CGNS_ENUMV(MIXED)) { cgi_error("Element Type %s not supported in:'%s'", cg_ElementTypeName(el_type), section[0][n].name); return CG_ERROR; } } /* reordered in 3.1 */ else if (el_type > CGNS_ENUMV(PYRA_5) && el_type < CGNS_ENUMV(NGON_n)) { if (el_type == CGNS_ENUMV(PYRA_14)) el_type = CGNS_ENUMV(PYRA_13); else el_type--; changed++; } } section[0][n].el_type = el_type; section[0][n].el_bound = edata[1]; CGNS_FREE(vdata); if (INVALID_ENUM(el_type,NofValidElementTypes)) { cgi_error("Invalid Element Type for Elements_t :'%s'", section[0][n].name); return CG_ERROR; } /* Descriptor_t */ if (cgi_get_nodes(section[0][n].id, "Descriptor_t", §ion[0][n].ndescr, &idi)) return CG_ERROR; if (section[0][n].ndescr>0) { section[0][n].descr = CGNS_NEW(cgns_descr, section[0][n].ndescr); for (i=0; icgio, idi[i], temp_name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* ElementConnectivity */ if (strcmp(temp_name,"ElementConnectivity")==0) { if (section[0][n].connect) { cgi_error("Error: ElementConnectivity defined more than once"); return CG_ERROR; } section[0][n].connect = CGNS_NEW(cgns_array, 1); section[0][n].connect->id = idi[i]; section[0][n].connect->link = cgi_read_link(idi[i]); section[0][n].connect->in_link = linked; if (cgi_read_array(section[0][n].connect, "Elements_t", section[0][n].id)) return CG_ERROR; /* check data */ if (strcmp(section[0][n].connect->data_type,"I4") && strcmp(section[0][n].connect->data_type,"I8")) { cgi_error("Datatype %s not supported for element connectivity", section[0][n].connect->data_type); return CG_ERROR; } if (cg_npe(section[0][n].el_type, &npe)) return CG_ERROR; if (cg->version <= 1100) { if (section[0][n].connect->dim_vals[0] != npe || section[0][n].connect->dim_vals[1] != nelements || section[0][n].connect->data_dim != 2 ) { cgi_error("Error exit: Element connectivity incorrectly defined"); return CG_ERROR; } /* Rewrite with new data array parameters starting with version 1200 */ section[0][n].connect->data_dim = 1; section[0][n].connect->dim_vals[0] = npe*nelements; section[0][n].connect->dim_vals[1] = 0; if (cg->mode == CG_MODE_MODIFY && !linked) { /* read the data into memory */ if (cgi_read_node(section[0][n].connect->id, section[0][n].connect->name, section[0][n].connect->data_type, &ndim, dim_vals, &vdata, READ_DATA)) return CG_ERROR; if (cgio_set_dimensions(cg->cgio, section[0][n].connect->id, "I4", 1, section[0][n].connect->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } if (cgio_write_all_data(cg->cgio, section[0][n].connect->id, vdata)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } CGNS_FREE(vdata); } } else if (cg->version < 3100) { cgsize_t size, *elem_data = 0; int modified = 0; if (section[0][n].el_type == CGNS_ENUMV(MIXED)) { int ne; size = section[0][n].connect->dim_vals[0]; elem_data = CGNS_NEW(cgsize_t, size); if (cgi_read_int_data(section[0][n].connect->id, section[0][n].connect->data_type, size, elem_data)) return CG_ERROR; for (size = 0, ne = 0; ne < nelements; ne++) { el_type = (CGNS_ENUMT(ElementType_t))elem_data[size]; if (cg->version < 3000) { if (el_type > CGNS_ENUMV(MIXED)) { modified++; el_type++; elem_data[size] = el_type; } } else { if (el_type > CGNS_ENUMV(PYRA_5) && el_type < CGNS_ENUMV(NGON_n)) { if (el_type == CGNS_ENUMV(PYRA_14)) el_type = CGNS_ENUMV(PYRA_13); else el_type--; modified++; elem_data[size] = el_type; } } if (el_type > CGNS_ENUMV(NGON_n)) npe = el_type - CGNS_ENUMV(NGON_n); else cg_npe (el_type, &npe); if (npe <= 0) { cgi_error("Error exit: invalid element type in MIXED elements"); return CG_ERROR; } size += (npe + 1); } if (!modified) { CGNS_FREE(elem_data); elem_data = 0; } } size = cgi_element_data_size(section[0][n].el_type, nelements, elem_data, NULL); if (size < 0) return CG_ERROR; /* size may be zero, since elements not read */ if ((size && section[0][n].connect->dim_vals[0] != size) || section[0][n].connect->data_dim != 1) { cgi_error("Error exit: Element connectivity incorrectly defined"); return CG_ERROR; } /* rewrite if needed */ if ((changed || modified) && cg->mode == CG_MODE_MODIFY && !linked) { if (changed) { dim_vals[0] = (cgsize_t)section[0][n].el_type; dim_vals[1] = (cgsize_t)section[0][n].el_bound; if (cgio_write_all_data(cg->cgio, section[0][n].id, dim_vals)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } changed = 0; } if (modified) { if (strcmp(section[0][n].connect->data_type, CG_SIZE_DATATYPE)) { if (cgio_set_dimensions(cg->cgio, section[0][n].connect->id, CG_SIZE_DATATYPE, 1, section[0][n].connect->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } strcpy(section[0][n].connect->data_type, CG_SIZE_DATATYPE); } if (cgio_write_all_data(cg->cgio, section[0][n].connect->id, elem_data)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } CGNS_FREE(elem_data); elem_data = 0; } } if (elem_data) { strcpy(section[0][n].connect->data_type, CG_SIZE_DATATYPE); section[0][n].connect->data = (void *)elem_data; } } if (cg->version < 4000 && cg->version != 3400) { cgsize_t size, *elem_data = 0; if (section[0][n].el_type == CGNS_ENUMV(NGON_n) || section[0][n].el_type == CGNS_ENUMV(NFACE_n) ) { cgsize_t size_offset, size_connect; cgsize_t *connect_offset = 0; cgsize_t *connect_new = 0; cgsize_t ne; size = section[0][n].connect->dim_vals[0]; elem_data = CGNS_NEW(cgsize_t, size); if (cgi_read_int_data(section[0][n].connect->id, section[0][n].connect->data_type, size, elem_data)) return CG_ERROR; size_offset = nelements +1; connect_offset = CGNS_NEW(cgsize_t, size_offset); connect_offset[0] = 0; for (size = 0, size_connect = 0, ne = 0; ne < nelements; ne++) { int idx = 0; npe = (int) elem_data[size++]; connect_offset[ne + 1] = connect_offset[ne] + npe; for (idx = 0; idx < npe; idx++) { elem_data[size_connect] = elem_data[size]; size_connect++; size++; } } if (section[0][n].connect_offset) { CGNS_FREE(section[0][n].connect_offset); section[0][n].connect_offset = 0; } section[0][n].connect_offset = CGNS_NEW(cgns_array, 1); memset(section[0][n].connect_offset, 0, sizeof(cgns_array)); strcpy(section[0][n].connect_offset->data_type, CG_SIZE_DATATYPE); strcpy(section[0][n].connect_offset->name, "ElementStartOffset"); section[0][n].connect_offset->data_dim = 1; section[0][n].connect_offset->dim_vals[0] = size_offset; section[0][n].connect_offset->data = (void *)connect_offset; if (cg->mode == CG_MODE_MODIFY && !linked) { section[0][n].connect->dim_vals[0] = size_connect; if (cgio_set_dimensions(cg->cgio, section[0][n].connect->id, CG_SIZE_DATATYPE, 1, section[0][n].connect->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } strcpy(section[0][n].connect->data_type, CG_SIZE_DATATYPE); if (cgio_write_all_data(cg->cgio, section[0][n].connect->id, elem_data)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } CGNS_FREE(elem_data); elem_data = 0; cgi_write_array(section[0][n].id, section[0][n].connect_offset); section[0][n].connect_offset->data = 0; CGNS_FREE(connect_offset); connect_offset = 0; } else { connect_new = CGNS_NEW(cgsize_t, size_connect); memcpy(connect_new, elem_data, size_connect*sizeof(cgsize_t)); strcpy(section[0][n].connect->data_type, CG_SIZE_DATATYPE); section[0][n].connect->dim_vals[0] = size_connect; section[0][n].connect->data = (void *) connect_new; CGNS_FREE(elem_data); elem_data = 0; } } if (section[0][n].el_type == CGNS_ENUMV(MIXED)) { cgsize_t size_offset; cgsize_t *elem_offset = 0; int ne; size = section[0][n].connect->dim_vals[0]; elem_data = CGNS_NEW(cgsize_t, size); if (cgi_read_int_data(section[0][n].connect->id, section[0][n].connect->data_type, size, elem_data)) return CG_ERROR; size_offset = nelements +1; elem_offset = CGNS_NEW(cgsize_t, size_offset); elem_offset[0] = 0; for (size = 0, ne = 0; ne < nelements; ne++) { cg_npe(elem_data[size], &npe); elem_offset[ne + 1] = elem_offset[ne] + (npe + 1); size += (npe + 1); } CGNS_FREE(elem_data); elem_data = 0; /* check */ if (section[0][n].connect_offset) { CGNS_FREE(section[0][n].connect_offset); section[0][n].connect_offset = 0; } section[0][n].connect_offset = CGNS_NEW(cgns_array, 1); memset(section[0][n].connect_offset, 0, sizeof(cgns_array)); strcpy(section[0][n].connect_offset->data_type, CG_SIZE_DATATYPE); strcpy(section[0][n].connect_offset->name, "ElementStartOffset"); section[0][n].connect_offset->data_dim = 1; section[0][n].connect_offset->dim_vals[0] = size_offset; section[0][n].connect_offset->data = (void *)elem_offset; if (cg->mode == CG_MODE_MODIFY && !linked) { cgi_write_array(section[0][n].id, section[0][n].connect_offset); section[0][n].connect_offset->data = 0; CGNS_FREE(elem_offset); elem_offset = 0; } } } } else if (strcmp(temp_name,"ElementStartOffset")==0) { if (section[0][n].connect_offset) { cgi_error("Error: ElementStartOffset defined more than once"); return CG_ERROR; } section[0][n].connect_offset = CGNS_NEW(cgns_array, 1); section[0][n].connect_offset->id = idi[i]; section[0][n].connect_offset->link = cgi_read_link(idi[i]); section[0][n].connect_offset->in_link = linked; if (cgi_read_array(section[0][n].connect_offset, "Elements_t", section[0][n].id)) return CG_ERROR; /* check data */ if (strcmp(section[0][n].connect_offset->data_type,"I4") && strcmp(section[0][n].connect_offset->data_type,"I8")) { cgi_error("Datatype %s not supported for element 'ElementStartOffset'", section[0][n].connect_offset->data_type); return CG_ERROR; } } else if (strcmp(temp_name,"ParentData")==0) { if (section[0][n].parelem) { cgi_error("Error: Element ParentData defined more than once"); return CG_ERROR; } section[0][n].parelem = CGNS_NEW(cgns_array, 1); section[0][n].parelem->id = idi[i]; section[0][n].parelem->link = cgi_read_link(idi[i]); section[0][n].parelem->in_link = linked; if (cgi_read_array(section[0][n].parelem, "Elements_t", section[0][n].id)) return CG_ERROR; /* check data */ if (strcmp(section[0][n].parelem->data_type,"I4") && strcmp(section[0][n].parelem->data_type,"I8")) { cgi_error("Datatype %s not supported for element 'ParentData'", section[0][n].parelem->data_type); return CG_ERROR; } if(section[0][n].parelem->range[0] > 0 && section[0][n].parelem->range[1] > 0) pdata_cnt = section[0][n].parelem->range[1] - section[0][n].parelem->range[0] + 1; else pdata_cnt = nelements; if (section[0][n].parelem->dim_vals[0] != pdata_cnt || section[0][n].parelem->dim_vals[1] != 4 || section[0][n].parelem->data_dim != 2 ) { cgi_error("Error exit: Element 'ParentData' incorrectly defined"); return CG_ERROR; } } else if (strcmp(temp_name,"ParentElements")==0) { if (section[0][n].parelem) { cgi_error("Error: Element ParentElements defined more than once"); return CG_ERROR; } section[0][n].parelem = CGNS_NEW(cgns_array, 1); section[0][n].parelem->id = idi[i]; section[0][n].parelem->link = cgi_read_link(idi[i]); section[0][n].parelem->in_link = linked; if (cgi_read_array(section[0][n].parelem, "Elements_t", section[0][n].id)) return CG_ERROR; /* check data */ if (strcmp(section[0][n].parelem->data_type,"I4") && strcmp(section[0][n].parelem->data_type,"I8")) { cgi_error("Datatype %s not supported for element 'ParentElements'", section[0][n].parelem->data_type); return CG_ERROR; } if(section[0][n].parelem->range[0] > 0 && section[0][n].parelem->range[1] > 0) pdata_cnt = section[0][n].parelem->range[1] - section[0][n].parelem->range[0] + 1; else pdata_cnt = nelements; if (section[0][n].parelem->dim_vals[0] != pdata_cnt || section[0][n].parelem->dim_vals[1] != 2 || section[0][n].parelem->data_dim != 2 ) { cgi_error("Error exit: Element 'ParentElements' incorrectly defined"); return CG_ERROR; } } else if (strcmp(temp_name,"ParentElementsPosition")==0) { if (section[0][n].parface) { cgi_error("Error: Element ParentElementsPosition defined more than once"); return CG_ERROR; } section[0][n].parface = CGNS_NEW(cgns_array, 1); section[0][n].parface->id = idi[i]; section[0][n].parface->link = cgi_read_link(idi[i]); section[0][n].parface->in_link = linked; if (cgi_read_array(section[0][n].parface, "Elements_t", section[0][n].id)) return CG_ERROR; /* check data */ if (strcmp(section[0][n].parface->data_type,"I4") && strcmp(section[0][n].parface->data_type,"I8")) { cgi_error("Datatype %s not supported for element 'ParentElementsPosition'", section[0][n].parelem->data_type); return CG_ERROR; } if(section[0][n].parface->range[0] > 0 && section[0][n].parface->range[1] > 0) pdata_cnt = section[0][n].parface->range[1] - section[0][n].parface->range[0] + 1; else pdata_cnt = nelements; if (section[0][n].parface->dim_vals[0] != pdata_cnt || section[0][n].parface->dim_vals[1] != 2 || section[0][n].parface->data_dim != 2 ) { cgi_error("Error exit: Element 'ParentElementsPosition' incorrectly defined"); return CG_ERROR; } } } /* loop through DataArray_t */ /* check cgi_array_print("connect",section[0][n].connect); if (section[0][n].parent) cgi_array_print("parent",section[0][n].parent); */ if (nchild) CGNS_FREE(idi); if (section[0][n].connect == 0) { cgi_error("Error exit: ElementConnectivity undefined in Element_t node '%s'.", section[0][n].name); return CG_ERROR; } /* UserDefinedData_t */ if (cgi_read_user_data(linked, section[0][n].id, §ion[0][n].nuser_data, §ion[0][n].user_data)) return CG_ERROR; if (section[0][n].parelem != NULL && 0 == strcmp(section[0][n].parelem->name, "ParentData") && cg->mode == CG_MODE_MODIFY && !linked && cg->filetype != CG_FILE_ADF2) { void *pardata; pdata_cnt = section[0][n].parelem->dim_vals[0]; strcpy(data_type, section[0][n].parelem->data_type); if (0 == strcmp(data_type, "I8")) { pardata = malloc((size_t)(pdata_cnt * 4 * sizeof(cglong_t))); vdata = (void *)(((cglong_t *)pardata) + (pdata_cnt * 2)); } else { pardata = malloc((size_t)(pdata_cnt * 4 * sizeof(int))); vdata = (void *)(((int *)pardata) + (pdata_cnt * 2)); } if (pardata == NULL) { cgi_error("malloc failed for ParentData conversion array"); return CG_ERROR; } if (cgio_read_all_data_type(cg->cgio, section[0][n].parelem->id, data_type, pardata)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } if (cgi_delete_node(section[0][n].id, section[0][n].parelem->id)) return CG_ERROR; memset(section[0][n].parelem, 0, sizeof(cgns_array)); strcpy(section[0][n].parelem->data_type, data_type); strcpy(section[0][n].parelem->name, "ParentElements"); section[0][n].parelem->data_dim =2; section[0][n].parelem->dim_vals[0]=pdata_cnt; section[0][n].parelem->dim_vals[1]=2; if (cgi_write_array(section[0][n].id, section[0][n].parelem)) return CG_ERROR; if (cgio_write_all_data(cg->cgio, section[0][n].parelem->id, pardata)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } section[0][n].parface = CGNS_NEW(cgns_array, 1); strcpy(section[0][n].parface->data_type, data_type); strcpy(section[0][n].parface->name, "ParentElementsPosition"); section[0][n].parface->data_dim =2; section[0][n].parface->dim_vals[0]=pdata_cnt; section[0][n].parface->dim_vals[1]=2; if (cgi_write_array(section[0][n].id, section[0][n].parface)) return CG_ERROR; if (cgio_write_all_data(cg->cgio, section[0][n].parface->id, vdata)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } } } /* loop through element sections */ CGNS_FREE(id); return CG_OK; } int cgi_read_sol(int in_link, double parent_id, int *nsols, cgns_sol **sol) { double *id, *idf; int s, z, n, linked; cgsize_t DataSize[3], DataCount = 0; if (cgi_get_nodes(parent_id, "FlowSolution_t", nsols, &id)) return CG_ERROR; if (*nsols<=0) { sol[0] = 0; return CG_OK; } sol[0] = CGNS_NEW(cgns_sol, (*nsols)); for (s=0; s<(*nsols); s++) { sol[0][s].id = id[s]; sol[0][s].link = cgi_read_link(id[s]); sol[0][s].in_link = in_link; linked = sol[0][s].link ? 1 : in_link; /* FlowSolution_t Name */ if (cgio_get_name(cg->cgio, sol[0][s].id, sol[0][s].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* GridLocation */ if (cgi_read_location(sol[0][s].id, sol[0][s].name, &sol[0][s].location)) return CG_ERROR; /* Rind Planes */ if (cgi_read_rind(sol[0][s].id, &sol[0][s].rind_planes)) return CG_ERROR; /* Determine data size */ if (cgi_datasize(Idim, CurrentDim, sol[0][s].location, sol[0][s].rind_planes, DataSize)) return CG_ERROR; /* check for PointList/PointRange */ if (cgi_read_one_ptset(linked, sol[0][s].id, &sol[0][s].ptset)) return CG_ERROR; if (sol[0][s].ptset != NULL) { if (sol[0][s].ptset->type == CGNS_ENUMV(ElementList) || sol[0][s].ptset->type == CGNS_ENUMV(ElementRange)) { cgi_error("ElementList/Range not supported under FlowSolution"); return CG_ERROR; } DataCount = sol[0][s].ptset->size_of_patch; } /* DataArray_t */ if (cgi_get_nodes(sol[0][s].id, "DataArray_t", &sol[0][s].nfields, &idf)) return CG_ERROR; if (sol[0][s].nfields > 0) { sol[0][s].field = CGNS_NEW(cgns_array, sol[0][s].nfields); for (z=0; zcgio, zc[i].id, zc[i].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* OversetHoles_t */ if (cgi_get_nodes(zc[i].id, "OversetHoles_t", &zc[i].nholes, &id)) return CG_ERROR; if (zc[i].nholes > 0) { zc[i].hole = CGNS_NEW(cgns_hole,zc[i].nholes); for (n=0; n 0) { zc[i].conn = CGNS_NEW(cgns_conn,zc[i].nconns); for (n=0; n0) { zc[i].one21 = CGNS_NEW(cgns_1to1, zc[i].n1to1); for (n=0; n0) { zc[i].descr = CGNS_NEW(cgns_descr, zc[i].ndescr); for (n=0; nlink ? 1 : one21->in_link; double *IA_id, *IR_id, *id; char_33 name, data_type; char *string_data; void *vdata; cgsize_t dim_vals[12]; /* get donor name */ if (cgi_read_string(one21->id, one21->name, &string_data)) return CG_ERROR; strcpy(one21->donor, string_data); CGNS_FREE(string_data); /* get ADF-ID of point sets for donor and receiver */ one21->ptset.id=0; one21->ptset.link=0; one21->dptset.id=0; one21->dptset.link=0; if (cgi_get_nodes(one21->id, "IndexRange_t", &nIR_t, &IR_id)) return CG_ERROR; for (i=0; icgio, IR_id[i], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "PointRange")==0) { if (one21->ptset.id==0) { one21->ptset.id=IR_id[i]; one21->ptset.link=cgi_read_link(IR_id[i]); one21->ptset.in_link=linked; one21->ptset.type=CGNS_ENUMV(PointRange); } else { cgi_error("Multiple PointRange definition for %s",one21->name); return CG_ERROR; } } else if (strcmp(name, "PointRangeDonor")==0) { if (one21->dptset.id==0) { one21->dptset.id=IR_id[i]; one21->dptset.link=cgi_read_link(IR_id[i]); one21->dptset.in_link=linked; one21->dptset.type=CGNS_ENUMV(PointRangeDonor); } else { cgi_error("Multiple PointRangeDonor definition for %s",one21->name); return CG_ERROR; } } } if (nIR_t>0) CGNS_FREE(IR_id); if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (one21->ptset.id==0 || one21->dptset.id==0) { cgi_error("PointRange or PointRangeDonor undefined for %s",one21->name); return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { /* * Convert the double id to a hid_t id and compare that to 0 instead of * comparing doubles, this avoids issues with comparing doubles when * compiler optimization is enabled. */ hid_t hid_ptset, hid_dptset; to_HDF_ID(one21->ptset.id,hid_ptset); to_HDF_ID(one21->dptset.id,hid_dptset); if (hid_ptset==0 || hid_dptset==0) { cgi_error("PointRange or PointRangeDonor undefined for %s",one21->name); return CG_ERROR; } } #endif else { return CG_ERROR; } /* Read Point set Receiver */ if (cgi_read_ptset(one21->id, &one21->ptset)) return CG_ERROR; /* Read Point set Donor */ if (cgi_read_ptset(one21->id, &one21->dptset)) return CG_ERROR; /* Get "int[IndexDimension]" children */ if (cgi_get_nodes(one21->id, "\"int[IndexDimension]\"", &nIA_t, &IA_id)) return CG_ERROR; if (nIA_t==0) { one21->transform = CGNS_NEW(int, Idim); /* set default transformation matrix to 1,2,3 */ for (i=0; itransform[i]=i+1; } else if (nIA_t<0 || nIA_t>1) { cgi_error("Invalid definition of transformation matrix for %s",one21->name); return CG_ERROR; } else if (nIA_t==1) { if (cgi_read_node(IA_id[0], name, data_type, &ndim, dim_vals, &vdata, READ_DATA)) { cgi_error("Error reading 1to1-connectivity transformation matrix"); return CG_ERROR; } one21->transform = (int *)vdata; /* verify plausibility of data */ if (strcmp("Transform", name)) { cgi_error("The ADF name should be 'Transform' and not '%s'",name); return CG_ERROR; } if (strcmp(data_type, "I4")!=0) { cgi_error("Data type '%s' not supported for Transform",data_type); return CG_ERROR; } if (ndim != 1 || dim_vals[0] != Idim) { cgi_error("Error in dimension for node type Transform"); return CG_ERROR; } for (i=0; itransform[i] >Idim || one21->transform[i] <(-1*Idim)) { cgi_error("Invalid transformation matrix"); return CG_ERROR; } } CGNS_FREE(IA_id); } /* Ordinal_t */ if (cgi_read_ordinal(one21->id, &one21->ordinal)) return CG_ERROR; /* Descriptor_t */ if (cgi_get_nodes(one21->id, "Descriptor_t", &one21->ndescr, &id)) return CG_ERROR; if (one21->ndescr>0) { one21->descr = CGNS_NEW(cgns_descr, one21->ndescr); for (n=0; nndescr; n++) { one21->descr[n].id = id[n]; one21->descr[n].link = cgi_read_link(id[n]); one21->descr[n].in_link = linked; if (cgi_read_string(id[n], one21->descr[n].name, &one21->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, one21->id, &one21->nuser_data, &one21->user_data)) return CG_ERROR; /* GridConnectivityProperty_t */ if (cgi_read_cprop(linked, one21->id, &one21->cprop)) return CG_ERROR; return CG_OK; } int cgi_read_conn(cgns_conn *conn) { int i, nchild; int linked = conn->link ? 1 : conn->in_link; char_33 name, parent_label; double *id, parent_id; char *string_data; /* allocated in cgi_read_node */ /* get donor name */ if (cgi_read_string(conn->id, conn->name, &string_data)) return CG_ERROR; if (cgi_check_strlen(string_data)) return CG_ERROR; strcpy(conn->donor, string_data); CGNS_FREE(string_data); /* GridLocation */ if (cgi_read_location(conn->id, conn->name, &conn->location)) return CG_ERROR; if (conn->location != CGNS_ENUMV(Vertex) && conn->location != CGNS_ENUMV(CellCenter) && conn->location != CGNS_ENUMV(FaceCenter) && conn->location != CGNS_ENUMV(IFaceCenter) && conn->location != CGNS_ENUMV(JFaceCenter) && conn->location != CGNS_ENUMV(KFaceCenter)) { cgi_error("Unsupported GridLocation %s for Connectivity %s", cg_GridLocationName(conn->location), conn->name); return CG_ERROR; } /* Receiver IndexArray_t ? */ conn->ptset.id=0; conn->ptset.link=0; if (cgi_get_nodes(conn->id, "IndexArray_t", &nchild, &id)) return CG_ERROR; for (i=0; icgio, id[i], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "PointList")==0) { if (conn->ptset.id==0) { conn->ptset.id=id[i]; conn->ptset.link=cgi_read_link(id[i]); conn->ptset.in_link=linked; conn->ptset.type=CGNS_ENUMV( PointList ); if (cgi_read_ptset(conn->id, &conn->ptset)) return CG_ERROR; } else { cgi_error("Multiple PointList definition for %s",conn->name); return CG_ERROR; } } } if (nchild>0) CGNS_FREE(id); /* Receiver IndexRange_t ? */ if (cgi_get_nodes(conn->id, "IndexRange_t", &nchild, &id)) return CG_ERROR; for (i=0; icgio, id[i], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "PointRange")==0) { if (conn->ptset.id==0) { conn->ptset.id=id[i]; conn->ptset.link=cgi_read_link(id[i]); conn->ptset.in_link=linked; conn->ptset.type=CGNS_ENUMV( PointRange ); if (cgi_read_ptset(conn->id, &conn->ptset)) return CG_ERROR; } else { cgi_error("Multiple PointSet definition for %s",conn->name); return CG_ERROR; } } } if (nchild>0) CGNS_FREE(id); /* check */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (conn->ptset.id==0) { cgi_error("Neither PointRange nor PointList defined for GridConnectivity_t '%s'", conn->name); return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(conn->ptset.id, hid); if (hid==0) { cgi_error("Neither PointRange nor PointList defined for GridConnectivity_t '%s'", conn->name); return CG_ERROR; } } #endif else { return CG_ERROR; } /* Find the parent node for Donor IndexArray_t */ parent_id = 0; parent_label[0]='\0'; if (cg->version <1100 || cg->version>1200) { /* Version 1.05 and 1.27+ put IndexArray_t directly under GridConnectivity_t */ parent_id = conn->id; strcpy(parent_label,"GridConnectivity_t"); } else { /* version 1.1 to 1.20 used intermediate structures StructuredDonor_t & UnstructuredDonor_t */ if (cgi_get_nodes(conn->id, "StructuredDonor_t", &nchild, &id)) return CG_ERROR; if (nchild>1) { cgi_error("StructuredDonor_t defined more than once for GridConnectivity_t '%s'", conn->name); return CG_ERROR; } else if (nchild==1) { parent_id = id[0]; strcpy(parent_label,"StructuredDonor_t"); CGNS_FREE(id); } if (cgi_get_nodes(conn->id, "UnstructuredDonor_t", &nchild, &id)) return CG_ERROR; if (nchild>1) { cgi_error("UnstructuredDonor_t defined more than once for GridConnectivity_t '%s'", conn->name); return CG_ERROR; } else if (nchild==1) { if (parent_id) { cgi_error("Multiple donors found under GridConnectivity_t '%s'",conn->name); return CG_ERROR; } parent_id = id[0]; strcpy(parent_label,"UnstructuredDonor_t"); CGNS_FREE(id); } if (!parent_id) { cgi_error("Error: Donor data undefined for GridConnectivity_t '%s'", conn->name); return CG_ERROR; } } /* Read Donor IndexArray_t */ conn->dptset.id=0; conn->dptset.link=0; if (cgi_get_nodes(parent_id, "IndexArray_t", &nchild, &id)) return CG_ERROR; for (i=0; icgio, id[i], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "PointListDonor") && strcmp(name, "CellListDonor")) continue; if (conn->dptset.id==0) { conn->dptset.id=id[i]; conn->dptset.link=cgi_read_link(id[i]); conn->dptset.in_link=linked; if (strcmp(name, "PointListDonor")==0) conn->dptset.type=CGNS_ENUMV( PointListDonor ); else { if (strcmp(parent_label,"StructuredDonor_t")==0) { cgi_error("StructuredDonor_t doesn't support CellListDonor"); return CG_ERROR; } conn->dptset.type=CGNS_ENUMV( CellListDonor ); } if (cgi_read_ptset(parent_id, &conn->dptset)) return CG_ERROR; } else { cgi_error("Multiple PointListDonor/CellListDonor definition for %s",conn->name); return CG_ERROR; } } if (nchild>0) CGNS_FREE(id); /* if (conn->dptset.id==0) { cgi_error("Error: Donor patch undefined for GridConnectivity_t '%s'", conn->name); return CG_ERROR; } */ /* Read InterpolantsDonor if it exist */ conn->interpolants=0; conn->narrays = 0; if (strcmp(parent_label,"StructuredDonor_t")) { if (cgi_get_nodes(parent_id, "DataArray_t", &nchild, &id)) return CG_ERROR; conn->narrays = nchild; for (i=0; icgio, id[i], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "InterpolantsDonor")) continue; if (conn->interpolants==0) { conn->interpolants = CGNS_NEW(cgns_array, 1); conn->interpolants->id = id[0]; conn->interpolants->link = cgi_read_link(id[0]); conn->interpolants->in_link = linked; if (cgi_read_array(conn->interpolants, parent_label, parent_id)) return CG_ERROR; } else { cgi_error("InterpolantsDonor defined more than once for GridConnectivity_t '%s'", conn->name); return CG_ERROR; } } if (nchild) CGNS_FREE(id); } /* Get GridConnectivityType_t (conn->type) */ if (cgi_get_nodes(conn->id, "GridConnectivityType_t", &nchild, &id)) return CG_ERROR; if (nchild==0) { conn->type = CGNS_ENUMV( Overset ); } else if (nchild<0 || nchild>1) { cgi_error("Invalid definition of GridConnectivityType_t for %s",conn->name); return CG_ERROR; } else if (nchild==1) { /* Read the grid connectivity type value in the GridConnectivityType_t node */ if (cgi_read_string(id[0], name, &string_data)) return CG_ERROR; if (cgi_GridConnectivityType(string_data, &conn->type)) return CG_ERROR; CGNS_FREE(string_data); } if (nchild) CGNS_FREE(id); /* update the version */ if (cg->mode == CG_MODE_MODIFY && !linked && cg->version >= 1100 && cg->version <= 1200) { if (cgio_move_node(cg->cgio, parent_id, conn->dptset.id, conn->id)) { cg_io_error("cgio_move_node"); return CG_ERROR; } if (conn->interpolants) { if (cgio_move_node(cg->cgio, parent_id, conn->interpolants->id, conn->id)) { cg_io_error("cgio_move_node"); return CG_ERROR; } } if (cgi_delete_node(conn->id, parent_id)) return CG_ERROR; } /* Ordinal_t */ conn->ordinal=0; if (cgi_read_ordinal(conn->id, &conn->ordinal)) return CG_ERROR; /* Descriptor_t */ if (cgi_get_nodes(conn->id, "Descriptor_t", &conn->ndescr, &id)) return CG_ERROR; if (conn->ndescr>0) { conn->descr = CGNS_NEW(cgns_descr, conn->ndescr); for (i=0; indescr; i++) { conn->descr[i].id = id[i]; conn->descr[i].link = cgi_read_link(id[i]); conn->descr[i].in_link = linked; if (cgi_read_string(id[i], conn->descr[i].name, &conn->descr[i].text)) return CG_ERROR; } CGNS_FREE(id); } /* GridConnectivityProperty_t */ if (cgi_read_cprop(linked, conn->id, &conn->cprop)) return CG_ERROR; /* UserDefinedData_t */ if (cgi_read_user_data(linked, conn->id, &conn->nuser_data, &conn->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_cprop(int in_link, double parent_id, cgns_cprop **cprop) { int nchild, n, linked; double *id; char *type_name; /* allocated in cgi_read_node */ char_33 name; /* get number of GridConnectivityProperty_t nodes and their ID */ if (cgi_get_nodes(parent_id, "GridConnectivityProperty_t", &nchild, &id)) return CG_ERROR; if (nchild<=0) { cprop[0]=0; return CG_OK; } else if (nchild>1) { cgi_error("Error: Multiple GridConnectivityProperty_t found..."); CGNS_FREE(id); return CG_ERROR; } cprop[0] = CGNS_NEW(cgns_cprop, 1); cprop[0]->id = id[0]; cprop[0]->link = cgi_read_link(id[0]); cprop[0]->in_link = in_link; linked = cprop[0]->link ? 1 : in_link; CGNS_FREE(id); /* Descriptor_t */ if (cgi_get_nodes(cprop[0]->id, "Descriptor_t", &nchild, &id)) return CG_ERROR; cprop[0]->ndescr = 0; if (nchild>0) { cprop[0]->ndescr = nchild; cprop[0]->descr = CGNS_NEW(cgns_descr, nchild); for (n=0; ndescr[n].id = id[n]; cprop[0]->descr[n].link = cgi_read_link(id[n]); cprop[0]->descr[n].in_link = linked; if (cgi_read_string(id[n], cprop[0]->descr[n].name, &cprop[0]->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, cprop[0]->id, &cprop[0]->nuser_data, &cprop[0]->user_data)) return CG_ERROR; /* AverageInterface_t */ if (cgi_get_nodes(cprop[0]->id, "AverageInterface_t", &nchild, &id)) return CG_ERROR; if (nchild<=0) { cprop[0]->caverage = 0; } else if (nchild>1) { cgi_error("Error: Multiple AverageInterface_t found..."); CGNS_FREE(id); return CG_ERROR; } else { cprop[0]->caverage = CGNS_NEW(cgns_caverage, 1); cprop[0]->caverage->id = id[0]; cprop[0]->caverage->link = cgi_read_link(id[0]); cprop[0]->caverage->in_link = linked; in_link = cprop[0]->caverage->link ? 1 : linked; CGNS_FREE(id); /* Descriptor_t */ if (cgi_get_nodes(cprop[0]->caverage->id, "Descriptor_t", &nchild, &id)) return CG_ERROR; cprop[0]->caverage->ndescr = 0; if (nchild>0) { cprop[0]->caverage->ndescr = nchild; cprop[0]->caverage->descr = CGNS_NEW(cgns_descr, nchild); for (n=0; ncaverage->descr[n].id = id[n]; cprop[0]->caverage->descr[n].link = cgi_read_link(id[n]); cprop[0]->caverage->descr[n].in_link = in_link; if (cgi_read_string(id[n], cprop[0]->caverage->descr[n].name, &cprop[0]->caverage->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(in_link, cprop[0]->caverage->id, &cprop[0]->caverage->nuser_data, &cprop[0]->caverage->user_data)) return CG_ERROR; /* AverageInterfaceType_t */ if (cgi_get_nodes(cprop[0]->caverage->id, "AverageInterfaceType_t", &nchild, &id)) return CG_ERROR; if (nchild==0) { cgi_error("Error: AverageInterfaceType_t missing under AverageInterface_t"); return CG_ERROR; } else if (nchild >1) { cgi_error("File incorrect: multiple definition of AverageInterfaceType"); CGNS_FREE(id); return CG_ERROR; } else { if (cgi_read_string(id[0], name, &type_name)) return CG_ERROR; CGNS_FREE(id); if (cgi_AverageInterfaceType(type_name, &cprop[0]->caverage->type)) return CG_ERROR; CGNS_FREE(type_name); } } /* Periodic_t */ if (cgi_get_nodes(cprop[0]->id, "Periodic_t", &nchild, &id)) return CG_ERROR; if (nchild<=0) { cprop[0]->cperio = 0; } else if (nchild>1) { cgi_error("Error: Multiple Periodic_t found..."); CGNS_FREE(id); return CG_ERROR; } else { cprop[0]->cperio = CGNS_NEW(cgns_cperio, 1); cprop[0]->cperio->id = id[0]; cprop[0]->cperio->link = cgi_read_link(id[0]); cprop[0]->cperio->in_link = linked; in_link = cprop[0]->cperio->link ? 1 : linked; CGNS_FREE(id); /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(in_link, cprop[0]->cperio->id, &cprop[0]->cperio->ndescr, &cprop[0]->cperio->descr, &cprop[0]->cperio->data_class, &cprop[0]->cperio->units)) return CG_ERROR; /* UserDefinedData_t */ if (cgi_read_user_data(in_link, cprop[0]->cperio->id, &cprop[0]->cperio->nuser_data, &cprop[0]->cperio->user_data)) return CG_ERROR; /* DataArray_t: RotationCenter, RotationAngle, Translation: */ if (cgi_get_nodes(cprop[0]->cperio->id, "DataArray_t", &nchild, &id)) return CG_ERROR; if (nchild==0) { cgi_error("Error: Three DataArray_t nodes missing under Periodic_t"); return CG_ERROR; } else if (nchild!=3) { cgi_error("Error: 3 DataArray_t required under Periodic_t"); CGNS_FREE(id); return CG_ERROR; } cprop[0]->cperio->narrays = nchild; cprop[0]->cperio->array = CGNS_NEW(cgns_array, cprop[0]->cperio->narrays); for (n=0; n<(cprop[0]->cperio->narrays); n++) { cgns_array *array; cprop[0]->cperio->array[n].id = id[n]; cprop[0]->cperio->array[n].link = cgi_read_link(id[n]); cprop[0]->cperio->array[n].in_link = in_link; if (cgi_read_array(&cprop[0]->cperio->array[n], "Periodic_t", cprop[0]->cperio->id)) return CG_ERROR; array = &cprop[0]->cperio->array[n]; /* check data */ if (strcmp("RotationCenter",array->name) && strcmp("RotationAngle",array->name) && strcmp("Translation",array->name)) { cgi_error("Error: Wrong DataArray_t found under Periodic_t: '%s'",array->name); CGNS_FREE(id); return CG_ERROR; } else if (strcmp(array->data_type,"R4") || array->data_dim!=1 || array->dim_vals[0]!=Pdim) { cgi_error("Error: Array '%s' incorrectly sized",array->name); CGNS_FREE(id); return CG_ERROR; } } /* loop through arrays */ CGNS_FREE(id); } return CG_OK; } int cgi_read_hole(cgns_hole *hole) { int linked = hole->link ? 1 : hole->in_link; int nIA_t, nIR_t; double *IA_id, *IR_id, *id; int set, n; /* name of OversetHoles_t Node */ if (cgio_get_name(cg->cgio, hole->id, hole->name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* GridLocation */ if (cgi_read_location(hole->id, hole->name, &hole->location)) return CG_ERROR; if (hole->location != CGNS_ENUMV( Vertex ) && hole->location != CGNS_ENUMV( CellCenter )) { cgi_error("Unsupported GridLocation %s for Overset Hole %s", cg_GridLocationName(hole->location), hole->name); return CG_ERROR; } /* get number of IndexArray_t and IndexRange_t nodes and their ID */ if (cgi_get_nodes(hole->id, "IndexArray_t", &nIA_t, &IA_id)) return CG_ERROR; if (cgi_get_nodes(hole->id, "IndexRange_t", &nIR_t, &IR_id)) return CG_ERROR; /* Hole defined with several PointRange */ if (nIA_t==0 && nIR_t>0) { hole->nptsets = nIR_t; hole->ptset = CGNS_NEW(cgns_ptset, nIR_t); for (set=0; setptset[set].id = IR_id[set]; hole->ptset[set].link = cgi_read_link(IR_id[set]); hole->ptset[set].in_link = linked; hole->ptset[set].type = CGNS_ENUMV( PointRange ); if (cgi_read_ptset(hole->id, &hole->ptset[set])) return CG_ERROR; } CGNS_FREE(IR_id); /* Hole defined with one single PointList */ } else if (nIA_t==1 && nIR_t==0) { hole->nptsets = 1; hole->ptset = CGNS_NEW(cgns_ptset, 1); hole->ptset[0].id = IA_id[0]; hole->ptset[0].link = cgi_read_link(IA_id[0]); hole->ptset[0].in_link = linked; hole->ptset[0].type = CGNS_ENUMV( PointList ); if (cgi_read_ptset(hole->id, &hole->ptset[0])) return CG_ERROR; CGNS_FREE(IA_id); /* Empty hole (requested by Cetin) */ } else if (nIA_t==0 && nIR_t==0) { hole->nptsets = 1; hole->ptset = CGNS_NEW(cgns_ptset, 1); hole->ptset[0].npts = 0; hole->ptset[0].type = CGNS_ENUMV( PointList ); /* initialize */ strcpy(hole->ptset[0].data_type, "I4"); hole->ptset[0].id = 0; hole->ptset[0].link = 0; hole->ptset[0].in_link = linked; strcpy(hole->ptset[0].name,"Empty"); } else { cgi_error("Overset hole '%s' defined incorrectly with %d IndexArray_t and %d IndexRange_t.", hole->name, nIA_t, nIR_t); return CG_ERROR; } /* Descriptor_t */ if (cgi_get_nodes(hole->id, "Descriptor_t", &hole->ndescr, &id)) return CG_ERROR; if (hole->ndescr>0) { hole->descr = CGNS_NEW(cgns_descr, hole->ndescr); for (n=0; nndescr; n++) { hole->descr[n].id = id[n]; hole->descr[n].link = cgi_read_link(id[n]); hole->descr[n].in_link = linked; if (cgi_read_string(id[n], hole->descr[n].name, &hole->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, hole->id, &hole->nuser_data, &hole->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_zboco(int in_link, double parent_id, cgns_zboco **zboco) { int nnod, n, linked; double *id; if (cgi_get_nodes(parent_id, "ZoneBC_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { zboco[0] = 0; return CG_OK; } zboco[0] = CGNS_NEW(cgns_zboco, 1); zboco[0]->id = id[0]; zboco[0]->link = cgi_read_link(id[0]); zboco[0]->in_link = in_link; linked = zboco[0]->link ? 1 : in_link; CGNS_FREE(id); /* Name */ if (cgio_get_name(cg->cgio, zboco[0]->id, zboco[0]->name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* get number of BC_t */ if (cgi_get_nodes(zboco[0]->id, "BC_t", &zboco[0]->nbocos, &id)) return CG_ERROR; if (zboco[0]->nbocos > 0) { zboco[0]->boco = CGNS_NEW(cgns_boco,zboco[0]->nbocos); for (n=0; nnbocos; n++) { zboco[0]->boco[n].id = id[n]; zboco[0]->boco[n].link = cgi_read_link(id[n]); zboco[0]->boco[n].in_link = linked; if (cgi_read_boco(&zboco[0]->boco[n])) return CG_ERROR; } /* loop through BC_t nodes */ CGNS_FREE(id); } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, zboco[0]->id, &zboco[0]->ndescr, &zboco[0]->descr, &zboco[0]->data_class, &zboco[0]->units)) return CG_ERROR; /* ReferenceState_t */ if (cgi_read_state(linked, zboco[0]->id, &zboco[0]->state)) return CG_ERROR; /* UserDefinedData_t */ if (cgi_read_user_data(linked, zboco[0]->id, &zboco[0]->nuser_data, &zboco[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_boco(cgns_boco *boco) { int ierr=0, modified = 0; int linked = boco->link ? 1 : boco->in_link; int nIA_t, n, i; double *IA_id, *id; char *boconame; char_33 name, data_type; cgns_ptset *ptset; int ndim; cgsize_t dim_vals[12]; void *vdata; /* get BC_t */ if (cgi_read_string(boco->id, boco->name, &boconame) || cgi_BCType(boconame, &boco->type)) return CG_ERROR; CGNS_FREE(boconame); /* GridLocation_t */ if (cg->version > 1200) { if (cgi_read_location(boco->id, boco->name, &boco->location)) return CG_ERROR; } else { /* Until version 1.2, GridLocation was under BCDataSet_t */ if (boco->ndataset) { /* Wild assumption that all BCDataSet have same GridLocation_t value */ if (cgi_read_location(boco->dataset[0].id, boco->dataset[0].name, &boco->location)) return CG_ERROR; } else { boco->location= CGNS_ENUMV(Vertex); } } /* read point set */ if (cgi_read_one_ptset(linked, boco->id, &boco->ptset)) return CG_ERROR; if (boco->ptset == 0) { cgi_error("Boundary condition patch '%s' not defined",boco->name); return CG_ERROR; } #ifdef CG_FIX_ELEMENTLIST_RANGE /* fix ElementList/Range - no longer allowed (CPEX 0031) */ if (boco->ptset->type == CGNS_ENUMV(ElementList) || boco->ptset->type == CGNS_ENUMV(ElementRange)) { modified++; if (boco->ptset->type == CGNS_ENUMV(ElementList)) { boco->ptset->type = CGNS_ENUMV(PointList); strcpy(boco->ptset->name, "PointList"); } else { boco->ptset->type = CGNS_ENUMV(PointRange); strcpy(boco->ptset->name, "PointRange"); } if (Cdim == 1) boco->location = CGNS_ENUMV(Vertex); else if (Cdim == 2) boco->location = CGNS_ENUMV(EdgeCenter); else boco->location = CGNS_ENUMV(FaceCenter); } #endif /* fix GridLocation */ #ifdef CG_FIX_BC_CELL_CENTER if (boco->location == CGNS_ENUMV(CellCenter)) { if (Cdim == 1) boco->location = CGNS_ENUMV(Vertex); else if (Cdim == 2) boco->location = CGNS_ENUMV(EdgeCenter); else boco->location = CGNS_ENUMV(FaceCenter); cgi_warning("GridLocation CellCenter for BC_t is deprecated - " "changed to %s", GridLocationName[boco->location]); modified++; } #endif /* FamilyName_t */ /* -- FAMILY TREE -- */ if (cgi_read_family_name(linked, boco->id, boco->name, boco->family_name)) return CG_ERROR; /* CPEX 0034 */ if (cgi_get_nodes(boco->id, "AdditionalFamilyName_t", &boco->nfamname, &id)) return CG_ERROR; if (boco->nfamname > 0) { char *fam; boco->famname = CGNS_NEW(cgns_famname, boco->nfamname); for (n = 0; n < boco->nfamname; n++) { boco->famname[n].id = id[n]; if (cgi_read_string(id[n], boco->famname[n].name, &fam)) return CG_ERROR; strncpy(boco->famname[n].family, fam, (CG_MAX_GOTO_DEPTH*(CGIO_MAX_NAME_LENGTH+1))); CGNS_FREE(fam); } CGNS_FREE(id); } /* InwardNormalList */ boco->normal = 0; if (cgi_get_nodes(boco->id, "IndexArray_t", &nIA_t, &IA_id)) return CG_ERROR; for (n=0; ncgio, IA_id[n], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "InwardNormalList")) continue; boco->normal = CGNS_NEW(cgns_array, 1); boco->normal->id = IA_id[n]; boco->normal->link = cgi_read_link(IA_id[n]); boco->normal->in_link = linked; if (cgi_read_node(IA_id[n], boco->normal->name, boco->normal->data_type, &boco->normal->data_dim, boco->normal->dim_vals, &boco->normal->data, READ_DATA)) { cgi_error("Error reading boco->normal"); return CG_ERROR; } /* set to NULL useless elements of data structure */ boco->normal->ndescr = 0; boco->normal->units = 0; boco->normal->exponents = 0; boco->normal->convert = 0; /* data verify */ if (boco->normal->data_dim!=2 || boco->normal->dim_vals[0]!=Pdim || boco->normal->dim_vals[1]!=boco->ptset->size_of_patch || (strcmp(boco->normal->data_type,"R4") && strcmp(boco->normal->data_type,"R8"))) { /*printf("boco->normal->dim_vals[1]=%d, boco->ptset->size_of_patch=%d\n", boco->normal->dim_vals[1],boco->ptset->size_of_patch);*/ cgi_error("InwardNormalList incorrectly defined for BC_t '%s'",boco->name); return CG_ERROR; } break; } if (nIA_t) CGNS_FREE(IA_id); /* InwardNormalIndex */ boco->Nindex = 0; if (cgi_get_nodes(boco->id, "\"int[IndexDimension]\"", &nIA_t, &IA_id)) return CG_ERROR; for (n=0; ncgio, IA_id[n], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "InwardNormalIndex")) continue; boco->index_id=IA_id[n]; if (cgi_read_node(IA_id[n], name, data_type, &ndim, dim_vals, &vdata, READ_DATA)) return CG_ERROR; if (strcmp(data_type,"I4")!=0 || dim_vals[0]!=Idim) { cgi_error("InwardNormalIndex incorrectly defined for BC_t '%s'",boco->name); return CG_ERROR; } boco->Nindex = (int *)vdata; break; } if (nIA_t) CGNS_FREE(IA_id); /* BCDataSet_t */ if (cgi_read_dataset(linked, boco->id, &boco->ndataset, &boco->dataset)) return CG_ERROR; /* Verify that BCData for Dirichlet/Neumann contains the right number of data */ for (n=0; nndataset; n++) { ptset = boco->dataset[n].ptset ? boco->dataset[n].ptset : boco->ptset; if (boco->dataset[n].dirichlet) { for (i=0; idataset[n].dirichlet->narrays; i++) { cgns_array array = boco->dataset[n].dirichlet->array[i]; if (array.data_dim!=1 || (array.dim_vals[0] != 1 && array.dim_vals[0] != ptset->size_of_patch)) { cgi_error("Wrong array size for Dirichlet data"); return CG_ERROR; } } } if (boco->dataset[n].neumann) { for (i=0; idataset[n].neumann->narrays; i++) { cgns_array array = boco->dataset[n].neumann->array[i]; if (array.data_dim!=1 || (array.dim_vals[0] != 1 && array.dim_vals[0] != ptset->size_of_patch)) { cgi_error("Wrong array size for Neumann data"); return CG_ERROR; } } } } if ((cg->version <= 1270 || modified) && cg->mode == CG_MODE_MODIFY && !linked) { double dummy_id; /* fix point set name */ if (cgio_get_name(cg->cgio, boco->ptset->id, name) || strcmp(name, boco->ptset->name)) { if (cgio_set_name(cg->cgio, boco->id, boco->ptset->id, boco->ptset->name)) { cg_io_error("cgio_set_name"); return CG_ERROR; } } /* fix grid location */ ierr = cgio_get_node_id(cg->cgio, boco->id, "GridLocation", &dummy_id); if (!ierr) cgi_delete_node(boco->id, dummy_id); if (boco->location != CGNS_ENUMV(Vertex)) { const char *locname = GridLocationName[boco->location]; cgsize_t len = (cgsize_t)strlen(locname); if (cgi_new_node(boco->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &len, locname)) return CG_ERROR; } } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, boco->id, &boco->ndescr, &boco->descr, &boco->data_class, &boco->units)) return CG_ERROR; /* ReferenceState_t */ if (cgi_read_state(linked, boco->id, &boco->state)) return CG_ERROR; /* Ordinal_t */ if (cgi_read_ordinal(boco->id, &boco->ordinal)) return CG_ERROR; /* BCProperty_t */ if (cgi_read_bprop(linked, boco->id, &boco->bprop)) return CG_ERROR; /* UserDefinedData_t */ if (cgi_read_user_data(linked, boco->id, &boco->nuser_data, &boco->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_bprop(int in_link, double parent_id, cgns_bprop **bprop) { int nchild, n, linked; double *id; char *type_name; /* allocated in cgi_read_node */ char_33 name; /* get number of BCProperty_t nodes and their ID */ if (cgi_get_nodes(parent_id, "BCProperty_t", &nchild, &id)) return CG_ERROR; if (nchild<=0) { bprop[0]=0; return CG_OK; } else if (nchild>1) { cgi_error("Error: Multiple BCProperty_t found..."); CGNS_FREE(id); return CG_ERROR; } bprop[0] = CGNS_NEW(cgns_bprop, 1); bprop[0]->id = id[0]; bprop[0]->link = cgi_read_link(id[0]); bprop[0]->in_link = in_link; linked = bprop[0]->link ? 1 : in_link; CGNS_FREE(id); /* Descriptor_t */ if (cgi_get_nodes(bprop[0]->id, "Descriptor_t", &nchild, &id)) return CG_ERROR; bprop[0]->ndescr = 0; if (nchild>0) { bprop[0]->ndescr = nchild; bprop[0]->descr = CGNS_NEW(cgns_descr, nchild); for (n=0; ndescr[n].id = id[n]; bprop[0]->descr[n].link = cgi_read_link(id[n]); bprop[0]->descr[n].in_link = linked; if (cgi_read_string(id[n], bprop[0]->descr[n].name, &bprop[0]->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, bprop[0]->id, &bprop[0]->nuser_data, &bprop[0]->user_data)) return CG_ERROR; /* WallFunction_t */ if (cgi_get_nodes(bprop[0]->id, "WallFunction_t", &nchild, &id)) return CG_ERROR; if (nchild<=0) { bprop[0]->bcwall = 0; } else if (nchild>1) { cgi_error("Error: Multiple WallFunction_t found..."); CGNS_FREE(id); return CG_ERROR; } else { bprop[0]->bcwall = CGNS_NEW(cgns_bcwall, 1); bprop[0]->bcwall->id = id[0]; bprop[0]->bcwall->link = cgi_read_link(id[0]); bprop[0]->bcwall->in_link = linked; in_link = bprop[0]->bcwall->link ? 1 : linked; CGNS_FREE(id); /* Descriptor_t */ if (cgi_get_nodes(bprop[0]->bcwall->id, "Descriptor_t", &nchild, &id)) return CG_ERROR; bprop[0]->bcwall->ndescr = 0; if (nchild>0) { bprop[0]->bcwall->ndescr = nchild; bprop[0]->bcwall->descr = CGNS_NEW(cgns_descr, nchild); for (n=0; nbcwall->descr[n].id = id[n]; bprop[0]->bcwall->descr[n].link = cgi_read_link(id[n]); bprop[0]->bcwall->descr[n].in_link = in_link; if (cgi_read_string(id[n], bprop[0]->bcwall->descr[n].name, &bprop[0]->bcwall->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(in_link, bprop[0]->bcwall->id, &bprop[0]->bcwall->nuser_data, &bprop[0]->bcwall->user_data)) return CG_ERROR; /* WallFunctionType_t */ if (cgi_get_nodes(bprop[0]->bcwall->id, "WallFunctionType_t", &nchild, &id)) return CG_ERROR; if (nchild==0) { cgi_error("Error: WallFunctionType_t missing under WallFunction_t"); return CG_ERROR; } else if (nchild >1) { cgi_error("File incorrect: multiple definition of WallFunctionType"); CGNS_FREE(id); return CG_ERROR; } else { if (cgi_read_string(id[0], name, &type_name)) return CG_ERROR; CGNS_FREE(id); if (cgi_WallFunctionType(type_name, &bprop[0]->bcwall->type)) return CG_ERROR; CGNS_FREE(type_name); } } /* Area_t */ if (cgi_get_nodes(bprop[0]->id, "Area_t", &nchild, &id)) return CG_ERROR; if (nchild<=0) { bprop[0]->bcarea = 0; } else if (nchild>1) { cgi_error("Error: Multiple Area_t found..."); CGNS_FREE(id); return CG_ERROR; } else { bprop[0]->bcarea = CGNS_NEW(cgns_bcarea, 1); bprop[0]->bcarea->id = id[0]; bprop[0]->bcarea->link = cgi_read_link(id[0]); bprop[0]->bcarea->in_link = linked; in_link = bprop[0]->bcarea->link ? 1 : linked; CGNS_FREE(id); /* Descriptor_t */ if (cgi_get_nodes(bprop[0]->bcarea->id, "Descriptor_t", &nchild, &id)) return CG_ERROR; bprop[0]->bcarea->ndescr = 0; if (nchild>0) { bprop[0]->bcarea->ndescr = nchild; bprop[0]->bcarea->descr = CGNS_NEW(cgns_descr, nchild); for (n=0; nbcarea->descr[n].id = id[n]; bprop[0]->bcarea->descr[n].link = cgi_read_link(id[n]); bprop[0]->bcarea->descr[n].in_link = in_link; if (cgi_read_string(id[n], bprop[0]->bcarea->descr[n].name, &bprop[0]->bcarea->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(in_link, bprop[0]->bcarea->id, &bprop[0]->bcarea->nuser_data, &bprop[0]->bcarea->user_data)) return CG_ERROR; /* AreaType_t */ if (cgi_get_nodes(bprop[0]->bcarea->id, "AreaType_t", &nchild, &id)) return CG_ERROR; if (nchild==0) { cgi_error("Error: AreaType_t missing under Area_t"); return CG_ERROR; } else if (nchild >1) { cgi_error("File incorrect: multiple definition of AreaType"); CGNS_FREE(id); return CG_ERROR; } else { if (cgi_read_string(id[0], name, &type_name)) return CG_ERROR; CGNS_FREE(id); if (cgi_AreaType(type_name, &bprop[0]->bcarea->type)) return CG_ERROR; CGNS_FREE(type_name); } /* DataArray_t: SurfaceArea , RegionName */ if (cgi_get_nodes(bprop[0]->bcarea->id, "DataArray_t", &nchild, &id)) return CG_ERROR; if (nchild==0) { cgi_error("Error: SurfaceArea and RegionName missing under Area_t"); return CG_ERROR; } else if (nchild!=2) { cgi_error("Error: 2 DataArray_t (SurfaceArea & RegionName) required under Area_t"); CGNS_FREE(id); return CG_ERROR; } bprop[0]->bcarea->narrays = nchild; bprop[0]->bcarea->array = CGNS_NEW(cgns_array, bprop[0]->bcarea->narrays); for (n=0; n<(bprop[0]->bcarea->narrays); n++) { cgns_array *array; bprop[0]->bcarea->array[n].id = id[n]; bprop[0]->bcarea->array[n].link = cgi_read_link(id[n]); bprop[0]->bcarea->array[n].in_link = in_link; if (cgi_read_array(&bprop[0]->bcarea->array[n], "Area_t", bprop[0]->bcarea->id)) return CG_ERROR; /* check data */ array = &bprop[0]->bcarea->array[n]; if ((strcmp("SurfaceArea",array->name)==0 && (strcmp(array->data_type,"R4") || array->data_dim!=1 || array->dim_vals[0]!=1)) || (strcmp("RegionName",array->name)==0 && (strcmp(array->data_type,"C1") || array->data_dim!=1 || array->dim_vals[0]!=32)) ){ cgi_error("Error: Array '%s' incorrectly sized",array->name); CGNS_FREE(id); return CG_ERROR; } else if (strcmp("SurfaceArea",array->name) && strcmp("RegionName",array->name)) { cgi_error("Error: Wrong DataArray_t found under Area_t: '%s'",array->name); CGNS_FREE(id); return CG_ERROR; } } /* loop through arrays */ CGNS_FREE(id); } return CG_OK; } int cgi_read_dataset(int in_link, double parent_id, int *ndataset, cgns_dataset **dataset) { int n, i, nnod, linked; double *id, *ids; char_33 name; char *string_data; double *IA_id, *IR_id; int nIA_t, nIR_t, nn; /* BCDataSet_t */ if (cgi_get_nodes(parent_id, "BCDataSet_t", ndataset, &id)) return CG_ERROR; if (*ndataset<=0) { dataset[0]=0; return CG_OK; } dataset[0]=CGNS_NEW(cgns_dataset, (*ndataset)); for (n=0; n<*ndataset; n++) { dataset[0][n].id = id[n]; dataset[0][n].link = cgi_read_link(id[n]); dataset[0][n].in_link = in_link; linked = dataset[0][n].link ? 1 : in_link; if (cgi_read_string(dataset[0][n].id, dataset[0][n].name, &string_data) || cgi_BCType(string_data, &dataset[0][n].type)) return CG_ERROR; CGNS_FREE(string_data); /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, dataset[0][n].id, &dataset[0][n].ndescr, &dataset[0][n].descr, &dataset[0][n].data_class, &dataset[0][n].units)) return CG_ERROR; /* ReferenceState_t */ if (cgi_read_state(linked, dataset[0][n].id, &dataset[0][n].state)) return CG_ERROR; /* BCData_t */ dataset[0][n].dirichlet=dataset[0][n].neumann=0; if (cgi_get_nodes(dataset[0][n].id, "BCData_t", &nnod, &ids)) return CG_ERROR; if (nnod>0) { for (i=0; icgio, ids[i], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name,"DirichletData")==0) { if (dataset[0][n].dirichlet!=0) { cgi_error("Dirichet Data defined more than once..."); return CG_ERROR; } dataset[0][n].dirichlet=CGNS_NEW(cgns_bcdata, 1); dataset[0][n].dirichlet->id = ids[i]; dataset[0][n].dirichlet->link = cgi_read_link(ids[i]); dataset[0][n].dirichlet->in_link = linked; strcpy(dataset[0][n].dirichlet->name,"DirichletData"); if (cgi_read_bcdata(dataset[0][n].dirichlet)) return CG_ERROR; } else if (strcmp(name,"NeumannData")==0) { if (dataset[0][n].neumann!=0) { cgi_error("Neumann Data defined more than once..."); return CG_ERROR; } dataset[0][n].neumann=CGNS_NEW(cgns_bcdata, 1); dataset[0][n].neumann->id = ids[i]; dataset[0][n].neumann->link = cgi_read_link(ids[i]); dataset[0][n].neumann->in_link = linked; strcpy(dataset[0][n].neumann->name,"NeumannData"); if (cgi_read_bcdata(dataset[0][n].neumann)) return CG_ERROR; } } CGNS_FREE(ids); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, dataset[0][n].id, &dataset[0][n].nuser_data, &dataset[0][n].user_data)) return CG_ERROR; /* GridLocation_t */ if (cgi_read_location(dataset[0][n].id, dataset[0][n].name, &dataset[0][n].location)) return CG_ERROR; /* PointSet */ /* get number of IndexArray_t and IndexRange_t nodes and their * ID */ if (cgi_get_nodes(dataset[0][n].id, "IndexArray_t", &nIA_t, &IA_id)) return CG_ERROR; if (cgi_get_nodes(dataset[0][n].id, "IndexRange_t", &nIR_t, &IR_id)) return CG_ERROR; /* initialized */ dataset[0][n].ptset = 0; for (nn=0; nncgio, IR_id[nn], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name,"PointRange") && strcmp(name,"ElementRange")) { cgi_error("Invalid name for IndexRange_t"); return CG_ERROR; } if (dataset[0][n].ptset!=0) { cgi_error("Multiple definition of boundary patch found"); return CG_ERROR; } dataset[0][n].ptset = CGNS_NEW(cgns_ptset, 1); if (strcmp(name,"ElementRange")==0) dataset[0][n].ptset->type = CGNS_ENUMV(ElementRange); else dataset[0][n].ptset->type = CGNS_ENUMV(PointRange); dataset[0][n].ptset->id=IR_id[nn]; dataset[0][n].ptset->link=cgi_read_link(IR_id[nn]); dataset[0][n].ptset->in_link=linked; if (cgi_read_ptset(dataset[0][n].id, dataset[0][n].ptset)) return CG_ERROR; } if (nIR_t) CGNS_FREE(IR_id); for (nn=0; nncgio, IA_id[nn], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "PointList") && strcmp(name,"ElementList")) continue; if (dataset[0][n].ptset!=0) { cgi_error("Multiple definition of boundary patch found"); return CG_ERROR; } dataset[0][n].ptset = CGNS_NEW(cgns_ptset, 1); if (strcmp(name,"ElementList")==0) dataset[0][n].ptset->type = CGNS_ENUMV( ElementList ); else dataset[0][n].ptset->type = CGNS_ENUMV( PointList ); dataset[0][n].ptset->id = IA_id[nn]; dataset[0][n].ptset->link = cgi_read_link(IA_id[nn]); dataset[0][n].ptset->in_link = linked; if (cgi_read_ptset(dataset[0][n].id, dataset[0][n].ptset)) return CG_ERROR; } if (nIA_t) CGNS_FREE(IA_id); } CGNS_FREE(id); return CG_OK; } int cgi_read_bcdata(cgns_bcdata *bcdata) { int n, linked = bcdata->link ? 1 : bcdata->in_link; double *id; /* DataArray_t */ if (cgi_get_nodes(bcdata->id, "DataArray_t", &bcdata->narrays, &id)) return CG_ERROR; if (bcdata->narrays>0) { bcdata->array = CGNS_NEW(cgns_array, bcdata->narrays); for (n=0; nnarrays; n++) { bcdata->array[n].id = id[n]; bcdata->array[n].link = cgi_read_link(id[n]); bcdata->array[n].in_link = linked; cgi_read_array(&bcdata->array[n],"BCData_t",bcdata->id); } CGNS_FREE(id); } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, bcdata->id, &bcdata->ndescr, &bcdata->descr, &bcdata->data_class, &bcdata->units)) return CG_ERROR; /* UserDefinedData_t */ if (cgi_read_user_data(linked, bcdata->id, &bcdata->nuser_data, &bcdata->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_one_ptset(int linked, double parent_id, cgns_ptset **pptset) { int i, nI_t; double *I_id; char_33 name; cgns_ptset *ptset = NULL; if (cgi_get_nodes(parent_id, "IndexArray_t", &nI_t, &I_id)) return CG_ERROR; for (i = 0; i < nI_t; i++) { if (cgio_get_name(cg->cgio, I_id[i], name)) { cg_io_error("cgio_get_name for PointList"); return CG_ERROR; } if (strcmp(name, "PointList") && strcmp(name, "ElementList")) continue; if (ptset != NULL) { cgi_error("Multiple definitions of PointList/PointRange"); CGNS_FREE(ptset); return CG_ERROR; } ptset = CGNS_NEW(cgns_ptset, 1); if (0 == strcmp(name, "ElementList")) ptset->type = CGNS_ENUMV(ElementList); else ptset->type = CGNS_ENUMV(PointList); ptset->id=I_id[i]; ptset->link=cgi_read_link(I_id[i]); ptset->in_link=linked; if (cgi_read_ptset(I_id[i], ptset)){ CGNS_FREE(ptset); return CG_ERROR; } } if (nI_t) CGNS_FREE(I_id); if (cgi_get_nodes(parent_id, "IndexRange_t", &nI_t, &I_id)) return CG_ERROR; for (i = 0; i < nI_t; i++) { if (cgio_get_name(cg->cgio, I_id[i], name)) { cg_io_error("cgio_get_name for PointRange"); return CG_ERROR; } if (strcmp(name, "PointRange") && strcmp(name, "ElementRange")) continue; if (ptset != NULL) { cgi_error("Multiple definitions of PointList/PointRange"); CGNS_FREE(ptset); return CG_ERROR; } ptset = CGNS_NEW(cgns_ptset, 1); if (0 == strcmp(name, "ElementRange")) ptset->type = CGNS_ENUMV(ElementRange); else ptset->type = CGNS_ENUMV(PointRange); ptset->id=I_id[i]; ptset->link=cgi_read_link(I_id[i]); ptset->in_link=linked; if (cgi_read_ptset(I_id[i], ptset)){ CGNS_FREE(ptset); return CG_ERROR; } } if (nI_t) CGNS_FREE(I_id); *pptset = ptset; return CG_OK; } int cgi_read_ptset(double parent_id, cgns_ptset *ptset) { int ndim; cgsize_t dim_vals[12]; void **dummy=0; /* Get name of point set just to verify consistency */ if (cgi_read_node(ptset->id, ptset->name, ptset->data_type, &ndim, dim_vals, dummy, SKIP_DATA)) { cgi_error("Error reading ptset"); return CG_ERROR; } /* change read data for ElementList/Range stuff */ if (cg->version <= 1200 && ndim == 1 && (ptset->type == CGNS_ENUMV(ElementRange) || ptset->type == CGNS_ENUMV(ElementList))) { ndim = 2; dim_vals[1]=dim_vals[0]; dim_vals[0]=Idim; if (cg->mode == CG_MODE_MODIFY && ptset->link == 0 && ptset->in_link == 0) { if (cgio_set_dimensions(cg->cgio, ptset->id, CG_SIZE_DATATYPE, 2, dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } } } /* verify that the name matches the type intended */ if (INVALID_ENUM(ptset->type,NofValidPointSetTypes)) { cgi_error("Invalid point set type: '%s'",ptset->name); return CG_ERROR; } /* verify data type */ if (strcmp(ptset->data_type,"I4") && strcmp(ptset->data_type,"I8")) { cgi_error("Data type %s not supported for point set type %d", ptset->data_type, ptset->type); return CG_ERROR; } /* verify dimension vector */ if (!(ndim==2 && dim_vals[0]>0 && dim_vals[1]>0)) { cgi_error("Invalid definition of point set: ptset->type='%s', ndim=%d, dim_vals[0]=%" PRIdCGSIZE , PointSetTypeName[ptset->type], ndim, dim_vals[0]); return CG_ERROR; } /* npts */ ptset->npts = dim_vals[1]; /* size_of_patch */ if (ptset->type == CGNS_ENUMV(PointList) || ptset->type == CGNS_ENUMV(ElementList) || ptset->type == CGNS_ENUMV(PointListDonor) || ptset->type == CGNS_ENUMV(CellListDonor)) { ptset->size_of_patch = ptset->npts; } else { /* read points to calculate size_of_patch */ int i; cgsize_t size=1; for (i=0; iname); return CG_ERROR; } if (0 == strcmp(ptset->data_type,"I8")) { cglong_t total = 1; cglong_t *pnts = CGNS_NEW(cglong_t, size); if (cgio_read_all_data_type(cg->cgio, ptset->id, ptset->data_type, pnts)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } #if CG_SIZEOF_SIZE == 32 if (cgio_check_dimensions(2*Idim, pnts)) { cg_io_error("cgio_check_dimensions"); return CG_ERROR; } #endif for (i=0; i CG_MAX_INT32) { cgi_error("patch size too large for a 32-bit integer"); return CG_ERROR; } #endif ptset->size_of_patch = (cgsize_t)total; } else if (0 == strcmp(ptset->data_type,"I4")) { int *pnts = CGNS_NEW(int, size); if (cgio_read_all_data_type(cg->cgio, ptset->id, ptset->data_type, pnts)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } ptset->size_of_patch = 1; for (i=0; isize_of_patch *= (pnts[i+Idim]-pnts[i]+1); CGNS_FREE(pnts); } else { cgi_error("Invalid datatype for a range pointset"); return CG_ERROR; } } return CG_OK; } int cgi_read_equations_node(int linked, cgns_equations** equations) { double* id; int n, nnod, ndim; char* string_data; char_33 name, data_type; cgsize_t dim_vals[12]; void* vdata; /* GoverningEquations_t */ equations[0]->governing = 0; if (cgi_get_nodes(equations[0]->id, "GoverningEquations_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) { equations[0]->governing = CGNS_NEW(cgns_governing, 1); equations[0]->governing->id = id[0]; equations[0]->governing->link = cgi_read_link(id[0]); equations[0]->governing->in_link = linked; if (cgi_read_string(id[0], equations[0]->governing->name, &string_data) || cgi_GoverningEquationsType(string_data, &equations[0]->governing->type)) return CG_ERROR; CGNS_FREE(string_data); CGNS_FREE(id); /* initialize dependants */ equations[0]->governing->diffusion_model = 0; /* DiffusionModel */ if (cgi_get_nodes(equations[0]->governing->id, "\"int[1+...+IndexDimension]\"", &nnod, &id)) return CG_ERROR; if (nnod > 0) { if (cgi_read_node(id[0], name, data_type, &ndim, dim_vals, &vdata, READ_DATA)) { cgi_error("Error reading diffusion model"); return CG_ERROR; } if (ndim != 1 || dim_vals[0] <= 0 || strcmp(data_type, "I4")) { cgi_error("Diffusion Model '%s' defined incorrectly", name); return CG_ERROR; } equations[0]->governing->dim_vals = (int)dim_vals[0], equations[0]->governing->diffusion_model = (int*)vdata; CGNS_FREE(id); } /* Descriptor_t */ if (cgi_get_nodes(equations[0]->governing->id, "Descriptor_t", &equations[0]->governing->ndescr, &id)) return CG_ERROR; if (equations[0]->governing->ndescr > 0) { equations[0]->governing->descr = CGNS_NEW(cgns_descr, equations[0]->governing->ndescr); for (n = 0; n < equations[0]->governing->ndescr; n++) { equations[0]->governing->descr[n].id = id[n]; equations[0]->governing->descr[n].link = cgi_read_link(id[n]); equations[0]->governing->descr[n].in_link = linked; if (cgi_read_string(id[n], equations[0]->governing->descr[n].name, &equations[0]->governing->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, equations[0]->governing->id, &equations[0]->governing->nuser_data, &equations[0]->governing->user_data)) return CG_ERROR; } /* GasModel_t */ if (cgi_read_model(linked, equations[0]->id, "GasModel_t", &equations[0]->gas)) return CG_ERROR; /* ViscosityModel_t */ if (cgi_read_model(linked, equations[0]->id, "ViscosityModel_t", &equations[0]->visc)) return CG_ERROR; /* ThermalConductivityModel_t */ if (cgi_read_model(linked, equations[0]->id, "ThermalConductivityModel_t", &equations[0]->conduct)) return CG_ERROR; /* TurbulenceClosure_t */ if (cgi_read_model(linked, equations[0]->id, "TurbulenceClosure_t", &equations[0]->closure)) return CG_ERROR; /* TurbulenceModel_t */ if (cgi_read_model(linked, equations[0]->id, "TurbulenceModel_t", &equations[0]->turbulence)) return CG_ERROR; /* initialize dependants */ if (equations[0]->turbulence) { equations[0]->turbulence->diffusion_model = 0; /* DiffusionModel */ if (cgi_get_nodes(equations[0]->turbulence->id, "\"int[1+...+IndexDimension]\"", &nnod, &id)) return CG_ERROR; if (nnod > 0) { if (cgi_read_node(id[0], name, data_type, &ndim, dim_vals, &vdata, READ_DATA)) { cgi_error("Error reading Turbulence Diffusion Model"); return CG_ERROR; } if (ndim != 1 || dim_vals[0] <= 0 || strcmp(data_type, "I4")) { cgi_error("Diffusion Model '%s' defined incorrectly", name); return CG_ERROR; } equations[0]->turbulence->dim_vals = (int)dim_vals[0], equations[0]->turbulence->diffusion_model = (int*)vdata; CGNS_FREE(id); } } /* ThermalRelaxationModel_t */ if (cgi_read_model(linked, equations[0]->id, "ThermalRelaxationModel_t", &equations[0]->relaxation)) return CG_ERROR; /* ChemicalKineticsModel_t */ if (cgi_read_model(linked, equations[0]->id, "ChemicalKineticsModel_t", &equations[0]->chemkin)) return CG_ERROR; /* EquationDimension */ equations[0]->equation_dim = 0; if (cgi_get_nodes(equations[0]->id, "\"int\"", &nnod, &id)) return CG_ERROR; if (nnod > 0) { if (cgi_read_node(id[0], name, data_type, &ndim, dim_vals, &vdata, READ_DATA)) { cgi_error("Error reading base"); return CG_ERROR; } /* verify data */ if (strcmp(name, "EquationDimension") || strcmp(data_type, "I4") || ndim != 1 || dim_vals[0] != 1) { cgi_error("Error reading equation dimension for Flow Equation Set"); return CG_ERROR; } equations[0]->equation_dim = *((int*)vdata); CGNS_FREE(vdata); CGNS_FREE(id); } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, equations[0]->id, &equations[0]->ndescr, &equations[0]->descr, &equations[0]->data_class, &equations[0]->units)) return CG_ERROR; /* UserDefinedData_t */ if (cgi_read_user_data(linked, equations[0]->id, &equations[0]->nuser_data, &equations[0]->user_data)) return CG_ERROR; /* EMElectricFieldModel_t */ if (cgi_read_model(linked, equations[0]->id, "EMElectricFieldModel_t", &equations[0]->elecfield)) return CG_ERROR; /* EMMagneticFieldModel_t */ if (cgi_read_model(linked, equations[0]->id, "EMMagneticFieldModel_t", &equations[0]->magnfield)) return CG_ERROR; /* EMConductivityModel_t */ if (cgi_read_model(linked, equations[0]->id, "EMConductivityModel_t", &equations[0]->emconduct)) return CG_ERROR; return CG_OK; } int cgi_read_equations_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_equations** equations) { int nnod, start, linked; nnod = nnodes; start = 0; if (nnod <= 0) { equations[0] = 0; return CG_OK; } equations[0] = CGNS_NEW(cgns_equations, 1); equations[0]->id = nodelist[start].id; equations[0]->link = cgi_read_link(nodelist[start].id); equations[0]->in_link = in_link; linked = equations[0]->link ? 1 : in_link; strcpy(equations[0]->name, "FlowEquationSet"); if (cgi_read_equations_node(linked, equations)) return CG_ERROR; return CG_OK; } int cgi_read_equations(int in_link, double parent_id, cgns_equations **equations) { double *id; int nnod, linked; if (cgi_get_nodes(parent_id, "FlowEquationSet_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { equations[0]=0; return CG_OK; } equations[0] = CGNS_NEW(cgns_equations, 1); equations[0]->id = id[0]; equations[0]->link = cgi_read_link(id[0]); equations[0]->in_link = in_link; linked = equations[0]->link ? 1 : in_link; CGNS_FREE(id); strcpy(equations[0]->name, "FlowEquationSet"); if (cgi_read_equations_node(linked, equations)) return CG_ERROR; return CG_OK; } int cgi_read_model(int in_link, double parent_id, char *label, cgns_model **model) { int n, nnod, linked; double *id; char *string_data; if (cgi_get_nodes(parent_id, label, &nnod, &id)) return CG_ERROR; if (nnod<=0) { model[0]=0; return CG_OK; } model[0] = CGNS_NEW(cgns_model,1); model[0]->id = id[0]; model[0]->link = cgi_read_link(id[0]); model[0]->in_link = in_link; linked = model[0]->link ? 1 : in_link; CGNS_FREE(id); /* Model Type */ if (cgi_read_string(model[0]->id, model[0]->name, &string_data)) return CG_ERROR; if (cgi_ModelType(string_data, &model[0]->type)) return CG_ERROR; CGNS_FREE(string_data); /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, model[0]->id, &model[0]->ndescr, &model[0]->descr, &model[0]->data_class, &model[0]->units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(model[0]->id, "DataArray_t", &model[0]->narrays, &id)) return CG_ERROR; if (model[0]->narrays>0) { model[0]->array = CGNS_NEW(cgns_array, model[0]->narrays); for (n=0; nnarrays; n++) { model[0]->array[n].id = id[n]; model[0]->array[n].link = cgi_read_link(id[n]); model[0]->array[n].in_link = linked; if (cgi_read_array(&model[0]->array[n],"Model_t", model[0]->id)) return CG_ERROR; /* verify data */ if (model[0]->array[n].data_dim!=1 || model[0]->array[n].dim_vals[0]!=1) { cgi_error("Wrong data dimension in %s definition",model[0]->name); return CG_ERROR; } } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, model[0]->id, &model[0]->nuser_data, &model[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_state_from_list(int in_link, const _childnode_t *nodelist, int nnodes, cgns_state** state) { char_33 name; int n, nnod, defined = 0, linked; int start = 0; char* string_data; double* id; nnod = nnodes; if (nnod <= 0) { state[0] = 0; return CG_OK; } state[0] = CGNS_NEW(cgns_state, 1); state[0]->id = nodelist[start].id; state[0]->link = cgi_read_link(nodelist[start].id); state[0]->in_link = in_link; linked = state[0]->link ? 1 : in_link; /* Name */ strcpy(state[0]->name, nodelist[start].name); /* initialize dependents */ state[0]->data_class = CGNS_ENUMV(DataClassNull); state[0]->StateDescription = 0; state[0]->ndescr = 0; /* Descriptor_t and ReferenceStateDescription */ if (cgi_get_nodes(state[0]->id, "Descriptor_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) { for (n = 0; n < nnod; n++) { if (cgio_get_name(cg->cgio, id[n], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "ReferenceStateDescription")) { if (state[0]->ndescr == 0) state[0]->descr = CGNS_NEW(cgns_descr, 1); else state[0]->descr = CGNS_RENEW(cgns_descr, state[0]->ndescr + 1, state[0]->descr); state[0]->descr[state[0]->ndescr].id = id[n]; state[0]->descr[state[0]->ndescr].link = cgi_read_link(id[n]); state[0]->descr[state[0]->ndescr].in_link = linked; if (cgi_read_string(id[n], state[0]->descr[state[0]->ndescr].name, &state[0]->descr[state[0]->ndescr].text)) return CG_ERROR; state[0]->ndescr++; } else { if (defined) { cgi_error("Reference State node may only hold one ReferenceStateDescription"); return CG_ERROR; } state[0]->StateDescription = CGNS_NEW(cgns_descr, 1); state[0]->StateDescription->id = id[n]; state[0]->StateDescription->link = cgi_read_link(id[n]); state[0]->StateDescription->in_link = linked; if (cgi_read_string(id[n], state[0]->StateDescription->name, &state[0]->StateDescription->text)) return CG_ERROR; defined++; } } CGNS_FREE(id); } /* DataClass_t */ if (cgi_get_nodes(state[0]->id, "DataClass_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) { if (cgi_read_string(id[0], name, &string_data)) return CG_ERROR; cgi_DataClass(string_data, &state[0]->data_class); CGNS_FREE(string_data); CGNS_FREE(id); } /* DimensionalUnits_t */ if (cgi_read_units(linked, state[0]->id, &state[0]->units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(state[0]->id, "DataArray_t", &state[0]->narrays, &id)) return CG_ERROR; if (state[0]->narrays > 0) { state[0]->array = CGNS_NEW(cgns_array, state[0]->narrays); for (n = 0; n < state[0]->narrays; n++) { state[0]->array[n].id = id[n]; state[0]->array[n].link = cgi_read_link(id[n]); state[0]->array[n].in_link = linked; if (cgi_read_array(&state[0]->array[n], "ReferenceState_t", state[0]->id)) return CG_ERROR; /* verify data */ if (state[0]->array[n].data_dim != 1 || state[0]->array[n].dim_vals[0] != 1) { cgi_error("Wrong data dimension in Reference State definition"); return CG_ERROR; } } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, state[0]->id, &state[0]->nuser_data, &state[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_state(int in_link, double parent_id, cgns_state **state) { char_33 name; int n, nnod, defined=0, linked; double *id; char *string_data; if (cgi_get_nodes(parent_id, "ReferenceState_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { state[0]=0; return CG_OK; } state[0] = CGNS_NEW(cgns_state, 1); state[0]->id=id[0]; state[0]->link=cgi_read_link(id[0]); state[0]->in_link=in_link; linked = state[0]->link ? 1 : in_link; CGNS_FREE(id); /* Name */ if (cgio_get_name(cg->cgio, state[0]->id, state[0]->name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* initialize dependents */ state[0]->data_class = CGNS_ENUMV( DataClassNull ); state[0]->StateDescription = 0; state[0]->ndescr=0; /* Descriptor_t and ReferenceStateDescription */ if (cgi_get_nodes(state[0]->id, "Descriptor_t", &nnod, &id)) return CG_ERROR; if (nnod>0) { for (n=0; ncgio, id[n], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name,"ReferenceStateDescription")) { if (state[0]->ndescr==0) state[0]->descr = CGNS_NEW(cgns_descr, 1); else state[0]->descr = CGNS_RENEW(cgns_descr, state[0]->ndescr+1, state[0]->descr); state[0]->descr[state[0]->ndescr].id = id[n]; state[0]->descr[state[0]->ndescr].link = cgi_read_link(id[n]); state[0]->descr[state[0]->ndescr].in_link = linked; if (cgi_read_string(id[n], state[0]->descr[state[0]->ndescr].name, &state[0]->descr[state[0]->ndescr].text)) return CG_ERROR; state[0]->ndescr++; } else { if (defined) { cgi_error("Reference State node may only hold one ReferenceStateDescription"); return CG_ERROR; } state[0]->StateDescription= CGNS_NEW(cgns_descr, 1); state[0]->StateDescription->id = id[n]; state[0]->StateDescription->link = cgi_read_link(id[n]); state[0]->StateDescription->in_link = linked; if (cgi_read_string(id[n], state[0]->StateDescription->name, &state[0]->StateDescription->text)) return CG_ERROR; defined ++; } } CGNS_FREE(id); } /* DataClass_t */ if (cgi_get_nodes(state[0]->id, "DataClass_t", &nnod, &id)) return CG_ERROR; if (nnod>0) { if (cgi_read_string(id[0], name, &string_data)) return CG_ERROR; cgi_DataClass(string_data, &state[0]->data_class); CGNS_FREE(string_data); CGNS_FREE(id); } /* DimensionalUnits_t */ if (cgi_read_units(linked, state[0]->id, &state[0]->units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(state[0]->id, "DataArray_t", &state[0]->narrays, &id)) return CG_ERROR; if (state[0]->narrays>0) { state[0]->array = CGNS_NEW(cgns_array, state[0]->narrays); for (n=0; nnarrays; n++) { state[0]->array[n].id = id[n]; state[0]->array[n].link = cgi_read_link(id[n]); state[0]->array[n].in_link = linked; if (cgi_read_array(&state[0]->array[n],"ReferenceState_t", state[0]->id)) return CG_ERROR; /* verify data */ if (state[0]->array[n].data_dim!=1 || state[0]->array[n].dim_vals[0]!=1) { cgi_error("Wrong data dimension in Reference State definition"); return CG_ERROR; } } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, state[0]->id, &state[0]->nuser_data, &state[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_gravity_from_list(int in_link, const _childnode_t *nodelist, const int nnodes, cgns_gravity** gravity) { int i, nnod, linked; double* id; char_33 temp_name; //Assume nodelist is full of LabelGravity_t nnod = nnodes; if (nnod <= 0) { gravity[0] = 0; return CG_OK; } gravity[0] = CGNS_NEW(cgns_gravity, 1); gravity[0]->id = nodelist[0].id; gravity[0]->link = cgi_read_link(nodelist[0].id); gravity[0]->in_link = in_link; linked = gravity[0]->link ? 1 : in_link; /* Name */ strcpy(gravity[0]->name, nodelist[0].name); /* initialize dependents */ gravity[0]->vector = 0; gravity[0]->narrays = 0; /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, gravity[0]->id, &gravity[0]->ndescr, &gravity[0]->descr, &gravity[0]->data_class, &gravity[0]->units)) return CG_ERROR; /* DataArray_t: GravityVector */ if (cgi_get_nodes(gravity[0]->id, "DataArray_t", &nnod, &id)) return CG_ERROR; for (i = 0; i < nnod; i++) { if (cgio_get_name(cg->cgio, id[i], temp_name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* GravityVector */ if (strcmp(temp_name, "GravityVector") == 0) { gravity[0]->vector = CGNS_NEW(cgns_array, 1); gravity[0]->vector->id = id[i]; gravity[0]->vector->link = cgi_read_link(id[i]); gravity[0]->vector->in_link = linked; if (cgi_read_array(gravity[0]->vector, "Gravity_t", gravity[0]->id)) return CG_ERROR; gravity[0]->narrays = 1; /* check data */ if (strcmp(gravity[0]->vector->data_type, "R4")) { cgi_error("Datatype %s not supported for gravity vector", gravity[0]->vector->data_type); return CG_ERROR; } if (gravity[0]->vector->data_dim != 1 || gravity[0]->vector->dim_vals[0] != Pdim) { cgi_error("Error exit: Gravity vector incorrectly dimensioned"); return CG_ERROR; } } } /* loop through DataArray_t */ if (nnod) CGNS_FREE(id); /* check data */ if (gravity[0]->vector == 0) { cgi_error("Error exit: Gravity vector undefined in Gravity_t node"); return CG_ERROR; } /* UserDefinedData_t */ if (cgi_read_user_data(linked, gravity[0]->id, &gravity[0]->nuser_data, &gravity[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_gravity(int in_link, double parent_id, cgns_gravity **gravity) { int i, nnod, linked; double *id; char_33 temp_name; if (cgi_get_nodes(parent_id, "Gravity_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { gravity[0]=0; return CG_OK; } gravity[0] = CGNS_NEW(cgns_gravity, 1); gravity[0]->id=id[0]; gravity[0]->link=cgi_read_link(id[0]); gravity[0]->in_link=in_link; linked = gravity[0]->link ? 1 : in_link; CGNS_FREE(id); /* Name */ if (cgio_get_name(cg->cgio, gravity[0]->id, gravity[0]->name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* initialize dependents */ gravity[0]->vector=0; gravity[0]->narrays = 0; /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, gravity[0]->id, &gravity[0]->ndescr, &gravity[0]->descr, &gravity[0]->data_class, &gravity[0]->units)) return CG_ERROR; /* DataArray_t: GravityVector */ if (cgi_get_nodes(gravity[0]->id, "DataArray_t", &nnod, &id)) return CG_ERROR; for (i=0; icgio, id[i], temp_name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* GravityVector */ if (strcmp(temp_name,"GravityVector")==0) { gravity[0]->vector = CGNS_NEW(cgns_array, 1); gravity[0]->vector->id = id[i]; gravity[0]->vector->link = cgi_read_link(id[i]); gravity[0]->vector->in_link = linked; if (cgi_read_array(gravity[0]->vector, "Gravity_t", gravity[0]->id)) return CG_ERROR; gravity[0]->narrays = 1; /* check data */ if (strcmp(gravity[0]->vector->data_type,"R4")) { cgi_error("Datatype %s not supported for gravity vector",gravity[0]->vector->data_type); return CG_ERROR; } if (gravity[0]->vector->data_dim != 1 || gravity[0]->vector->dim_vals[0] != Pdim) { cgi_error("Error exit: Gravity vector incorrectly dimensioned"); return CG_ERROR; } } } /* loop through DataArray_t */ if (nnod) CGNS_FREE(id); /* check data */ if (gravity[0]->vector == 0) { cgi_error("Error exit: Gravity vector undefined in Gravity_t node"); return CG_ERROR; } /* UserDefinedData_t */ if (cgi_read_user_data(linked, gravity[0]->id, &gravity[0]->nuser_data, &gravity[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_axisym_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_axisym** axisym) { int i, nnod, linked, ref_point_flag = 0, axis_flag = 0; double* id; char_33 temp_name; nnod = nnodes; if (nnod <= 0) { axisym[0] = 0; return CG_OK; } if (Pdim != 2) { cgi_error("Error: Axisymmetry_t can only be defined for 2D data model"); return CG_ERROR; } axisym[0] = CGNS_NEW(cgns_axisym, 1); axisym[0]->id = nodelist[0].id; axisym[0]->link = cgi_read_link(nodelist[0].id); axisym[0]->in_link = in_link; linked = axisym[0]->link ? 1 : in_link; /* Name */ strcpy(axisym[0]->name, nodelist[0].name); /* initialize dependents */ axisym[0]->narrays = 0; /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, axisym[0]->id, &axisym[0]->ndescr, &axisym[0]->descr, &axisym[0]->data_class, &axisym[0]->units)) return CG_ERROR; /* DataArray_t: Required: AxisymmetryReferencePoint, AxisymmetryAxisVector Optional: AxisymmetryAngle, CoordinateNames */ if (cgi_get_nodes(axisym[0]->id, "DataArray_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) axisym[0]->array = CGNS_NEW(cgns_array, nnod); for (i = 0; i < nnod; i++) { if (cgio_get_name(cg->cgio, id[i], temp_name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* AxisymmetryReferencePoint & AxisymmetryAxisVector */ if (strcmp(temp_name, "AxisymmetryReferencePoint") == 0 || strcmp(temp_name, "AxisymmetryAxisVector") == 0) { if (strcmp(temp_name, "AxisymmetryReferencePoint") == 0) ref_point_flag = 1; else if (strcmp(temp_name, "AxisymmetryAxisVector") == 0) axis_flag = 1; axisym[0]->array[axisym[0]->narrays].id = id[i]; axisym[0]->array[axisym[0]->narrays].link = cgi_read_link(id[i]); axisym[0]->array[axisym[0]->narrays].in_link = linked; if (cgi_read_array(&axisym[0]->array[axisym[0]->narrays], "Axisymmetry_t", axisym[0]->id)) return CG_ERROR; /* check data */ if (strcmp(axisym[0]->array[axisym[0]->narrays].data_type, "R4")) { cgi_error("Error: Datatype %s not supported for %s", axisym[0]->array[axisym[0]->narrays].data_type, temp_name); return CG_ERROR; } if (axisym[0]->array[axisym[0]->narrays].data_dim != 1 || axisym[0]->array[axisym[0]->narrays].dim_vals[0] != Pdim) { cgi_error("Error: %s incorrectly dimensioned", temp_name); return CG_ERROR; } axisym[0]->narrays++; } /* AxisymmetryAngle */ else if (strcmp(temp_name, "AxisymmetryAngle") == 0) { axisym[0]->array[axisym[0]->narrays].id = id[i]; axisym[0]->array[axisym[0]->narrays].link = cgi_read_link(id[i]); axisym[0]->array[axisym[0]->narrays].in_link = linked; if (cgi_read_array(&axisym[0]->array[axisym[0]->narrays], "Axisymmetry_t", axisym[0]->id)) return CG_ERROR; /* check data */ if (strcmp(axisym[0]->array[axisym[0]->narrays].data_type, "R4")) { cgi_error("Error: Datatype %s not supported for %s", axisym[0]->array[axisym[0]->narrays].data_type, temp_name); return CG_ERROR; } if (axisym[0]->array[axisym[0]->narrays].data_dim != 1 || axisym[0]->array[axisym[0]->narrays].dim_vals[0] != 1) { cgi_error("Error: %s incorrectly dimensioned", temp_name); return CG_ERROR; } axisym[0]->narrays++; } /* CoordinateNames */ else if (strcmp(temp_name, "CoordinateNames") == 0) { axisym[0]->array[axisym[0]->narrays].id = id[i]; axisym[0]->array[axisym[0]->narrays].link = cgi_read_link(id[i]); axisym[0]->array[axisym[0]->narrays].in_link = linked; if (cgi_read_array(&axisym[0]->array[axisym[0]->narrays], "Axisymmetry_t", axisym[0]->id)) return CG_ERROR; /* check data */ if (strcmp(axisym[0]->array[axisym[0]->narrays].data_type, "C1")) { cgi_error("Error: Datatype %s not supported for %s", axisym[0]->array[axisym[0]->narrays].data_type, temp_name); return CG_ERROR; } if (axisym[0]->array[axisym[0]->narrays].data_dim != 2 || axisym[0]->array[axisym[0]->narrays].dim_vals[0] != 32 || axisym[0]->array[axisym[0]->narrays].dim_vals[1] != 2) { cgi_error("Error: %s incorrectly dimensioned", temp_name); return CG_ERROR; } axisym[0]->narrays++; } } /* loop through DataArray_t */ if (nnod) CGNS_FREE(id); /* check data */ if (!ref_point_flag || !axis_flag) { cgi_error("Error: AxisymmetryReferencePoint & AxisymmetryAxisVector are required"); return CG_ERROR; } /* UserDefinedData_t */ if (cgi_read_user_data(linked, axisym[0]->id, &axisym[0]->nuser_data, &axisym[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_axisym(int in_link, double parent_id, cgns_axisym **axisym) { int i, nnod, linked, ref_point_flag=0, axis_flag=0; double *id; char_33 temp_name; if (cgi_get_nodes(parent_id, "Axisymmetry_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { axisym[0]=0; return CG_OK; } if (Pdim !=2) { cgi_error("Error: Axisymmetry_t can only be defined for 2D data model"); return CG_ERROR; } axisym[0] = CGNS_NEW(cgns_axisym, 1); axisym[0]->id=id[0]; axisym[0]->link=cgi_read_link(id[0]); axisym[0]->in_link=in_link; linked = axisym[0]->link ? 1 : in_link; CGNS_FREE(id); /* Name */ if (cgio_get_name(cg->cgio, axisym[0]->id, axisym[0]->name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* initialize dependents */ axisym[0]->narrays=0; /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, axisym[0]->id, &axisym[0]->ndescr, &axisym[0]->descr, &axisym[0]->data_class, &axisym[0]->units)) return CG_ERROR; /* DataArray_t: Required: AxisymmetryReferencePoint, AxisymmetryAxisVector Optional: AxisymmetryAngle, CoordinateNames */ if (cgi_get_nodes(axisym[0]->id, "DataArray_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) axisym[0]->array = CGNS_NEW(cgns_array, nnod); for (i=0; icgio, id[i], temp_name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* AxisymmetryReferencePoint & AxisymmetryAxisVector */ if (strcmp(temp_name,"AxisymmetryReferencePoint")==0 || strcmp(temp_name,"AxisymmetryAxisVector")==0) { if (strcmp(temp_name,"AxisymmetryReferencePoint")==0) ref_point_flag = 1; else if (strcmp(temp_name,"AxisymmetryAxisVector")==0) axis_flag = 1; axisym[0]->array[axisym[0]->narrays].id = id[i]; axisym[0]->array[axisym[0]->narrays].link = cgi_read_link(id[i]); axisym[0]->array[axisym[0]->narrays].in_link = linked; if (cgi_read_array(&axisym[0]->array[axisym[0]->narrays], "Axisymmetry_t", axisym[0]->id)) return CG_ERROR; /* check data */ if (strcmp(axisym[0]->array[axisym[0]->narrays].data_type,"R4")) { cgi_error("Error: Datatype %s not supported for %s", axisym[0]->array[axisym[0]->narrays].data_type, temp_name); return CG_ERROR; } if (axisym[0]->array[axisym[0]->narrays].data_dim != 1 || axisym[0]->array[axisym[0]->narrays].dim_vals[0] != Pdim) { cgi_error("Error: %s incorrectly dimensioned",temp_name); return CG_ERROR; } axisym[0]->narrays ++; } /* AxisymmetryAngle */ else if (strcmp(temp_name,"AxisymmetryAngle")==0) { axisym[0]->array[axisym[0]->narrays].id = id[i]; axisym[0]->array[axisym[0]->narrays].link = cgi_read_link(id[i]); axisym[0]->array[axisym[0]->narrays].in_link = linked; if (cgi_read_array(&axisym[0]->array[axisym[0]->narrays], "Axisymmetry_t", axisym[0]->id)) return CG_ERROR; /* check data */ if (strcmp(axisym[0]->array[axisym[0]->narrays].data_type,"R4")) { cgi_error("Error: Datatype %s not supported for %s", axisym[0]->array[axisym[0]->narrays].data_type, temp_name); return CG_ERROR; } if (axisym[0]->array[axisym[0]->narrays].data_dim != 1 || axisym[0]->array[axisym[0]->narrays].dim_vals[0] != 1) { cgi_error("Error: %s incorrectly dimensioned",temp_name); return CG_ERROR; } axisym[0]->narrays ++; } /* CoordinateNames */ else if (strcmp(temp_name,"CoordinateNames")==0) { axisym[0]->array[axisym[0]->narrays].id = id[i]; axisym[0]->array[axisym[0]->narrays].link = cgi_read_link(id[i]); axisym[0]->array[axisym[0]->narrays].in_link = linked; if (cgi_read_array(&axisym[0]->array[axisym[0]->narrays], "Axisymmetry_t", axisym[0]->id)) return CG_ERROR; /* check data */ if (strcmp(axisym[0]->array[axisym[0]->narrays].data_type,"C1")) { cgi_error("Error: Datatype %s not supported for %s", axisym[0]->array[axisym[0]->narrays].data_type, temp_name); return CG_ERROR; } if (axisym[0]->array[axisym[0]->narrays].data_dim != 2 || axisym[0]->array[axisym[0]->narrays].dim_vals[0] != 32 || axisym[0]->array[axisym[0]->narrays].dim_vals[1] != 2) { cgi_error("Error: %s incorrectly dimensioned",temp_name); return CG_ERROR; } axisym[0]->narrays ++; } } /* loop through DataArray_t */ if (nnod) CGNS_FREE(id); /* check data */ if (!ref_point_flag || !axis_flag) { cgi_error("Error: AxisymmetryReferencePoint & AxisymmetryAxisVector are required"); return CG_ERROR; } /* UserDefinedData_t */ if (cgi_read_user_data(linked, axisym[0]->id, &axisym[0]->nuser_data, &axisym[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_rotating_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_rotating** rotating) { int i, nnod, linked, rot_rate_flag = 0, rot_center_flag = 0; double* id; char_33 temp_name; nnod = nnodes; if (nnod <= 0) { rotating[0] = 0; return CG_OK; } rotating[0] = CGNS_NEW(cgns_rotating, 1); rotating[0]->id = nodelist[0].id; rotating[0]->link = cgi_read_link(nodelist[0].id); rotating[0]->in_link = in_link; linked = rotating[0]->link ? 1 : in_link; /* Name */ strcpy(rotating[0]->name, nodelist[0].name); /* initialize dependents */ rotating[0]->narrays = 0; /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, rotating[0]->id, &rotating[0]->ndescr, &rotating[0]->descr, &rotating[0]->data_class, &rotating[0]->units)) return CG_ERROR; /* DataArray_t: Required: RotationCenter, RotationRateVector Optional: none */ if (cgi_get_nodes(rotating[0]->id, "DataArray_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) rotating[0]->array = CGNS_NEW(cgns_array, nnod); for (i = 0; i < nnod; i++) { if (cgio_get_name(cg->cgio, id[i], temp_name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* RotationCenter, RotationRateVector */ if (strcmp(temp_name, "RotationCenter") == 0 || strcmp(temp_name, "RotationRateVector") == 0) { if (strcmp(temp_name, "RotationCenter") == 0) rot_center_flag = 1; else if (strcmp(temp_name, "RotationRateVector") == 0) rot_rate_flag = 1; rotating[0]->array[rotating[0]->narrays].id = id[i]; rotating[0]->array[rotating[0]->narrays].link = cgi_read_link(id[i]); rotating[0]->array[rotating[0]->narrays].in_link = linked; if (cgi_read_array(&rotating[0]->array[rotating[0]->narrays], "RotatingCoordinates_t", rotating[0]->id)) return CG_ERROR; /* check data */ if (strcmp(rotating[0]->array[rotating[0]->narrays].data_type, "R4")) { cgi_error("Error: Datatype %s not supported for %s", rotating[0]->array[rotating[0]->narrays].data_type, temp_name); return CG_ERROR; } if (rotating[0]->array[rotating[0]->narrays].data_dim != 1 || rotating[0]->array[rotating[0]->narrays].dim_vals[0] != Pdim) { cgi_error("Error: %s incorrectly dimensioned", temp_name); return CG_ERROR; } rotating[0]->narrays++; } } /* loop through DataArray_t */ if (nnod) CGNS_FREE(id); /* check data */ if (!rot_rate_flag || !rot_center_flag) { cgi_error("Error: RotationCenter & RotationRateVector are required"); return CG_ERROR; } /* UserDefinedData_t */ if (cgi_read_user_data(linked, rotating[0]->id, &rotating[0]->nuser_data, &rotating[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_rotating(int in_link, double parent_id, cgns_rotating **rotating) { int i, nnod, linked, rot_rate_flag=0, rot_center_flag=0; double *id; char_33 temp_name; if (cgi_get_nodes(parent_id, "RotatingCoordinates_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { rotating[0]=0; return CG_OK; } rotating[0] = CGNS_NEW(cgns_rotating, 1); rotating[0]->id=id[0]; rotating[0]->link=cgi_read_link(id[0]); rotating[0]->in_link=in_link; linked = rotating[0]->link ? 1 : in_link; CGNS_FREE(id); /* Name */ if (cgio_get_name(cg->cgio, rotating[0]->id, rotating[0]->name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* initialize dependents */ rotating[0]->narrays=0; /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, rotating[0]->id, &rotating[0]->ndescr, &rotating[0]->descr, &rotating[0]->data_class, &rotating[0]->units)) return CG_ERROR; /* DataArray_t: Required: RotationCenter, RotationRateVector Optional: none */ if (cgi_get_nodes(rotating[0]->id, "DataArray_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) rotating[0]->array = CGNS_NEW(cgns_array, nnod); for (i=0; icgio, id[i], temp_name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* RotationCenter, RotationRateVector */ if (strcmp(temp_name,"RotationCenter")==0 || strcmp(temp_name,"RotationRateVector")==0) { if (strcmp(temp_name,"RotationCenter")==0) rot_center_flag = 1; else if (strcmp(temp_name,"RotationRateVector")==0) rot_rate_flag = 1; rotating[0]->array[rotating[0]->narrays].id = id[i]; rotating[0]->array[rotating[0]->narrays].link = cgi_read_link(id[i]); rotating[0]->array[rotating[0]->narrays].in_link = linked; if (cgi_read_array(&rotating[0]->array[rotating[0]->narrays], "RotatingCoordinates_t", rotating[0]->id)) return CG_ERROR; /* check data */ if (strcmp(rotating[0]->array[rotating[0]->narrays].data_type,"R4")) { cgi_error("Error: Datatype %s not supported for %s", rotating[0]->array[rotating[0]->narrays].data_type, temp_name); return CG_ERROR; } if (rotating[0]->array[rotating[0]->narrays].data_dim != 1 || rotating[0]->array[rotating[0]->narrays].dim_vals[0] != Pdim) { cgi_error("Error: %s incorrectly dimensioned",temp_name); return CG_ERROR; } rotating[0]->narrays ++; } } /* loop through DataArray_t */ if (nnod) CGNS_FREE(id); /* check data */ if (!rot_rate_flag || !rot_center_flag) { cgi_error("Error: RotationCenter & RotationRateVector are required"); return CG_ERROR; } /* UserDefinedData_t */ if (cgi_read_user_data(linked, rotating[0]->id, &rotating[0]->nuser_data, &rotating[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_converg_from_list(int in_link, _childnode_t *nodelist, int nnodes, cgns_converg** converg) { char_33 data_type, name; int ndim, n, nnod; double* id; char* string_data; void* iterations; int nnorm = 0, linked; cgsize_t dim_vals[12]; nnod = nnodes; if (nnod <= 0) { converg[0] = 0; return CG_OK; } converg[0] = CGNS_NEW(cgns_converg, 1); converg[0]->id = nodelist[0].id; converg[0]->link = cgi_read_link(nodelist[0].id); converg[0]->in_link = in_link; linked = converg[0]->link ? 1 : in_link; if (cgi_read_node(converg[0]->id, converg[0]->name, data_type, &ndim, dim_vals, &iterations, READ_DATA)) { cgi_error("Error reading Convergence History node"); return CG_ERROR; } /* The check was modified because Bob was storing other type of data at the level. This is a temporary changed */ if (strcmp(data_type, "I4") == 0 && dim_vals[0] >= 1) { converg[0]->iterations = *((int*)iterations); CGNS_FREE(iterations); } else converg[0]->iterations = 0; /* initialize dependents */ converg[0]->data_class = CGNS_ENUMV(DataClassNull); converg[0]->NormDefinitions = 0; converg[0]->ndescr = 0; /* Descriptor_t and NormDefinitions */ if (cgi_get_nodes(converg[0]->id, "Descriptor_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) { for (n = 0; n < nnod; n++) { if (cgio_get_name(cg->cgio, id[n], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "NormDefinitions")) { if (converg[0]->ndescr == 0) converg[0]->descr = CGNS_NEW(cgns_descr, 1); else converg[0]->descr = CGNS_RENEW(cgns_descr, converg[0]->ndescr + 1, converg[0]->descr); converg[0]->descr[converg[0]->ndescr].id = id[n]; converg[0]->descr[converg[0]->ndescr].link = cgi_read_link(id[n]); converg[0]->descr[converg[0]->ndescr].in_link = linked; if (cgi_read_string(id[n], converg[0]->descr[converg[0]->ndescr].name, &converg[0]->descr[converg[0]->ndescr].text)) return CG_ERROR; converg[0]->ndescr++; } else { if (nnorm) { cgi_error("Convergence History may only hold one NormDefinitions Node"); return CG_ERROR; } converg[0]->NormDefinitions = CGNS_NEW(cgns_descr, 1); converg[0]->NormDefinitions->id = id[n]; converg[0]->NormDefinitions->link = cgi_read_link(id[n]); converg[0]->NormDefinitions->in_link = linked; if (cgi_read_string(id[n], converg[0]->NormDefinitions->name, &converg[0]->NormDefinitions->text)) return CG_ERROR; nnorm++; } } CGNS_FREE(id); } /* DataClass_t */ if (cgi_get_nodes(converg[0]->id, "DataClass_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) { if (cgi_read_string(id[0], name, &string_data)) return CG_ERROR; cgi_DataClass(string_data, &converg[0]->data_class); CGNS_FREE(string_data); CGNS_FREE(id); } /* DimensionalUnits_t */ if (cgi_read_units(linked, converg[0]->id, &converg[0]->units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(converg[0]->id, "DataArray_t", &converg[0]->narrays, &id)) return CG_ERROR; if (converg[0]->narrays > 0) { converg[0]->array = CGNS_NEW(cgns_array, converg[0]->narrays); for (n = 0; n < converg[0]->narrays; n++) { converg[0]->array[n].id = id[n]; converg[0]->array[n].link = cgi_read_link(id[n]); converg[0]->array[n].in_link = linked; if (cgi_read_array(&converg[0]->array[n], "ConvergenceHistory_t", converg[0]->id)) return CG_ERROR; /* verify data : Temporiraly commented for Bob Bush if (converg[0]->array[n].data_dim!=1) { cgi_error("Wrong nr of dimension in Conversion History definition"); return CG_ERROR; } */ } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, converg[0]->id, &converg[0]->nuser_data, &converg[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_converg(int in_link, double parent_id, cgns_converg **converg) { char_33 data_type, name; int ndim, n, nnod; double *id; char *string_data; void *iterations; int nnorm=0, linked; cgsize_t dim_vals[12]; if (cgi_get_nodes(parent_id, "ConvergenceHistory_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { converg[0]=0; return CG_OK; } converg[0] = CGNS_NEW(cgns_converg, 1); converg[0]->id = id[0]; converg[0]->link = cgi_read_link(id[0]); converg[0]->in_link = in_link; linked = converg[0]->link ? 1 : in_link; CGNS_FREE(id); if (cgi_read_node(converg[0]->id, converg[0]->name, data_type, &ndim, dim_vals, &iterations, READ_DATA)) { cgi_error("Error reading Convergence History node"); return CG_ERROR; } /* verify data: Temporarily commented and replaced by 4 lines below if (strcmp(data_type,"I4") || ndim!=1 || dim_vals[0]!=1) { cgi_error("ConvergenceHistory_t node '%s' incorrect",converg[0]->name); return CG_ERROR; } converg[0]->iterations = *((int *)iterations); CGNS_FREE(iterations); */ /* The check was removed because Bob was storing other type of data at the level. This is a temporary changed */ if (strcmp(data_type,"I4")==0 && dim_vals[0]>=1) { converg[0]->iterations = *((int *)iterations); CGNS_FREE(iterations); } else converg[0]->iterations=0; /* initialize dependents */ converg[0]->data_class = CGNS_ENUMV( DataClassNull ); converg[0]->NormDefinitions = 0; converg[0]->ndescr=0; /* Descriptor_t and NormDefinitions */ if (cgi_get_nodes(converg[0]->id, "Descriptor_t", &nnod, &id)) return CG_ERROR; if (nnod>0) { for (n=0; ncgio, id[n], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name,"NormDefinitions")) { if (converg[0]->ndescr==0) converg[0]->descr = CGNS_NEW(cgns_descr, 1); else converg[0]->descr=CGNS_RENEW(cgns_descr,converg[0]->ndescr+1,converg[0]->descr); converg[0]->descr[converg[0]->ndescr].id = id[n]; converg[0]->descr[converg[0]->ndescr].link = cgi_read_link(id[n]); converg[0]->descr[converg[0]->ndescr].in_link = linked; if (cgi_read_string(id[n], converg[0]->descr[converg[0]->ndescr].name, &converg[0]->descr[converg[0]->ndescr].text)) return CG_ERROR; converg[0]->ndescr++; } else { if (nnorm) { cgi_error("Convergence History may only hold one NormDefinitions Node"); return CG_ERROR; } converg[0]->NormDefinitions = CGNS_NEW(cgns_descr, 1); converg[0]->NormDefinitions->id = id[n]; converg[0]->NormDefinitions->link = cgi_read_link(id[n]); converg[0]->NormDefinitions->in_link = linked; if (cgi_read_string(id[n], converg[0]->NormDefinitions->name, &converg[0]->NormDefinitions->text)) return CG_ERROR; nnorm ++; } } CGNS_FREE(id); } /* DataClass_t */ if (cgi_get_nodes(converg[0]->id, "DataClass_t", &nnod, &id)) return CG_ERROR; if (nnod>0) { if (cgi_read_string(id[0], name, &string_data)) return CG_ERROR; cgi_DataClass(string_data, &converg[0]->data_class); CGNS_FREE(string_data); CGNS_FREE(id); } /* DimensionalUnits_t */ if (cgi_read_units(linked, converg[0]->id, &converg[0]->units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(converg[0]->id, "DataArray_t", &converg[0]->narrays, &id)) return CG_ERROR; if (converg[0]->narrays>0) { converg[0]->array = CGNS_NEW(cgns_array, converg[0]->narrays); for (n=0; nnarrays; n++) { converg[0]->array[n].id = id[n]; converg[0]->array[n].link = cgi_read_link(id[n]); converg[0]->array[n].in_link = linked; if (cgi_read_array(&converg[0]->array[n],"ConvergenceHistory_t", converg[0]->id)) return CG_ERROR; /* verify data : Temporiraly commented for Bob Bush if (converg[0]->array[n].data_dim!=1) { cgi_error("Wrong nr of dimension in Conversion History definition"); return CG_ERROR; } */ } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, converg[0]->id, &converg[0]->nuser_data, &converg[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_discrete(int in_link, double parent_id, int *ndiscrete, cgns_discrete **discrete) { double *id, *idi; int n, i, j, linked; cgsize_t DataSize[3], DataCount = 0; if (cgi_get_nodes(parent_id, "DiscreteData_t", ndiscrete, &id)) return CG_ERROR; if (*ndiscrete<=0) { discrete[0] = 0; return CG_OK; } discrete[0] = CGNS_NEW(cgns_discrete, (*ndiscrete)); for (n=0; n<(*ndiscrete); n++) { discrete[0][n].id = id[n]; discrete[0][n].link = cgi_read_link(id[n]); discrete[0][n].in_link = in_link; linked = discrete[0][n].link ? 1 : in_link; /* name of node */ if (cgio_get_name(cg->cgio, id[n], discrete[0][n].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, id[n], &discrete[0][n].ndescr, &discrete[0][n].descr, &discrete[0][n].data_class, &discrete[0][n].units)) return CG_ERROR; /* GridLocation_t */ if (cgi_read_location(discrete[0][n].id, discrete[0][n].name, &discrete[0][n].location)) return CG_ERROR; /* Rind Planes */ if (cgi_read_rind(discrete[0][n].id, &discrete[0][n].rind_planes)) return CG_ERROR; /* Determine data size */ if (cgi_datasize(Idim, CurrentDim, discrete[0][n].location, discrete[0][n].rind_planes, DataSize)) return CG_ERROR; /* check for PointList/PointRange */ if (cgi_read_one_ptset(linked, discrete[0][n].id, &discrete[0][n].ptset)) return CG_ERROR; if (discrete[0][n].ptset != NULL) { if (discrete[0][n].ptset->type == CGNS_ENUMV(ElementList) || discrete[0][n].ptset->type == CGNS_ENUMV(ElementRange)) { cgi_error("ElementList/Range not supported under DiscreteData"); return CG_ERROR; } DataCount = discrete[0][n].ptset->size_of_patch; } /* DataArray_t */ if (cgi_get_nodes(discrete[0][n].id, "DataArray_t", &discrete[0][n].narrays, &idi)) return CG_ERROR; if (discrete[0][n].narrays>0) { discrete[0][n].array = CGNS_NEW(cgns_array, discrete[0][n].narrays); for (i=0; icgio, integral[0][n].id, integral[0][n].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, integral[0][n].id, &integral[0][n].ndescr, &integral[0][n].descr, &integral[0][n].data_class, &integral[0][n].units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(integral[0][n].id, "DataArray_t", &integral[0][n].narrays, &idi)) return CG_ERROR; if (integral[0][n].narrays > 0) { integral[0][n].array = CGNS_NEW(cgns_array, integral[0][n].narrays); for (i = 0; i < integral[0][n].narrays; i++) { integral[0][n].array[i].id = idi[i]; integral[0][n].array[i].link = cgi_read_link(idi[i]); integral[0][n].array[i].in_link = linked; if (cgi_read_array(&integral[0][n].array[i], "IntegralData_t", integral[0][n].id)) return CG_ERROR; } CGNS_FREE(idi); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, integral[0][n].id, &integral[0][n].nuser_data, &integral[0][n].user_data)) return CG_ERROR; } return CG_OK; } int cgi_read_integral(int in_link, double parent_id, int *nintegrals, cgns_integral **integral) { double *id, *idi; int n, i, linked; if (cgi_get_nodes(parent_id, "IntegralData_t", nintegrals, &id)) return CG_ERROR; if (*nintegrals<=0) { integral[0] = 0; return CG_OK; } integral[0] = CGNS_NEW(cgns_integral, (*nintegrals)); for (n=0; n<(*nintegrals); n++) { integral[0][n].id = id[n]; integral[0][n].link = cgi_read_link(id[n]); integral[0][n].in_link = in_link; linked = integral[0][n].link ? 1 : in_link; /* IntegralData_t Name */ if (cgio_get_name(cg->cgio, integral[0][n].id, integral[0][n].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, id[n], &integral[0][n].ndescr, &integral[0][n].descr, &integral[0][n].data_class, &integral[0][n].units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(id[n], "DataArray_t", &integral[0][n].narrays, &idi)) return CG_ERROR; if (integral[0][n].narrays>0) { integral[0][n].array = CGNS_NEW(cgns_array, integral[0][n].narrays); for (i=0; iname)==0 || strcmp("RigidRotationAngle",array->name)==0 || strcmp("RigidVelocity" ,array->name)==0 || strcmp("RigidRotationRate" ,array->name)==0) { if (strcmp(array->data_type,"R4") && strcmp(array->data_type,"R8")) { cgi_error("Wrong data type for %s",array->name); return CG_ERROR; } if ((strcmp("OriginLocation",array->name)==0 && array->data_dim!=2) || (strcmp("OriginLocation",array->name) && array->data_dim!=1) || array->dim_vals[0]!=Pdim || (strcmp("OriginLocation",array->name)==0 && array->dim_vals[1]!=2)) { cgi_error("Wrong data dimension in '%s' definition",array->name); return CG_ERROR; } } } /* loop through DataArray_t */ for (i=0; i0) { amotion[0][n].array = CGNS_NEW(cgns_array, amotion[0][n].narrays); for (i=0; ilink ? 1 : array->in_link; char_33 data_type, temp_name; int nchild, ndim; double *idi; cgsize_t dim_vals[12]; /* These data arrays are not loaded in memory, just their addresses */ if (strcmp(parent_label,"GridCoordinates_t")==0 || strcmp(parent_label,"FlowSolution_t")==0 || strcmp(parent_label,"Elements_t")==0 || strcmp(parent_label,"ZoneSubRegion_t")==0 || strcmp(parent_label,"DiscreteData_t")==0 || strcmp(parent_label,"ParticleCoordinates_t")==0 || strcmp(parent_label,"ParticleSolution_t")==0 || strcmp(parent_label,"UserDefinedData_t")==0) { data_flag=SKIP_DATA; array->data=0; } if (cgi_read_node(array->id, array->name, array->data_type, &array->data_dim, array->dim_vals, &array->data, data_flag)) { cgi_error("Error reading array under %s",parent_label); return CG_ERROR; } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, array->id, &array->ndescr, &array->descr, &array->data_class, &array->units)) return CG_ERROR; /* DataConversion_t */ if (cgi_read_conversion(linked, array->id, &array->convert)) return CG_ERROR; /* DimensionalExponents_t */ if (cgi_read_exponents(linked, array->id, &array->exponents)) return CG_ERROR; /* IndexRange_t */ if (cgi_get_nodes(array->id, "IndexRange_t", &nchild, &idi)) return CG_ERROR; if (nchild==1) { void *vdata; if (cgi_read_node(idi[0], temp_name, data_type, &ndim, dim_vals, &vdata, READ_DATA)) { cgi_error("Error reading array range"); return CG_ERROR; } if (nchild) CGNS_FREE(idi); /* verify that the name matches the type intended */ if (strcmp(temp_name,"ArrayDataRange")) { cgi_error("Invalid point set type: '%s'",temp_name); return CG_ERROR; } /* Accept only I4 and I8 */ if (strcmp(data_type,"I4") && strcmp(data_type,"I8")) { cgi_error("Data type %s not supported for ArrayDataRange", data_type); return CG_ERROR; } /* verify dimension vector */ if (ndim!=1 || dim_vals[0]!=2) { cgi_error("Invalid dimensions in definition of ArrayDataRange"); return CG_ERROR; } /* nelements */ if (0 == strcmp(data_type,"I8")) { cglong_t *data = (cglong_t *)vdata; #if CG_SIZEOF_SIZE == 32 if (cgio_check_dimensions(2, data)) { cg_io_error("cgio_check_dimensions"); return CG_ERROR; } #endif array->range[0] = (cgsize_t)data[0]; array->range[1] = (cgsize_t)data[1]; } else { int *data = (int *)vdata; array->range[0] = (cgsize_t)data[0]; array->range[1] = (cgsize_t)data[1]; } CGNS_FREE(vdata); } return CG_OK; } int cgi_read_conversion(int in_link, double parent_id, cgns_conversion **convert) { int nnod, ndim; double *id; cgsize_t dim_vals[12]; if (cgi_get_nodes(parent_id, "DataConversion_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { convert[0]=0; return CG_OK; } convert[0] = CGNS_NEW(cgns_conversion, 1); convert[0]->id = id[0]; convert[0]->link = cgi_read_link(id[0]); convert[0]->in_link = in_link; CGNS_FREE(id); if (cgi_read_node(convert[0]->id, convert[0]->name, convert[0]->data_type, &ndim, dim_vals, &convert[0]->data, READ_DATA)) { cgi_error("Error reading '%s'",convert[0]->name); return CG_ERROR; } if (strcmp(convert[0]->data_type,"R4") && strcmp(convert[0]->data_type,"R8")) { cgi_error("Wrong Data Type in '%s'",convert[0]->name); return CG_ERROR; } if (ndim!=1 || dim_vals[0]!=2) { cgi_error("Wrong dimensions in '%s'",convert[0]->name); return CG_ERROR; } return CG_OK; } int cgi_read_exponents(int in_link, double parent_id, cgns_exponent **exponents) { int nnod, ndim; double *id; cgsize_t dim_vals[12]; if (cgi_get_nodes(parent_id, "DimensionalExponents_t", &nnod, &id)) return CG_ERROR; if (nnod <= 0) { exponents[0]=0; return CG_OK; } exponents[0] = CGNS_NEW(cgns_exponent, 1); exponents[0]->id = id[0]; exponents[0]->link = cgi_read_link(id[0]); exponents[0]->in_link = in_link; CGNS_FREE(id); if (cgi_read_node(exponents[0]->id, exponents[0]->name, exponents[0]->data_type, &ndim, dim_vals, &exponents[0]->data, READ_DATA)) { cgi_error("Error reading '%s'",exponents[0]->name); return CG_ERROR; } if (strcmp(exponents[0]->data_type,"R4") && strcmp(exponents[0]->data_type,"R8")) { cgi_error("Wrong Data Type in '%s'",exponents[0]->name); return CG_ERROR; } if (ndim != 1 || dim_vals[0] != 5) { cgi_error("Wrong dimensions in '%s'",exponents[0]->name); return CG_ERROR; } exponents[0]->nexps = 5; if (cgi_get_nodes(exponents[0]->id, "AdditionalExponents_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) { int ierr; char_33 data_type, name; void *data; ierr = cgi_read_node(id[0], name, data_type, &ndim, dim_vals, &data, READ_DATA); CGNS_FREE(id); if (ierr) { cgi_error("Error reading AdditionalExponents for '%s'", exponents[0]->name); return CG_ERROR; } if (strcmp(data_type, exponents[0]->data_type)) { CGNS_FREE(data); cgi_error("mismatch in data type for AdditionalExponents for '%s'", exponents[0]->name); return CG_ERROR; } if (ndim != 1 || dim_vals[0] != 3) { CGNS_FREE(data); cgi_error("Wrong dimensions in AdditionalExponents for '%s'", exponents[0]->name); return CG_ERROR; } exponents[0]->data = (void *) realloc (exponents[0]->data, 8 * size_of(exponents[0]->data_type)); if (exponents[0]->data == NULL) { CGNS_FREE(data); cgi_error("realloc failed for DimensionalExponents"); return CG_ERROR; } if (0 == strcmp(exponents[0]->data_type,"R4")) { float *exps = (float *)exponents[0]->data; for (ndim = 0; ndim < 3; ndim++) exps[5+ndim] = *((float *)data + ndim); } else { double *exps = (double *)exponents[0]->data; for (ndim = 0; ndim < 3; ndim++) exps[5+ndim] = *((double *)data + ndim); } exponents[0]->nexps = 8; CGNS_FREE(data); } return CG_OK; } int cgi_read_units_node(int in_link, cgns_units** units) { char_33 unit_name; char* string_data; double* id; int nnod; if (cgi_read_string(units[0]->id, units[0]->name, &string_data)) return CG_ERROR; if (strlen(string_data) != 32 * 5) { CGNS_FREE(string_data); cgi_error("Dimensional Units defined incorrectly."); return CG_ERROR; } units[0]->nunits = 5; /* change from Celcius to Celsius */ if (0 == strncmp(&string_data[96], "Celcius", 7)) { string_data[99] = 's'; if (cg->mode == CG_MODE_MODIFY && !in_link) { if (cgio_write_all_data(cg->cgio, units[0]->id, string_data)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } } } strncpy(unit_name, string_data, 32); unit_name[32] = 0; cgi_MassUnits(unit_name, &units[0]->mass); strncpy(unit_name, &string_data[32], 32); unit_name[32] = 0; cgi_LengthUnits(unit_name, &units[0]->length); strncpy(unit_name, &string_data[64], 32); unit_name[32] = 0; cgi_TimeUnits(unit_name, &units[0]->time); strncpy(unit_name, &string_data[96], 32); unit_name[32] = 0; cgi_TemperatureUnits(unit_name, &units[0]->temperature); strncpy(unit_name, &string_data[128], 32); unit_name[32] = 0; cgi_AngleUnits(unit_name, &units[0]->angle); CGNS_FREE(string_data); units[0]->current = CGNS_ENUMV(ElectricCurrentUnitsNull); units[0]->amount = CGNS_ENUMV(SubstanceAmountUnitsNull); units[0]->intensity = CGNS_ENUMV(LuminousIntensityUnitsNull); if (cgi_get_nodes(units[0]->id, "AdditionalUnits_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) { int ierr = cgi_read_string(id[0], unit_name, &string_data); CGNS_FREE(id); if (ierr) return CG_ERROR; if (strlen(string_data) != 32 * 3) { CGNS_FREE(string_data); cgi_error("AdditionalUnits for '%s' defined incorrectly.", units[0]->name); return CG_ERROR; } units[0]->nunits = 8; strncpy(unit_name, string_data, 32); unit_name[32] = 0; cgi_ElectricCurrentUnits(unit_name, &units[0]->current); strncpy(unit_name, &string_data[32], 32); unit_name[32] = 0; cgi_SubstanceAmountUnits(unit_name, &units[0]->amount); strncpy(unit_name, &string_data[64], 32); unit_name[32] = 0; cgi_LuminousIntensityUnits(unit_name, &units[0]->intensity); CGNS_FREE(string_data); } return CG_OK; } int cgi_read_units(int in_link, double parent_id, cgns_units **units) { double *id; int nnod; if (cgi_get_nodes(parent_id, "DimensionalUnits_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { units[0]=0; return CG_OK; } units[0] = CGNS_NEW(cgns_units, 1); units[0]->id = id[0]; units[0]->link = cgi_read_link(id[0]); units[0]->in_link = in_link; CGNS_FREE(id); if (cgi_read_units_node(in_link, units)) return CG_ERROR; return CG_OK; } int cgi_read_string(double id, char_33 name, char **string_data) { int n, ndim; char_33 data_type; cgsize_t length[2], len=1; if (cgi_read_node(id, name, data_type, &ndim, length, (void **)string_data, READ_DATA)) { cgi_error("Error reading string"); return CG_ERROR; } /* verify dimensions */ if (strcmp(data_type,"C1")!=0) { cgi_error("Invalid datatype for character data: %s",data_type); return CG_ERROR; } /* add the string terminator */ for (n=0; n 0) { descr[0] = CGNS_NEW(cgns_descr, ndescr); for (n = 0; n < (ndescr); n++) { descr[0][n].id = nodelist[n].id; descr[0][n].link = cgi_read_link(nodelist[n].id); descr[0][n].in_link = in_link; if (cgi_read_string(nodelist[n].id, descr[0][n].name, &descr[0][n].text)) return CG_ERROR; } } /* DataClass_t */ *data_class = CGNS_ENUMV(DataClassNull); nodelist = nodebylabel[LabelDataClass_t]; if (ndata_class > 0) { if (cgi_read_string(nodelist[0].id, name, &string_data)) return CG_ERROR; cgi_DataClass(string_data, data_class); CGNS_FREE(string_data); } /* DimensionalUnits_t */ nodelist = nodebylabel[LabelDimensionalUnits_t]; if (ndimensional_units > 0) { units[0] = CGNS_NEW(cgns_units, 1); units[0]->id = nodelist[0].id; units[0]->link = cgi_read_link(nodelist[0].id); units[0]->in_link = in_link; if (cgi_read_units_node(in_link, units)) return CG_ERROR; } else { units[0] = 0; } return CG_OK; } int cgi_read_DDD(int in_link, double parent_id, int *ndescr, cgns_descr **descr, CGNS_ENUMV( DataClass_t ) *data_class, cgns_units **units) { double *id; int n, nnod; char_33 name; char *string_data; /* Descriptor_t */ descr[0] = 0; if (cgi_get_nodes(parent_id, "Descriptor_t", ndescr, &id)) return CG_ERROR; if (*ndescr>0) { descr[0] = CGNS_NEW(cgns_descr, (*ndescr)); for (n=0; n<(*ndescr); n++) { descr[0][n].id = id[n]; descr[0][n].link = cgi_read_link(id[n]); descr[0][n].in_link = in_link; if (cgi_read_string(id[n], descr[0][n].name, &descr[0][n].text)) return CG_ERROR; } CGNS_FREE(id); } /* DataClass_t */ *data_class = CGNS_ENUMV( DataClassNull ); if (cgi_get_nodes(parent_id, "DataClass_t", &nnod, &id)) return CG_ERROR; if (nnod>0) { if (cgi_read_string(id[0], name, &string_data)) return CG_ERROR; cgi_DataClass(string_data, data_class); CGNS_FREE(string_data); CGNS_FREE(id); } /* DimensionalUnits_t */ if (cgi_read_units(in_link, parent_id, units)) return CG_ERROR; return CG_OK; } int cgi_read_ordinal(double parent_id, int *ordinal) { int nnod; double *id; char_33 name, data_type; int ndim; void *ordinal_data; cgsize_t dim_vals[12]; if (cgi_get_nodes(parent_id, "Ordinal_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { (*ordinal)=0; return CG_OK; } if (cgi_read_node(id[0], name, data_type, &ndim, dim_vals, &ordinal_data, READ_DATA)) { cgi_error("Error reading Ordinal node"); return CG_ERROR; } if (ndim!=1 || dim_vals[0]!=1 || strcmp(data_type,"I4")) { cgi_error("Ordinal '%s' defined incorrectly",name); return CG_ERROR; } CGNS_FREE(id); (*ordinal)=*(int *)ordinal_data; CGNS_FREE(ordinal_data); return CG_OK; } int cgi_read_rind(double parent_id, int **rind_planes) { int n, nnod; double *id; char_33 name, data_type; int ndim; cgsize_t dim_vals[12]; if (cgi_get_nodes(parent_id, "Rind_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { rind_planes[0] = (int *) malloc (2*Idim*sizeof(int)); if (!rind_planes[0]) { cgi_error("Error allocating rind_planes."); return CG_ERROR; } for (n=0; n<2*Idim; n++) rind_planes[0][n]=0; return CG_OK; } if (cgi_read_node(id[0], name, data_type, &ndim, dim_vals, (void **)rind_planes, READ_DATA)) { cgi_error("Error reading Rind Planes"); return CG_ERROR; } if (ndim!=1 || dim_vals[0]!=2*Idim || strcmp(data_type,"I4")) { cgi_error("Rind Planes '%s' defined incorrectly",name); return CG_ERROR; } CGNS_FREE(id); return CG_OK; } int cgi_read_location(double parent_id, char_33 parent_name, CGNS_ENUMT(GridLocation_t) *location) { int nGL_t; double *id; char *location_name; /* allocated in cgi_read_node */ char_33 name; /* get number of GridLocation_t nodes and their ID */ if (cgi_get_nodes(parent_id, "GridLocation_t", &nGL_t, &id)) return CG_ERROR; if (nGL_t==0) { *location = CGNS_ENUMV( Vertex ); } else if (nGL_t<0 || nGL_t >1) { cgi_error("Invalid definition of GridLocation for %s",parent_name); return CG_ERROR; } else if (nGL_t==1) { /* Read the grid location value in the GridLocation_t node */ if (cgi_read_string(id[0], name, &location_name)) return CG_ERROR; CGNS_FREE(id); if (cgi_GridLocation(location_name, location)) return CG_ERROR; CGNS_FREE(location_name); } return CG_OK; } int cgi_read_zonetype(double parent_id, char_33 parent_name, CGNS_ENUMT(ZoneType_t) *type) { int nchild; double *id; char *zonetype_name; /* allocated in cgi_read_node */ char_33 name; /* get number of ZoneType_t nodes and their ID */ if (cgi_get_nodes(parent_id, "ZoneType_t", &nchild, &id)) return CG_ERROR; if (nchild==0) { /* set default */ *type = CGNS_ENUMV( Structured ); return CG_OK; } if (nchild >1) { cgi_error("Invalid definition of ZoneType for %s",parent_name); return CG_ERROR; } if (cgi_read_string(id[0], name, &zonetype_name)) return CG_ERROR; CGNS_FREE(id); if (cgi_ZoneType(zonetype_name, type)) return CG_ERROR; CGNS_FREE(zonetype_name); return CG_OK; } int cgi_read_simulation_from_list(_childnode_t* nodelist, int nnodes, CGNS_ENUMT(SimulationType_t)* type, double* type_id) { int nchild; char* type_name; /* allocated in cgi_read_node */ char_33 name; /* initialize */ *type = CGNS_ENUMV(SimulationTypeNull); *type_id = 0; /* get number of SimulationType_t nodes and their ID */ nchild = nnodes; if (nchild == 0) return CG_OK; if (nchild > 1) { cgi_error("File incorrect: multiple definition of SimulationType"); return CG_ERROR; } *type_id = nodelist[0].id; if (cgi_read_string(nodelist[0].id, name, &type_name)) return CG_ERROR; if (cgi_SimulationType(type_name, type)) return CG_ERROR; CGNS_FREE(type_name); return CG_OK; } int cgi_read_simulation(double parent_id, CGNS_ENUMT(SimulationType_t) *type, double *type_id) { int nchild; double *id; char *type_name; /* allocated in cgi_read_node */ char_33 name; /* initialize */ *type = CGNS_ENUMV( SimulationTypeNull ); *type_id = 0; /* get number of SimulationType_t nodes and their ID */ if (cgi_get_nodes(parent_id, "SimulationType_t", &nchild, &id)) return CG_ERROR; if (nchild==0) return CG_OK; if (nchild >1) { cgi_error("File incorrect: multiple definition of SimulationType"); return CG_ERROR; } *type_id = id[0]; if (cgi_read_string(id[0], name, &type_name)) return CG_ERROR; CGNS_FREE(id); if (cgi_SimulationType(type_name, type)) return CG_ERROR; CGNS_FREE(type_name); return CG_OK; } int cgi_read_biter_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_biter** biter) { double* id; char_33 datatype; cgns_array* array; int ndim, * data, nnod; int i, linked; int nzones_max = 0, nfamilies_max = 0; void* vdata; cgsize_t dim_vals[12]; /* get number of BaseIterativeData_t node */ nnod = nnodes; if (nnod <= 0) { biter[0] = 0; return CG_OK; } else if (nnod > 1) { cgi_error("Error: Multiple BaseIterativeData_t found..."); return CG_ERROR; } biter[0] = CGNS_NEW(cgns_biter, 1); biter[0]->id = nodelist[0].id; biter[0]->link = cgi_read_link(nodelist[0].id); biter[0]->in_link = in_link; linked = biter[0]->link ? 1 : in_link; /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, biter[0]->id, &biter[0]->ndescr, &biter[0]->descr, &biter[0]->data_class, &biter[0]->units)) return CG_ERROR; /* Name and NumberOfSteps */ NumberOfSteps = biter[0]->nsteps = 0; if (cgi_read_node(biter[0]->id, biter[0]->name, datatype, &ndim, dim_vals, &vdata, READ_DATA)) { cgi_error("Error reading BaseIterativeData_t"); return CG_ERROR; } if (ndim != 1 || dim_vals[0] != 1 || strcmp(datatype, "I4")) { cgi_error("Error in data dimension or type for NumberOfSteps"); return CG_ERROR; } data = (int*)vdata; if (data[0] < 0) { cgi_error("Error in data: NumberOfSteps<0!"); return CG_ERROR; } NumberOfSteps = biter[0]->nsteps = data[0]; if (biter[0]->nsteps == 0) return CG_OK; CGNS_FREE(vdata); /* UserDefinedData_t */ if (cgi_read_user_data(linked, biter[0]->id, &biter[0]->nuser_data, &biter[0]->user_data)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(biter[0]->id, "DataArray_t", &biter[0]->narrays, &id)) return CG_ERROR; if (biter[0]->narrays == 0) return CG_OK; /* If no arrays we're done. */ biter[0]->array = CGNS_NEW(cgns_array, biter[0]->narrays); for (i = 0; i < (biter[0]->narrays); i++) { biter[0]->array[i].id = id[i]; biter[0]->array[i].link = cgi_read_link(id[i]); biter[0]->array[i].in_link = linked; if (cgi_read_array(&biter[0]->array[i], "BaseIterativeData_t", biter[0]->id)) return CG_ERROR; array = &biter[0]->array[i]; /* check data */ if (strcmp("TimeValues", array->name) == 0 || strcmp("IterationValues", array->name) == 0 || strcmp("NumberOfZones", array->name) == 0 || strcmp("NumberOfFamilies", array->name) == 0) { if (array->data_dim != 1 || array->dim_vals[0] != biter[0]->nsteps) { cgi_error("Error: Array '%s' incorrectly sized", array->name); return CG_ERROR; } if ((strcmp("TimeValues", array->name) == 0 && strcmp(array->data_type, "R4") && strcmp(array->data_type, "R8")) || (strcmp("IterationValues", array->name) == 0 && strcmp(array->data_type, "I4"))) { cgi_error("Incorrect data type for %s under %s", array->name, biter[0]->name); return CG_ERROR; } } } /* loop through arrays */ CGNS_FREE(id); /* check data: verify that at least one of {TimeValues or IterationValues} is defined */ for (i = 0; i < (biter[0]->narrays); i++) { array = &biter[0]->array[i]; if (strcmp("TimeValues", array->name) == 0 || strcmp("IterationValues", array->name) == 0) break; if (i == ((biter[0]->narrays) - 1)) { cgi_error("Error: TimeValues or IterationValues must be defined for '%s'", biter[0]->name); return CG_ERROR; } } /* check data: Compute nzones_max and nfamilies_max */ for (i = 0; i < (biter[0]->narrays); i++) { int step; array = &biter[0]->array[i]; if (strcmp("NumberOfZones", array->name) == 0) { for (step = 0; step < biter[0]->nsteps; step++) { int nzones = *((int*)(array->data) + step); nzones_max = MAX(nzones_max, nzones); } } else if (strcmp("NumberOfFamilies", array->name) == 0) { for (step = 0; step < biter[0]->nsteps; step++) { int nfamilies = *((int*)(array->data) + step); nfamilies_max = MAX(nfamilies_max, nfamilies); } } } /* check data: ZonePointers can't be defined without NumberOfZones and FamilyPointers can't be defined without NumberOfFamilies */ for (i = 0; i < (biter[0]->narrays); i++) { array = &biter[0]->array[i]; if (strcmp("ZonePointers", array->name) == 0) { if (nzones_max == 0) { cgi_error("NumberofZones (DataArray_t) missing under %s", biter[0]->name); return CG_ERROR; } else { /* check dimensions and data type */ if (array->data_dim != 3 || array->dim_vals[0] != 32 || array->dim_vals[1] != nzones_max || array->dim_vals[2] != biter[0]->nsteps || strcmp(array->data_type, "C1")) { cgi_error("Incorrect definition of ZonePointers under %s", biter[0]->name); return CG_ERROR; } } } else if (strcmp("FamilyPointers", array->name) == 0) { if (nfamilies_max == 0) { cgi_error("NumberOfFamilies (DataArray_t) missing under %s", biter[0]->name); return CG_ERROR; } else { /* check dimensions and data type */ if (array->data_dim != 3 || array->dim_vals[0] != 32 || array->dim_vals[1] != nfamilies_max || array->dim_vals[2] != biter[0]->nsteps || strcmp(array->data_type, "C1")) { cgi_error("Incorrect definition of FamilyPointers under %s", biter[0]->name); return CG_ERROR; } } } } return CG_OK; } int cgi_read_biter(int in_link, double parent_id, cgns_biter **biter) { double *id; char_33 datatype; cgns_array *array; int ndim, *data, nnod; int i, linked; int nzones_max = 0, nfamilies_max = 0; void *vdata; cgsize_t dim_vals[12]; /* get number of BaseIterativeData_t node */ if (cgi_get_nodes(parent_id, "BaseIterativeData_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { biter[0]=0; return CG_OK; } else if (nnod>1) { cgi_error("Error: Multiple BaseIterativeData_t found..."); return CG_ERROR; } biter[0] = CGNS_NEW(cgns_biter, 1); biter[0]->id = id[0]; biter[0]->link = cgi_read_link(id[0]); biter[0]->in_link = in_link; linked = biter[0]->link ? 1 : in_link; CGNS_FREE(id); /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, biter[0]->id, &biter[0]->ndescr, &biter[0]->descr, &biter[0]->data_class, &biter[0]->units)) return CG_ERROR; /* Name and NumberOfSteps */ NumberOfSteps = biter[0]->nsteps = 0; if (cgi_read_node(biter[0]->id, biter[0]->name, datatype, &ndim, dim_vals, &vdata, READ_DATA)) { cgi_error("Error reading BaseIterativeData_t"); return CG_ERROR; } if (ndim!=1 || dim_vals[0]!=1 || strcmp(datatype,"I4")) { cgi_error("Error in data dimension or type for NumberOfSteps"); return CG_ERROR; } data = (int *)vdata; if (data[0]<0) { cgi_error("Error in data: NumberOfSteps<0!"); return CG_ERROR; } NumberOfSteps = biter[0]->nsteps = data[0]; if (biter[0]->nsteps == 0) return CG_OK; CGNS_FREE(vdata); /* UserDefinedData_t */ if (cgi_read_user_data(linked, biter[0]->id, &biter[0]->nuser_data, &biter[0]->user_data)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(biter[0]->id, "DataArray_t", &biter[0]->narrays, &id)) return CG_ERROR; if (biter[0]->narrays == 0) return CG_OK; /* If no arrays we're done. */ biter[0]->array = CGNS_NEW(cgns_array, biter[0]->narrays); for (i=0; i<(biter[0]->narrays); i++) { biter[0]->array[i].id = id[i]; biter[0]->array[i].link = cgi_read_link(id[i]); biter[0]->array[i].in_link = linked; if (cgi_read_array(&biter[0]->array[i], "BaseIterativeData_t", biter[0]->id)) return CG_ERROR; array = &biter[0]->array[i]; /* check data */ if (strcmp("TimeValues",array->name)==0 || strcmp("IterationValues",array->name)==0 || strcmp("NumberOfZones",array->name)==0 || strcmp("NumberOfFamilies",array->name)==0) { if (array->data_dim!=1 || array->dim_vals[0]!=biter[0]->nsteps) { cgi_error("Error: Array '%s' incorrectly sized",array->name); return CG_ERROR; } if ((strcmp("TimeValues",array->name)==0 && strcmp(array->data_type,"R4") && strcmp(array->data_type,"R8")) || (strcmp("IterationValues",array->name)==0 && strcmp(array->data_type,"I4"))) { cgi_error("Incorrect data type for %s under %s",array->name,biter[0]->name); return CG_ERROR; } } } /* loop through arrays */ CGNS_FREE(id); /* check data: verify that at least one of {TimeValues or IterationValues} is defined */ for (i=0; i<(biter[0]->narrays); i++) { array = &biter[0]->array[i]; if (strcmp("TimeValues",array->name)==0 || strcmp("IterationValues",array->name)==0) break; if (i == ((biter[0]->narrays)-1)) { cgi_error("Error: TimeValues or IterationValues must be defined for '%s'",biter[0]->name); return CG_ERROR; } } /* check data: Compute nzones_max and nfamilies_max */ for (i=0; i<(biter[0]->narrays); i++) { int step; array = &biter[0]->array[i]; if (strcmp("NumberOfZones",array->name)==0) { for (step=0; stepnsteps; step++) { int nzones = *((int *)(array->data)+step); nzones_max = MAX(nzones_max, nzones); } } else if (strcmp("NumberOfFamilies",array->name)==0) { for (step=0; stepnsteps; step++) { int nfamilies = *((int *)(array->data)+step); nfamilies_max = MAX(nfamilies_max, nfamilies); } } } /* check data: ZonePointers can't be defined without NumberOfZones and FamilyPointers can't be defined without NumberOfFamilies */ for (i=0; i<(biter[0]->narrays); i++) { array = &biter[0]->array[i]; if (strcmp("ZonePointers",array->name)==0) { if (nzones_max==0) { cgi_error("NumberofZones (DataArray_t) missing under %s",biter[0]->name); return CG_ERROR; } else { /* check dimensions and data type */ if (array->data_dim!=3 || array->dim_vals[0]!=32 || array->dim_vals[1]!=nzones_max || array->dim_vals[2]!=biter[0]->nsteps || strcmp(array->data_type,"C1")) { cgi_error("Incorrect definition of ZonePointers under %s",biter[0]->name); return CG_ERROR; } } } else if (strcmp("FamilyPointers",array->name)==0) { if (nfamilies_max==0) { cgi_error("NumberOfFamilies (DataArray_t) missing under %s",biter[0]->name); return CG_ERROR; } else { /* check dimensions and data type */ if (array->data_dim!=3 || array->dim_vals[0]!=32 || array->dim_vals[1]!=nfamilies_max || array->dim_vals[2]!=biter[0]->nsteps || strcmp(array->data_type,"C1")) { cgi_error("Incorrect definition of FamilyPointers under %s",biter[0]->name); return CG_ERROR; } } } } return CG_OK; } int cgi_read_ziter(int in_link, double parent_id, cgns_ziter **ziter) { double *id = NULL; cgns_array *array = NULL; char_33 datatype; int ndim, nnod; void *data = NULL; int i, linked; cgsize_t dim_vals[12]; /* get number of ZoneIterativeData_t node */ if (cgi_get_nodes(parent_id, "ZoneIterativeData_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { ziter[0]=0; return CG_OK; } else if (nnod>1) { cgi_error("Error: Multiple ZoneIterativeData_t found..."); goto cleanup; } ziter[0] = CGNS_NEW(cgns_ziter, 1); ziter[0]->id = id[0]; ziter[0]->link = cgi_read_link(id[0]); ziter[0]->in_link = in_link; linked = ziter[0]->link ? 1 : in_link; /* Name */ if (cgi_read_node(ziter[0]->id, ziter[0]->name, datatype, &ndim, dim_vals, &data, READ_DATA)) { cgi_error("Error reading ZoneIterativeData_t"); goto cleanup; } if (strcmp(datatype,"MT")) { cgi_error("Error in ZoneIterativeData_t node"); goto cleanup; } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, ziter[0]->id, &ziter[0]->ndescr, &ziter[0]->descr, &ziter[0]->data_class, &ziter[0]->units)) goto cleanup; /* UserDefinedData_t */ if (cgi_read_user_data(linked, ziter[0]->id, &ziter[0]->nuser_data, &ziter[0]->user_data)) goto cleanup; /* DataArray_t */ CGNS_FREE(id); if (cgi_get_nodes(ziter[0]->id, "DataArray_t", &ziter[0]->narrays, &id)) goto cleanup; if (ziter[0]->narrays==0) return CG_OK; /* If no arrays we're done. */ ziter[0]->array = CGNS_NEW(cgns_array,ziter[0]->narrays); for (i=0; i<(ziter[0]->narrays); i++) { ziter[0]->array[i].id = id[i]; ziter[0]->array[i].link = cgi_read_link(id[i]); ziter[0]->array[i].in_link = linked; if (cgi_read_array(&ziter[0]->array[i], "ZoneIterativeData_t", ziter[0]->id)) goto cleanup; array = &ziter[0]->array[i]; /* check data */ if (strcmp("RigidGridMotionPointers",array->name)==0 || strcmp("ArbitraryGridMotionPointers",array->name)==0 || strcmp("GridCoordinatesPointers",array->name)==0 || strcmp("FlowSolutionPointers",array->name)==0) { if (array->data_dim!=2 || array->dim_vals[0]!=32 || array->dim_vals[1]!=NumberOfSteps) { cgi_error("Error: Array '%s/%s' incorrectly sized", ziter[0]->name, array->name); goto cleanup; } if (strcmp(array->data_type,"C1")) { cgi_error("Incorrect data type for %s under %s",array->name,ziter[0]->name); goto cleanup; } } } /* loop through arrays */ CGNS_FREE(id); return CG_OK; cleanup: CGNS_FREE(id); return CG_ERROR; } int cgi_read_user_data_from_list(int in_link, _childnode_t* nodelist, int nnodes, int* nuser_data, cgns_user_data** user_data) { double* idi; int n, i, linked; double* IA_id, * IR_id; int nIA_t, nIR_t, nn; char_33 name; *nuser_data = nnodes; if (*nuser_data <= 0) { user_data[0] = 0; return CG_OK; } user_data[0] = CGNS_NEW(cgns_user_data, (*nuser_data)); for (n = 0; n < (*nuser_data); n++) { user_data[0][n].id = nodelist[n].id; user_data[0][n].link = cgi_read_link(nodelist[n].id); user_data[0][n].in_link = in_link; linked = user_data[0][n].link ? 1 : in_link; /* UserDefinedData_t Name */ if (cgio_get_name(cg->cgio, user_data[0][n].id, user_data[0][n].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, user_data[0][n].id, &user_data[0][n].ndescr, &user_data[0][n].descr, &user_data[0][n].data_class, &user_data[0][n].units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(user_data[0][n].id, "DataArray_t", &user_data[0][n].narrays, &idi)) return CG_ERROR; if (user_data[0][n].narrays > 0) { user_data[0][n].array = CGNS_NEW(cgns_array, user_data[0][n].narrays); for (i = 0; i < user_data[0][n].narrays; i++) { user_data[0][n].array[i].id = idi[i]; user_data[0][n].array[i].link = cgi_read_link(idi[i]); user_data[0][n].array[i].in_link = linked; if (cgi_read_array(&user_data[0][n].array[i], "UserDefinedData_t", user_data[0][n].id)) return CG_ERROR; } CGNS_FREE(idi); } /* GridLocation_t */ if (cgi_read_location(user_data[0][n].id, user_data[0][n].name, &user_data[0][n].location)) return CG_ERROR; /* FamilyName_t */ /* -- FAMILY TREE -- */ if (cgi_read_family_name(linked, user_data[0][n].id, user_data[0][n].name, user_data[0][n].family_name)) return CG_ERROR; /* CPEX 0034 - AdditionalFamilyNames */ if (cgi_get_nodes(user_data[0][n].id, "AdditionalFamilyName_t", &user_data[0][n].nfamname, &idi)) return CG_ERROR; if (user_data[0][n].nfamname > 0) { char* fam; user_data[0][n].famname = CGNS_NEW(cgns_famname, user_data[0][n].nfamname); for (i = 0; i < user_data[0][n].nfamname; i++) { user_data[0][n].famname[i].id = idi[i]; if (cgi_read_string(idi[i], user_data[0][n].famname[i].name, &fam)) return CG_ERROR; strncpy(user_data[0][n].famname[i].family, fam, (CG_MAX_GOTO_DEPTH * 33)); CGNS_FREE(fam); } CGNS_FREE(idi); } /* Ordinal_t */ if (cgi_read_ordinal(user_data[0][n].id, &user_data[0][n].ordinal)) return CG_ERROR; /* PointSet */ /* get number of IndexArray_t and IndexRange_t nodes and their * ID */ if (cgi_get_nodes(user_data[0][n].id, "IndexArray_t", &nIA_t, &IA_id)) return CG_ERROR; if (cgi_get_nodes(user_data[0][n].id, "IndexRange_t", &nIR_t, &IR_id)) return CG_ERROR; /* initialized */ user_data[0][n].ptset = 0; for (nn = 0; nn < nIR_t; nn++) { if (cgio_get_name(cg->cgio, IR_id[nn], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "PointRange") && strcmp(name, "ElementRange")) { cgi_error("Invalid name for IndexRange_t"); return CG_ERROR; } if (user_data[0][n].ptset != 0) { cgi_error("Multiple definition of boundary patch found"); return CG_ERROR; } user_data[0][n].ptset = CGNS_NEW(cgns_ptset, 1); if (strcmp(name, "ElementRange") == 0) user_data[0][n].ptset->type = CGNS_ENUMV(ElementRange); else user_data[0][n].ptset->type = CGNS_ENUMV(PointRange); user_data[0][n].ptset->id = IR_id[nn]; user_data[0][n].ptset->link = cgi_read_link(IR_id[nn]); user_data[0][n].ptset->in_link = linked; if (cgi_read_ptset(user_data[0][n].id, user_data[0][n].ptset)) return CG_ERROR; } if (nIR_t) CGNS_FREE(IR_id); for (nn = 0; nn < nIA_t; nn++) { if (cgio_get_name(cg->cgio, IA_id[nn], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "PointList") && strcmp(name, "ElementList")) continue; if (user_data[0][n].ptset != 0) { cgi_error("Multiple definition of boundary patch found"); return CG_ERROR; } user_data[0][n].ptset = CGNS_NEW(cgns_ptset, 1); if (strcmp(name, "ElementList") == 0) user_data[0][n].ptset->type = CGNS_ENUMV(ElementList); else user_data[0][n].ptset->type = CGNS_ENUMV(PointList); user_data[0][n].ptset->id = IA_id[nn]; user_data[0][n].ptset->link = cgi_read_link(IA_id[nn]); user_data[0][n].ptset->in_link = linked; if (cgi_read_ptset(user_data[0][n].id, user_data[0][n].ptset)) return CG_ERROR; } if (nIA_t) CGNS_FREE(IA_id); /* UserDefinedData_t */ if (cgi_read_user_data(linked, user_data[0][n].id, &user_data[0][n].nuser_data, &user_data[0][n].user_data)) return CG_ERROR; } return CG_OK; } int cgi_read_user_data(int in_link, double parent_id, int *nuser_data, cgns_user_data **user_data) { double *id, *idi; int n, i, linked; double *IA_id, *IR_id; int nIA_t, nIR_t, nn; char_33 name; if (cgi_get_nodes(parent_id, "UserDefinedData_t", nuser_data, &id)) return CG_ERROR; if (*nuser_data<=0) { user_data[0] = 0; return CG_OK; } user_data[0] = CGNS_NEW(cgns_user_data, (*nuser_data)); for (n=0; n<(*nuser_data); n++) { user_data[0][n].id = id[n]; user_data[0][n].link = cgi_read_link(id[n]); user_data[0][n].in_link = in_link; linked = user_data[0][n].link ? 1 : in_link; /* UserDefinedData_t Name */ if (cgio_get_name(cg->cgio, user_data[0][n].id, user_data[0][n].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, id[n], &user_data[0][n].ndescr, &user_data[0][n].descr, &user_data[0][n].data_class, &user_data[0][n].units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(id[n], "DataArray_t", &user_data[0][n].narrays, &idi)) return CG_ERROR; if (user_data[0][n].narrays>0) { user_data[0][n].array = CGNS_NEW(cgns_array, user_data[0][n].narrays); for (i=0; i 0) { char *fam; user_data[0][n].famname = CGNS_NEW(cgns_famname, user_data[0][n].nfamname); for (i = 0; i < user_data[0][n].nfamname; i++) { user_data[0][n].famname[i].id = idi[i]; if (cgi_read_string(idi[i], user_data[0][n].famname[i].name, &fam)) return CG_ERROR; strncpy(user_data[0][n].famname[i].family, fam, (CG_MAX_GOTO_DEPTH*33)); CGNS_FREE(fam); } CGNS_FREE(idi); } /* Ordinal_t */ if (cgi_read_ordinal(user_data[0][n].id, &user_data[0][n].ordinal)) return CG_ERROR; /* PointSet */ /* get number of IndexArray_t and IndexRange_t nodes and their * ID */ if (cgi_get_nodes(user_data[0][n].id, "IndexArray_t", &nIA_t, &IA_id)) return CG_ERROR; if (cgi_get_nodes(user_data[0][n].id, "IndexRange_t", &nIR_t, &IR_id)) return CG_ERROR; /* initialized */ user_data[0][n].ptset = 0; for (nn=0; nncgio, IR_id[nn], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name,"PointRange") && strcmp(name,"ElementRange")) { cgi_error("Invalid name for IndexRange_t"); return CG_ERROR; } if (user_data[0][n].ptset!=0) { cgi_error("Multiple definition of boundary patch found"); return CG_ERROR; } user_data[0][n].ptset = CGNS_NEW(cgns_ptset, 1); if (strcmp(name,"ElementRange")==0) user_data[0][n].ptset->type = CGNS_ENUMV( ElementRange ); else user_data[0][n].ptset->type = CGNS_ENUMV( PointRange ); user_data[0][n].ptset->id=IR_id[nn]; user_data[0][n].ptset->link=cgi_read_link(IR_id[nn]); user_data[0][n].ptset->in_link=linked; if (cgi_read_ptset(user_data[0][n].id, user_data[0][n].ptset)) return CG_ERROR; } if (nIR_t) CGNS_FREE(IR_id); for (nn=0; nncgio, IA_id[nn], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "PointList") && strcmp(name,"ElementList")) continue; if (user_data[0][n].ptset!=0) { cgi_error("Multiple definition of boundary patch found"); return CG_ERROR; } user_data[0][n].ptset = CGNS_NEW(cgns_ptset, 1); if (strcmp(name,"ElementList")==0) user_data[0][n].ptset->type = CGNS_ENUMV( ElementList ); else user_data[0][n].ptset->type = CGNS_ENUMV( PointList ); user_data[0][n].ptset->id = IA_id[nn]; user_data[0][n].ptset->link = cgi_read_link(IA_id[nn]); user_data[0][n].ptset->in_link = linked; if (cgi_read_ptset(user_data[0][n].id, user_data[0][n].ptset)) return CG_ERROR; } if (nIA_t) CGNS_FREE(IA_id); /* UserDefinedData_t */ if (cgi_read_user_data(linked, user_data[0][n].id, &user_data[0][n].nuser_data, &user_data[0][n].user_data)) return CG_ERROR; } CGNS_FREE(id); return CG_OK; } int cgi_read_subregion(int in_link, double parent_id, int *nsubreg, cgns_subreg **subreg) { double *id, *idi; int n, i, linked; double *IA_id, *IR_id; int nIA_t, nIR_t, nn; char_33 data_type, name; cgns_subreg *reg; int ndim, ndescr; char *text; void *data; cgsize_t dim_vals[12]; if (cgi_get_nodes(parent_id, "ZoneSubRegion_t", nsubreg, &id)) return CG_ERROR; if (*nsubreg <= 0) { *subreg = 0; return CG_OK; } reg = CGNS_NEW(cgns_subreg, (*nsubreg)); *subreg = reg; for (n = 0; n < (*nsubreg); n++) { reg[n].id = id[n]; reg[n].link = cgi_read_link(id[n]); reg[n].in_link = in_link; linked = reg[n].link ? 1 : in_link; if (cgi_read_node(reg[n].id, reg[n].name, data_type, &ndim, dim_vals, &data, READ_DATA)) { cgi_error("Error reading ZoneSubRegion node"); return CG_ERROR; } if (ndim != 1 || dim_vals[0] != 1 || strcmp(data_type, "I4")) { cgi_error("Bad dimension value for ZoneSubRegion node"); return CG_ERROR; } reg[n].reg_dim = *((int *)data); CGNS_FREE(data); /* Descriptor_t */ if (cgi_get_nodes(id[n], "Descriptor_t", &nn, &idi)) return CG_ERROR; ndescr = 0; if (nn > 0) { for (i = 0; i < nn; i++) { if (cgi_read_string(idi[i], name, &text)) return CG_ERROR; if (0 == strcmp(name, "BCRegionName")) { reg[n].bcname = CGNS_NEW(cgns_descr, 1); reg[n].bcname->id = idi[i]; reg[n].bcname->link = cgi_read_link(idi[i]); reg[n].bcname->in_link = in_link; strcpy(reg[n].bcname->name, name); reg[n].bcname->text = text; } else if (0 == strcmp(name, "GridConnectivityRegionName")) { reg[n].gcname = CGNS_NEW(cgns_descr, 1); reg[n].gcname->id = idi[i]; reg[n].gcname->link = cgi_read_link(idi[i]); reg[n].gcname->in_link = in_link; strcpy(reg[n].gcname->name, name); reg[n].gcname->text = text; } else { CGNS_FREE(text); ndescr++; } } } if (ndescr > 0) { int j = 0; reg[n].ndescr = ndescr; reg[n].descr = CGNS_NEW(cgns_descr, ndescr); for (i = 0; i < nn; i++) { if (cgi_read_string(idi[i], name, &text)) return CG_ERROR; if (strcmp(name, "BCRegionName") && strcmp(name, "GridConnectivityRegionName")) { reg[n].descr[j].id = idi[i]; reg[n].descr[j].link = cgi_read_link(idi[i]); reg[n].descr[j].in_link = in_link; strcpy(reg[n].descr[j].name, name); reg[n].descr[j].text = text; j++; } else { CGNS_FREE(text); } } } if (nn) CGNS_FREE(idi); /* DataClass_t */ if (cgi_get_nodes(id[n], "DataClass_t", &nn, &idi)) return CG_ERROR; if (nn > 0) { if (cgi_read_string(idi[0], name, &text)) return CG_ERROR; cgi_DataClass(text, ®[n].data_class); CGNS_FREE(text); CGNS_FREE(idi); } /* DimensionalUnits_t */ if (cgi_read_units(in_link, id[n], ®[n].units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(id[n], "DataArray_t", ®[n].narrays, &idi)) return CG_ERROR; if (reg[n].narrays > 0) { reg[n].array = CGNS_NEW(cgns_array, reg[n].narrays); for (i = 0; i < reg[n].narrays; i++) { reg[n].array[i].id = idi[i]; reg[n].array[i].link = cgi_read_link(idi[i]); reg[n].array[i].in_link = linked; if (cgi_read_array(®[n].array[i], "ZoneSubRegion_t", reg[n].id)) return CG_ERROR; } CGNS_FREE(idi); } /* GridLocation_t */ if (cgi_read_location(reg[n].id, reg[n].name, ®[n].location)) return CG_ERROR; /* FamilyName_t */ /* -- FAMILY TREE -- */ if (cgi_read_family_name(linked, reg[n].id, reg[n].name, reg[n].family_name)) return CG_ERROR; /* CPEX 0034 */ if (cgi_get_nodes(reg[n].id, "AdditionalFamilyName_t", ®[n].nfamname, &idi)) return CG_ERROR; if (reg[n].nfamname > 0) { char *fam; reg[n].famname = CGNS_NEW(cgns_famname, reg[n].nfamname); for (i = 0; i < reg[n].nfamname; i++) { reg[n].famname[i].id = idi[i]; if (cgi_read_string(idi[i], reg[n].famname[i].name, &fam)) return CG_ERROR; strncpy(reg[n].famname[i].family, fam, (20*33)-1); CGNS_FREE(fam); } CGNS_FREE(idi); } /* PointSet */ /* get number of IndexArray_t and IndexRange_t nodes and their ID */ if (cgi_get_nodes(reg[n].id, "IndexArray_t", &nIA_t, &IA_id)) return CG_ERROR; if (cgi_get_nodes(reg[n].id, "IndexRange_t", &nIR_t, &IR_id)) return CG_ERROR; /* initialized */ reg[n].ptset = 0; for (nn = 0; nn < nIR_t; nn++) { if (cgio_get_name(cg->cgio, IR_id[nn], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name,"PointRange")) { cgi_error("Invalid name for IndexRange_t"); return CG_ERROR; } if (reg[n].ptset != NULL) { cgi_error("Multiple definition of boundary patch found"); return CG_ERROR; } reg[n].ptset = CGNS_NEW(cgns_ptset, 1); reg[n].ptset->type = CGNS_ENUMV(PointRange); reg[n].ptset->id=IR_id[nn]; reg[n].ptset->link=cgi_read_link(IR_id[nn]); reg[n].ptset->in_link=linked; if (cgi_read_ptset(reg[n].id, reg[n].ptset)) return CG_ERROR; } if (nIR_t) CGNS_FREE(IR_id); for (nn = 0; nn < nIA_t; nn++) { if (cgio_get_name(cg->cgio, IA_id[nn], name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } if (strcmp(name, "PointList")) continue; if (reg[n].ptset != NULL) { cgi_error("Multiple definition of boundary patch found"); return CG_ERROR; } reg[n].ptset = CGNS_NEW(cgns_ptset, 1); reg[n].ptset->type = CGNS_ENUMV(PointList); reg[n].ptset->id = IA_id[nn]; reg[n].ptset->link = cgi_read_link(IA_id[nn]); reg[n].ptset->in_link = linked; if (cgi_read_ptset(reg[n].id, reg[n].ptset)) return CG_ERROR; } if (nIA_t) CGNS_FREE(IA_id); /* Rind Planes */ if (cgi_read_rind(reg[n].id, ®[n].rind_planes)) return CG_ERROR; /* UserDefinedData_t */ if (cgi_read_user_data(linked, reg[n].id, ®[n].nuser_data, ®[n].user_data)) return CG_ERROR; } CGNS_FREE(id); return CG_OK; } int cgi_read_node_data(double node_id, char_33 data_type, int* ndim, cgsize_t* dim_vals, void** data) { int n; cgsize_t size = 1; /* read node data type */ if (cgio_get_data_type(cg->cgio, node_id, data_type)) { cg_io_error("cgio_get_data_type"); return CG_ERROR; } if (strcmp(data_type, "MT") == 0) { *ndim = 0; return CG_OK; } if (cgio_get_dimensions(cg->cgio, node_id, ndim, dim_vals)) { cg_io_error("cgio_get_dimensions"); return CG_ERROR; } /* allocate data */ for (n = 0; n < (*ndim); n++) size *= dim_vals[n]; if (size <= 0) { cgi_error("Error reading node data"); return CG_ERROR; } if (strcmp(data_type, "I4") == 0) data[0] = CGNS_NEW(int, size); else if (strcmp(data_type, "I8") == 0) data[0] = CGNS_NEW(cglong_t, size); else if (strcmp(data_type, "R4") == 0) data[0] = CGNS_NEW(float, size); else if (strcmp(data_type, "R8") == 0) data[0] = CGNS_NEW(double, size); else if (strcmp(data_type, "C1") == 0) data[0] = CGNS_NEW(char, size + 1); /* read data */ if (cgio_read_all_data_type(cg->cgio, node_id, data_type, data[0])) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } return CG_OK; } int cgi_read_node(double node_id, char_33 name, char_33 data_type, int *ndim, cgsize_t *dim_vals, void **data, int data_flag) { int n; cgsize_t size=1; /* name of node */ if (cgio_get_name(cg->cgio, node_id, name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* read node data type */ if (cgio_get_data_type(cg->cgio, node_id, data_type)) { cg_io_error("cgio_get_data_type"); return CG_ERROR; } if (strcmp(data_type,"MT")==0) { *ndim = 0; return CG_OK; } if (cgio_get_dimensions(cg->cgio, node_id, ndim, dim_vals)) { cg_io_error("cgio_get_dimensions"); return CG_ERROR; } /* Skipping data */ if (!data_flag) return CG_OK; /* allocate data */ for (n=0; n<(*ndim); n++) size*=dim_vals[n]; if (size<=0) { cgi_error("Error reading node %s",name); return CG_ERROR; } if (strcmp(data_type,"I4")==0) data[0]=CGNS_NEW(int, size); else if (strcmp(data_type,"I8")==0) data[0]=CGNS_NEW(cglong_t, size); else if (strcmp(data_type,"R4")==0) data[0]=CGNS_NEW(float, size); else if (strcmp(data_type,"R8")==0) data[0]=CGNS_NEW(double, size); else if (strcmp(data_type,"C1")==0) data[0]=CGNS_NEW(char, size+1); /* read data */ if (cgio_read_all_data_type(cg->cgio, node_id, data_type, data[0])) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } return CG_OK; } cgns_link *cgi_read_link (double node_id) { int len; cgns_link *link; if (cgio_is_link(cg->cgio, node_id, &len)) { cg_io_error ("cgio_is_link"); return CG_OK; } if (len > 0) { int file_len, name_len; if (cgio_link_size (cg->cgio, node_id, &file_len, &name_len)) { cg_io_error ("cgio_link_size"); return CG_OK; } len = name_len + file_len + 2; link = (cgns_link *) cgi_malloc (1, len + sizeof(cgns_link)); link->filename = (char *)(link + 1); link->name_in_file = link->filename + file_len + 1; if (cgio_get_link(cg->cgio, node_id, link->filename, link->name_in_file)) { free (link); cg_io_error ("cgio_get_link"); return CG_OK; } link->filename[file_len] = 0; link->name_in_file[name_len] = 0; return link; } return CG_OK; } int cgi_read_particle(cgns_pzone *pzone) { int n, ndim; int in_link = pzone->link ? 1 : pzone->in_link; char_33 data_type; void *vdata; double *id; cgsize_t dim_vals[12]; /* ParticleZone_t, assume pzone->name is already read */ if (cgi_read_node_data(pzone->id, data_type, &ndim, dim_vals, &vdata)) { cgi_error("Error reading node ParticleZone_t"); return CG_ERROR; } /* verify data read */ if (ndim!=1) { cgi_error("Wrong number of dimension for a ParticleZone_t node"); return CG_ERROR; } /* Reset Idim so that cgi_* routines work properly with particles */ Idim = 1; if (0 == strcmp(data_type, "I8")) { cglong_t *particle_dim = (cglong_t *)vdata; #if CG_SIZEOF_SIZE == 32 if (particle_dim[0] > CG_MAX_INT32) { cgi_error("array size exceeds that for a 32-bit integer"); return 1; } #endif pzone->nparticles = (cgsize_t)particle_dim[0]; } else if (0 == strcmp(data_type, "I4")) { int *particle_dim = (int *)vdata; pzone->nparticles = (cgsize_t)particle_dim[0]; } else { cgi_error("Unsupported data type for ParticleZone_t node %s= %s", pzone->name, data_type); return CG_ERROR; } CGNS_FREE(vdata); CurrentParticleSize = pzone->nparticles; /* ParticleCoordinates_t - particle zone coords */ if (cgi_read_particle_pcoor(in_link, pzone->id, &pzone->npcoor, &pzone->pcoor)) return CG_ERROR; /* FamilyName_t */ /* -- FAMILY TREE -- */ if (cgi_read_family_name(in_link, pzone->id, pzone->name, pzone->family_name)) return CG_ERROR; /* CPEX 0034 */ /* -- FAMILY TREE -- */ if (cgi_get_nodes(pzone->id, "AdditionalFamilyName_t", &pzone->nfamname, &id)) return CG_ERROR; if (pzone->nfamname > 0) { char *fam; pzone->famname = CGNS_NEW(cgns_famname, pzone->nfamname); for (n = 0; n < pzone->nfamname; n++) { pzone->famname[n].id = id[n]; if (cgi_read_string(id[n], pzone->famname[n].name, &fam)) return CG_ERROR; strncpy(pzone->famname[n].family, fam, (CG_MAX_GOTO_DEPTH*(CGIO_MAX_NAME_LENGTH+1))); CGNS_FREE(fam); } CGNS_FREE(id); } /* ParticleSolution_t */ if (cgi_read_particle_sol(in_link, pzone->id, &pzone->nsols, &pzone->sol)) return CG_ERROR; /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(in_link, pzone->id, &pzone->ndescr, &pzone->descr, &pzone->data_class, &pzone->units)) return CG_ERROR; /* ParticleEquationSet_t */ if (cgi_read_particle_equations(in_link, pzone->id, &pzone->equations)) return CG_ERROR; /* IntegralData_t */ if (cgi_read_integral(in_link, pzone->id, &pzone->nintegrals, &pzone->integral)) return CG_ERROR; /* ReferenceState_t */ if (cgi_read_state(in_link, pzone->id, &pzone->state)) return CG_ERROR; /* ParticleIterativeData_t can only exist if BaseIterativeData_t exist because it depends on it */ if (NumberOfSteps) { if (cgi_read_piter(in_link, pzone->id, &pzone->piter)) return CG_ERROR; } else pzone->piter = 0; /* UserDefinedData_t */ if (cgi_read_user_data(in_link, pzone->id, &pzone->nuser_data, &pzone->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_particle_sol(int in_link, double parent_id, int *nsols, cgns_psol **sol) { double *id, *idf; int s, z, linked; cgsize_t DataCount = 0; if (cgi_get_nodes(parent_id, "ParticleSolution_t", nsols, &id)) return CG_ERROR; if (*nsols<=0) { sol[0] = 0; return CG_OK; } sol[0] = CGNS_NEW(cgns_psol, (*nsols)); for (s=0; s<(*nsols); s++) { sol[0][s].id = id[s]; sol[0][s].link = cgi_read_link(id[s]); sol[0][s].in_link = in_link; linked = sol[0][s].link ? 1 : in_link; /* ParticleSolution_t Name */ if (cgio_get_name(cg->cgio, sol[0][s].id, sol[0][s].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* check for PointList/PointRange */ if (cgi_read_one_ptset(linked, sol[0][s].id, &sol[0][s].ptset)) return CG_ERROR; if (sol[0][s].ptset != NULL) { if (sol[0][s].ptset->type == CGNS_ENUMV(ElementList) || sol[0][s].ptset->type == CGNS_ENUMV(ElementRange)) { cgi_error("ElementList/Range not supported under ParticleSolution"); return CG_ERROR; } DataCount = sol[0][s].ptset->size_of_patch; } /* DataArray_t */ if (cgi_get_nodes(sol[0][s].id, "DataArray_t", &sol[0][s].nfields, &idf)) return CG_ERROR; if (sol[0][s].nfields > 0) { sol[0][s].field = CGNS_NEW(cgns_array, sol[0][s].nfields); for (z=0; zcgio, pcoor[0][g].id, pcoor[0][g].name)) { cg_io_error("cgio_get_name"); return CG_ERROR; } /* DataArray_t */ if (cgi_get_nodes(pcoor[0][g].id, "DataArray_t", &pcoor[0][g].ncoords, &id)) return CG_ERROR; if (pcoor[0][g].ncoords > 0) { pcoor[0][g].coord = CGNS_NEW(cgns_array, pcoor[0][g].ncoords); for (p=0; p1) { cgi_error("Error: Multiple ParticleIterativeData_t found..."); goto cleanup; } piter[0] = CGNS_NEW(cgns_ziter, 1); piter[0]->id = id[0]; piter[0]->link = cgi_read_link(id[0]); piter[0]->in_link = in_link; linked = piter[0]->link ? 1 : in_link; /* Name */ if (cgi_read_node(piter[0]->id, piter[0]->name, datatype, &ndim, dim_vals, &data, READ_DATA)) { cgi_error("Error reading ParticleIterativeData_t"); goto cleanup; } if (strcmp(datatype,"MT")) { cgi_error("Error in ParticleIterativeData_t node"); goto cleanup; } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, piter[0]->id, &piter[0]->ndescr, &piter[0]->descr, &piter[0]->data_class, &piter[0]->units)) goto cleanup; /* UserDefinedData_t */ if (cgi_read_user_data(linked, piter[0]->id, &piter[0]->nuser_data, &piter[0]->user_data)) goto cleanup; /* DataArray_t */ CGNS_FREE(id); if (cgi_get_nodes(piter[0]->id, "DataArray_t", &piter[0]->narrays, &id)) goto cleanup; if (piter[0]->narrays==0) return CG_OK; /* If no arrays we're done. */ piter[0]->array = CGNS_NEW(cgns_array, piter[0]->narrays); for (i=0; i<(piter[0]->narrays); i++) { piter[0]->array[i].id = id[i]; piter[0]->array[i].link = cgi_read_link(id[i]); piter[0]->array[i].in_link = linked; if (cgi_read_array(&piter[0]->array[i], "ParticleIterativeData_t", piter[0]->id)) goto cleanup; array = &piter[0]->array[i]; /* check data */ if (strcmp("ParticleSolutionPointers",array->name)==0){ if (array->data_dim!=2 || array->dim_vals[0]!=32 || array->dim_vals[1]!=NumberOfSteps) { cgi_error("Error: Array '%s/%s' incorrectly sized", piter[0]->name, array->name); goto cleanup; } if (strcmp(array->data_type,"C1")) { cgi_error("Incorrect data type for %s under %s", array->name, piter[0]->name); goto cleanup; } } } /* loop through arrays */ CGNS_FREE(id); return CG_OK; cleanup: CGNS_FREE(id); return CG_ERROR; } int cgi_read_particle_model(int in_link, double parent_id, char *label, cgns_pmodel **model) { int n, nnod, linked; double *id; char *string_data; if (cgi_get_nodes(parent_id, label, &nnod, &id)) return CG_ERROR; if (nnod<=0) { model[0]=0; return CG_OK; } model[0] = CGNS_NEW(cgns_pmodel,1); model[0]->id = id[0]; model[0]->link = cgi_read_link(id[0]); model[0]->in_link = in_link; linked = model[0]->link ? 1 : in_link; CGNS_FREE(id); /* Particle Model Type */ if (cgi_read_string(model[0]->id, model[0]->name, &string_data)) return CG_ERROR; if (cgi_ParticleModelType(string_data, &model[0]->type)) return CG_ERROR; CGNS_FREE(string_data); /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, model[0]->id, &model[0]->ndescr, &model[0]->descr, &model[0]->data_class, &model[0]->units)) return CG_ERROR; /* DataArray_t */ if (cgi_get_nodes(model[0]->id, "DataArray_t", &model[0]->narrays, &id)) return CG_ERROR; if (model[0]->narrays>0) { model[0]->array = CGNS_NEW(cgns_array, model[0]->narrays); for (n=0; nnarrays; n++) { model[0]->array[n].id = id[n]; model[0]->array[n].link = cgi_read_link(id[n]); model[0]->array[n].in_link = linked; if (cgi_read_array(&model[0]->array[n],"ParticleModel_t", model[0]->id)) return CG_ERROR; /* verify data */ if (model[0]->array[n].data_dim!=1 || model[0]->array[n].dim_vals[0]!=1) { cgi_error("Wrong data dimension in %s definition",model[0]->name); return CG_ERROR; } } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, model[0]->id, &model[0]->nuser_data, &model[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_particle_equations_node(int linked, cgns_pequations** equations) { double* id; int n, nnod, ndim; char* string_data; char_33 name, data_type; cgsize_t dim_vals[12]; void* vdata; /* ParticleGoverningEquations_t */ equations[0]->governing = 0; if (cgi_get_nodes(equations[0]->id, "ParticleGoverningEquations_t", &nnod, &id)) return CG_ERROR; if (nnod > 0) { equations[0]->governing = CGNS_NEW(cgns_pgoverning, 1); equations[0]->governing->id = id[0]; equations[0]->governing->link = cgi_read_link(id[0]); equations[0]->governing->in_link = linked; if (cgi_read_string(id[0], equations[0]->governing->name, &string_data) || cgi_ParticleGoverningEquationsType(string_data, &equations[0]->governing->type)) return CG_ERROR; CGNS_FREE(string_data); CGNS_FREE(id); /* Descriptor_t */ if (cgi_get_nodes(equations[0]->governing->id, "Descriptor_t", &equations[0]->governing->ndescr, &id)) return CG_ERROR; if (equations[0]->governing->ndescr > 0) { equations[0]->governing->descr = CGNS_NEW(cgns_descr, equations[0]->governing->ndescr); for (n = 0; n < equations[0]->governing->ndescr; n++) { equations[0]->governing->descr[n].id = id[n]; equations[0]->governing->descr[n].link = cgi_read_link(id[n]); equations[0]->governing->descr[n].in_link = linked; if (cgi_read_string(id[n], equations[0]->governing->descr[n].name, &equations[0]->governing->descr[n].text)) return CG_ERROR; } CGNS_FREE(id); } /* UserDefinedData_t */ if (cgi_read_user_data(linked, equations[0]->governing->id, &equations[0]->governing->nuser_data, &equations[0]->governing->user_data)) return CG_ERROR; } /* ParticleCollisionModel_t */ if (cgi_read_particle_model(linked, equations[0]->id, "ParticleCollisionModel_t", &equations[0]->collision)) return CG_ERROR; /* ParticleBreakupModel_t */ if (cgi_read_particle_model(linked, equations[0]->id, "ParticleBreakupModel_t", &equations[0]->breakup)) return CG_ERROR; /* ParticleForceModel_t */ if (cgi_read_particle_model(linked, equations[0]->id, "ParticleForceModel_t", &equations[0]->force)) return CG_ERROR; /* ParticleWallInteractionModel_t */ if (cgi_read_particle_model(linked, equations[0]->id, "ParticleWallInteractionModel_t", &equations[0]->wallinteract)) return CG_ERROR; /* ParticlePhaseChangeModel_t */ if (cgi_read_particle_model(linked, equations[0]->id, "ParticlePhaseChangeModel_t", &equations[0]->phasechange)) return CG_ERROR; /* EquationDimension */ equations[0]->equation_dim = 0; if (cgi_get_nodes(equations[0]->id, "\"int\"", &nnod, &id)) return CG_ERROR; if (nnod > 0) { if (cgi_read_node(id[0], name, data_type, &ndim, dim_vals, &vdata, READ_DATA)) { cgi_error("Error reading base"); return CG_ERROR; } /* verify data */ if (strcmp(name, "EquationDimension") || strcmp(data_type, "I4") || ndim != 1 || dim_vals[0] != 1) { cgi_error("Error reading equation dimension for Particle Equation Set"); return CG_ERROR; } equations[0]->equation_dim = *((int*)vdata); CGNS_FREE(vdata); CGNS_FREE(id); } /* Descriptor_t, DataClass_t, DimensionalUnits_t */ if (cgi_read_DDD(linked, equations[0]->id, &equations[0]->ndescr, &equations[0]->descr, &equations[0]->data_class, &equations[0]->units)) return CG_ERROR; /* UserDefinedData_t */ if (cgi_read_user_data(linked, equations[0]->id, &equations[0]->nuser_data, &equations[0]->user_data)) return CG_ERROR; return CG_OK; } int cgi_read_particle_equations_from_list(int in_link, _childnode_t* nodelist, int nnodes, cgns_pequations** equations) { int nnod, start, linked; nnod = nnodes; start = 0; if (nnod <= 0) { equations[0] = 0; return CG_OK; } equations[0] = CGNS_NEW(cgns_pequations, 1); equations[0]->id = nodelist[start].id; equations[0]->link = cgi_read_link(nodelist[start].id); equations[0]->in_link = in_link; linked = equations[0]->link ? 1 : in_link; strcpy(equations[0]->name, "ParticleEquationSet"); if (cgi_read_particle_equations_node(linked, equations)) return CG_ERROR; return CG_OK; } int cgi_read_particle_equations(int in_link, double parent_id, cgns_pequations **equations) { double *id; int nnod, linked; if (cgi_get_nodes(parent_id, "ParticleEquationSet_t", &nnod, &id)) return CG_ERROR; if (nnod<=0) { equations[0]=0; return CG_OK; } equations[0] = CGNS_NEW(cgns_pequations, 1); equations[0]->id = id[0]; equations[0]->link = cgi_read_link(id[0]); equations[0]->in_link = in_link; linked = equations[0]->link ? 1 : in_link; CGNS_FREE(id); strcpy(equations[0]->name, "ParticleEquationSet"); if (cgi_read_particle_equations_node(linked, equations)) return CG_ERROR; return CG_OK; } int cgi_datasize(int ndim, cgsize_t *dims, CGNS_ENUMV(GridLocation_t) location, int *rind_planes, cgsize_t *DataSize) { int j; if (location==CGNS_ENUMV( Vertex )) { for (j=0; j CG_MAX_INT32) { cgi_error("array size exceeds that for a 32-bit integer"); return CG_ERROR; } return CG_OK; } int cgi_check_location(int dim, CGNS_ENUMT(ZoneType_t) type, CGNS_ENUMT(GridLocation_t) loc) { if (loc == CGNS_ENUMV(Vertex) || loc == CGNS_ENUMV(CellCenter)) return CG_OK; if (loc == CGNS_ENUMV(EdgeCenter)) { if (dim >= 2) return CG_OK; } else if (loc == CGNS_ENUMV(FaceCenter)) { if (dim >= 3) return CG_OK; } else if (loc == CGNS_ENUMV(IFaceCenter) || loc == CGNS_ENUMV(JFaceCenter) || loc == CGNS_ENUMV(KFaceCenter)) { if (type != CGNS_ENUMV(Structured)) { cgi_error("GridLocation [IJK]FaceCenter only valid for Structured Grid"); return CG_ERROR; } if (dim >= 3) return CG_OK; } cgi_error("GridLocation %s not valid for CellDimension %d", cg_GridLocationName(loc), dim); return CG_ERROR; } int cgi_read_int_data(double id, char_33 data_type, cgsize_t cnt, cgsize_t *data) { cgsize_t n; #if CG_SIZEOF_SIZE == 64 if (0 == strcmp(data_type, "I4")) { int *pnts = (int *)malloc((size_t)(cnt*sizeof(int))); if (NULL == pnts) { cgi_error("Error allocating I4->I8 data array..."); return CG_ERROR; } if (cgio_read_all_data_type(cg->cgio, id, data_type,(void *)pnts)) { cg_io_error("cgio_read_all_data_type"); CGNS_FREE(pnts); return CG_ERROR; } for (n = 0; n < cnt; n++) data[n] = (cgsize_t)pnts[n]; CGNS_FREE(pnts); } #else if (0 == strcmp(data_type, "I8")) { cglong_t *pnts = (cglong_t *)malloc((size_t)(cnt*sizeof(cglong_t))); if (NULL == pnts) { cgi_error("Error allocating I8->I4 data array..."); return CG_ERROR; } if (cgio_read_all_data_type(cg->cgio, id, data_type, (void *)pnts)) { cg_io_error("cgio_read_all_data_type"); CGNS_FREE(pnts); return CG_ERROR; } for (n = 0; n < cnt; n++) data[n] = (cgsize_t)pnts[n]; CGNS_FREE(pnts); } #endif else { if (cgio_read_all_data_type(cg->cgio, id, data_type, (void *)data)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } return CG_OK; } int cgi_read_offset_data_type(double id, char const *data_type, cgsize_t start, cgsize_t end, char const *m_type, void* data) { cgsize_t cnt = end - start + 1; cgsize_t s_start[1], s_end[1], s_stride[1]; cgsize_t m_start[1], m_end[1], m_stride[1], m_dim[1]; int ier = CG_OK; s_start[0] = start; s_end[0] = end; s_stride[0] = 1; m_start[0] = 1; m_end[0] = cnt; m_stride[0] = 1; m_dim[0] = cnt; if (0 == strcmp(data_type, "I4") && 0 == strcmp(m_type, "I4")) { if (cgio_read_data_type(cg->cgio, id, s_start, s_end, s_stride, "I4", 1, m_dim, m_start, m_end, m_stride, data)) { cg_io_error("cgio_read_data"); return CG_ERROR; } } else if (0 == strcmp(data_type, "I8") && 0 == strcmp(m_type, "I8")) { if (cgio_read_data_type(cg->cgio, id, s_start, s_end, s_stride, "I8", 1, m_dim, m_start, m_end, m_stride, data)) { cg_io_error("cgio_read_data"); return CG_ERROR; } } else { if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { void* conv_data = NULL; conv_data = malloc(((size_t)cnt) * size_of(data_type)); if (conv_data == NULL) { cgi_error("Error allocating conv_data"); return CG_ERROR; } if (cgio_read_data_type(cg->cgio, id, s_start, s_end, s_stride, data_type, 1, m_dim, m_start, m_end, m_stride, conv_data)) { free(conv_data); cg_io_error("cgio_read_data_type"); return CG_ERROR; } ier = cgi_convert_data(cnt, cgi_datatype(data_type), conv_data, cgi_datatype(m_type), data); free(conv_data); if (ier) return CG_ERROR; } else { /* in situ conversion */ if (cgio_read_data_type(cg->cgio, id, s_start, s_end, s_stride, m_type, 1, m_dim, m_start, m_end, m_stride, data)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } return CG_OK; } int cgi_convert_data(cgsize_t cnt, CGNS_ENUMT(DataType_t) from_type, const void *from_data, CGNS_ENUMT(DataType_t) to_type, void *to_data) { int ierr = 0; cgsize_t n; if (from_type == CGNS_ENUMV(Character)) { const char *src = (const char *)from_data; /* C1 -> C1 */ if (to_type == CGNS_ENUMV(Character)) { char *dest = (char *)to_data; for (n = 0; n < cnt; n++) dest[n] = (char)src[n]; } /* C1 -> I4 */ else if (to_type == CGNS_ENUMV(Integer)) { int *dest = (int *)to_data; for (n = 0; n < cnt; n++) dest[n] = (int)src[n]; } /* C1 -> I8 */ else if (to_type == CGNS_ENUMV(LongInteger)) { cglong_t *dest = (cglong_t *)to_data; for (n = 0; n < cnt; n++) dest[n] = (cglong_t)src[n]; } /* C1 -> R4 */ else if (to_type == CGNS_ENUMV(RealSingle)) { float *dest = (float *)to_data; for (n = 0; n < cnt; n++) dest[n] = (float)src[n]; } /* C1 -> R8 */ else if (to_type == CGNS_ENUMV(RealDouble)) { double *dest = (double *)to_data; for (n = 0; n < cnt; n++) dest[n] = (double)src[n]; } else { ierr = 1; } } else if (from_type == CGNS_ENUMV(Integer)) { const int *src = (const int *)from_data; /* I4 -> C1 */ if (to_type == CGNS_ENUMV(Character)) { char *dest = (char *)to_data; for (n = 0; n < cnt; n++) dest[n] = (char)src[n]; } /* I4 -> I4 */ else if (to_type == CGNS_ENUMV(Integer)) { int *dest = (int *)to_data; for (n = 0; n < cnt; n++) dest[n] = (int)src[n]; } /* I4 -> I8 */ else if (to_type == CGNS_ENUMV(LongInteger)) { cglong_t *dest = (cglong_t *)to_data; for (n = 0; n < cnt; n++) dest[n] = (cglong_t)src[n]; } /* I4 -> R4 */ else if (to_type == CGNS_ENUMV(RealSingle)) { float *dest = (float *)to_data; for (n = 0; n < cnt; n++) dest[n] = (float)src[n]; } /* I4 -> R8 */ else if (to_type == CGNS_ENUMV(RealDouble)) { double *dest = (double *)to_data; for (n = 0; n < cnt; n++) dest[n] = (double)src[n]; } else { ierr = 1; } } else if (from_type == CGNS_ENUMV(LongInteger)) { const cglong_t *src = (const cglong_t *)from_data; /* I8 -> C1 */ if (to_type == CGNS_ENUMV(Character)) { char *dest = (char *)to_data; for (n = 0; n < cnt; n++) dest[n] = (char)src[n]; } /* I8 -> I4 */ else if (to_type == CGNS_ENUMV(Integer)) { int *dest = (int *)to_data; for (n = 0; n < cnt; n++) dest[n] = (int)src[n]; } /* I8 -> I8 */ else if (to_type == CGNS_ENUMV(LongInteger)) { cglong_t *dest = (cglong_t *)to_data; for (n = 0; n < cnt; n++) dest[n] = (cglong_t)src[n]; } /* I8 -> R4 */ else if (to_type == CGNS_ENUMV(RealSingle)) { float *dest = (float *)to_data; for (n = 0; n < cnt; n++) dest[n] = (float)src[n]; } /* I8 -> R8 */ else if (to_type == CGNS_ENUMV(RealDouble)) { double *dest = (double *)to_data; for (n = 0; n < cnt; n++) dest[n] = (double)src[n]; } else { ierr = 1; } } else if (from_type == CGNS_ENUMV(RealSingle)) { const float *src = (const float *)from_data; /* R4 -> C1 */ if (to_type == CGNS_ENUMV(Character)) { char *dest = (char *)to_data; for (n = 0; n < cnt; n++) dest[n] = (char)src[n]; } /* R4 -> I4 */ else if (to_type == CGNS_ENUMV(Integer)) { int *dest = (int *)to_data; for (n = 0; n < cnt; n++) dest[n] = (int)src[n]; } /* R4 -> I8 */ else if (to_type == CGNS_ENUMV(LongInteger)) { cglong_t *dest = (cglong_t *)to_data; for (n = 0; n < cnt; n++) dest[n] = (cglong_t)src[n]; } /* R4 -> R4 */ else if (to_type == CGNS_ENUMV(RealSingle)) { float *dest = (float *)to_data; for (n = 0; n < cnt; n++) dest[n] = (float)src[n]; } /* R4 -> R8 */ else if (to_type == CGNS_ENUMV(RealDouble)) { double *dest = (double *)to_data; for (n = 0; n < cnt; n++) dest[n] = (double)src[n]; } else { ierr = 1; } } else if (from_type == CGNS_ENUMV(RealDouble)) { const double *src = (const double *)from_data; /* R8 -> C1 */ if (to_type == CGNS_ENUMV(Character)) { char *dest = (char *)to_data; for (n = 0; n < cnt; n++) dest[n] = (char)src[n]; } /* R8 -> I4 */ else if (to_type == CGNS_ENUMV(Integer)) { int *dest = (int *)to_data; for (n = 0; n < cnt; n++) dest[n] = (int)src[n]; } /* R8 -> I8 */ else if (to_type == CGNS_ENUMV(LongInteger)) { cglong_t *dest = (cglong_t *)to_data; for (n = 0; n < cnt; n++) dest[n] = (cglong_t)src[n]; } /* R8 -> R4 */ else if (to_type == CGNS_ENUMV(RealSingle)) { float *dest = (float *)to_data; for (n = 0; n < cnt; n++) dest[n] = (float)src[n]; } /* R8 -> R8 */ else if (to_type == CGNS_ENUMV(RealDouble)) { double *dest = (double *)to_data; for (n = 0; n < cnt; n++) dest[n] = (double)src[n]; } else { ierr = 1; } } #if CG_BUILD_COMPLEX_C99_EXT else if (from_type == CGNS_ENUMV(ComplexSingle)) { const cg_complex_float *src = (const cg_complex_float *)from_data; /* X4 -> X4 */ if (to_type == CGNS_ENUMV(ComplexSingle)) { cg_complex_float *dest = (cg_complex_float *)to_data; for (n = 0; n < cnt; n++) dest[n] = src[n]; } /* X4 -> X8 */ else if (to_type == CGNS_ENUMV(ComplexDouble)) { cg_complex_double *dest = (cg_complex_double *)to_data; for (n = 0; n < cnt; n++) { __real__(dest[n]) = (double)crealf(src[n]); __imag__(dest[n]) = (double)cimagf(src[n]); } } else { ierr = 1; } } else if (from_type == CGNS_ENUMV(ComplexDouble)) { const cg_complex_double *src = (const cg_complex_double *)from_data; /* X8 -> X8 */ if (to_type == CGNS_ENUMV(ComplexDouble)) { cg_complex_double *dest = (cg_complex_double *)to_data; for (n = 0; n < cnt; n++) dest[n] = src[n]; } /* X8 -> X4 */ else if (to_type == CGNS_ENUMV(ComplexSingle)) { cg_complex_float *dest = (cg_complex_float *)to_data; for (n = 0; n < cnt; n++) { __real__(dest[n]) = (float)creal(src[n]); __imag__(dest[n]) = (float)cimag(src[n]); } } else { ierr = 1; } } #endif else { ierr = 1; } if (ierr) cgi_error("invalid data type conversion %d->%d", from_type, to_type); return ierr; } /***********************************************************************\ * Write a CGNS file from in-memory data * \***********************************************************************/ int cgi_write(int file_number) { cgns_base *base; int n, b; cgsize_t dim_vals; double dummy_id; float FileVersion; cg = cgi_get_file(file_number); if (cg == 0) return CG_ERROR; /* write version number */ dim_vals = 1; /* Changed due to round off error on CRAY: FileVersion = (float)CGNSLibVersion/1000; */ /* The FileVersion will always be the latest if (cg->version == 1050) FileVersion = (float) 1.05; else if (cg->version == 1100) FileVersion = (float) 1.10; else if (cg->version == 1200) FileVersion = (float) 1.2; else if (cg->version == 1270) FileVersion = (float) 1.27; else if (cg->version == 2000) FileVersion = (float) 2.00; else if (cg->version == 2100) FileVersion = (float) 2.10; else { cgi_error("FileVersion can't be set in cgi_write!"); return CG_ERROR; } */ FileVersion = (float) CGNS_DOTVERS; if (cgi_new_node(cg->rootid, "CGNSLibraryVersion", "CGNSLibraryVersion_t", &dummy_id, "R4", 1, &dim_vals, (void *)&FileVersion)) return CG_ERROR; /* write all CGNSBase_t nodes in ADF file */ for (b=0; bnbases; b++) { int *data; data = CGNS_NEW(int, 2); base = &(cg->base[b]); data[0]=base->cell_dim; data[1]=base->phys_dim; /* Create the CGNSBase_t nodes */ dim_vals=2; if (cgi_new_node(cg->rootid, base->name, "CGNSBase_t", &base->id, "I4", 1, &dim_vals, (void *)data)) return CG_ERROR; CGNS_FREE(data); /* set Global variable */ Cdim = base->cell_dim; Pdim = base->phys_dim; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(base->id, &base->descr[n])) return CG_ERROR; /* ReferenceState_t */ if (base->state && cgi_write_state(base->id, base->state)) return CG_ERROR; /* Gravity_t */ if (base->gravity && cgi_write_gravity(base->id, base->gravity)) return CG_ERROR; /* Axisymmetry_t */ if (base->axisym && cgi_write_axisym(base->id, base->axisym)) return CG_ERROR; /* RotatingCoordinates_t */ if (base->rotating && cgi_write_rotating(base->id, base->rotating)) return CG_ERROR; /* Zone_t */ for (n=0; nnzones; n++) { if (cgi_write_zone(base->id, &base->zone[n])) return CG_ERROR; } /* Family_t */ for (n=0; nnfamilies; n++) if (cgi_write_family(base->id, &base->family[n])) return CG_ERROR; /* DataClass_t */ if (base->data_class && cgi_write_dataclass(base->id, base->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (base->units && cgi_write_units(base->id, base->units)) return CG_ERROR; /* ConvergenceHistory_t */ if (base->converg && cgi_write_converg(base->id, base->converg)) return CG_ERROR; /* FlowEquationSet_t */ if (base->equations && cgi_write_equations(base->id, base->equations)) return CG_ERROR; /* ParticleEquationSet_t */ if (base->pequations && cgi_write_particle_equations(base->id, base->pequations)) return CG_ERROR; /* IntegralData_t */ for (n=0; nnintegrals; n++) if (cgi_write_integral(base->id, &base->integral[n])) return CG_ERROR; /* SimulationType_t */ if (base->type) { dim_vals = (cgsize_t)strlen(SimulationTypeName[base->type]); if (cgi_new_node(base->id, "SimulationType", "SimulationType_t", &base->type_id, "C1", 1, &dim_vals, (void *)SimulationTypeName[base->type])) return CG_ERROR; } /* BaseIterativeData_t */ if (base->biter && cgi_write_biter(base->id, base->biter)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(base->id, &base->user_data[n])) return CG_ERROR; /* ParticleZone_t */ for (n=0; nnpzones; n++) if (cgi_write_particle(base->id, &base->pzone[n])) return CG_ERROR; } return CG_OK; } int cgi_write_zone(double parent_id, cgns_zone *zone) { int n; cgsize_t dim_vals[2]; double dummy_id; Idim = zone->index_dim; if (zone->link) { return cgi_write_link(parent_id, zone->name, zone->link, &zone->id); } /* Create the Zone_t nodes */ dim_vals[0]= Idim; dim_vals[1]= 3; if (cgi_new_node(parent_id, zone->name, "Zone_t", &zone->id, CG_SIZE_DATATYPE, 2, dim_vals, (void *)zone->nijk)) return CG_ERROR; /* write ZoneType */ dim_vals[0] = (cgsize_t)strlen(ZoneTypeName[zone->type]); if (cgi_new_node(zone->id, "ZoneType", "ZoneType_t", &dummy_id, "C1", 1, dim_vals, (void *)ZoneTypeName[zone->type])) return CG_ERROR; /* set Global variable for (n=0; nnijk[n]; */ /* GridCoordinates_t */ for (n=0; nnzcoor; n++) if (cgi_write_zcoor(zone->id, &zone->zcoor[n])) return CG_ERROR; /* FamilyName_t */ if (zone->family_name[0]!='\0') { dim_vals[0] = (cgsize_t)strlen(zone->family_name); if (cgi_new_node(zone->id, "FamilyName", "FamilyName_t", &dummy_id, "C1", 1, dim_vals, (void *)zone->family_name)) return CG_ERROR; } /* CPEX 0034 */ for (n = 0; n < zone->nfamname; n++) { dim_vals[0] = (cgsize_t)strlen(zone->famname[n].family); if (cgi_new_node(zone->id, zone->famname[n].name, "AdditionalFamilyName_t", &dummy_id, "C1", 1, dim_vals, (void *)zone->famname[n].family)) return CG_ERROR; } /* Elements_t */ for (n=0; nnsections; n++) if (cgi_write_section(zone->id, &zone->section[n])) return CG_ERROR; /* FlowSolution_t */ for (n=0; nnsols; n++) if (cgi_write_sol(zone->id, &zone->sol[n])) return CG_ERROR; /* ZoneGridConnectivity_t */ for (n=0; nnzconn; n++) if (cgi_write_zconn(zone->id, &zone->zconn[n])) return CG_ERROR; /* ZoneBC_t */ if (zone->zboco && cgi_write_zboco(zone->id, zone->zboco)) return CG_ERROR; /* DescreteData_t */ for (n=0; nndiscrete; n++) if (cgi_write_discrete(zone->id, &zone->discrete[n])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(zone->id, &zone->descr[n])) return CG_ERROR; /* ReferenceState_t */ if (zone->state && cgi_write_state(zone->id, zone->state)) return CG_ERROR; /* DataClass_t */ if (zone->data_class && cgi_write_dataclass(zone->id, zone->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (zone->units && cgi_write_units(zone->id, zone->units)) return CG_ERROR; /* ConvergenceHistory_t */ if (zone->converg && cgi_write_converg(zone->id, zone->converg)) return CG_ERROR; /* FlowEquationSet_t */ if (zone->equations && cgi_write_equations(zone->id, zone->equations)) return CG_ERROR; /* IntegralData_t */ for (n=0; nnintegrals; n++) if (cgi_write_integral(zone->id, &zone->integral[n])) return CG_ERROR; /* Ordinal_t */ if (zone->ordinal && cgi_write_ordinal(zone->id, zone->ordinal)) return CG_ERROR; /* RigidGridMotion_t */ for (n=0; nnrmotions; n++) if (cgi_write_rmotion(zone->id, &zone->rmotion[n])) return CG_ERROR; /* ArbitraryGridMotion_t */ for (n=0; nnamotions; n++) if (cgi_write_amotion(zone->id, &zone->amotion[n])) return CG_ERROR; /* ZoneIterativeData_t */ if (zone->ziter && cgi_write_ziter(zone->id, zone->ziter)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(zone->id, &zone->user_data[n])) return CG_ERROR; /* RotatingCoordinates_t */ if (zone->rotating && cgi_write_rotating(zone->id, zone->rotating)) return CG_ERROR; return CG_OK; } int cgi_write_family(double parent_id, cgns_family *family) /* ** FAMILY TREE ** */ { int n; cgsize_t dim_vals; if (family->link) { return cgi_write_link(parent_id, family->name, family->link, &family->id); } /* Family_t */ if (cgi_new_node(parent_id, family->name, "Family_t", &family->id, "MT", 0, 0, 0)) return CG_ERROR; /* CPEX 0033 */ for (n = 0; n < family->nfamname; n++) { dim_vals = (cgsize_t)strlen(family->famname[n].family); if (cgi_new_node(family->id, family->famname[n].name, "FamilyName_t", &family->famname[n].id, "C1", 1, &dim_vals, (void *)family->famname[n].family)) return CG_ERROR; } /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(family->id, &family->descr[n])) return CG_ERROR; /* FamilyBC_t */ for (n=0; nnfambc; n++) { cgns_fambc *fambc = &family->fambc[n]; if (fambc->link) { if (cgi_write_link(family->id, fambc->name, fambc->link, &fambc->id)) return CG_ERROR; } else { int i; dim_vals = (cgsize_t)strlen(BCTypeName[fambc->type]); if (cgi_new_node(family->id, fambc->name, "FamilyBC_t", &fambc->id, "C1", 1, &dim_vals, BCTypeName[fambc->type])) return CG_ERROR; /* FamilyBCDataSet_t */ for (i=0; i < fambc->ndataset; i++) if (cgi_write_dataset(fambc->id, "FamilyBCDataSet_t", &fambc->dataset[i])) return CG_ERROR; } } /* GeometryReference_t */ for (n=0; nngeos; n++) { int i; double dummy_id; cgns_geo *geo = &family->geo[n]; if (geo->link) { if (cgi_write_link(family->id, geo->name, geo->link, &geo->id)) return CG_ERROR; } else { if (cgi_new_node(family->id, geo->name, "GeometryReference_t", &geo->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor */ for (i=0; indescr; i++) if (cgi_write_descr(geo->id, &geo->descr[i])) return CG_ERROR; /* GeometryFile */ dim_vals = (cgsize_t)strlen(geo->file); if (cgi_new_node(geo->id, "GeometryFile", "GeometryFile_t", &dummy_id, "C1", 1, &dim_vals, geo->file)) return CG_ERROR; /* GeometryFormat */ dim_vals = (cgsize_t)strlen(geo->format); if (cgi_new_node(geo->id, "GeometryFormat", "GeometryFormat_t", &dummy_id, "C1", 1, &dim_vals, geo->format)) return CG_ERROR; /* GeometryEntities */ for (i=0; inpart; i++) { if (cgi_new_node(geo->id, geo->part[i].name, "GeometryEntity_t", &dummy_id, "MT", 0, 0, 0)) return CG_ERROR; } /* UserDefinedData_t */ for (i=0; inuser_data; i++) { if (cgi_write_user_data(geo->id, &geo->user_data[i])) return CG_ERROR; } } } /* Ordinal_t */ if (family->ordinal && cgi_write_ordinal(family->id, family->ordinal)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(family->id, &family->user_data[n])) return CG_ERROR; /* RotatingCoordinates_t */ if (family->rotating && cgi_write_rotating(family->id, family->rotating)) return CG_ERROR; /* ** FAMILY TREE ** */ for( n = 0; n < family->nfamilies; n++ ) { if (cgi_write_family(family->id, &family->family[n])) return CG_ERROR; } return CG_OK; } int cgi_write_section(double parent_id, cgns_section *section) { int n, data[2]; cgsize_t dim_vals; double dummy_id; HDF5storage_type = CG_CONTIGUOUS; if (section->link) { return cgi_write_link(parent_id, section->name, section->link, §ion->id); } /* Elements_t */ dim_vals = 2; data[0]=section->el_type; data[1]=section->el_bound; if (cgi_new_node(parent_id, section->name, "Elements_t", §ion->id, "I4", 1, &dim_vals, data)) return CG_ERROR; /* ElementRange */ if (cgi_new_node(section->id, "ElementRange", "IndexRange_t", &dummy_id, CG_SIZE_DATATYPE, 1, &dim_vals, section->range)) return CG_ERROR; /* ElementConnectivity */ if (section->connect && cgi_write_array(section->id, section->connect)) return CG_ERROR; /* ElementStartOffset */ if (section->connect_offset && cgi_write_array(section->id, section->connect_offset)) return CG_ERROR; /* ParentData */ if (section->parelem && cgi_write_array(section->id, section->parelem)) return CG_ERROR; if (section->parface && cgi_write_array(section->id, section->parface)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(section->id, §ion->descr[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(section->id, §ion->user_data[n])) return CG_ERROR; HDF5storage_type = CG_COMPACT; return CG_OK; } int cgi_write_zcoor(double parent_id, cgns_zcoor *zcoor) { int n; if (zcoor->link) { return cgi_write_link(parent_id, zcoor->name, zcoor->link, &zcoor->id); } /* GridCoordinates_t */ if (cgi_new_node(parent_id, zcoor->name, "GridCoordinates_t", &zcoor->id, "MT", 0, 0, 0)) return CG_ERROR; /* Rind_t */ if (cgi_write_rind(zcoor->id, zcoor->rind_planes, Idim)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(zcoor->id, &zcoor->descr[n])) return CG_ERROR; /* DataClass_t */ if (zcoor->data_class && cgi_write_dataclass(zcoor->id, zcoor->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (zcoor->units && cgi_write_units(zcoor->id, zcoor->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nncoords; n++) if (cgi_write_array(zcoor->id, &zcoor->coord[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(zcoor->id, &zcoor->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_sol(double parent_id, cgns_sol *sol) { int n; cgsize_t dim_vals; double dummy_id; if (sol->link) { return cgi_write_link(parent_id, sol->name, sol->link, &sol->id); } /* FlowSolution_t */ if (cgi_new_node(parent_id, sol->name, "FlowSolution_t", &sol->id, "MT", 0, 0, 0)) return CG_ERROR; /* GridLocation_t */ if (sol->location!=CGNS_ENUMV( Vertex )) { dim_vals = (cgsize_t)strlen(GridLocationName[sol->location]); if (cgi_new_node(sol->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[sol->location])) return CG_ERROR; } /* Rind_t */ if (cgi_write_rind(sol->id, sol->rind_planes, Idim)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(sol->id, &sol->descr[n])) return CG_ERROR; /* DataClass_t */ if (sol->data_class && cgi_write_dataclass(sol->id, sol->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (sol->units && cgi_write_units(sol->id, sol->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnfields; n++) if (cgi_write_array(sol->id, &sol->field[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(sol->id, &sol->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_zconn(double parent_id, cgns_zconn *zconn) { int n; if (zconn->link) { return cgi_write_link(parent_id, zconn->name, zconn->link, &zconn->id); } /* ZoneGridConnectivity_t */ if (cgi_new_node(parent_id, zconn->name, "ZoneGridConnectivity_t", &zconn->id, "MT", 0, 0, 0)) return CG_ERROR; /* GridConnectivity1to1_t */ for (n=0; nn1to1; n++) if (cgi_write_1to1(zconn->id, &zconn->one21[n])) return CG_ERROR; /* GridConnectivity_t */ for (n=0; nnconns; n++) if (cgi_write_conns(zconn->id, &zconn->conn[n])) return CG_ERROR; /* OversetHoles_t */ for (n=0; nnholes; n++) if (cgi_write_holes(zconn->id, &zconn->hole[n])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(zconn->id, &zconn->descr[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(zconn->id, &zconn->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_1to1(double parent_id, cgns_1to1 *one21) { int n; cgsize_t dim_vals; double dummy_id; cgns_ptset *ptset; if (one21->link) { return cgi_write_link(parent_id, one21->name, one21->link, &one21->id); } dim_vals = (cgsize_t)strlen(one21->donor); if (cgi_new_node(parent_id, one21->name, "GridConnectivity1to1_t", &one21->id, "C1", 1, &dim_vals, one21->donor)) return CG_ERROR; /* Transform */ dim_vals = Idim; if (cgi_new_node(one21->id, "Transform", "\"int[IndexDimension]\"", &dummy_id, "I4", 1, &dim_vals, (void *)one21->transform)) return CG_ERROR; /* PointRange & PointRangeDonor: Move nodes to their final positions */ ptset = &(one21->ptset); if (cgi_move_node(cg->rootid, ptset->id, one21->id, PointSetTypeName[ptset->type])) return CG_ERROR; ptset = &(one21->dptset); if (cgi_move_node(cg->rootid, ptset->id, one21->id, PointSetTypeName[ptset->type])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(one21->id, &one21->descr[n])) return CG_ERROR; /* Ordinal_t */ if (one21->ordinal && cgi_write_ordinal(one21->id, one21->ordinal)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(one21->id, &one21->user_data[n])) return CG_ERROR; /* GridConnectivityProperty_t */ if (one21->cprop && cgi_write_cprop(one21->id, one21->cprop)) return CG_ERROR; return CG_OK; } int cgi_write_conns(double parent_id, cgns_conn *conn) { int n; cgsize_t dim_vals; double dummy_id; cgns_ptset *ptset; HDF5storage_type = CG_CONTIGUOUS; if (conn->link) { return cgi_write_link(parent_id, conn->name, conn->link, &conn->id); } dim_vals = (cgsize_t)strlen(conn->donor); if (cgi_new_node(parent_id, conn->name, "GridConnectivity_t", &conn->id, "C1", 1, &dim_vals, conn->donor)) return CG_ERROR; /* GridConnectivityType_t */ dim_vals = (cgsize_t)strlen(GridConnectivityTypeName[conn->type]); if (cgi_new_node(conn->id, "GridConnectivityType", "GridConnectivityType_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridConnectivityTypeName[conn->type])) return CG_ERROR; /* write GridLocation */ if (conn->location!=CGNS_ENUMV( Vertex )) { dim_vals = (cgsize_t)strlen(GridLocationName[conn->location]); if (cgi_new_node(conn->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[conn->location])) return CG_ERROR; } /* PointRange or PointList: Move node to its final position */ ptset = &(conn->ptset); if (cgi_move_node(cg->rootid, ptset->id, conn->id, PointSetTypeName[ptset->type])) return CG_ERROR; /* Cell or Point ListDonor: Move node to its final position */ ptset = &(conn->dptset); if (ptset->id) { if (cgi_move_node(cg->rootid, ptset->id, conn->id, PointSetTypeName[ptset->type])) return CG_ERROR; } /* InterpolantsDonor */ if (conn->interpolants) { if (cgi_write_array(conn->id, conn->interpolants)) return CG_ERROR; } /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(conn->id, &conn->descr[n])) return CG_ERROR; /* Ordinal_t */ if (conn->ordinal && cgi_write_ordinal(conn->id, conn->ordinal)) return CG_ERROR; /* GridConnectivityProperty_t */ if (conn->cprop && cgi_write_cprop(conn->id, conn->cprop)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(conn->id, &conn->user_data[n])) return CG_ERROR; HDF5storage_type = CG_COMPACT; return CG_OK; } int cgi_write_cprop(double parent_id, cgns_cprop *cprop) { cgsize_t dim_vals; int n; double dummy_id; if (cprop->link) { return cgi_write_link(parent_id, "GridConnectivityProperty", cprop->link, &cprop->id); } /* GridConnectivityProperty_t */ if (cgi_new_node(parent_id, "GridConnectivityProperty", "GridConnectivityProperty_t", &cprop->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(cprop->id, &cprop->descr[n])) return CG_ERROR; /* AverageInterface_t */ if (cprop->caverage) { cgns_caverage *caverage = cprop->caverage; if (caverage->link) { if (cgi_write_link(cprop->id, "AverageInterface", caverage->link, &caverage->id)) return CG_ERROR; } else { if (cgi_new_node(cprop->id, "AverageInterface", "AverageInterface_t", &caverage->id, "MT", 0, 0, 0)) return CG_ERROR; /* AverageInterface_t/Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(caverage->id, &caverage->descr[n])) return CG_ERROR; /* AverageInterface_t/AverageInterfaceType_t */ dim_vals = (cgsize_t)strlen(AverageInterfaceTypeName[caverage->type]); if (cgi_new_node(caverage->id, "AverageInterfaceType", "AverageInterfaceType_t", &dummy_id, "C1", 1, &dim_vals, (void *)AverageInterfaceTypeName[caverage->type])) return CG_ERROR; /* AverageInterface_t/UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(caverage->id, &caverage->user_data[n])) return CG_ERROR; } } /* Periodic_t */ if (cprop->cperio) { cgns_cperio *cperio = cprop->cperio; if (cperio->link) { if (cgi_write_link(cprop->id, "Periodic", cperio->link, &cperio->id)) return CG_ERROR; } else { if (cgi_new_node(cprop->id, "Periodic", "Periodic_t", &cperio->id, "MT", 0, 0, 0)) return CG_ERROR; /* Periodic_t/Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(cperio->id, &cperio->descr[n])) return CG_ERROR; /* Periodic_t/DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(cperio->id, &cperio->array[n])) return CG_ERROR; /* Periodic_t/DataClass_t */ if (cperio->data_class && cgi_write_dataclass(cperio->id, cperio->data_class)) return CG_ERROR; /* Periodic_t/DimensionalUnits_t */ if (cperio->units && cgi_write_units(cperio->id, cperio->units)) return CG_ERROR; /* Periodic_t/UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(cperio->id, &cperio->user_data[n])) return CG_ERROR; } } /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(cprop->id, &cprop->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_holes(double parent_id, cgns_hole *hole) { int n; cgsize_t dim_vals; double dummy_id; char PointSetName[33]; cgns_ptset *ptset; if (hole->link) { return cgi_write_link(parent_id, hole->name, hole->link, &hole->id); } /* OversetHoles_t */ if (cgi_new_node(parent_id, hole->name, "OversetHoles_t", &hole->id, "MT", 0, 0, 0)) return CG_ERROR; /* GridLocation_t */ if (hole->location!=CGNS_ENUMV( Vertex )) { dim_vals = (cgsize_t)strlen(GridLocationName[hole->location]); if (cgi_new_node(hole->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[hole->location])) return CG_ERROR; } /* PointRange(s) and PointList */ for (n=0; nnptsets; n++) { ptset = &(hole->ptset[n]); if (ptset->type == CGNS_ENUMV( PointRange )) sprintf(PointSetName,"PointRange%d",n+1); else sprintf(PointSetName,"PointSetTypeName[ptset->type]"); /* Move node to its final position */ if (cgi_move_node(cg->rootid, ptset->id, hole->id, PointSetName)) return CG_ERROR; } /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(hole->id, &hole->descr[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(hole->id, &hole->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_zboco(double parent_id, cgns_zboco *zboco) { int n; if (zboco->link) { return cgi_write_link(parent_id, "ZoneBC", zboco->link, &zboco->id); } /* ZoneBC_t */ if (cgi_new_node(parent_id, "ZoneBC", "ZoneBC_t", &zboco->id, "MT", 0, 0, 0)) return CG_ERROR; /* BC_t */ for (n=0; nnbocos; n++) if (cgi_write_boco(zboco->id, &zboco->boco[n])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(zboco->id, &zboco->descr[n])) return CG_ERROR; /* ReferenceState_t */ if (zboco->state && cgi_write_state(zboco->id, zboco->state)) return CG_ERROR; /* DataClass_t */ if (zboco->data_class && cgi_write_dataclass(zboco->id, zboco->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (zboco->units && cgi_write_units(zboco->id, zboco->units)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(zboco->id, &zboco->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_boco(double parent_id, cgns_boco *boco) { cgsize_t dim_vals; int n; double dummy_id; if (boco->link) { return cgi_write_link(parent_id, boco->name, boco->link, &boco->id); } /* BC_t */ dim_vals = (cgsize_t)strlen(BCTypeName[boco->type]); if (cgi_new_node(parent_id, boco->name, "BC_t", &boco->id, "C1", 1, &dim_vals, BCTypeName[boco->type])) return CG_ERROR; /* PointRange, PointList: Move node to its final position */ if (boco->ptset) { /* Move node to its final position */ if (cgi_move_node(cg->rootid, boco->ptset->id, boco->id, PointSetTypeName[boco->ptset->type])) return CG_ERROR; } /* GridLocation_t */ if (boco->location != CGNS_ENUMV( Vertex )) { dim_vals = (cgsize_t)strlen(GridLocationName[boco->location]); if (cgi_new_node(boco->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[boco->location])) return CG_ERROR; } /* FamilyName_t */ if (boco->family_name[0]!='\0') { dim_vals = (cgsize_t)strlen(boco->family_name); if (cgi_new_node(boco->id, "FamilyName", "FamilyName_t", &dummy_id, "C1", 1, &dim_vals, (void *)boco->family_name)) return CG_ERROR; } /* CPEX 0034 */ for (n = 0; n < boco->nfamname; n++) { dim_vals = (cgsize_t)strlen(boco->famname[n].family); if (cgi_new_node(boco->id, boco->famname[n].name, "AdditionalFamilyName_t", &dummy_id, "C1", 1, &dim_vals, (void *)boco->famname[n].family)) return CG_ERROR; } /* BCDataSet_t */ for (n=0; nndataset; n++) if (cgi_write_dataset(boco->id, "BCDataSet_t", &boco->dataset[n])) return CG_ERROR; /* InwardNormalIndex */ if (boco->Nindex) { dim_vals = Idim; if (cgi_new_node(boco->id, "InwardNormalIndex", "\"int[IndexDimension]\"", &boco->index_id, "I4", 1, &dim_vals, (void *)boco->Nindex)) return CG_ERROR; } /* InwardNormalList */ if (boco->normal) { if (boco->normal->link) { if (cgi_write_link(boco->id, boco->normal->name, boco->normal->link, &boco->normal->id)) return CG_ERROR; } else { if (cgi_new_node(boco->id, boco->normal->name, "IndexArray_t", &boco->normal->id, boco->normal->data_type, boco->normal->data_dim, boco->normal->dim_vals, boco->normal->data)) return CG_ERROR; } } /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(boco->id, &boco->descr[n])) return CG_ERROR; /* ReferenceState_t */ if (boco->state && cgi_write_state(boco->id, boco->state)) return CG_ERROR; /* DataClass_t */ if (boco->data_class && cgi_write_dataclass(boco->id, boco->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (boco->units && cgi_write_units(boco->id, boco->units)) return CG_ERROR; /* Ordinal_t */ if (boco->ordinal && cgi_write_ordinal(boco->id, boco->ordinal)) return CG_ERROR; /* BCProperty_t */ if (boco->bprop && cgi_write_bprop(boco->id, boco->bprop)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(boco->id, &boco->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_bprop(double parent_id, cgns_bprop *bprop) { cgsize_t dim_vals; int n; double dummy_id; if (bprop->link) { return cgi_write_link(parent_id, "BCProperty", bprop->link, &bprop->id); } /* BCProperty_t */ if (cgi_new_node(parent_id, "BCProperty", "BCProperty_t", &bprop->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(bprop->id, &bprop->descr[n])) return CG_ERROR; /* WallFunction_t */ if (bprop->bcwall) { cgns_bcwall *bcwall = bprop->bcwall; if (bcwall->link) { if (cgi_write_link(bprop->id, "WallFunction", bcwall->link, &bcwall->id)) return CG_ERROR; } else { if (cgi_new_node(bprop->id, "WallFunction", "WallFunction_t", &bcwall->id, "MT", 0, 0, 0)) return CG_ERROR; /* WallFunction_t/Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(bcwall->id, &bcwall->descr[n])) return CG_ERROR; /* WallFunction_t/WallFunctionType_t */ dim_vals = (cgsize_t)strlen(WallFunctionTypeName[bcwall->type]); if (cgi_new_node(bcwall->id, "WallFunctionType", "WallFunctionType_t", &dummy_id, "C1", 1, &dim_vals, (void *)WallFunctionTypeName[bcwall->type])) return CG_ERROR; /* WallFunction_t/UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(bcwall->id, &bcwall->user_data[n])) return CG_ERROR; } } /* Area_t */ if (bprop->bcarea) { cgns_bcarea *bcarea = bprop->bcarea; if (bcarea->link) { if (cgi_write_link(bprop->id, "Area", bcarea->link, &bcarea->id)) return CG_ERROR; } else { if (cgi_new_node(bprop->id, "Area", "Area_t", &bcarea->id, "MT", 0, 0, 0)) return CG_ERROR; /* Area_t/Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(bcarea->id, &bcarea->descr[n])) return CG_ERROR; /* Area_t/AreaType_t */ dim_vals = (cgsize_t)strlen(AreaTypeName[bcarea->type]); if (cgi_new_node(bcarea->id, "AreaType", "AreaType_t", &dummy_id, "C1", 1, &dim_vals, (void *)AreaTypeName[bcarea->type])) return CG_ERROR; /* Area_t/DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(bcarea->id, &bcarea->array[n])) return CG_ERROR; /* Area_t/UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(bcarea->id, &bcarea->user_data[n])) return CG_ERROR; } } /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(bprop->id, &bprop->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_dataset(double parent_id, const char *label, cgns_dataset *dataset) { cgsize_t dim_vals; int n; double dummy_id; if (dataset->link) { return cgi_write_link(parent_id, dataset->name, dataset->link, &dataset->id); } /* BCDataSet_t */ dim_vals= (cgsize_t)strlen(BCTypeName[dataset->type]); if (cgi_new_node(parent_id, dataset->name, label, &dataset->id, "C1", 1, &dim_vals, (void *)BCTypeName[dataset->type])) return CG_ERROR; /* DirichletData */ if (dataset->dirichlet) { if (dataset->dirichlet->link) { if (cgi_write_link(dataset->id, "DirichletData", dataset->dirichlet->link, &dataset->dirichlet->id)) return CG_ERROR; } else { if (cgi_new_node(dataset->id, "DirichletData", "BCData_t", &dataset->dirichlet->id, "MT", 0, 0, 0)) return CG_ERROR; if (cgi_write_bcdata(dataset->dirichlet->id, dataset->dirichlet)) return CG_ERROR; } } /* NeumannData */ if (dataset->neumann) { if (dataset->neumann->link) { if (cgi_write_link(dataset->id, "NeumannData", dataset->neumann->link, &dataset->neumann->id)) return CG_ERROR; } else { if (cgi_new_node(dataset->id, "NeumannData", "BCData_t", &dataset->neumann->id, "MT", 0, 0, 0)) return CG_ERROR; if (cgi_write_bcdata(dataset->neumann->id, dataset->neumann)) return CG_ERROR; } } /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(dataset->id, &dataset->descr[n])) return CG_ERROR; /* ReferenceState_t */ if (dataset->state && cgi_write_state(dataset->id, dataset->state)) return CG_ERROR; /* DataClass_t */ if (dataset->data_class && cgi_write_dataclass(dataset->id, dataset->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (dataset->units && cgi_write_units(dataset->id, dataset->units)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(dataset->id, &dataset->user_data[n])) return CG_ERROR; /* GridLocation_t */ if (dataset->location != CGNS_ENUMV( Vertex )) { dim_vals = (cgsize_t)strlen(GridLocationName[dataset->location]); if (cgi_new_node(dataset->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[dataset->location])) return CG_ERROR; } /* PointRange, PointList: Move node to its final position */ if (dataset->ptset) { /* Move node to its final position */ if (cgi_move_node(cg->rootid, dataset->ptset->id, dataset->id, PointSetTypeName[dataset->ptset->type])) return CG_ERROR; } return CG_OK; } int cgi_write_bcdata(double bcdata_id, cgns_bcdata *bcdata) { int n; /* DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(bcdata_id, &bcdata->array[n])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(bcdata_id, &bcdata->descr[n])) return CG_ERROR; /* DataClass_t */ if (bcdata->data_class && cgi_write_dataclass(bcdata->id, bcdata->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (bcdata->units && cgi_write_units(bcdata->id, bcdata->units)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(bcdata->id, &bcdata->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_ptset(double parent_id, char *name, cgns_ptset *ptset, int ndim, void *ptset_ptr) { cgsize_t dim_vals[12]; int num_dim; char_33 label; int HDF5storage_type_original = HDF5storage_type; if (ptset->link) { return cgi_write_link(parent_id, name, ptset->link, &ptset->id); } /* Set label */ if (ptset->type == CGNS_ENUMV(PointRange) || ptset->type == CGNS_ENUMV(ElementRange) || ptset->type == CGNS_ENUMV(PointRangeDonor)) strcpy(label,"IndexRange_t"); else strcpy(label,"IndexArray_t"); /* Dimension vector */ dim_vals[0]=ndim; dim_vals[1]=ptset->npts; num_dim = 2; // PointLists should be contiguous for parallel reading/writing if (ptset->type == CGNS_ENUMV(PointList) || ptset->type == CGNS_ENUMV(PointListDonor) || ptset->type == CGNS_ENUMV(ElementList) || ptset->type == CGNS_ENUMV(CellListDonor)) { HDF5storage_type = CG_CONTIGUOUS; } /* Create the node */ if (cgi_new_node(parent_id, name, label, &ptset->id, ptset->data_type, num_dim, dim_vals, ptset_ptr)) return CG_ERROR; HDF5storage_type = HDF5storage_type_original; return CG_OK; } int cgi_write_equations(double parent_id, cgns_equations *equations) { int n; cgsize_t dim_vals; double dummy_id; cgns_governing *governing; if (equations->link) { return cgi_write_link(parent_id, "FlowEquationSet", equations->link, &equations->id); } /* FlowEquationSet_t */ if (cgi_new_node(parent_id, "FlowEquationSet", "FlowEquationSet_t", &equations->id, "MT", 0, 0, 0)) return CG_ERROR; /* EquationDimension */ if (equations->equation_dim) { dim_vals=1; if (cgi_new_node(equations->id, "EquationDimension", "\"int\"", &dummy_id, "I4", 1, &dim_vals, (void *)&equations->equation_dim)) return CG_ERROR; } /* GoverningEquations_t */ if (equations->governing) { governing = equations->governing; if (governing->link) { if (cgi_write_link(equations->id, "GoverningEquations", governing->link, &governing->id)) return CG_ERROR; } else { dim_vals = (cgsize_t)strlen(GoverningEquationsTypeName[governing->type]); if (cgi_new_node(equations->id, "GoverningEquations", "GoverningEquations_t", &governing->id, "C1", 1, &dim_vals, GoverningEquationsTypeName[governing->type])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(governing->id, &governing->descr[n])) return CG_ERROR; /* DiffusionModel */ if (governing->diffusion_model) { dim_vals=governing->dim_vals; if (cgi_new_node(governing->id, "DiffusionModel", "\"int[1+...+IndexDimension]\"", &dummy_id, "I4", 1, &dim_vals, (void *)governing->diffusion_model)) return CG_ERROR; } /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(governing->id, &governing->user_data[n])) return CG_ERROR; } } /* GasModel_t */ if (equations->gas && cgi_write_model(equations->id, equations->gas)) return CG_ERROR; /* ViscosityModel_t */ if (equations->visc && cgi_write_model(equations->id, equations->visc)) return CG_ERROR; /* ThermalConductivityModel_t */ if (equations->conduct && cgi_write_model(equations->id, equations->conduct)) return CG_ERROR; /* TurbulenceClosure_t */ if (equations->closure && cgi_write_model(equations->id, equations->closure)) return CG_ERROR; /* TurbulenceModel_t */ if (equations->turbulence) { if (cgi_write_model(equations->id, equations->turbulence)) return CG_ERROR; /* DiffusionModel */ if (equations->turbulence->diffusion_model) { dim_vals=equations->turbulence->dim_vals; if (cgi_new_node(equations->turbulence->id, "DiffusionModel", "\"int[1+...+IndexDimension]\"", &dummy_id, "I4", 1, &dim_vals, (void *) equations->turbulence->diffusion_model)) return CG_ERROR; } } /* ThermalRelaxationModel_t */ if (equations->relaxation && cgi_write_model(equations->id, equations->relaxation)) return CG_ERROR; /* ChemicalKineticsModel_t */ if (equations->chemkin && cgi_write_model(equations->id, equations->chemkin)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(equations->id, &equations->descr[n])) return CG_ERROR; /* DataClass_t */ if (equations->data_class && cgi_write_dataclass(equations->id, equations->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (equations->units && cgi_write_units(equations->id, equations->units)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(equations->id, &equations->user_data[n])) return CG_ERROR; /* EMElectricFieldModel_t */ if (equations->elecfield && cgi_write_model(equations->id, equations->elecfield)) return CG_ERROR; /* EMMagneticFieldModel_t */ if (equations->magnfield && cgi_write_model(equations->id, equations->magnfield)) return CG_ERROR; /* EMConductivityModel_t */ if (equations->emconduct && cgi_write_model(equations->id, equations->emconduct)) return CG_ERROR; return CG_OK; } int cgi_write_model(double parent_id, cgns_model *model) { int n; cgsize_t dim_vals; char_33 label; if (model->link) { return cgi_write_link(parent_id, model->name, model->link, &model->id); } /* xModel_t */ sprintf(label,"%.30s_t",model->name); dim_vals = (cgsize_t)strlen(ModelTypeName[model->type]); if (cgi_new_node(parent_id, model->name, label, &model->id, "C1", 1, &dim_vals, ModelTypeName[model->type])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(model->id, &model->descr[n])) return CG_ERROR; /* DataClass_t */ if (model->data_class && cgi_write_dataclass(model->id, model->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (model->units && cgi_write_units(model->id, model->units)) return CG_ERROR; /* DataArray */ for (n=0; nnarrays; n++) if (cgi_write_array(model->id, &model->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(model->id, &model->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_state(double parent_id, cgns_state *state) { int n; if (state->link) { return cgi_write_link(parent_id, "ReferenceState", state->link, &state->id); } /* ReferenceState_t */ if (cgi_new_node(parent_id, "ReferenceState", "ReferenceState_t", &state->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(state->id, &state->descr[n])) return CG_ERROR; /* ReferenceStateDescription */ if (state->StateDescription && cgi_write_descr(state->id, state->StateDescription)) return CG_ERROR; /* DataClass_t */ if (state->data_class && cgi_write_dataclass(state->id, state->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (state->units && cgi_write_units(state->id, state->units)) return CG_ERROR; /* DataArray */ for (n=0; nnarrays; n++) if (cgi_write_array(state->id, &state->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(state->id, &state->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_gravity(double parent_id, cgns_gravity *gravity) { int n; if (gravity->link) { return cgi_write_link(parent_id, "Gravity", gravity->link, &gravity->id); } /* Gravity_t */ if (cgi_new_node(parent_id, "Gravity", "Gravity_t", &gravity->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(gravity->id, &gravity->descr[n])) return CG_ERROR; /* DataClass_t */ if (gravity->data_class && cgi_write_dataclass(gravity->id, gravity->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (gravity->units && cgi_write_units(gravity->id, gravity->units)) return CG_ERROR; /* DataArray */ if (gravity->vector && cgi_write_array(gravity->id, gravity->vector)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(gravity->id, &gravity->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_axisym(double parent_id, cgns_axisym *axisym) { int n; if (axisym->link) { return cgi_write_link(parent_id, "Axisymmetry", axisym->link, &axisym->id); } /* Axisymmetry_t */ if (cgi_new_node(parent_id, "Axisymmetry", "Axisymmetry_t", &axisym->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(axisym->id, &axisym->descr[n])) return CG_ERROR; /* DataClass_t */ if (axisym->data_class && cgi_write_dataclass(axisym->id, axisym->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (axisym->units && cgi_write_units(axisym->id, axisym->units)) return CG_ERROR; /* DataArray */ for (n=0; nnarrays; n++) if (cgi_write_array(axisym->id, &axisym->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(axisym->id, &axisym->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_rotating(double parent_id, cgns_rotating *rotating) { int n; if (rotating->link) { return cgi_write_link(parent_id, "RotatingCoordinates", rotating->link, &rotating->id); } /* RotatingCoordinates_t */ if (cgi_new_node(parent_id, "RotatingCoordinates", "RotatingCoordinates_t", &rotating->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(rotating->id, &rotating->descr[n])) return CG_ERROR; /* DataClass_t */ if (rotating->data_class && cgi_write_dataclass(rotating->id, rotating->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (rotating->units && cgi_write_units(rotating->id, rotating->units)) return CG_ERROR; /* DataArray */ for (n=0; nnarrays; n++) if (cgi_write_array(rotating->id, &rotating->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(rotating->id, &rotating->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_converg(double parent_id, cgns_converg *converg) { int n; cgsize_t dim_vals; if (converg->link) { return cgi_write_link(parent_id, converg->name, converg->link, &converg->id); } /* ConvergenceHistory_t */ dim_vals = 1; if (cgi_new_node(parent_id, converg->name, "ConvergenceHistory_t", &converg->id, "I4", 1, &dim_vals, (void *)&converg->iterations)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(converg->id, &converg->descr[n])) return CG_ERROR; /* NormDefinitions */ if (converg->NormDefinitions && cgi_write_descr(converg->id, converg->NormDefinitions)) return CG_ERROR; /* DataClass_t */ if (converg->data_class && cgi_write_dataclass(converg->id, converg->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (converg->units && cgi_write_units(converg->id, converg->units)) return CG_ERROR; /* DataArray */ for (n=0; nnarrays; n++) if (cgi_write_array(converg->id, &converg->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(converg->id, &converg->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_discrete(double parent_id, cgns_discrete *discrete) { int n; cgsize_t dim_vals; double dummy_id; if (discrete->link) { return cgi_write_link(parent_id, discrete->name, discrete->link, &discrete->id); } /* DiscreteData_t */ if (cgi_new_node(parent_id, discrete->name, "DiscreteData_t", &discrete->id, "MT", 0, 0, 0)) return CG_ERROR; /* GridLocation_t */ if (discrete->location != CGNS_ENUMV( Vertex )) { dim_vals = (cgsize_t)strlen(GridLocationName[discrete->location]); if (cgi_new_node(discrete->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[discrete->location])) return CG_ERROR; } /* Rind_t */ if (cgi_write_rind(discrete->id, discrete->rind_planes, Idim)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(discrete->id, &discrete->descr[n])) return CG_ERROR; /* DataClass_t */ if (discrete->data_class && cgi_write_dataclass(discrete->id, discrete->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (discrete->units && cgi_write_units(discrete->id, discrete->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(discrete->id, &discrete->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(discrete->id, &discrete->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_integral(double parent_id, cgns_integral *integral) { int n; if (integral->link) { return cgi_write_link(parent_id, integral->name, integral->link, &integral->id); } /* IntegralData_t */ if (cgi_new_node(parent_id, integral->name, "IntegralData_t", &integral->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(integral->id, &integral->descr[n])) return CG_ERROR; /* DataClass_t */ if (integral->data_class && cgi_write_dataclass(integral->id, integral->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (integral->units && cgi_write_units(integral->id, integral->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(integral->id, &integral->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(integral->id, &integral->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_rmotion(double parent_id, cgns_rmotion *rmotion) { int n; cgsize_t dim_vals; if (rmotion->link) { return cgi_write_link(parent_id, rmotion->name, rmotion->link, &rmotion->id); } /* RigidGridMotion_t Name and RigidGridMotionType_t */ dim_vals=(cgsize_t)strlen(RigidGridMotionTypeName[rmotion->type]); if (cgi_new_node(parent_id, rmotion->name, "RigidGridMotion_t", &rmotion->id, "C1", 1, &dim_vals, (void *)RigidGridMotionTypeName[rmotion->type])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(rmotion->id, &rmotion->descr[n])) return CG_ERROR; /* DataClass_t */ if (rmotion->data_class && cgi_write_dataclass(rmotion->id, rmotion->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (rmotion->units && cgi_write_units(rmotion->id, rmotion->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(rmotion->id, &rmotion->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(rmotion->id, &rmotion->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_amotion(double parent_id, cgns_amotion *amotion) { int n; cgsize_t dim_vals; double dummy_id; if (amotion->link) { return cgi_write_link(parent_id, amotion->name, amotion->link, &amotion->id); } /* ArbitraryGridMotion_t Name and ArbitraryGridMotionType_t */ dim_vals=(cgsize_t)strlen(ArbitraryGridMotionTypeName[amotion->type]); if (cgi_new_node(parent_id, amotion->name, "ArbitraryGridMotion_t", &amotion->id, "C1", 1, &dim_vals, (void *)ArbitraryGridMotionTypeName[amotion->type])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(amotion->id, &amotion->descr[n])) return CG_ERROR; /* GridLocation_t */ if (amotion->location != CGNS_ENUMV( Vertex )) { dim_vals = (cgsize_t)strlen(GridLocationName[amotion->location]); if (cgi_new_node(amotion->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[amotion->location])) return CG_ERROR; } /* Rind_t */ if (cgi_write_rind(amotion->id, amotion->rind_planes, Idim)) return CG_ERROR; /* DataClass_t */ if (amotion->data_class && cgi_write_dataclass(amotion->id, amotion->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (amotion->units && cgi_write_units(amotion->id, amotion->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(amotion->id, &amotion->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(amotion->id, &amotion->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_biter(double parent_id, cgns_biter *biter) { int n; cgsize_t dim_vals; if (biter->link) { return cgi_write_link(parent_id, biter->name, biter->link, &biter->id); } /* BaseIterativeData_t name and NumberOfSteps */ dim_vals=1; if (cgi_new_node(parent_id, biter->name, "BaseIterativeData_t", &biter->id, "I4", 1, &dim_vals, (void *)&biter->nsteps)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(biter->id, &biter->descr[n])) return CG_ERROR; /* DataClass_t */ if (biter->data_class && cgi_write_dataclass(biter->id, biter->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (biter->units && cgi_write_units(biter->id, biter->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(biter->id, &biter->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(biter->id, &biter->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_ziter(double parent_id, cgns_ziter *ziter) { int n; if (ziter->link) { return cgi_write_link(parent_id, ziter->name, ziter->link, &ziter->id); } /* ZoneIterativeData_t name */ if (cgi_new_node(parent_id, ziter->name, "ZoneIterativeData_t", &ziter->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(ziter->id, &ziter->descr[n])) return CG_ERROR; /* DataClass_t */ if (ziter->data_class && cgi_write_dataclass(ziter->id, ziter->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (ziter->units && cgi_write_units(ziter->id, ziter->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(ziter->id, &ziter->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(ziter->id, &ziter->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_array(double parent_id, cgns_array *array) { int n; cgsize_t dim_vals; double dummy_id; HDF5storage_type = CG_CONTIGUOUS; if (array->link) { return cgi_write_link(parent_id, array->name, array->link, &array->id); } if (cgi_new_node(parent_id, array->name, "DataArray_t", &array->id, array->data_type, array->data_dim, array->dim_vals, array->data)) return CG_ERROR; /* DimensionalExponents_t */ if (array->exponents && cgi_write_exponents(array->id, array->exponents)) return CG_ERROR; /* DataConversion_t */ if (array->convert) { dim_vals=2; if (cgi_new_node(array->id, "DataConversion", "DataConversion_t", &array->convert->id, array->convert->data_type, 1, &dim_vals, array->convert->data)) return CG_ERROR; } /* DataClass_t */ if (array->data_class && cgi_write_dataclass(array->id, array->data_class)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(array->id, &array->descr[n])) return CG_ERROR; /* DimensionalUnits_t */ if (array->units && cgi_write_units(array->id, array->units)) return CG_ERROR; /* ElementRange */ dim_vals = 2; if(array->range[0] != 0 && array->range[1] != 0) if (cgi_new_node(array->id, "ArrayDataRange", "IndexRange_t", &dummy_id, "I4", 1, &dim_vals, array->range)) return CG_ERROR; HDF5storage_type = CG_COMPACT; return CG_OK; } int cgi_write_rind(double parent_id, int *rind_planes, int index_dim) { int n; cgsize_t dim_vals; double dummy_id; /* write Rind only if different from the default (6*0) */ if (rind_planes==0) return CG_OK; for (n=0; n<2*index_dim; n++) { if (rind_planes[n]!=0) { dim_vals=2*index_dim; if (cgi_new_node(parent_id, "Rind", "Rind_t", &dummy_id, "I4", 1, &dim_vals, (void *)rind_planes)) return CG_ERROR; return CG_OK; } } return CG_OK; } int cgi_write_units(double parent_id, cgns_units *units) { char *string_data; cgsize_t dim_vals[2]; if (units->link) { return cgi_write_link(parent_id, "DimensionalUnits", units->link, &units->id); } string_data = (char *) malloc ((32*5+1)*sizeof(char)); if (string_data == NULL) { cgi_error("Error allocating memory in cgi_write_units."); return CG_ERROR; } sprintf(string_data,"%-32s%-32s%-32s%-32s%-32s",MassUnitsName[units->mass], LengthUnitsName[units->length], TimeUnitsName[units->time], TemperatureUnitsName[units->temperature], AngleUnitsName[units->angle]); dim_vals[0]=32; dim_vals[1]=5; if (cgi_new_node(parent_id, "DimensionalUnits", "DimensionalUnits_t", &units->id, "C1", 2, dim_vals, (void *)string_data)) return CG_ERROR; if (units->nunits == 8) { double dummy_id; sprintf(string_data, "%-32s%-32s%-32s", ElectricCurrentUnitsName[units->current], SubstanceAmountUnitsName[units->amount], LuminousIntensityUnitsName[units->intensity]); dim_vals[1]=3; if (cgi_new_node(units->id, "AdditionalUnits", "AdditionalUnits_t", &dummy_id, "C1", 2, dim_vals, (void *)string_data)) return CG_ERROR; } CGNS_FREE(string_data); return CG_OK; } int cgi_write_exponents(double parent_id, cgns_exponent *exponent) { cgsize_t dim_vals = 5; if (cgi_new_node(parent_id, "DimensionalExponents", "DimensionalExponents_t", &exponent->id, exponent->data_type, 1, &dim_vals, exponent->data)) return CG_ERROR; if (exponent->nexps == 8) { double dummy_id; void *data; if (0 == strcmp(exponent->data_type,"R4")) data = (void *)((float *)exponent->data + 5); else data = (void *)((double *)exponent->data + 5); dim_vals = 3; if (cgi_new_node(exponent->id, "AdditionalExponents", "AdditionalExponents_t", &dummy_id, exponent->data_type, 1, &dim_vals, data)) return CG_ERROR; } return CG_OK; } int cgi_write_dataclass(double parent_id, CGNS_ENUMV(DataClass_t) data_class) { cgsize_t dim_vals; double dummy_id; dim_vals=(cgsize_t)strlen(DataClassName[data_class]); if (cgi_new_node(parent_id, "DataClass", "DataClass_t", &dummy_id, "C1", 1, &dim_vals, (void *)DataClassName[data_class])) return CG_ERROR; return CG_OK; } int cgi_write_descr(double parent_id, cgns_descr *descr) { cgsize_t dim_vals; if (descr->link) { return cgi_write_link(parent_id, descr->name, descr->link, &descr->id); } dim_vals=(cgsize_t)strlen(descr->text); if (cgi_new_node(parent_id, descr->name, "Descriptor_t", &descr->id, "C1", 1, &dim_vals, (void *)descr->text)) return CG_ERROR; return CG_OK; } int cgi_write_ordinal(double parent_id, int ordinal) { cgsize_t dim_vals; double dummy_id; dim_vals=1; if (cgi_new_node(parent_id, "Ordinal", "Ordinal_t", &dummy_id, "I4", 1, &dim_vals, (void *)&ordinal)) return CG_ERROR; return CG_OK; } int cgi_write_user_data(double parent_id, cgns_user_data *user_data) { int n; cgsize_t dim_vals; double dummy_id; if (user_data->link) { return cgi_write_link(parent_id, user_data->name, user_data->link, &user_data->id); } /* UserDefinedData_t */ if (cgi_new_node(parent_id, user_data->name, "UserDefinedData_t", &user_data->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(user_data->id, &user_data->descr[n])) return CG_ERROR; /* DataClass_t */ if (user_data->data_class && cgi_write_dataclass(user_data->id, user_data->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (user_data->units && cgi_write_units(user_data->id, user_data->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(user_data->id, &user_data->array[n])) return CG_ERROR; /* GridLocation_t */ if (user_data->location != CGNS_ENUMV( Vertex )) { dim_vals = (cgsize_t)strlen(GridLocationName[user_data->location]); if (cgi_new_node(user_data->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[user_data->location])) return CG_ERROR; } /* FamilyName_t */ if (user_data->family_name[0]!='\0') { dim_vals = (cgsize_t)strlen(user_data->family_name); if (cgi_new_node(user_data->id, "FamilyName", "FamilyName_t", &dummy_id, "C1", 1, &dim_vals, (void *)user_data->family_name)) return CG_ERROR; } /* CPEX 0034 */ for (n = 0; n < user_data->nfamname; n++) { dim_vals = (cgsize_t)strlen(user_data->famname[n].family); if (cgi_new_node(user_data->id, user_data->famname[n].name, "AdditionalFamilyName_t", &dummy_id, "C1", 1, &dim_vals, (void *)user_data->famname[n].family)) return CG_ERROR; } /* Ordinal_t */ if (user_data->ordinal && cgi_write_ordinal(user_data->id, user_data->ordinal)) return CG_ERROR; /* PointRange, PointList: Move node to its final position */ if (user_data->ptset) { /* Move node to its final position */ if (cgi_move_node(cg->rootid, user_data->ptset->id, user_data->id, PointSetTypeName[user_data->ptset->type])) return CG_ERROR; } /* UserDefinedData_t */ for (n=0; n < user_data->nuser_data; n++) if (cgi_write_user_data(user_data->id, &user_data->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_link(double parent_id, char *name, cgns_link *link, double *id) { if (cgio_create_link(cg->cgio, parent_id, name, link->filename, link->name_in_file, id)) { cg_io_error("cgio_create_link"); return CG_ERROR; } (cg->added)++; return CG_OK; } int cgi_write_particle(double parent_id, cgns_pzone *pzone) { int n; cgsize_t dim_vals[1]; double dummy_id; if (pzone->link) { return cgi_write_link(parent_id, pzone->name, pzone->link, &pzone->id); } /* Create the ParticleZone_t nodes */ dim_vals[0]= 1; if (cgi_new_node(parent_id, pzone->name, "ParticleZone_t", &pzone->id, CG_SIZE_DATATYPE, 1, dim_vals, &pzone->nparticles)) return CG_ERROR; /* ParticleCoordinates_t */ for (n=0; nnpcoor; n++) if (cgi_write_pcoor(pzone->id, &pzone->pcoor[n])) return CG_ERROR; /* FamilyName_t */ if (pzone->family_name[0]!='\0') { dim_vals[0] = (cgsize_t)strlen(pzone->family_name); if (cgi_new_node(pzone->id, "FamilyName", "FamilyName_t", &dummy_id, "C1", 1, dim_vals, (void *)pzone->family_name)) return CG_ERROR; } /* CPEX 0034 */ for (n = 0; n < pzone->nfamname; n++) { dim_vals[0] = (cgsize_t)strlen(pzone->famname[n].family); if (cgi_new_node(pzone->id, pzone->famname[n].name, "AdditionalFamilyName_t", &dummy_id, "C1", 1, dim_vals, (void *)pzone->famname[n].family)) return CG_ERROR; } /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(pzone->id, &pzone->descr[n])) return CG_ERROR; /* DataClass_t */ if (pzone->data_class && cgi_write_dataclass(pzone->id, pzone->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (pzone->units && cgi_write_units(pzone->id, pzone->units)) return CG_ERROR; /* IntegralData_t */ for (n=0; nnintegrals; n++) if (cgi_write_integral(pzone->id, &pzone->integral[n])) return CG_ERROR; /* ParticleIterativeData_t */ if (pzone->piter && cgi_write_ziter(pzone->id, pzone->piter)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(pzone->id, &pzone->user_data[n])) return CG_ERROR; /* ParticleSolution_t */ for (n=0; nnsols; n++) if (cgi_write_particle_sol(pzone->id, &pzone->sol[n])) return CG_ERROR; /* ParticleEquationSet_t */ if (pzone->equations && cgi_write_particle_equations(pzone->id, pzone->equations)) return CG_ERROR; return CG_OK; } int cgi_write_pcoor(double parent_id, cgns_pcoor *pcoor) { int n; if (pcoor->link) { return cgi_write_link(parent_id, pcoor->name, pcoor->link, &pcoor->id); } /* ParticleCoordinates_t */ if (cgi_new_node(parent_id, pcoor->name, "ParticleCoordinates_t", &pcoor->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(pcoor->id, &pcoor->descr[n])) return CG_ERROR; /* DataClass_t */ if (pcoor->data_class && cgi_write_dataclass(pcoor->id, pcoor->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (pcoor->units && cgi_write_units(pcoor->id, pcoor->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nncoords; n++) if (cgi_write_array(pcoor->id, &pcoor->coord[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(pcoor->id, &pcoor->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_particle_sol(double parent_id, cgns_psol *sol) { int n; if (sol->link) { return cgi_write_link(parent_id, sol->name, sol->link, &sol->id); } /* ParticleSolution_t */ if (cgi_new_node(parent_id, sol->name, "ParticleSolution_t", &sol->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(sol->id, &sol->descr[n])) return CG_ERROR; /* DataClass_t */ if (sol->data_class && cgi_write_dataclass(sol->id, sol->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (sol->units && cgi_write_units(sol->id, sol->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnfields; n++) if (cgi_write_array(sol->id, &sol->field[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(sol->id, &sol->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_piter(double parent_id, cgns_ziter *piter) { int n; if (piter->link) { return cgi_write_link(parent_id, piter->name, piter->link, &piter->id); } /* ParticleIterativeData_t name */ if (cgi_new_node(parent_id, piter->name, "ParticleIterativeData_t", &piter->id, "MT", 0, 0, 0)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(piter->id, &piter->descr[n])) return CG_ERROR; /* DataClass_t */ if (piter->data_class && cgi_write_dataclass(piter->id, piter->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (piter->units && cgi_write_units(piter->id, piter->units)) return CG_ERROR; /* DataArray_t */ for (n=0; nnarrays; n++) if (cgi_write_array(piter->id, &piter->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(piter->id, &piter->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_particle_equations(double parent_id, cgns_pequations *equations) { int n; cgsize_t dim_vals; double dummy_id; cgns_pgoverning *governing; if (equations->link) { return cgi_write_link(parent_id, "ParticleEquationSet", equations->link, &equations->id); } /* ParticleEquationSet_t */ if (cgi_new_node(parent_id, "ParticleEquationSet", "ParticleEquationSet_t", &equations->id, "MT", 0, 0, 0)) return CG_ERROR; /* EquationDimension */ if (equations->equation_dim) { dim_vals=1; if (cgi_new_node(equations->id, "EquationDimension", "\"int\"", &dummy_id, "I4", 1, &dim_vals, (void *)&equations->equation_dim)) return CG_ERROR; } /* ParticleGoverningEquations_t */ if (equations->governing) { governing = equations->governing; if (governing->link) { if (cgi_write_link(equations->id, "ParticleGoverningEquations", governing->link, &governing->id)) return CG_ERROR; } else { dim_vals = (cgsize_t)strlen(ParticleGoverningEquationsTypeName[governing->type]); if (cgi_new_node(equations->id, "ParticleGoverningEquations", "ParticleGoverningEquations_t", &governing->id, "C1", 1, &dim_vals, ParticleGoverningEquationsTypeName[governing->type])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(governing->id, &governing->descr[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(governing->id, &governing->user_data[n])) return CG_ERROR; } } /* ParticleCollisionModel_t */ if (equations->collision && cgi_write_particle_model(equations->id, equations->collision)) return CG_ERROR; /* ParticleBreakupModel_t */ if (equations->breakup && cgi_write_particle_model(equations->id, equations->breakup)) return CG_ERROR; /* ParticleForceModel_t */ if (equations->force && cgi_write_particle_model(equations->id, equations->force)) return CG_ERROR; /* ParticleWallInteractionModel_t */ if (equations->wallinteract && cgi_write_particle_model(equations->id, equations->wallinteract)) return CG_ERROR; /* ParticlePhaseChangeModel_t */ if (equations->phasechange && cgi_write_particle_model(equations->id, equations->phasechange)) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(equations->id, &equations->descr[n])) return CG_ERROR; /* DataClass_t */ if (equations->data_class && cgi_write_dataclass(equations->id, equations->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (equations->units && cgi_write_units(equations->id, equations->units)) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(equations->id, &equations->user_data[n])) return CG_ERROR; return CG_OK; } int cgi_write_particle_model(double parent_id, cgns_pmodel *model) { int n; cgsize_t dim_vals; char_33 label; if (model->link) { return cgi_write_link(parent_id, model->name, model->link, &model->id); } /* xParticleModel_t */ sprintf(label,"%.30s_t",model->name); dim_vals = (cgsize_t)strlen(ParticleModelTypeName[model->type]); if (cgi_new_node(parent_id, model->name, label, &model->id, "C1", 1, &dim_vals, ParticleModelTypeName[model->type])) return CG_ERROR; /* Descriptor_t */ for (n=0; nndescr; n++) if (cgi_write_descr(model->id, &model->descr[n])) return CG_ERROR; /* DataClass_t */ if (model->data_class && cgi_write_dataclass(model->id, model->data_class)) return CG_ERROR; /* DimensionalUnits_t */ if (model->units && cgi_write_units(model->id, model->units)) return CG_ERROR; /* DataArray */ for (n=0; nnarrays; n++) if (cgi_write_array(model->id, &model->array[n])) return CG_ERROR; /* UserDefinedData_t */ for (n=0; nnuser_data; n++) if (cgi_write_user_data(model->id, &model->user_data[n])) return CG_ERROR; return CG_OK; } /* cgi_new_node creates an ADF node under parent_id and returns node_id */ int cgi_new_node(double parent_id, char const *name, char const *label, double *node_id, char const *data_type, int ndim, cgsize_t const *dim_vals, void const *data) { /* verify input */ if (cgi_check_strlen(name) || cgi_check_strlen(label) || cgi_check_strlen(data_type)) return CG_ERROR; if (cgio_create_node(cg->cgio, parent_id, name, node_id)) { cg_io_error("cgio_create_node"); return CG_ERROR; } (cg->added)++; if (cgio_set_label(cg->cgio, *node_id, label)) { cg_io_error("cgio_set_label"); return CG_ERROR; } /* return if empty */ if (strcmp(data_type, "MT")==0) return CG_OK; if (cgio_set_dimensions(cg->cgio, *node_id, data_type, ndim, dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } if (data == NULL) return CG_OK; #if 0 /* verify that data doesn't contain NaN */ if (strcmp(data_type,"I4")==0 || strcmp(data_type,"I8")==0 || strcmp(data_type,"R4")==0 || strcmp(data_type,"R8")==0) { cgsize_t i, ndata=1, nbad=0; for (i=0; icgio, *node_id, data)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } return CG_OK; } /* cgi_new_node_partial creates an ADF node under parent_id and returns * node_id * It will write data for a subset of dim_vals based on rmin and rmax * using ADF_Write_Data(..). */ int cgi_new_node_partial(double parent_id, char const *name, char const *label, double *node_id, char const *data_type, int numdim, cgsize_t const *dims, cgsize_t const *s_start, cgsize_t const *s_end, int m_numdim, cgsize_t const *m_dims, cgsize_t const *m_start, cgsize_t const *m_end, void const *data) { cgsize_t i; /* stride used for both file and memory */ cgsize_t stride[CGIO_MAX_DIMENSIONS]; /* verify input */ if (cgi_check_strlen(name) || cgi_check_strlen(label) || cgi_check_strlen(data_type)) return CG_ERROR; if (cgio_create_node(cg->cgio, parent_id, name, node_id)) { cg_io_error("cgio_create_node"); return CG_ERROR; } (cg->added)++; if (cgio_set_label(cg->cgio, *node_id, label)) { cg_io_error("cgio_set_label"); return CG_ERROR; } /* return if empty */ if (strcmp(data_type, "MT")==0) return CG_OK; if (cgio_set_dimensions(cg->cgio, *node_id, data_type, numdim, dims)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } if (data == NULL) return CG_OK; #if 0 /* verify that data doesn't contain NaN */ if (strcmp(data_type,"I4")==0 || strcmp(data_type,"I8")==0 || strcmp(data_type,"R4")==0 || strcmp(data_type,"R8")==0) { cgsize_t ndata = 1, nbad=0; for (i=0; icgio, *node_id, s_start, s_end, stride, m_numdim, m_dims, m_start, m_end, stride, data)) { cg_io_error("cgio_write_data"); return CG_ERROR; } return CG_OK; } int cgi_move_node(double current_parent_id, double node_id, double new_parent_id, cchar_33 node_name) { if (cgio_move_node(cg->cgio, current_parent_id, node_id, new_parent_id)) { cg_io_error("cgio_move_node"); return CG_ERROR; } if (cgio_set_name(cg->cgio, new_parent_id, node_id, node_name)) { cg_io_error("cgio_set_name"); return CG_ERROR; } return CG_OK; } int cgi_delete_node (double parent_id, double node_id) { (cg->deleted)++; if (cgio_delete_node(cg->cgio, parent_id, node_id)) { cg_io_error ("cgio_delete_node"); return CG_ERROR; } return CG_OK; } /***********************************************************************\ * General array reading and writing * \***********************************************************************/ int cgi_array_general_verify_range( const cgi_rw op_rw, /* [I] CGI_Read or CGI_Write */ const void* rind_index, /* [I] how to index rind planes */ const int* rind_planes, /* [I] sizes of rind planes */ const int s_numdim, /* [I] rank in file */ const cgsize_t *s_dimvals, /* [I] dimensions of array in memory */ const cgsize_t *rmin, /* [I] range min in file */ const cgsize_t *rmax, /* [I] range max in file */ const int m_numdim, /* [I] rank in memory */ const cgsize_t *m_dimvals, /* [I] dimensions of array in memory */ const cgsize_t *m_rmin, /* [I] range min in memory */ const cgsize_t *m_rmax, /* [I] range max in memory */ cgsize_t *s_rmin, /* [O] internal range min in file */ cgsize_t *s_rmax, /* [O] internal range max in file */ cgsize_t *stride, /* [O] stride (always 1) */ int *s_access_full_range, /* [O] T: access all of file array */ int *m_access_full_range, /* [O] T: access all of memory array */ cgsize_t *numpt) /* [O] number of points accessed */ { cgsize_t s_numpt = 1, m_numpt = 1; cgsize_t npt; int n; int s_reset_range = 1; *s_access_full_range = 1; *m_access_full_range = 1; /*** verification for dataset in file */ /* verify that range requested is not NULL */ if (rmin == NULL || rmax == NULL) { cgi_error("NULL range value"); return CG_ERROR; } /* check if requested to return full range */ for (n=0; n rmax[n] || rmax[n] > s_dimvals[n] || rmin[n] < 1) { cgi_error("Invalid range of data requested"); return CG_ERROR; } } else { /* new behavior consistent with SIDS */ if (rmin[n] > rmax[n] || rmax[n] > (s_dimvals[n] - rind_planes[2*n]) || rmin[n] < (1 - rind_planes[2*n])) { cgi_error("Invalid range of data requested"); return CG_ERROR; } } } } /*** verification for dataset in memory */ /* verify the rank and dimensions of the memory array */ if (m_numdim <= 0 || m_numdim > CGIO_MAX_DIMENSIONS) { cgi_error("Invalid number of dimensions in memory array"); return CG_ERROR; } if (m_dimvals == NULL) { cgi_error("NULL dimension value"); return CG_ERROR; } for (n=0; n m_rmax[n] || m_rmax[n] > m_dimvals[n] || m_rmin[n] < 1) { cgi_error("Invalid range of memory array provided"); return CG_ERROR; } } /* check if requested to return full range */ for (n=0; ndata_type); const cgsize_t *s_dimvals = array->dim_vals; /* verify the ranges provided and set s_rmin and s_rmax giving internal file-space ranges */ cgsize_t s_rmin[CGIO_MAX_DIMENSIONS], s_rmax[CGIO_MAX_DIMENSIONS]; cgsize_t stride[CGIO_MAX_DIMENSIONS]; ier = cgi_array_general_verify_range( CGI_Read, rind_index, rind_planes, s_numdim, s_dimvals, rmin, rmax, m_numdim, m_dimvals, m_rmin, m_rmax, s_rmin, s_rmax, stride, &s_access_full_range, &m_access_full_range, &numpt); if (ier != CG_OK) return ier; const int access_full_range = (s_access_full_range == 1) && (m_access_full_range == 1); if (s_type == m_type) { /* quick transfer of data if same data types */ if (access_full_range) { if (cgio_read_all_data_type(cg->cgio, array->id, cgi_adf_datatype(m_type), data)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, array->id, s_rmin, s_rmax, stride, cgi_adf_datatype(m_type), m_numdim, m_dimvals, m_rmin, m_rmax, stride, data)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } else if (cg->filetype == CGIO_FILE_ADF2 || cg->filetype == CGIO_FILE_ADF) { /* need to read into temp array to convert data */ /* only able to convert for full range in memory */ if (!m_access_full_range) { cgi_error("Reading to partial range in memory with data conversion " "is not supported in ADF file format"); return CG_ERROR; } void *conv_data; conv_data = malloc(((size_t)numpt)*size_of(array->data_type)); if (conv_data == NULL) { cgi_error("Error allocating conv_data"); return CG_ERROR; } if (access_full_range) { if (cgio_read_all_data_type(cg->cgio, array->id, array->data_type, conv_data)) { free(conv_data); cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, array->id, s_rmin, s_rmax, stride, array->data_type, m_numdim, m_dimvals, m_rmin, m_rmax, stride, conv_data)) { free(conv_data); cg_io_error("cgio_read_data_type"); return CG_ERROR; } } ier = cgi_convert_data(numpt, s_type, conv_data, m_type, data); free(conv_data); if (ier) return CG_ERROR; } else { /* in-situ conversion */ if (access_full_range) { if (cgio_read_all_data_type(cg->cgio, array->id, cgi_adf_datatype(m_type), data)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, array->id, s_rmin, s_rmax, stride, cgi_adf_datatype(m_type), m_numdim, m_dimvals, m_rmin, m_rmax, stride, data)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } return CG_OK; } /* s_ prefix is file space, m_ prefix is memory space, p_ is parent node data */ int cgi_array_general_write( double p_id, /* [I] id of parent node */ int *p_narraylist, /* [I/O] number of arrays in parent */ cgns_array **p_arraylist, /* [I/O] arrays in parent */ const char *const arrayname, /* [I] name of array to write to */ const void* rind_index, /* [I] how to index rind planes */ const int* rind_planes, /* [I] sizes of rind planes */ CGNS_ENUMT(DataType_t) s_type, /* [I] data type in file */ const int s_numdim, /* [I] rank in file */ const cgsize_t *s_dimvals, /* [I] dimensions of array in file */ const cgsize_t *rmin, /* [I] range min in file */ const cgsize_t *rmax, /* [I] range max in file */ CGNS_ENUMT(DataType_t) m_type, /* [I] data type in memory */ const int m_numdim, /* [I] rank in memory */ const cgsize_t *m_dimvals, /* [I] dimensions of array in memory */ const cgsize_t *m_rmin, /* [I] range min in memory */ const cgsize_t *m_rmax, /* [I] range max in memory */ const void* data, /* [I] data to store */ int *A) /* [O] array index for new array */ { int s_access_full_range, m_access_full_range, n, idx, ier; cgsize_t numpt; /* verify the ranges provided and set s_rmin and s_rmax giving internal file-space ranges */ cgsize_t s_rmin[CGIO_MAX_DIMENSIONS], s_rmax[CGIO_MAX_DIMENSIONS]; cgsize_t stride[CGIO_MAX_DIMENSIONS]; ier = cgi_array_general_verify_range( CGI_Write, rind_index, rind_planes, s_numdim, s_dimvals, rmin, rmax, m_numdim, m_dimvals, m_rmin, m_rmax, s_rmin, s_rmax, stride, &s_access_full_range, &m_access_full_range, &numpt); if (ier != CG_OK) return ier; const int access_full_range = (s_access_full_range == 1) && (m_access_full_range == 1); cgns_array *array; /* check for existing array */ int have_dup = 0; if (p_narraylist == NULL) { /* data array */ int ier = 0; /* note: this will allocate a DataArray_t node if existing not found */ array = cgi_array_address(CG_MODE_WRITE, 1, 0, arrayname, &have_dup, &ier); if (array == 0) return ier; if (cgi_posit_id(&p_id)) return CG_ERROR; } else { for (idx=0; idx<(*p_narraylist); idx++) { if (strcmp(arrayname, (*p_arraylist)[idx].name) == 0) { have_dup = 1; array = &((*p_arraylist)[idx]); break; } } } if (have_dup) { /* overwrite a DataArray_t node of same name, size and data-type: */ /* array rank in file must agree */ if (array->data_dim != s_numdim) { cgi_error("Mismatch in array rank"); return CG_ERROR; } /* array dimensions in file must agree */ for (n = 0; ndim_vals[n] != s_dimvals[n]) { cgi_error("Mismatch in array dimension %d", n); return CG_ERROR; } } /* data type in file must agree */ if (strcmp(array->data_type, cgi_adf_datatype(s_type))) { cgi_error("Mismatch in data types"); return CG_ERROR; } } else { /* add a DataArray_t node if not already done */ if (p_narraylist) { if (*p_narraylist == 0) { *p_arraylist = CGNS_NEW(cgns_array, (*p_narraylist)+1); } else { *p_arraylist = CGNS_RENEW(cgns_array, (*p_narraylist)+1, *p_arraylist); } array = &((*p_arraylist)[*p_narraylist]); ++(*p_narraylist); (*A) = *p_narraylist; } /* save array information in memory */ memset(array, 0, sizeof(cgns_array)); strcpy(array->data_type, cgi_adf_datatype(m_type)); strcpy(array->name, arrayname); array->data_dim = s_numdim; for (n = 0; ndim_vals[n] = s_dimvals[n]; } /* save DataArray_t node on disk: */ if (cgi_new_node_partial(p_id, array->name, "DataArray_t", &array->id, array->data_type, s_numdim, s_dimvals, s_rmin, s_rmax, m_numdim, m_dimvals, m_rmin, m_rmax, NULL)) { return CG_ERROR; } } /* Do not write the data if NULL pointer. This is often used in parallel * cgns where only the metadata is being written in serial */ if (data == NULL) return CG_OK; if (s_type == m_type) { /* quick transfer of data if same data types */ if (access_full_range) { if (cgio_write_all_data(cg->cgio, array->id, data)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } } else { if (cgio_write_data(cg->cgio, array->id, s_rmin, s_rmax, stride, m_numdim, m_dimvals, m_rmin, m_rmax, stride, data)) { cg_io_error("cgio_write_data"); return CG_ERROR; } } } else if (cg->filetype == CGIO_FILE_ADF2 || cg->filetype == CGIO_FILE_ADF) { /* need to write into temp array to convert data */ /* only able to convert for full range in memory */ if (!m_access_full_range) { cgi_error("Writing from partial range in memory with data " "conversion is not supported in ADF file format"); return CG_ERROR; } void *conv_data; conv_data = malloc(((size_t)numpt)*size_of(array->data_type)); if (conv_data == NULL) { cgi_error("Error allocating conv_data"); return CG_ERROR; } if (cgi_convert_data(numpt, m_type, data, s_type, conv_data)) { free(conv_data); return CG_ERROR; } if (access_full_range) { if (cgio_write_all_data(cg->cgio, array->id, conv_data)) { free(conv_data); cg_io_error("cgio_write_all_data"); return CG_ERROR; } } else { if (cgio_write_data(cg->cgio, array->id, s_rmin, s_rmax, stride, m_numdim, m_dimvals, m_rmin, m_rmax, stride, conv_data)) { free(conv_data); cg_io_error("cgio_write_data"); return CG_ERROR; } } free(conv_data); } else { /* in-situ conversion */ if (access_full_range) { if (cgio_write_all_data_type(cg->cgio, array->id, cgi_adf_datatype(m_type), data)) { cg_io_error("cgio_write_all_data_type"); return CG_ERROR; } } else { if (cgio_write_data_type(cg->cgio, array->id, s_rmin, s_rmax, stride, cgi_adf_datatype(m_type), m_numdim, m_dimvals, m_rmin, m_rmax, stride, data)) { cg_io_error("cgio_write_data_type"); return CG_ERROR; } } } return CG_OK; } /***********************************************************************\ * Alphanumerical sorting routine * * Warning: This is an insert sort that leads to performance issues * \***********************************************************************/ int cgi_sort_names(int nnam, double *ids) { int i,j; char_33 temp; double temp_id; char_33 *names; names = CGNS_NEW(char_33, nnam); for (i=0; icgio, ids[i], names[i])) { cg_io_error("cgio_get_name"); CGNS_FREE(names); return CG_ERROR; } } for (i=1; i= 0 && strcmp(names[j], temp) > 0) { memcpy(names[j+1], names[j], 33); ids[j+1] = ids[j]; j = j - 1; } if (j + 1 == i) continue; memcpy(names[j + 1], temp, 33); ids[j + 1] = temp_id; } CGNS_FREE(names); return CG_OK; } /***********************************************************************\ * ADF parser: returns the children id with "label" under "parent_id" * \***********************************************************************/ int cgi_get_nodes(double parent_id, char *label, int *nnodes, double **id) { int nid, n, nchildren, len; char nodelabel[CGIO_MAX_NAME_LENGTH+1]; double *idlist; *nnodes = 0; if (cgio_number_children(cg->cgio, parent_id, &nchildren)) { cg_io_error ("cgio_number_children"); return CG_ERROR; } if (nchildren < 1) return CG_OK; idlist = CGNS_NEW (double, nchildren); if (cgio_children_ids(cg->cgio, parent_id, 1, nchildren, &len, idlist)) { cg_io_error ("cgio_children_ids"); return CG_ERROR; } if (len != nchildren) { CGNS_FREE (idlist); cgi_error ("mismatch in number of children and child IDs read"); return CG_ERROR; } nid = 0; for (nid = 0, n = 0; n < nchildren; n++) { if (cgio_get_label(cg->cgio, idlist[n], nodelabel)) { cg_io_error ("cgio_get_label"); return CG_ERROR; } if (0 == strcmp (nodelabel, label)) { if (nid < n) idlist[nid] = idlist[n]; nid++; } else cgio_release_id (cg->cgio, idlist[n]); } if (nid > 0) { *id = idlist; *nnodes = nid; } else CGNS_FREE (idlist); return CG_OK; } /***********************************************************************\ * Data Types functions * \***********************************************************************/ char *type_of(char_33 data_type) { if (strcmp(data_type, "I4")==0) return "int"; else if (strcmp(data_type, "R4")==0) return "float"; else if (strcmp(data_type, "R8")==0) return "double"; else if (strcmp(data_type, "C1")==0) return "char"; else { cgi_error("data_type '%s' not supported by function 'type_of'",data_type); return CG_OK; } } size_t size_of(const char_33 data_type) { if (strcmp(data_type, "I4") == 0) return sizeof(int); if (strcmp(data_type, "I8") == 0) return sizeof(cglong_t); if (strcmp(data_type, "R4") == 0) return sizeof(float); if (strcmp(data_type, "R8") == 0) return sizeof(double); if (strcmp(data_type, "C1") == 0) return sizeof(char); if (strcmp(data_type, "X4") == 0) return 2*sizeof(float); if (strcmp(data_type, "X8") == 0) return 2*sizeof(double); cgi_error("data_type '%s' not supported by function 'size_of'",data_type); return CG_OK; } const char *cgi_adf_datatype(CGNS_ENUMV(DataType_t) type) { if (type == CGNS_ENUMV(Integer)) return "I4"; if (type == CGNS_ENUMV(LongInteger)) return "I8"; if (type == CGNS_ENUMV(RealSingle)) return "R4"; if (type == CGNS_ENUMV(RealDouble)) return "R8"; if (type == CGNS_ENUMV(Character)) return "C1"; if (type == CGNS_ENUMV(ComplexSingle)) return "X4"; if (type == CGNS_ENUMV(ComplexDouble)) return "X8"; return "NULL"; } CGNS_ENUMT(DataType_t) cgi_datatype(char const *adf_type) { if (strncmp(adf_type, "I4", 33) == 0) return CGNS_ENUMV(Integer); if (strncmp(adf_type, "I8", 33) == 0) return CGNS_ENUMV(LongInteger); if (strncmp(adf_type, "R4", 33) == 0) return CGNS_ENUMV(RealSingle); if (strncmp(adf_type, "R8", 33) == 0) return CGNS_ENUMV(RealDouble); if (strncmp(adf_type, "C1", 33) == 0) return CGNS_ENUMV(Character); if (strncmp(adf_type, "X4", 33) == 0) return CGNS_ENUMV(ComplexSingle); if (strncmp(adf_type, "X8", 33) == 0) return CGNS_ENUMV(ComplexDouble); return CGNS_ENUMV(DataTypeNull); } /***********************************************************************\ * Check input functions * \***********************************************************************/ int cgi_zone_no(cgns_base *base, char *zonename, int *zone_no) { int i; for (i=0; inzones; i++) { if (strcmp(base->zone[i].name,zonename)==0) { *zone_no = i+1; return CG_OK; } } cgi_error("Zone %s not found",zonename); return CG_ERROR; } int cgi_check_strlen(char const *string) { if (strlen(string) > 32) { cgi_error("Name exceeds 32 characters limit: %s",string); return CG_ERROR; } return CG_OK; } int cgi_check_strlen_x2(char const *string) { int n1,n2; size_t p; if (strlen(string) > 65) { cgi_error("Name exceeds 65 characters limit: %s",string); return CG_ERROR; } p=0; n1=0; n2=0; while (string[p]) { if (string[p]=='/') { if (n2!=0){ cgi_error("Zone or Family with base scope should have only one / : %s",string); return CG_ERROR; } if (n1==0){ cgi_error("Base part of the name is empty in %s",string); return CG_ERROR; } if (p==strlen(string)-1){ cgi_error("Zone or Family part of the name is empty in %s",string); return CG_ERROR; } n2++; } if (!n2) n1++; else n2++; if (n1>32){ cgi_error("Base part of the name exceed 32 chars limit: %s",string); return CG_ERROR; } if (n2>34){ cgi_error("Zone or Family part of the name exceed 32 chars limit: %s",string); return CG_ERROR; } p++; } return CG_OK; } int cgi_check_mode(char const *filename, int file_mode, int mode_wanted) { if (mode_wanted==CG_MODE_READ && file_mode==CG_MODE_WRITE) { cgi_error("File %s not open for reading", filename); return CG_ERROR; } if (mode_wanted==CG_MODE_WRITE && file_mode==CG_MODE_READ) { cgi_error("File %s not open for writing", filename); return CG_ERROR; } return CG_OK; } /***********************************************************************\ * Miscellaneous * \***********************************************************************/ int cgi_add_czone(char_33 zonename, cgsize6_t range, cgsize6_t donor_range, int index_dim, int *ndouble, char_33 **Dzonename, cgsize6_t **Drange, cgsize6_t **Ddonor_range) { int differ=1, k, j; /* check if this interface was already found */ for (k=0; k<(*ndouble); k++) { if (strcmp(Dzonename[0][k],zonename)) { continue; } differ=0; for (j=0; jversion < 3200 && type >= CGNS_ENUMV(NGON_n)) npe = (int)(type - CGNS_ENUMV(NGON_n)); else cg_npe(type, &npe); if (npe <= 0) { cgi_error("unhandled element type in MIXED list - %d\n", type); return -1; } size += npe; } } else if (type == CGNS_ENUMV(NGON_n) || type == CGNS_ENUMV(NFACE_n)) { if (connect == 0) return CG_OK; /* Need to handle old version when opening old files */ if (connect_offset == 0) { if (cg->version < 4000) { for (ne = 0; ne < nelems; ne++) { npe = (int)connect[size++]; size += npe; } } else { cgi_error("missing ElementStartOffset for NGON_n or NFACE_n\n"); return -1; } } else { size = (connect_offset[nelems] - connect_offset[0]); } } else { if (cg_npe(type, &npe) || npe <= 0) { cgi_error("unhandled element type - %d\n", type); return -1; } size = nelems * npe; } return size; } /***********************************************************************\ * Get the memory address of a data structure * \***********************************************************************/ cgns_file *cgi_get_file(int file_number) { int filenum = file_number - file_number_offset; if (filenum <= 0 || filenum > n_cgns_files) { cgi_error("CGNS file %d is not open",file_number); return CG_OK; } cg = &(cgns_files[filenum-1]); if (cg->mode == CG_MODE_CLOSED) { cgi_error("CGNS %d is closed",file_number); return CG_OK; } return cg; } cgns_base *cgi_get_base(cgns_file *cg, int B) { if (B>cg->nbases || B<=0) { cgi_error("Base number %d invalid",B); return CG_OK; } return &(cg->base[B-1]); } cgns_zone *cgi_get_zone(cgns_file *cg, int B, int Z) { cgns_base *base; base = cgi_get_base(cg, B); if (base==0) return CG_OK; if (Z>base->nzones || Z<=0) { cgi_error("Zone number %d invalid",Z); return CG_OK; } return &(base->zone[Z-1]); } cgns_family *cgi_get_family(cgns_file *cg, int B, int F) { cgns_base *base; base = cgi_get_base(cg, B); if (base==0) return CG_OK; if (F>base->nfamilies || F<=0) { cgi_error("Family number %d invalid",F); return CG_OK; } return &base->family[F-1]; } cgns_biter *cgi_get_biter(cgns_file *cg, int B) { cgns_base *base; base = cgi_get_base(cg, B); if (base==0) return CG_OK; if (base->biter == 0) { cgi_error("BaseIterativeData_t node doesn't exist under CGNSBase %d",B); return CG_OK; } else return base->biter; } cgns_gravity *cgi_get_gravity(cgns_file *cg, int B) { cgns_base *base; base = cgi_get_base(cg, B); if (base==0) return CG_OK; if (base->gravity==0) { cgi_error("Gravity_t node doesn't exist under CGNSBase %d",B); return CG_OK; } else return base->gravity; } cgns_axisym *cgi_get_axisym(cgns_file *cg, int B) { cgns_base *base; base = cgi_get_base(cg, B); if (base==0) return CG_OK; if (base->axisym==0) { cgi_error("Axisymmetry_t node doesn't exist under CGNSBase %d",B); return CG_OK; } else return base->axisym; } cgns_rotating *cgi_get_rotating(cgns_file *cg, int B, int Z) { cgns_base *base; cgns_zone *zone; /* RotatingCoordinates_t under a base */ if (Z==0) { base = cgi_get_base(cg, B); if (base==0) return CG_OK; if (base->rotating==0) { cgi_error("RotatingCoordinates_t node doesn't exist under CGNSBase %d",B); return CG_OK; } else return base->rotating; } else { zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (zone->rotating==0) { cgi_error("RotatingCoordinates_t node doesn't exist under zone %d",Z); return CG_OK; } else return zone->rotating; } } cgns_ziter *cgi_get_ziter(cgns_file *cg, int B, int Z) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (zone->ziter == 0) { cgi_error("ZoneIterativeData_t node doesn't exist under zone %d",Z); return CG_OK; } else return zone->ziter; } cgns_zcoor *cgi_get_zcoorGC(cgns_file *cg, int B, int Z) { cgns_zone *zone; int i, index_dim; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; index_dim = zone->index_dim; if (zone->nzcoor == 0 && (cg->mode == CG_MODE_WRITE || cg->mode == CG_MODE_MODIFY)) { zone->zcoor = CGNS_NEW(cgns_zcoor, 1); strcpy(zone->zcoor->name, "GridCoordinates"); zone->zcoor->id = 0; zone->zcoor->link = 0; zone->zcoor->ndescr = 0; zone->zcoor->rind_planes = CGNS_NEW(int, 2*index_dim); for (i=0; i<2*index_dim; i++) zone->zcoor->rind_planes[i]=0; zone->zcoor->ncoords = 0; zone->zcoor->data_class = CGNS_ENUMV( DataClassNull ); zone->zcoor->units = 0; zone->zcoor->nuser_data= 0; if (cg->mode == CG_MODE_MODIFY) { /* Create node GridCoordinates_t node in file */ if (cgi_new_node(zone->id, "GridCoordinates", "GridCoordinates_t", &zone->zcoor->id, "MT", 0, 0, 0)) return CG_OK; } zone->nzcoor=1; return zone->zcoor; } else { for (i=0; inzcoor; i++) { if (strcmp(zone->zcoor[i].name,"GridCoordinates")==0) { return &zone->zcoor[i]; } } } cgi_error("Node 'GridCoordinates' not found for zone '%s'",zone->name); return CG_OK; } cgns_zcoor *cgi_get_zcoor(cgns_file *cg, int B, int Z, int C) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (C>zone->nzcoor || C<=0) { cgi_error("GridCoordinates node number %d invalid",C); return CG_OK; } return &(zone->zcoor[C-1]); } cgns_sol *cgi_get_sol(cgns_file *cg, int B, int Z, int S) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (S>zone->nsols || S<=0) { cgi_error("FlowSolution node number %d invalid",S); return CG_OK; } return &(zone->sol[S-1]); } cgns_section *cgi_get_section(cgns_file *cg, int B, int Z, int S) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (S>zone->nsections || S<=0) { cgi_error("Elements_t node number %d invalid",S); return CG_OK; } return &zone->section[S-1]; } cgns_array *cgi_get_field(cgns_file *cg, int B, int Z, int S, int F) { cgns_sol *sol; sol = cgi_get_sol(cg, B, Z, S); if (sol==0) return CG_OK; if (F>sol->nfields || F<=0) { cgi_error("Solution array number %d invalid",F); return CG_OK; } return &(sol->field[F-1]); } cgns_zconn *cgi_get_zconnZC(cgns_file *cg, int B, int Z, int C) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (C > 0 && C <= zone->nzconn) { zone->active_zconn = C; return &zone->zconn[C-1]; } cgi_error("ZoneGridConnectivity_t node number %d invalid",C); return CG_OK; } cgns_zconn *cgi_get_zconn(cgns_file *cg, int B, int Z) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; /* return active zconn if set */ if (zone->nzconn > 0 && zone->active_zconn > 0 && zone->active_zconn <= zone->nzconn) { return &zone->zconn[zone->active_zconn-1]; } /* Allocate automatically only in MODE_WRITE. In MODE_MODIFY, can't do it because a cg_goto would create the node even if not wanted */ if (zone->zconn == 0) { if (cg->mode == CG_MODE_WRITE) { zone->zconn = CGNS_NEW(cgns_zconn, 1); strcpy(zone->zconn->name, "ZoneGridConnectivity"); zone->zconn->id=0; zone->zconn->link=0; zone->zconn->ndescr=0; zone->zconn->n1to1=0; zone->zconn->nconns=0; zone->zconn->nholes=0; zone->zconn->nuser_data=0; } else { cgi_error("No grid connectivity information for zone %d", Z); return CG_OK; } } zone->active_zconn = 1; return zone->zconn; } cgns_cprop *cgi_get_cprop(cgns_file *cg, int B, int Z, int J) { cgns_conn *conn; conn = cgi_get_conn(cg, B, Z, J); if (conn==0) return CG_OK; if (conn->cprop == 0) cgi_error("GridConnectivityProperty_t node doesn't exist under GridConnectivity_t %d",J); return conn->cprop; } cgns_hole *cgi_get_hole(cgns_file *cg, int B, int Z, int J) { cgns_zconn *zconn; zconn = cgi_get_zconn(cg, B, Z); if (zconn==0) return CG_OK; if (J>zconn->nholes || J<=0) { cgi_error("OversetHoles node number %d invalid",J); return CG_OK; } return &(zconn->hole[J-1]); } cgns_conn *cgi_get_conn(cgns_file *cg, int B, int Z, int J) { cgns_zconn *zconn; zconn = cgi_get_zconn(cg, B, Z); if (zconn==0) return CG_OK; if (J>zconn->nconns || J<=0) { cgi_error("GridConnectivity_t node number %d invalid",J); return CG_OK; } return &(zconn->conn[J-1]); } cgns_1to1 *cgi_get_1to1(cgns_file *cg, int B, int Z, int J) { cgns_zconn *zconn; zconn = cgi_get_zconn(cg, B, Z); if (zconn==0) return CG_OK; if (J>zconn->n1to1 || J<=0) { cgi_error("GridConnectivity1to1_t node number %d invalid",J); return CG_OK; } return &(zconn->one21[J-1]); } cgns_zboco *cgi_get_zboco(cgns_file *cg, int B, int Z) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; /* Allocate automatically only in MODE_WRITE. In MODE_MODIFY, can't do it because a cg_goto would create the node even if not wanted */ if (zone->zboco == 0) { if (cg->mode == CG_MODE_WRITE) { zone->zboco = CGNS_NEW(cgns_zboco, 1); strcpy(zone->zboco->name,"ZoneBC"); zone->zboco->id=0; zone->zboco->link=0; zone->zboco->ndescr=0; zone->zboco->nbocos=0; zone->zboco->state=0; zone->zboco->data_class=CGNS_ENUMV( DataClassNull ); zone->zboco->units=0; zone->zboco->nuser_data=0; } else { cgi_error("No boundary condition data in zone %d",Z); return CG_OK; } } return zone->zboco; } cgns_bprop *cgi_get_bprop(cgns_file *cg, int B, int Z, int BC) { cgns_boco *boco; boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_OK; if (boco->bprop == 0) cgi_error("BCProperty_t node doesn't exist under BC_t %d",BC); return boco->bprop; } cgns_boco *cgi_get_boco(cgns_file *cg, int B, int Z, int BC) { cgns_zboco *zboco; zboco = cgi_get_zboco(cg, B, Z); if (zboco==0) return CG_OK; if (BC>zboco->nbocos || BC<=0) { cgi_error("BC_t node number %d invalid",BC); return CG_OK; } return &(zboco->boco[BC-1]); } cgns_dataset *cgi_get_dataset(cgns_file *cg, int B, int Z, int BC, int DSet) { cgns_boco *boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_OK; if (DSet>boco->ndataset || DSet<=0) { cgi_error("BCDataSet_t node number %d invalid",DSet); return CG_OK; } return &boco->dataset[DSet-1]; } cgns_bcdata *cgi_get_bcdata(cgns_file *cg, int B, int Z, int BC, int Dset, CGNS_ENUMV( BCDataType_t ) type) { cgns_dataset *dataset = cgi_get_dataset(cg, B, Z, BC, Dset); if (dataset==0) return CG_OK; if (type==CGNS_ENUMV( Dirichlet )) { if (dataset->dirichlet==0) { cgi_error("BCData_t type Dirichlet doesn't exist for Zone %d, BC=%d, BCDataSet=%d", Z, BC, Dset); return CG_OK; } else return dataset->dirichlet; } else if (type==CGNS_ENUMV( Neumann )) { if (dataset->neumann==0) { cgi_error("BCData_t type Neumann doesn't exist for Zone %d, BC=%d, BCDataSet=%d", Z, BC, Dset); return CG_OK; } else return dataset->neumann; } else { cgi_error("BCData must be of type Dirichlet or Neumann"); return CG_OK; } } cgns_converg *cgi_get_converg(cgns_file *cg, int B, int Z) { if (Z==0) { cgns_base *base=cgi_get_base(cg, B); if (base==0) return CG_OK; if (base->converg== 0) { cgi_error("ConvergenceHistory_t node doesn't exist under CGNSBase %d",B); return CG_OK; } else return base->converg; } else { cgns_zone *zone=cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (zone->converg== 0) { cgi_error("ConvergenceHistory_t node doesn't exist under CGNSBase %d, Zone %d",B,Z); return CG_OK; } else return zone->converg; } } cgns_equations *cgi_get_equations(cgns_file *cg, int B, int Z) { if (Z==0) { cgns_base *base=cgi_get_base(cg, B); if (base==0) return CG_OK; /* todo: error checking if node doesn't exist in all these cgi_get_functions */ /* also make sure that they are all initialized correctly */ if (base->equations == 0) { cgi_error("FlowEquationSet_t Node doesn't exist under CGNSBase %d",B); return CG_OK; } else return base->equations; } else { cgns_zone *zone=cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (zone->equations == 0) { cgi_error("FlowEquationSet_t Node doesn't exist under CGNSBase %d, Zone %d",B,Z); return CG_OK; } else return zone->equations; } } cgns_governing *cgi_get_governing(cgns_file *cg, int B, int Z) { cgns_equations *eq=cgi_get_equations(cg, B, Z); if (eq==0) return CG_OK; if (eq->governing==0) { if (Z==0) cgi_error("GoverningEquations_t undefined for CGNSBase %d",B); else cgi_error("GoverningEquations_t undefined for CGNSBase %d, Zone %d", B, Z); return CG_OK; } else return eq->governing; } cgns_model *cgi_get_model(cgns_file *cg, int B, int Z, char *model) { cgns_equations *eq=cgi_get_equations(cg, B, Z); if (eq==0) return CG_OK; if (strcmp(model, "GasModel_t")==0 && eq->gas) return eq->gas; else if (strcmp(model, "ViscosityModel_t")==0 && eq->visc) return eq->visc; else if (strcmp(model, "ThermalConductivityModel_t")==0 && eq->conduct) return eq->conduct; else if (strcmp(model, "TurbulenceModel_t")==0 && eq->turbulence) return eq->turbulence; else if (strcmp(model, "TurbulenceClosure_t")==0 && eq->closure) return eq->closure; else if (strcmp(model, "ThermalRelaxationModel_t")==0 && eq->relaxation) return eq->relaxation; else if (strcmp(model, "ChemicalKineticsModel_t")==0 && eq->chemkin) return eq->chemkin; else if (strcmp(model, "EMElectricFieldModel_t")==0 && eq->elecfield) return eq->elecfield; else if (strcmp(model, "EMMagneticFieldModel_t")==0 && eq->magnfield) return eq->magnfield; else if (strcmp(model, "EMConductivityModel_t")==0 && eq->emconduct) return eq->emconduct; else { if (Z==0) cgi_error("%s undefined for CGNSBase %d",model, B); else cgi_error("%s undefined for CGNSBase %d, Zone %d",model, B, Z); return CG_OK; } } cgns_integral *cgi_get_integral(cgns_file *cg, int B, int Z, int N) { if (Z==0) { cgns_base *base=cgi_get_base(cg, B); if (base==0) return CG_OK; if (N>base->nintegrals || N<=0) { cgi_error("IntegralData_t node number %d invalid under CGNSBase %d",N, B); return CG_OK; } else return &base->integral[N-1]; } else { cgns_zone *zone=cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (N>zone->nintegrals || N<=0) { cgi_error("IntegralData_t node number %d invalid under CGNSBase %d, Zone %d",N,B,Z); return CG_OK; } else return &zone->integral[N-1]; } } cgns_discrete *cgi_get_discrete(cgns_file *cg, int B, int Z, int D) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (D>zone->ndiscrete || D<=0) { cgi_error("DiscreteData node number %d invalid",D); return CG_OK; } return &zone->discrete[D-1]; } cgns_rmotion *cgi_get_rmotion(cgns_file *cg, int B, int Z, int R) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (R>zone->nrmotions || R<=0) { cgi_error("RigidGridMotion node number %d invalid",R); return CG_OK; } return &zone->rmotion[R-1]; } cgns_amotion *cgi_get_amotion(cgns_file *cg, int B, int Z, int R) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (R>zone->namotions || R<=0) { cgi_error("ArbitraryGridMotion node number %d invalid",R); return CG_OK; } return &zone->amotion[R-1]; } cgns_state *cgi_get_state(cgns_file *cg, int B, int Z, int P, int ZBC, int BC, int Dset) { /* defined under CGNSBase_t */ if (Z==0 && P == 0 && ZBC==0 && BC==0 && Dset==0) { cgns_base *base = cgi_get_base(cg, B); if (base==0) return CG_OK; if (base->state==0) { cgi_error("ReferenceState_t undefined under CGNSBase %d",B); return CG_OK; } else return base->state; /* defined under Zone_t */ } else if (P== 0 && ZBC==0 && BC==0 && Dset==0) { cgns_zone *zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (zone->state==0) { cgi_error("ReferenceState_t undefined under CGNSBase %d, Zone %d",B,Z); return CG_OK; } else return zone->state; /* defined under ParticleZone_t */ } else if (ZBC==0 && BC==0 && Dset==0) { cgns_pzone *pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_OK; if (pzone->state==0) { cgi_error("ReferenceState_t undefined under CGNSBase %d, ParticleZone %d",B,P); return CG_OK; } else return pzone->state; /* defined under ZoneBC_t */ } else if (BC==0 && Dset==0) { cgns_zboco *zboco = cgi_get_zboco(cg, B, Z); if (zboco==0) return CG_OK; if (zboco->state==0) { cgi_error("ReferenceState_t undefined under CGNSBase %d, Zone %d, ZoneBC_t",B,Z); return CG_OK; } else return zboco->state; /* defined under BC_t */ } else if (Dset==0) { cgns_boco *boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_OK; if (boco->state==0) { cgi_error("ReferenceState_t undefined under CGNSBase %d, Zone %d, BC_t %d",B,Z,BC); return CG_OK; } else return boco->state; /* defined under BCDataSet_t */ } else { cgns_dataset *dataset = cgi_get_dataset(cg, B, Z, BC, Dset); if (dataset==0) return CG_OK; if (dataset->state==0) { cgi_error("ReferenceState_t undefined under CGNSBase %d, Zone %d, BC_t %d, BCDataSet %d", B,Z,BC,Dset); return CG_OK; } else return dataset->state; } } cgns_subreg *cgi_get_subreg(cgns_file *cg, int B, int Z, int S) { cgns_zone *zone; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_OK; if (S > 0 && S <= zone->nsubreg) return &(zone->subreg[S-1]); cgi_error("ZoneSubRegion node number %d invalid", S); return NULL; } cgns_pzone *cgi_get_particle(cgns_file *cg, int B, int P) { cgns_base *base; base = cgi_get_base(cg, B); if (base==0) return CG_OK; if (P>base->npzones || P<=0) { cgi_error("ParticleZone number %d invalid", P); return CG_OK; } return &(base->pzone[P-1]); } cgns_pcoor *cgi_get_particle_pcoor(cgns_file *cg, int B, int P, int C) { cgns_pzone *pzone; pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_OK; if (C>pzone->npcoor || C<=0) { cgi_error("ParticleCoordinates node number %d invalid", C); return CG_OK; } return &(pzone->pcoor[C-1]); } cgns_pcoor *cgi_get_particle_pcoorPC(cgns_file *cg, int B, int P) { cgns_pzone *pzone; int i; pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_OK; if (pzone->npcoor == 0 && (cg->mode == CG_MODE_WRITE || cg->mode == CG_MODE_MODIFY)) { pzone->pcoor = CGNS_NEW(cgns_pcoor, 1); strcpy(pzone->pcoor->name, "ParticleCoordinates"); pzone->pcoor->id = 0; pzone->pcoor->link = 0; pzone->pcoor->ndescr = 0; pzone->pcoor->ncoords = 0; pzone->pcoor->data_class = CGNS_ENUMV( DataClassNull ); pzone->pcoor->units = 0; pzone->pcoor->nuser_data = 0; if (cg->mode == CG_MODE_MODIFY) { /* Create node ParticleCoordinates_t node in file */ if (cgi_new_node(pzone->id, "ParticleCoordinates", "ParticleCoordinates_t", &pzone->pcoor->id, "MT", 0, 0, 0)) return CG_OK; } pzone->npcoor=1; return pzone->pcoor; } else { for (i=0; inpcoor; i++) { if (strcmp(pzone->pcoor[i].name,"ParticleCoordinates")==0) { return &pzone->pcoor[i]; } } } return CG_OK; } cgns_psol *cgi_get_particle_sol(cgns_file *cg, int B, int P, int S) { cgns_pzone *pzone; pzone = cgi_get_particle(cg, B, P); if (pzone == 0) return CG_OK; if (S>pzone->nsols || S<=0) { cgi_error("Particle solution number %d invalid", S); return CG_OK; } return &(pzone->sol[S-1]); } cgns_array *cgi_get_particle_field(cgns_file *cg, int B, int P, int S, int F) { cgns_psol *sol; sol = cgi_get_particle_sol(cg, B, P, S); if (sol==0) return CG_OK; if (F>sol->nfields || F<=0) { cgi_error("Particle solution array number %d invalid", F); return CG_OK; } return &(sol->field[F-1]); } cgns_ziter *cgi_get_piter(cgns_file *cg, int B, int P) { cgns_pzone *pzone; pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_OK; if (pzone->piter == 0) { cgi_error("ParticleIterativeData_t node doesn't exist under ParticleZone %d", P); return CG_OK; } else return pzone->piter; } cgns_pequations *cgi_get_particle_equations(cgns_file *cg, int B, int P) { if (P==0) { cgns_base *base=cgi_get_base(cg, B); if (base==0) return CG_OK; if (base->pequations == 0) { cgi_error("ParticleEquationSet_t Node doesn't exist under CGNSBase %d",B); return CG_OK; } else return base->pequations; } else { cgns_pzone *pzone=cgi_get_particle(cg, B, P); if (pzone==0) return CG_OK; if (pzone->equations == 0) { cgi_error("ParticleEquationSet_t Node doesn't exist under CGNSBase %d, ParticleZone %d",B,P); return CG_OK; } else return pzone->equations; } } cgns_pgoverning *cgi_get_particle_governing(cgns_file *cg, int B, int P) { cgns_pequations *eq=cgi_get_particle_equations(cg, B, P); if (eq==0) return CG_OK; if (eq->governing==0) { if (P==0) cgi_error("ParticleGoverningEquations_t undefined for CGNSBase %d",B); else cgi_error("ParticleGoverningEquations_t undefined for CGNSBase %d, Particle %d", B, P); return CG_OK; } else return eq->governing; } /******************* Functions related to cg_goto **********************************/ static int cgi_add_posit(void *pos, char *label, int index, double id) { if (posit_depth == CG_MAX_GOTO_DEPTH) { cgi_error("max goto depth exceeded"); return CG_ERROR; } posit_stack[posit_depth].posit = pos; strcpy (posit_stack[posit_depth].label, label); posit_stack[posit_depth].index = index; posit_stack[posit_depth].id = id; posit = &posit_stack[posit_depth++]; return CG_OK; } static int cgi_next_posit(char *label, int index, char *name) { int n; /* CGNSBase_t */ if (0 == strcmp (posit->label, "CGNSBase_t")) { cgns_base *b = (cgns_base *)posit->posit; if (0 == strcmp (label, "Zone_t")) { if (--index < 0) { for (n = 0; n < b->nzones; n++) { if (0 == strcmp (b->zone[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->nzones) { posit_zone = index + 1; return cgi_add_posit((void *)&b->zone[index], label, index + 1, b->zone[index].id); } } else if (0 == strcmp (label, "ParticleZone_t")) { if (--index < 0) { for (n = 0; n < b->npzones; n++) { if (0 == strcmp (b->pzone[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->npzones) { return cgi_add_posit((void *)&b->pzone[index], label, index + 1, b->pzone[index].id); } } else if (0 == strcmp (label, "ReferenceState_t")) { if (b->state && (index == 1 || 0 == strcmp (b->state->name, name))) { return cgi_add_posit((void *)b->state, label, 1, b->state->id); } } else if (0 == strcmp (label, "Family_t")) { if (--index < 0) { for (n = 0; n < b->nfamilies; n++) { if (0 == strcmp (b->family[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->nfamilies) { return cgi_add_posit((void *)&b->family[index], label, index + 1, b->family[index].id); } } else if (0 == strcmp (label, "BaseIterativeData_t")) { if (b->biter && (index == 1 || 0 == strcmp (b->biter->name, name))) { return cgi_add_posit((void *)b->biter, label, 1, b->biter->id); } } else if (0 == strcmp (label, "ConvergenceHistory_t")) { if (b->converg && (index == 1 || 0 == strcmp (b->converg->name, name))) { return cgi_add_posit((void *)b->converg, label, 1, b->converg->id); } } else if (0 == strcmp (label, "FlowEquationSet_t")) { if (b->equations && (index == 1 || 0 == strcmp (b->equations->name, name))) { return cgi_add_posit((void *)b->equations, label, 1, b->equations->id); } } else if (0 == strcmp (label, "ParticleEquationSet_t")) { if (b->pequations && (index == 1 || 0 == strcmp (b->pequations->name, name))) { return cgi_add_posit((void *)b->pequations, label, 1, b->pequations->id); } } else if (0 == strcmp (label, "IntegralData_t")) { if (--index < 0) { for (n = 0; n < b->nintegrals; n++) { if (0 == strcmp (b->integral[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->nintegrals) { return cgi_add_posit((void *)&b->integral[index], label, index + 1, b->integral[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < b->nuser_data; n++) { if (0 == strcmp (b->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->nuser_data) { return cgi_add_posit((void *)&b->user_data[index], label, index + 1, b->user_data[index].id); } } else if (0 == strcmp (label, "Gravity_t")) { if (b->gravity && (index == 1 || 0 == strcmp (b->gravity->name, name))) { return cgi_add_posit((void *)b->gravity, label, 1, b->gravity->id); } } else if (0 == strcmp (label, "Axisymmetry_t")) { if (b->axisym && (index == 1 || 0 == strcmp (b->axisym->name, name))) { return cgi_add_posit((void *)b->axisym, label, 1, b->axisym->id); } } else if (0 == strcmp (label, "RotatingCoordinates_t")) { if (b->rotating && (index == 1 || 0 == strcmp (b->rotating->name, name))) { return cgi_add_posit((void *)b->rotating, label, 1, b->rotating->id); } } else return CG_INCORRECT_PATH; } /* Zone_t */ else if (0 == strcmp (posit->label, "Zone_t")) { cgns_zone *z = (cgns_zone *)posit->posit; if (0 == strcmp (label, "GridCoordinates_t")) { if (--index < 0) { for (n = 0; n < z->nzcoor; n++) { if (0 == strcmp (z->zcoor[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nzcoor) { return cgi_add_posit((void *)&z->zcoor[index], label, index + 1, z->zcoor[index].id); } } else if (0 == strcmp (label, "ZoneIterativeData_t")) { if (z->ziter && (index == 1 || 0 == strcmp (z->ziter->name, name))) { return cgi_add_posit((void *)z->ziter, label, 1, z->ziter->id); } } else if (0 == strcmp (label, "Elements_t")) { if (--index < 0) { for (n = 0; n < z->nsections; n++) { if (0 == strcmp (z->section[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nsections) { return cgi_add_posit((void *)&z->section[index], label, index + 1, z->section[index].id); } } else if (0 == strcmp (label, "FlowSolution_t")) { if (--index < 0) { for (n = 0; n < z->nsols; n++) { if (0 == strcmp (z->sol[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nsols) { return cgi_add_posit((void *)&z->sol[index], label, index + 1, z->sol[index].id); } } else if (0 == strcmp (label, "RigidGridMotion_t")) { if (--index < 0) { for (n = 0; n < z->nrmotions; n++) { if (0 == strcmp (z->rmotion[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nrmotions) { return cgi_add_posit((void *)&z->rmotion[index], label, index + 1, z->rmotion[index].id); } } else if (0 == strcmp (label, "ArbitraryGridMotion_t")) { if (--index < 0) { for (n = 0; n < z->namotions; n++) { if (0 == strcmp (z->amotion[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->namotions) { return cgi_add_posit((void *)&z->amotion[index], label, index + 1, z->amotion[index].id); } } else if (0 == strcmp (label, "ZoneGridConnectivity_t")) { if (--index < 0) { for (n = 0; n < z->nzconn; n++) { if (0 == strcmp (z->zconn[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nzconn) { return cgi_add_posit((void *)&z->zconn[index], label, index + 1, z->zconn[index].id); } } else if (0 == strcmp (label, "ZoneBC_t")) { if (z->zboco && (index == 1 || 0 == strcmp (z->zboco->name, name))) { return cgi_add_posit((void *)z->zboco, label, 1, z->zboco->id); } } else if (0 == strcmp (label, "DiscreteData_t")) { if (--index < 0) { for (n = 0; n < z->ndiscrete; n++) { if (0 == strcmp (z->discrete[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->ndiscrete) { return cgi_add_posit((void *)&z->discrete[index], label, index + 1, z->discrete[index].id); } } else if (0 == strcmp (label, "FlowEquationSet_t")) { if (z->equations && (index == 1 || 0 == strcmp (z->equations->name, name))) { return cgi_add_posit((void *)z->equations, label, 1, z->equations->id); } } else if (0 == strcmp (label, "ConvergenceHistory_t")) { if (z->converg && (index == 1 || 0 == strcmp (z->converg->name, name))) { return cgi_add_posit((void *)z->converg, label, 1, z->converg->id); } } else if (0 == strcmp (label, "IntegralData_t")) { if (--index < 0) { for (n = 0; n < z->nintegrals; n++) { if (0 == strcmp (z->integral[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nintegrals) { return cgi_add_posit((void *)&z->integral[index], label, index + 1, z->integral[index].id); } } else if (0 == strcmp (label, "ReferenceState_t")) { if (z->state && (index == 1 || 0 == strcmp (z->state->name, name))) { return cgi_add_posit((void *)z->state, label, 1, z->state->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < z->nuser_data; n++) { if (0 == strcmp (z->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nuser_data) { return cgi_add_posit((void *)&z->user_data[index], label, index + 1, z->user_data[index].id); } } else if (0 == strcmp (label, "RotatingCoordinates_t")) { if (z->rotating && (index == 1 || 0 == strcmp (z->rotating->name, name))) { return cgi_add_posit((void *)z->rotating, label, 1, z->rotating->id); } } else if (0 == strcmp (label, "ZoneSubRegion_t")) { if (--index < 0) { for (n = 0; n < z->nsubreg; n++) { if (0 == strcmp (z->subreg[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nsubreg) { return cgi_add_posit((void *)&z->subreg[index], label, index + 1, z->subreg[index].id); } } else return CG_INCORRECT_PATH; } /* ParticleZone_t*/ else if (0 == strcmp (posit->label, "ParticleZone_t")) { cgns_pzone *p = (cgns_pzone *)posit->posit; if (0 == strcmp (label, "ParticleCoordinates_t")) { if (--index < 0) { for (n = 0; n < p->npcoor; n++) { if (0 == strcmp (p->pcoor[n].name, name)) { index = n; break; } } } if (index >= 0 && index < p->npcoor) { return cgi_add_posit((void *)&p->pcoor[index], label, index + 1, p->pcoor[index].id); } } else if (0 == strcmp (label, "ParticleIterativeData_t")) { if (p->piter && (index == 1 || 0 == strcmp (p->piter->name, name))) { return cgi_add_posit((void *)p->piter, label, 1, p->piter->id); } } else if (0 == strcmp (label, "ParticleSolution_t")) { if (--index < 0) { for (n = 0; n < p->nsols; n++) { if (0 == strcmp (p->sol[n].name, name)) { index = n; break; } } } if (index >= 0 && index < p->nsols) { return cgi_add_posit((void *)&p->sol[index], label, index + 1, p->sol[index].id); } } else if (0 == strcmp (label, "ParticleEquationSet_t")) { if (p->equations && (index == 1 || 0 == strcmp (p->equations->name, name))) { return cgi_add_posit((void *)p->equations, label, 1, p->equations->id); } } else if (0 == strcmp (label, "IntegralData_t")) { if (--index < 0) { for (n = 0; n < p->nintegrals; n++) { if (0 == strcmp (p->integral[n].name, name)) { index = n; break; } } } if (index >= 0 && index < p->nintegrals) { return cgi_add_posit((void *)&p->integral[index], label, index + 1, p->integral[index].id); } } else if (0 == strcmp (label, "ReferenceState_t")) { if (p->state && (index == 1 || 0 == strcmp (p->state->name, name))) { return cgi_add_posit((void *)p->state, label, 1, p->state->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < p->nuser_data; n++) { if (0 == strcmp (p->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < p->nuser_data) { return cgi_add_posit((void *)&p->user_data[index], label, index + 1, p->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* GridCoordinates_t */ else if (0 == strcmp (posit->label, "GridCoordinates_t")) { cgns_zcoor *z = (cgns_zcoor *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < z->ncoords; n++) { if (0 == strcmp (z->coord[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->ncoords) { return cgi_add_posit((void *)&z->coord[index], label, index + 1, z->coord[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < z->nuser_data; n++) { if (0 == strcmp (z->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nuser_data) { return cgi_add_posit((void *)&z->user_data[index], label, index + 1, z->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ParticleCoordinates_t */ else if (0 == strcmp (posit->label, "ParticleCoordinates_t")) { cgns_pcoor *p = (cgns_pcoor *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < p->ncoords; n++) { if (0 == strcmp (p->coord[n].name, name)) { index = n; break; } } } if (index >= 0 && index < p->ncoords) { return cgi_add_posit((void *)&p->coord[index], label, index + 1, p->coord[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < p->nuser_data; n++) { if (0 == strcmp (p->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < p->nuser_data) { return cgi_add_posit((void *)&p->user_data[index], label, index + 1, p->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* FlowSolution_t */ else if (0 == strcmp (posit->label, "FlowSolution_t")) { cgns_sol *s = (cgns_sol *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < s->nfields; n++) { if (0 == strcmp (s->field[n].name, name)) { index = n; break; } } } if (index >= 0 && index < s->nfields) { return cgi_add_posit((void *)&s->field[index], label, index + 1, s->field[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < s->nuser_data; n++) { if (0 == strcmp (s->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < s->nuser_data) { return cgi_add_posit((void *)&s->user_data[index], label, index + 1, s->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ParticleSolution_t */ else if (0 == strcmp (posit->label, "ParticleSolution_t")) { cgns_psol *s = (cgns_psol *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < s->nfields; n++) { if (0 == strcmp (s->field[n].name, name)) { index = n; break; } } } if (index >= 0 && index < s->nfields) { return cgi_add_posit((void *)&s->field[index], label, index + 1, s->field[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < s->nuser_data; n++) { if (0 == strcmp (s->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < s->nuser_data) { return cgi_add_posit((void *)&s->user_data[index], label, index + 1, s->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ZoneGridConnectivity_t */ else if (0 == strcmp (posit->label, "ZoneGridConnectivity_t")) { cgns_zconn *z = (cgns_zconn *)posit->posit; if (0 == strcmp (label, "OversetHoles_t")) { if (--index < 0) { for (n = 0; n < z->nholes; n++) { if (0 == strcmp (z->hole[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nholes) { return cgi_add_posit((void *)&z->hole[index], label, index + 1, z->hole[index].id); } } else if (0 == strcmp (label, "GridConnectivity_t")) { if (--index < 0) { for (n = 0; n < z->nconns; n++) { if (0 == strcmp (z->conn[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nconns) { return cgi_add_posit((void *)&z->conn[index], label, index + 1, z->conn[index].id); } } else if (0 == strcmp (label, "GridConnectivity1to1_t")) { if (--index < 0) { for (n = 0; n < z->n1to1; n++) { if (0 == strcmp (z->one21[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->n1to1) { return cgi_add_posit((void *)&z->one21[index], label, index + 1, z->one21[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < z->nuser_data; n++) { if (0 == strcmp (z->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nuser_data) { return cgi_add_posit((void *)&z->user_data[index], label, index + 1, z->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* OversetHoles_t */ else if (0 == strcmp (posit->label, "OversetHoles_t")) { cgns_hole *h = (cgns_hole *)posit->posit; if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < h->nuser_data; n++) { if (0 == strcmp (h->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < h->nuser_data) { return cgi_add_posit((void *)&h->user_data[index], label, index + 1, h->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* GridConnectivity_t */ else if (0 == strcmp (posit->label, "GridConnectivity_t")) { cgns_conn *c = (cgns_conn *)posit->posit; if (0 == strcmp (label, "GridConnectivityProperty_t")) { if (c->cprop && (index == 1 || 0 == strcmp (c->cprop->name, name))) { return cgi_add_posit((void *)c->cprop, label, 1, c->cprop->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < c->nuser_data; n++) { if (0 == strcmp (c->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < c->nuser_data) { return cgi_add_posit((void *)&c->user_data[index], label, index + 1, c->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* GridConnectivity1to1_t */ else if (0 == strcmp (posit->label, "GridConnectivity1to1_t")) { cgns_1to1 *c = (cgns_1to1 *)posit->posit; if (0 == strcmp (label, "GridConnectivityProperty_t")) { if (c->cprop && (index == 1 || 0 == strcmp (c->cprop->name, name))) { return cgi_add_posit((void *)c->cprop, label, 1, c->cprop->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < c->nuser_data; n++) { if (0 == strcmp (c->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < c->nuser_data) { return cgi_add_posit((void *)&c->user_data[index], label, index + 1, c->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ZoneBC_t */ else if (0 == strcmp (posit->label, "ZoneBC_t")) { cgns_zboco *z = (cgns_zboco *)posit->posit; if (0 == strcmp (label, "BC_t")) { if (--index < 0) { for (n = 0; n < z->nbocos; n++) { if (0 == strcmp (z->boco[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nbocos) { return cgi_add_posit((void *)&z->boco[index], label, index + 1, z->boco[index].id); } } else if (0 == strcmp (label, "ReferenceState_t")) { if (z->state && (index == 1 || 0 == strcmp (z->state->name, name))) { return cgi_add_posit((void *)z->state, label, 1, z->state->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < z->nuser_data; n++) { if (0 == strcmp (z->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nuser_data) { return cgi_add_posit((void *)&z->user_data[index], label, index + 1, z->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* BC_t */ else if (0 == strcmp (posit->label, "BC_t")) { cgns_boco *b = (cgns_boco *)posit->posit; if (0 == strcmp (label, "BCDataSet_t")) { if (--index < 0) { for (n = 0; n < b->ndataset; n++) { if (0 == strcmp (b->dataset[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->ndataset) { return cgi_add_posit((void *)&b->dataset[index], label, index + 1, b->dataset[index].id); } } else if (0 == strcmp (label, "BCProperty_t")) { if (b->bprop && (index == 1 || 0 == strcmp (b->bprop->name, name))) { return cgi_add_posit((void *)b->bprop, label, 1, b->bprop->id); } } else if (0 == strcmp (label, "ReferenceState_t")) { if (b->state && (index == 1 || 0 == strcmp (b->state->name, name))) { return cgi_add_posit((void *)b->state, label, 1, b->state->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < b->nuser_data; n++) { if (0 == strcmp (b->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->nuser_data) { return cgi_add_posit((void *)&b->user_data[index], label, index + 1, b->user_data[index].id); } } else if (0 == strcmp (label, "IndexArray_t")) { if (b->ptset && (index == 1 || 0 == strcmp (b->ptset->name, name))) { return cgi_add_posit((void *)b->ptset, label, 1, b->ptset->id); } } else return CG_INCORRECT_PATH; } /* BCDataSet_t and FamilyBCDataSet_t */ else if (0 == strcmp (posit->label, "BCDataSet_t") || 0 == strcmp (posit->label, "FamilyBCDataSet_t")) { cgns_dataset *d = (cgns_dataset *)posit->posit; if (0 == strcmp (label, "BCData_t")) { if (d->dirichlet && (index == CGNS_ENUMV(Dirichlet) || 0 == strcmp (d->dirichlet->name, name))) { return cgi_add_posit((void *)d->dirichlet, label, 1, d->dirichlet->id); } if (d->neumann && (index == CGNS_ENUMV(Neumann) || 0 == strcmp (d->neumann->name, name))) { return cgi_add_posit((void *)d->neumann, label, 1, d->neumann->id); } } else if (0 == strcmp (label, "ReferenceState_t")) { if (d->state && (index == 1 || 0 == strcmp (d->state->name, name))) { return cgi_add_posit((void *)d->state, label, 1, d->state->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < d->nuser_data; n++) { if (0 == strcmp (d->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < d->nuser_data) { return cgi_add_posit((void *)&d->user_data[index], label, index + 1, d->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* BCData_t */ else if (0 == strcmp (posit->label, "BCData_t")) { cgns_bcdata *b = (cgns_bcdata *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < b->narrays; n++) { if (0 == strcmp (b->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->narrays) { return cgi_add_posit((void *)&b->array[index], label, index + 1, b->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < b->nuser_data; n++) { if (0 == strcmp (b->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->nuser_data) { return cgi_add_posit((void *)&b->user_data[index], label, index + 1, b->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* DiscreteData_t */ else if (0 == strcmp (posit->label, "DiscreteData_t")) { cgns_discrete *d = (cgns_discrete *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < d->narrays; n++) { if (0 == strcmp (d->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < d->narrays) { return cgi_add_posit((void *)&d->array[index], label, index + 1, d->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < d->nuser_data; n++) { if (0 == strcmp (d->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < d->nuser_data) { return cgi_add_posit((void *)&d->user_data[index], label, index + 1, d->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* FlowEquationSet_t */ else if (0 == strcmp (posit->label, "FlowEquationSet_t")) { cgns_equations *e = (cgns_equations *)posit->posit; if (0 == strcmp (label, "GoverningEquations_t")) { if (e->governing && (index == 1 || 0 == strcmp (e->governing->name, name))) { return cgi_add_posit((void *)e->governing, label, 1, e->governing->id); } } else if (0 == strcmp (label, "GasModel_t")) { if (e->gas && (index == 1 || 0 == strcmp (e->gas->name, name))) { return cgi_add_posit((void *)e->gas, label, 1, e->gas->id); } } else if (0 == strcmp (label, "ViscosityModel_t")) { if (e->visc && (index == 1 || 0 == strcmp (e->visc->name, name))) { return cgi_add_posit((void *)e->visc, label, 1, e->visc->id); } } else if (0 == strcmp (label, "ThermalConductivityModel_t")) { if (e->conduct && (index == 1 || 0 == strcmp (e->conduct->name, name))) { return cgi_add_posit((void *)e->conduct, label, 1, e->conduct->id); } } else if (0 == strcmp (label, "TurbulenceModel_t")) { if (e->turbulence && (index == 1 || 0 == strcmp (e->turbulence->name, name))) { return cgi_add_posit((void *)e->turbulence, label, 1, e->turbulence->id); } } else if (0 == strcmp (label, "TurbulenceClosure_t")) { if (e->closure && (index == 1 || 0 == strcmp (e->closure->name, name))) { return cgi_add_posit((void *)e->closure, label, 1, e->closure->id); } } else if (0 == strcmp (label, "ThermalRelaxationModel_t")) { if (e->relaxation && (index == 1 || 0 == strcmp (e->relaxation->name, name))) { return cgi_add_posit((void *)e->relaxation, label, 1, e->relaxation->id); } } else if (0 == strcmp (label, "ChemicalKineticsModel_t")) { if (e->chemkin && (index == 1 || 0 == strcmp (e->chemkin->name, name))) { return cgi_add_posit((void *)e->chemkin, label, 1, e->chemkin->id); } } else if (0 == strcmp (label, "EMConductivityModel_t")) { if (e->emconduct && (index == 1 || 0 == strcmp (e->emconduct->name, name))) { return cgi_add_posit((void *)e->emconduct, label, 1, e->emconduct->id); } } else if (0 == strcmp (label, "EMElectricFieldModel_t")) { if (e->elecfield && (index == 1 || 0 == strcmp (e->elecfield->name, name))) { return cgi_add_posit((void *)e->elecfield, label, 1, e->elecfield->id); } } else if (0 == strcmp (label, "EMMagneticFieldModel_t")) { if (e->magnfield && (index == 1 || 0 == strcmp (e->magnfield->name, name))) { return cgi_add_posit((void *)e->magnfield, label, 1, e->magnfield->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < e->nuser_data; n++) { if (0 == strcmp (e->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < e->nuser_data) { return cgi_add_posit((void *)&e->user_data[index], label, index + 1, e->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* GoverningEquations_t */ else if (0 == strcmp (posit->label, "GoverningEquations_t")) { cgns_governing *g = (cgns_governing *)posit->posit; if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < g->nuser_data; n++) { if (0 == strcmp (g->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < g->nuser_data) { return cgi_add_posit((void *)&g->user_data[index], label, index + 1, g->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* GasModel_t */ /* ViscosityModel_t */ /* ThermalConductivityModel_t */ /* TurbulenceModel_t */ /* TurbulenceClosure_t */ /* ThermalRelaxationModel_t */ /* ChemicalKineticsModel_t */ /* EMConductivityModel_t */ /* EMElectricFieldModel_t */ /* EMMagneticFieldModel_t */ else if (0 == strcmp (posit->label, "GasModel_t") || 0 == strcmp (posit->label, "ViscosityModel_t") || 0 == strcmp (posit->label, "ThermalConductivityModel_t") || 0 == strcmp (posit->label, "TurbulenceModel_t") || 0 == strcmp (posit->label, "TurbulenceClosure_t") || 0 == strcmp (posit->label, "ThermalRelaxationModel_t") || 0 == strcmp (posit->label, "ChemicalKineticsModel_t") || 0 == strcmp (posit->label, "EMConductivityModel_t") || 0 == strcmp (posit->label, "EMElectricFieldModel_t") || 0 == strcmp (posit->label, "EMMagneticFieldModel_t")) { cgns_model *m = (cgns_model *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < m->narrays; n++) { if (0 == strcmp (m->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < m->narrays) { return cgi_add_posit((void *)&m->array[index], label, index + 1, m->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < m->nuser_data; n++) { if (0 == strcmp (m->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < m->nuser_data) { return cgi_add_posit((void *)&m->user_data[index], label, index + 1, m->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ParticleEquationSet_t */ else if (0 == strcmp (posit->label, "ParticleEquationSet_t")) { cgns_pequations *e = (cgns_pequations *)posit->posit; if (0 == strcmp (label, "ParticleGoverningEquations_t")) { if (e->governing && (index == 1 || 0 == strcmp (e->governing->name, name))) { return cgi_add_posit((void *)e->governing, label, 1, e->governing->id); } } else if (0 == strcmp (label, "ParticleCollisionModel_t")) { if (e->collision && (index == 1 || 0 == strcmp (e->collision->name, name))) { return cgi_add_posit((void *)e->collision, label, 1, e->collision->id); } } else if (0 == strcmp (label, "ParticleBreakupModel_t")) { if (e->breakup && (index == 1 || 0 == strcmp (e->breakup->name, name))) { return cgi_add_posit((void *)e->breakup, label, 1, e->breakup->id); } } else if (0 == strcmp (label, "ParticleForceModel_t")) { if (e->force && (index == 1 || 0 == strcmp (e->force->name, name))) { return cgi_add_posit((void *)e->force, label, 1, e->force->id); } } else if (0 == strcmp (label, "ParticleWallInteractionModel_t")) { if (e->wallinteract && (index == 1 || 0 == strcmp (e->wallinteract->name, name))) { return cgi_add_posit((void *)e->wallinteract, label, 1, e->wallinteract->id); } } else if (0 == strcmp (label, "ParticlePhaseChangeModel_t")) { if (e->phasechange && (index == 1 || 0 == strcmp (e->phasechange->name, name))) { return cgi_add_posit((void *)e->phasechange, label, 1, e->phasechange->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < e->nuser_data; n++) { if (0 == strcmp (e->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < e->nuser_data) { return cgi_add_posit((void *)&e->user_data[index], label, index + 1, e->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ParticleGoverningEquations_t */ else if (0 == strcmp (posit->label, "ParticleGoverningEquations_t")) { cgns_pgoverning *g = (cgns_pgoverning *)posit->posit; if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < g->nuser_data; n++) { if (0 == strcmp (g->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < g->nuser_data) { return cgi_add_posit((void *)&g->user_data[index], label, index + 1, g->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ParticleCollisionModel_t */ /* ParticleBreakupModel_t */ /* ParticleForceModel_t */ /* ParticleWallInteractionModel_t */ /* ParticlePhaseChangeModel_t */ else if (0 == strcmp (posit->label, "ParticleCollisionModel_t") || 0 == strcmp (posit->label, "ParticleBreakupModel_t") || 0 == strcmp (posit->label, "ParticleForceModel_t") || 0 == strcmp (posit->label, "ParticleWallInteractionModel_t") || 0 == strcmp (posit->label, "ParticlePhaseChangeModel_t")) { cgns_pmodel *m = (cgns_pmodel *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < m->narrays; n++) { if (0 == strcmp (m->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < m->narrays) { return cgi_add_posit((void *)&m->array[index], label, index + 1, m->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < m->nuser_data; n++) { if (0 == strcmp (m->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < m->nuser_data) { return cgi_add_posit((void *)&m->user_data[index], label, index + 1, m->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ConvergenceHistory_t */ else if (0 == strcmp (posit->label, "ConvergenceHistory_t")) { cgns_converg *c = (cgns_converg *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < c->narrays; n++) { if (0 == strcmp (c->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < c->narrays) { return cgi_add_posit((void *)&c->array[index], label, index + 1, c->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < c->nuser_data; n++) { if (0 == strcmp (c->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < c->nuser_data) { return cgi_add_posit((void *)&c->user_data[index], label, index + 1, c->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* IntegralData_t */ else if (0 == strcmp (posit->label, "IntegralData_t")) { cgns_integral *i = (cgns_integral *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < i->narrays; n++) { if (0 == strcmp (i->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < i->narrays) { return cgi_add_posit((void *)&i->array[index], label, index + 1, i->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < i->nuser_data; n++) { if (0 == strcmp (i->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < i->nuser_data) { return cgi_add_posit((void *)&i->user_data[index], label, index + 1, i->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ReferenceState_t */ else if (0 == strcmp (posit->label, "ReferenceState_t")) { cgns_state *s = (cgns_state *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < s->narrays; n++) { if (0 == strcmp (s->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < s->narrays) { return cgi_add_posit((void *)&s->array[index], label, index + 1, s->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < s->nuser_data; n++) { if (0 == strcmp (s->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < s->nuser_data) { return cgi_add_posit((void *)&s->user_data[index], label, index + 1, s->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* Elements_t */ else if (0 == strcmp (posit->label, "Elements_t")) { cgns_section *s = (cgns_section *)posit->posit; if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < s->nuser_data; n++) { if (0 == strcmp (s->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < s->nuser_data) { return cgi_add_posit((void *)&s->user_data[index], label, index + 1, s->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* Family_t */ else if (0 == strcmp (posit->label, "Family_t")) { cgns_family *f = (cgns_family *)posit->posit; if (0 == strcmp (label, "GeometryReference_t")) { if (--index < 0) { for (n = 0; n < f->ngeos; n++) { if (0 == strcmp (f->geo[n].name, name)) { index = n; break; } } } if (index >= 0 && index < f->ngeos) { return cgi_add_posit((void *)&f->geo[index], label, index + 1, f->geo[index].id); } } else if (0 == strcmp (label, "FamilyBC_t")) { if (--index < 0) { for (n = 0; n < f->nfambc; n++) { if (0 == strcmp (f->fambc[n].name, name)) { index = n; break; } } } if (index >= 0 && index < f->nfambc) { return cgi_add_posit((void *)&f->fambc[index], label, index + 1, f->fambc[index].id); } } else if (0 == strcmp (label, "RotatingCoordinates_t")) { if (f->rotating && (index == 1 || 0 == strcmp (f->rotating->name, name))) { return cgi_add_posit((void *)f->rotating, label, 1, f->rotating->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < f->nuser_data; n++) { if (0 == strcmp (f->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < f->nuser_data) { return cgi_add_posit((void *)&f->user_data[index], label, index + 1, f->user_data[index].id); } } /* ** FAMILY TREE ** */ else if (0 == strcmp (label, "Family_t")) { if (--index < 0) { for (n = 0; n < f->nfamilies; n++) { if (0 == strcmp (f->family[n].name, name)) { index = n; break; } } } if (index >= 0 && index < f->nfamilies) { return cgi_add_posit((void *)&f->family[index], label, index + 1, f->family[index].id); } } else return CG_INCORRECT_PATH; } /* GeometryReference_t */ else if (0 == strcmp (posit->label, "GeometryReference_t")) { cgns_geo *g = (cgns_geo *)posit->posit; if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < g->nuser_data; n++) { if (0 == strcmp (g->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < g->nuser_data) { return cgi_add_posit((void *)&g->user_data[index], label, index + 1, g->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* FamilyBC_t */ else if (0 == strcmp (posit->label, "FamilyBC_t")) { cgns_fambc *f = (cgns_fambc *)posit->posit; if (0 == strcmp (label, "FamilyBCDataSet_t") || /* backwards compatibility */ 0 == strcmp (label, "BCDataSet_t")) { if (--index < 0) { for (n = 0; n < f->ndataset; n++) { if (0 == strcmp (f->dataset[n].name, name)) { index = n; break; } } } if (index >= 0 && index < f->ndataset) { return cgi_add_posit((void *)&f->dataset[index], "FamilyBCDataSet_t", index + 1, f->dataset[index].id); } } else return CG_INCORRECT_PATH; } /* RigidGridMotion_t */ else if (0 == strcmp (posit->label, "RigidGridMotion_t")) { cgns_rmotion *m = (cgns_rmotion *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < m->narrays; n++) { if (0 == strcmp (m->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < m->narrays) { return cgi_add_posit((void *)&m->array[index], label, index + 1, m->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < m->nuser_data; n++) { if (0 == strcmp (m->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < m->nuser_data) { return cgi_add_posit((void *)&m->user_data[index], label, index + 1, m->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ArbitraryGridMotion_t */ else if (0 == strcmp (posit->label, "ArbitraryGridMotion_t")) { cgns_amotion *m = (cgns_amotion *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < m->narrays; n++) { if (0 == strcmp (m->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < m->narrays) { return cgi_add_posit((void *)&m->array[index], label, index + 1, m->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < m->nuser_data; n++) { if (0 == strcmp (m->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < m->nuser_data) { return cgi_add_posit((void *)&m->user_data[index], label, index + 1, m->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* BaseIterativeData_t */ else if (0 == strcmp (posit->label, "BaseIterativeData_t")) { cgns_biter *b = (cgns_biter *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < b->narrays; n++) { if (0 == strcmp (b->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->narrays) { return cgi_add_posit((void *)&b->array[index], label, index + 1, b->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < b->nuser_data; n++) { if (0 == strcmp (b->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->nuser_data) { return cgi_add_posit((void *)&b->user_data[index], label, index + 1, b->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ZoneIterativeData_t and ParticleIterativeData_t*/ else if (0 == strcmp (posit->label, "ZoneIterativeData_t") || 0 == strcmp (posit->label, "ParticleIterativeData_t")) { cgns_ziter *z = (cgns_ziter *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < z->narrays; n++) { if (0 == strcmp (z->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->narrays) { return cgi_add_posit((void *)&z->array[index], label, index + 1, z->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < z->nuser_data; n++) { if (0 == strcmp (z->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < z->nuser_data) { return cgi_add_posit((void *)&z->user_data[index], label, index + 1, z->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* UserDefinedData_t */ else if (0 == strcmp (posit->label, "UserDefinedData_t")) { cgns_user_data *u = (cgns_user_data *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < u->narrays; n++) { if (0 == strcmp (u->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < u->narrays) { return cgi_add_posit((void *)&u->array[index], label, index + 1, u->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < u->nuser_data; n++) { if (0 == strcmp (u->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < u->nuser_data) { return cgi_add_posit((void *)&u->user_data[index], label, index + 1, u->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* Gravity_t */ else if (0 == strcmp (posit->label, "Gravity_t")) { cgns_gravity *g = (cgns_gravity *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < g->narrays; n++) { if (0 == strcmp (g->vector[n].name, name)) { index = n; break; } } } if (index >= 0 && index < g->narrays) { return cgi_add_posit((void *)&g->vector[index], label, index + 1, g->vector[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < g->nuser_data; n++) { if (0 == strcmp (g->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < g->nuser_data) { return cgi_add_posit((void *)&g->user_data[index], label, index + 1, g->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* Axisymmetry_t */ else if (0 == strcmp (posit->label, "Axisymmetry_t")) { cgns_axisym *a = (cgns_axisym *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < a->narrays; n++) { if (0 == strcmp (a->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < a->narrays) { return cgi_add_posit((void *)&a->array[index], label, index + 1, a->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < a->nuser_data; n++) { if (0 == strcmp (a->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < a->nuser_data) { return cgi_add_posit((void *)&a->user_data[index], label, index + 1, a->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* RotatingCoordinates_t */ else if (0 == strcmp (posit->label, "RotatingCoordinates_t")) { cgns_rotating *r = (cgns_rotating *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < r->narrays; n++) { if (0 == strcmp (r->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < r->narrays) { return cgi_add_posit((void *)&r->array[index], label, index + 1, r->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < r->nuser_data; n++) { if (0 == strcmp (r->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < r->nuser_data) { return cgi_add_posit((void *)&r->user_data[index], label, index + 1, r->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* BCProperty_t */ else if (0 == strcmp (posit->label, "BCProperty_t")) { cgns_bprop *b = (cgns_bprop *)posit->posit; if (0 == strcmp (label, "WallFunction_t")) { if (b->bcwall && (index == 1 || 0 == strcmp (b->bcwall->name, name))) { return cgi_add_posit((void *)b->bcwall, label, 1, b->bcwall->id); } } else if (0 == strcmp (label, "Area_t")) { if (b->bcarea && (index == 1 || 0 == strcmp (b->bcarea->name, name))) { return cgi_add_posit((void *)b->bcarea, label, 1, b->bcarea->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < b->nuser_data; n++) { if (0 == strcmp (b->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < b->nuser_data) { return cgi_add_posit((void *)&b->user_data[index], label, index + 1, b->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* WallFunction_t */ else if (0 == strcmp (posit->label, "WallFunction_t")) { cgns_bcwall *w = (cgns_bcwall *)posit->posit; if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < w->nuser_data; n++) { if (0 == strcmp (w->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < w->nuser_data) { return cgi_add_posit((void *)&w->user_data[index], label, index + 1, w->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* Area_t */ else if (0 == strcmp (posit->label, "Area_t")) { cgns_bcarea *a = (cgns_bcarea *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < a->narrays; n++) { if (0 == strcmp (a->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < a->narrays) { return cgi_add_posit((void *)&a->array[index], label, index + 1, a->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < a->nuser_data; n++) { if (0 == strcmp (a->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < a->nuser_data) { return cgi_add_posit((void *)&a->user_data[index], label, index + 1, a->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* GridConnectivityProperty_t */ else if (0 == strcmp (posit->label, "GridConnectivityProperty_t")) { cgns_cprop *c = (cgns_cprop *)posit->posit; if (0 == strcmp (label, "Periodic_t")) { if (c->cperio && (index == 1 || 0 == strcmp (c->cperio->name, name))) { return cgi_add_posit((void *)c->cperio, label, 1, c->cperio->id); } } else if (0 == strcmp (label, "AverageInterface_t")) { if (c->caverage && (index == 1 || 0 == strcmp (c->caverage->name, name))) { return cgi_add_posit((void *)c->caverage, label, 1, c->caverage->id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < c->nuser_data; n++) { if (0 == strcmp (c->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < c->nuser_data) { return cgi_add_posit((void *)&c->user_data[index], label, index + 1, c->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* Periodic_t */ else if (0 == strcmp (posit->label, "Periodic_t")) { cgns_cperio *p = (cgns_cperio *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < p->narrays; n++) { if (0 == strcmp (p->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < p->narrays) { return cgi_add_posit((void *)&p->array[index], label, index + 1, p->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < p->nuser_data; n++) { if (0 == strcmp (p->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < p->nuser_data) { return cgi_add_posit((void *)&p->user_data[index], label, index + 1, p->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* AverageInterface_t */ else if (0 == strcmp (posit->label, "AverageInterface_t")) { cgns_caverage *a = (cgns_caverage *)posit->posit; if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < a->nuser_data; n++) { if (0 == strcmp (a->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < a->nuser_data) { return cgi_add_posit((void *)&a->user_data[index], label, index + 1, a->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* ZoneSubRegion_t */ else if (0 == strcmp (posit->label, "ZoneSubRegion_t")) { cgns_subreg *r = (cgns_subreg *)posit->posit; if (0 == strcmp (label, "DataArray_t")) { if (--index < 0) { for (n = 0; n < r->narrays; n++) { if (0 == strcmp (r->array[n].name, name)) { index = n; break; } } } if (index >= 0 && index < r->narrays) { return cgi_add_posit((void *)&r->array[index], label, index + 1, r->array[index].id); } } else if (0 == strcmp (label, "UserDefinedData_t")) { if (--index < 0) { for (n = 0; n < r->nuser_data; n++) { if (0 == strcmp (r->user_data[n].name, name)) { index = n; break; } } } if (index >= 0 && index < r->nuser_data) { return cgi_add_posit((void *)&r->user_data[index], label, index + 1, r->user_data[index].id); } } else return CG_INCORRECT_PATH; } /* invalid */ else return CG_INCORRECT_PATH; return CG_NODE_NOT_FOUND; } int cgi_update_posit(int cnt, int *index, char **label) { int n, ierr; double pid, id; char lab[33], name[33]; if (posit == 0) { cgi_error("goto position not set"); return CG_ERROR; } for (n = 0; n < cnt; n++) { if (index[n] > 0) { strcpy(lab, label[n]); *name = 0; } else if (0 == strcmp(label[n], ".")) { continue; } else if (0 == strcmp(label[n], "..")) { if (posit_depth == 1) { cgi_error("can't go up beyond CGNSBase_t node"); posit = 0; return CG_ERROR; } if (0 == strcmp(posit->label, "Zone_t")) posit_zone = 0; posit_depth--; posit = &posit_stack[posit_depth-1]; continue; } else { if (cgi_posit_id (&pid)) { posit = 0; return CG_ERROR; } strcpy(name, label[n]); if (cgio_get_node_id(cg->cgio, pid, name, &id)) { posit = 0; cgi_error ("goto path not found"); return CG_NODE_NOT_FOUND; } if (cgio_get_label(cg->cgio, id, lab)) { posit = 0; cg_io_error("cgio_get_label"); return CG_ERROR; } } ierr = cgi_next_posit(lab, index[n], name); if (ierr) { if (ierr == CG_INCORRECT_PATH) { cgi_error("can't go to label '%s' under '%s'", lab, posit->label); } if (ierr == CG_NODE_NOT_FOUND) { if (index[n] > 0) cgi_error("index %d, label '%s' not a child of '%s'", index[n], lab, posit->label); else cgi_error("node '%s' not a child of '%s'", name, posit->label); } posit = 0; return ierr; } } return CG_OK; } int cgi_set_posit(int fn, int B, int n, int *index, char **label) { cgns_base *base; /* initialize */ posit = 0; posit_file = posit_base = posit_zone = posit_depth = 0; /* get file pointer */ cg = cgi_get_file(fn); if (cg == 0) return CG_OK; base = cgi_get_base(cg, B); if (base == 0) return CG_NODE_NOT_FOUND; posit_file = fn; posit_base = B; cgi_add_posit((void *)base, "CGNSBase_t", B, base->id); return cgi_update_posit(n, index, label); } int cgi_posit_id(double *posit_id) { /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return CG_ERROR; } *posit_id = posit->id; return CG_OK; } cgns_posit *cgi_get_posit() { /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return NULL; } return posit; } int cgi_posit_index_dim() { if (posit_base) { if (posit_zone) return cg->base[posit_base-1].zone[posit_zone-1].index_dim; return cg->base[posit_base-1].cell_dim; } return CG_OK; } /* All cgi_xxxxx_address functions return the memory address of the given *\ * xxxxx data structure, depending on the parent pointed to by cg_goto. * \* All possible parents of a given data structure must be represented. */ cgns_descr *cgi_descr_address(int local_mode, int given_no, char const *given_name, int *ier) { cgns_descr *descr=0; int n, allow_dup=0, error1=0, error2=0; double parent_id=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of Descriptor_t node: * CGNSBase_t, Zone_t, GridCoordinates_t, Elements_t, FlowSolution_t, * DiscreteData_t, ZoneGridConnectivity_t, GridConnectivity1to1_t, * GridConnectivity_t, OversetHoles_t, ZoneBC_t, BC_t, BCDataSet_t, * BCData_t, FlowEquationSet_t, GoverningEquations_t, GasModel_t, * ViscosityModel_t, ThermalConductivityModel_t, TurbulenceClosure_t, * TurbulenceModel_t, ThermalRelaxationModel_t, ChemicalKineticsModel_t, * EMElectricFieldModel_t, EMMagneticFieldModel_t, ParticleCollisionModel_t, * ParticleBreakupModel_t, ParticleForceModel_t, ParticleWallInteractionModel_t, * ParticlePhaseChangeModel_t, ConvergenceHistory_t, IntegralData_t, ReferenceState_t, * DataArray_t, Family_t, GeometryReference_t, RigidGridMotion_t, * ArbitraryGridMotion_t, BaseIterativeData_t, ZoneIterativeData_t, * UserDefinedData_t, Gravity_t, Axisymmetry_t, RotatingCoordinates_t, * BCProperty_t, WallFunction_t, Area_t, * GridConnectivityProperty_t, Periodic_t, AverageInterface_t * FamilyBCDataSet_t, ParticleZone_t, ParticleCoordinates_t, * ParticleSolution_t, ParticleGoverningEquations_t */ if (strcmp(posit->label,"CGNSBase_t")==0) ADDRESS4MULTIPLE(cgns_base, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"Zone_t")==0) ADDRESS4MULTIPLE(cgns_zone, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"GridCoordinates_t")==0) ADDRESS4MULTIPLE(cgns_zcoor, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ParticleCoordinates_t")==0) ADDRESS4MULTIPLE(cgns_pcoor, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"Elements_t")==0) ADDRESS4MULTIPLE(cgns_section, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"FlowSolution_t")==0) ADDRESS4MULTIPLE(cgns_sol, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ParticleSolution_t")==0) ADDRESS4MULTIPLE(cgns_psol, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"DiscreteData_t")==0) ADDRESS4MULTIPLE(cgns_discrete, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ZoneGridConnectivity_t")==0) ADDRESS4MULTIPLE(cgns_zconn, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"GridConnectivity1to1_t")==0) ADDRESS4MULTIPLE(cgns_1to1, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"GridConnectivity_t")==0) ADDRESS4MULTIPLE(cgns_conn, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"OversetHoles_t")==0) ADDRESS4MULTIPLE(cgns_hole, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ZoneBC_t")==0) ADDRESS4MULTIPLE(cgns_zboco, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"BC_t")==0) ADDRESS4MULTIPLE(cgns_boco, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"BCDataSet_t")==0 || strcmp(posit->label,"FamilyBCDataSet_t")==0) ADDRESS4MULTIPLE(cgns_dataset, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"BCData_t")==0) ADDRESS4MULTIPLE(cgns_bcdata, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"FlowEquationSet_t")==0) ADDRESS4MULTIPLE(cgns_equations, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"GoverningEquations_t")==0) ADDRESS4MULTIPLE(cgns_governing, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"GasModel_t")==0 || strcmp(posit->label,"ViscosityModel_t")==0 || strcmp(posit->label,"ThermalConductivityModel_t")==0 || strcmp(posit->label,"TurbulenceModel_t")==0 || strcmp(posit->label,"TurbulenceClosure_t")==0 || strcmp(posit->label,"ThermalRelaxationModel_t")==0 || strcmp(posit->label,"ChemicalKineticsModel_t")==0 || strcmp(posit->label,"EMElectricFieldModel_t")==0 || strcmp(posit->label,"EMMagneticFieldModel_t")==0 || strcmp(posit->label,"EMConductivityModel_t")==0) ADDRESS4MULTIPLE(cgns_model, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ParticleEquationSet_t")==0) ADDRESS4MULTIPLE(cgns_pequations, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ParticleGoverningEquations_t")==0) ADDRESS4MULTIPLE(cgns_pgoverning, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ParticleCollisionModel_t")==0 || strcmp(posit->label,"ParticleBreakupModel_t")==0 || strcmp(posit->label,"ParticleForceModel_t")==0 || strcmp(posit->label,"ParticleWallInteractionModel_t")==0 || strcmp(posit->label,"ParticlePhaseChangeModel_t")==0) ADDRESS4MULTIPLE(cgns_pmodel, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ConvergenceHistory_t")==0) ADDRESS4MULTIPLE(cgns_converg, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"IntegralData_t")==0) ADDRESS4MULTIPLE(cgns_integral, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ReferenceState_t")==0) ADDRESS4MULTIPLE(cgns_state, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"DataArray_t")==0) ADDRESS4MULTIPLE(cgns_array, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"Family_t")==0)/* -- FAMILY TREE -- */ ADDRESS4MULTIPLE(cgns_family, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"GeometryReference_t")==0) ADDRESS4MULTIPLE(cgns_geo, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"RigidGridMotion_t")==0) ADDRESS4MULTIPLE(cgns_rmotion, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) ADDRESS4MULTIPLE(cgns_amotion, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"BaseIterativeData_t")==0) ADDRESS4MULTIPLE(cgns_biter, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ZoneIterativeData_t")==0 || strcmp(posit->label,"ParticleIterativeData_t")==0) ADDRESS4MULTIPLE(cgns_ziter, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"UserDefinedData_t")==0) ADDRESS4MULTIPLE(cgns_user_data, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"Gravity_t")==0) ADDRESS4MULTIPLE(cgns_gravity, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"Axisymmetry_t")==0) ADDRESS4MULTIPLE(cgns_axisym, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"RotatingCoordinates_t")==0) ADDRESS4MULTIPLE(cgns_rotating, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"BCProperty_t")==0) ADDRESS4MULTIPLE(cgns_bprop, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"WallFunction_t")==0) ADDRESS4MULTIPLE(cgns_bcwall, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"Area_t")==0) ADDRESS4MULTIPLE(cgns_bcarea, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"GridConnectivityProperty_t")==0) ADDRESS4MULTIPLE(cgns_cprop, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"Periodic_t")==0) ADDRESS4MULTIPLE(cgns_cperio, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"AverageInterface_t")==0) ADDRESS4MULTIPLE(cgns_caverage, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ZoneSubRegion_t")==0) ADDRESS4MULTIPLE(cgns_subreg, ndescr, descr, cgns_descr) else if (strcmp(posit->label,"ParticleZone_t")==0) ADDRESS4MULTIPLE(cgns_pzone, ndescr, descr, cgns_descr) else { cgi_error("Descriptor_t node not supported under '%s' type node (cgi_descr_address)", posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1) { cgi_error("Duplicate child name found (%s) found under %s", given_name, posit->label); (*ier) = CG_ERROR; return CG_OK; } if (error2) { cgi_error("Descriptor number %d doesn't exist under %s", given_no, posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { /* parent_id!=0 only when overwriting */ if (cgi_delete_node (parent_id, descr->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_descr(descr); } return descr; } char *cgi_famname_address(int local_mode, int *ier) { double *id, parent_id; char *family_name=0; int nnod; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of FamilyName_t node: * Zone_t, BC_t, ZoneSubRegion_t, UserDefinedData_t, * ParticleZone_t */ if (strcmp(posit->label,"Zone_t")==0) { cgns_zone *zone = (cgns_zone *)posit->posit; family_name = zone->family_name; parent_id = zone->id; } else if (strcmp(posit->label,"BC_t")==0) { cgns_boco *boco = (cgns_boco *)posit->posit; family_name = boco->family_name; parent_id = boco->id; } else if (strcmp(posit->label,"UserDefinedData_t")==0) { cgns_user_data *user_data = (cgns_user_data *)posit->posit; family_name = user_data->family_name; parent_id = user_data->id; } else if (strcmp(posit->label,"ZoneSubRegion_t")==0) { cgns_subreg *subreg = (cgns_subreg *)posit->posit; family_name = subreg->family_name; parent_id = subreg->id; } else if (strcmp(posit->label,"ParticleZone_t")==0) { cgns_pzone *pzone = (cgns_pzone *)posit->posit; family_name = pzone->family_name; parent_id = pzone->id; } else { cgi_error("FamilyName_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (cg->mode == CG_MODE_MODIFY && local_mode == CG_MODE_WRITE) { if (cgi_get_nodes(parent_id, "FamilyName_t", &nnod, &id)) {/* -- FAMILY TREE -- */ *ier = CG_ERROR; return CG_OK; } if (nnod>0) { if (cgi_delete_node (parent_id, id[0])) { (*ier) = CG_ERROR; return CG_OK; } CGNS_FREE(id); } } return family_name; } cgns_famname *cgi_multfam_address(int local_mode, int given_no, char const *given_name, int *ier) { cgns_famname *famname=0; int n, allow_dup=0, error1=0, error2=0; double parent_id=0; if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } if (0 == strcmp(posit->label, "Zone_t")) ADDRESS4MULTIPLE(cgns_zone, nfamname, famname, cgns_famname) else if (0 == strcmp(posit->label, "BC_t")) ADDRESS4MULTIPLE(cgns_boco, nfamname, famname, cgns_famname) else if (0 == strcmp(posit->label, "ZoneSubRegion_t")) ADDRESS4MULTIPLE(cgns_subreg, nfamname, famname, cgns_famname) else if (0 == strcmp(posit->label, "UserDefinedData_t")) ADDRESS4MULTIPLE(cgns_user_data, nfamname, famname, cgns_famname) else if (0 == strcmp(posit->label, "Family_t")) /* ** FAMILY TREE ** */ ADDRESS4MULTIPLE(cgns_family, nfamname, famname, cgns_famname) else if (0 == strcmp(posit->label, "ParticleZone_t")) ADDRESS4MULTIPLE(cgns_pzone, nfamname, famname, cgns_famname) else { cgi_error("AdditionalFamilyName_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1) { cgi_error("Duplicate child name found (%s) found under %s", given_name, posit->label); (*ier) = CG_ERROR; return CG_OK; } if (error2) { cgi_error("AdditionalFamilyName index number %d doesn't exist under %s", given_no, posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { /* parent_id!=0 only when overwriting */ if (cgi_delete_node (parent_id, famname->id)) { (*ier) = CG_ERROR; return CG_OK; } } return famname; } CGNS_ENUMV(DataClass_t) *cgi_dataclass_address(int local_mode, int *ier) { double *id, parent_id; CGNS_ENUMV( DataClass_t ) *data_class=0; int nnod; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of DataClass_t node: * CGNSBase_t, Zone_t, GridCoordinates_t, FlowSolution_t, DiscreteData_t, * ZoneBC_t, BC_t, BCDataSet_t, BCData_t, FlowEquationSet_t, GasModel_t, * ViscosityModel_t, ThermalConductivityModel_t, TurbulenceClosure_t, * TurbulenceModel_t, ThermalRelaxationModel_t, ChemicalKineticsModel_t, * EMElectricFieldModel_t, EMMagneticFieldModel_t, ParticleCollisionModel_t, * ParticleBreakupModel_t, ParticleForceModel_t, ParticleWallInteractionModel_t, * ParticlePhaseChangeModel_t, ConvergenceHistory_t, IntegralData_t, ReferenceState_t, * DataArray_t, RigidGridMotion_t, ArbitraryGridMotion_t, BaseIterativeData_t, * ZoneIterativeData_t, UserDefinedData_t, Gravity_t, Axisymmetry_t * RotatingCoordinates_t, Periodic_t, FamilyBCDataSet_t, ParticleZone_t, * ParticleCoordinates_t, ParticleSolution_t, ParticleIterativeData_t */ if (strcmp(posit->label,"CGNSBase_t")==0) ADDRESS4SINGLE_ALLOC(cgns_base, data_class) else if (strcmp(posit->label,"Zone_t")==0) ADDRESS4SINGLE_ALLOC(cgns_zone, data_class) else if (strcmp(posit->label,"GridCoordinates_t")==0) ADDRESS4SINGLE_ALLOC(cgns_zcoor, data_class) else if (strcmp(posit->label,"ParticleCoordinates_t")==0) ADDRESS4SINGLE_ALLOC(cgns_pcoor, data_class) else if (strcmp(posit->label,"FlowSolution_t")==0) ADDRESS4SINGLE_ALLOC(cgns_sol, data_class) else if (strcmp(posit->label,"ParticleSolution_t")==0) ADDRESS4SINGLE_ALLOC(cgns_psol, data_class) else if (strcmp(posit->label,"DiscreteData_t")==0) ADDRESS4SINGLE_ALLOC(cgns_discrete, data_class) else if (strcmp(posit->label,"ZoneBC_t")==0) ADDRESS4SINGLE_ALLOC(cgns_zboco, data_class) else if (strcmp(posit->label,"BC_t")==0) ADDRESS4SINGLE_ALLOC(cgns_boco, data_class) else if (strcmp(posit->label,"BCDataSet_t")==0 || strcmp(posit->label,"FamilyBCDataSet_t")==0) ADDRESS4SINGLE_ALLOC(cgns_dataset, data_class) else if (strcmp(posit->label,"BCData_t")==0) ADDRESS4SINGLE_ALLOC(cgns_bcdata, data_class) else if (strcmp(posit->label,"FlowEquationSet_t")==0) ADDRESS4SINGLE_ALLOC(cgns_equations, data_class) else if (strcmp(posit->label,"GasModel_t")==0 || strcmp(posit->label,"ViscosityModel_t")==0 || strcmp(posit->label,"ThermalConductivityModel_t")==0 || strcmp(posit->label,"TurbulenceModel_t")==0 || strcmp(posit->label,"TurbulenceClosure_t")==0 || strcmp(posit->label,"ThermalRelaxationModel_t")==0 || strcmp(posit->label,"ChemicalKineticsModel_t")==0 || strcmp(posit->label,"EMElectricFieldModel_t")==0 || strcmp(posit->label,"EMMagneticFieldModel_t")==0 || strcmp(posit->label,"EMConductivityModel_t")==0) ADDRESS4SINGLE_ALLOC(cgns_model, data_class) else if (strcmp(posit->label,"ParticleEquationSet_t")==0) ADDRESS4SINGLE_ALLOC(cgns_pequations, data_class) else if (strcmp(posit->label,"ParticleCollisionModel_t")==0 || strcmp(posit->label,"ParticleBreakupModel_t")==0 || strcmp(posit->label,"ParticleForceModel_t")==0 || strcmp(posit->label,"ParticleWallInteractionModel_t")==0 || strcmp(posit->label,"ParticlePhaseChangeModel_t")==0) ADDRESS4SINGLE_ALLOC(cgns_pmodel, data_class) else if (strcmp(posit->label,"ConvergenceHistory_t")==0) ADDRESS4SINGLE_ALLOC(cgns_converg, data_class) else if (strcmp(posit->label,"IntegralData_t")==0) ADDRESS4SINGLE_ALLOC(cgns_integral, data_class) else if (strcmp(posit->label,"ReferenceState_t")==0) ADDRESS4SINGLE_ALLOC(cgns_state, data_class) else if (strcmp(posit->label,"DataArray_t")==0) ADDRESS4SINGLE_ALLOC(cgns_array, data_class) else if (strcmp(posit->label,"RigidGridMotion_t")==0) ADDRESS4SINGLE_ALLOC(cgns_rmotion, data_class) else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) ADDRESS4SINGLE_ALLOC(cgns_amotion, data_class) else if (strcmp(posit->label,"BaseIterativeData_t")==0) ADDRESS4SINGLE_ALLOC(cgns_biter, data_class) else if (strcmp(posit->label,"ZoneIterativeData_t")==0 || strcmp(posit->label,"ParticleIterativeData_t")==0) ADDRESS4SINGLE_ALLOC(cgns_ziter, data_class) else if (strcmp(posit->label,"UserDefinedData_t")==0) ADDRESS4SINGLE_ALLOC(cgns_user_data, data_class) else if (strcmp(posit->label,"Gravity_t")==0) ADDRESS4SINGLE_ALLOC(cgns_gravity, data_class) else if (strcmp(posit->label,"Axisymmetry_t")==0) ADDRESS4SINGLE_ALLOC(cgns_axisym, data_class) else if (strcmp(posit->label,"RotatingCoordinates_t")==0) ADDRESS4SINGLE_ALLOC(cgns_rotating, data_class) else if (strcmp(posit->label,"Periodic_t")==0) ADDRESS4SINGLE_ALLOC(cgns_cperio, data_class) else if (strcmp(posit->label,"ZoneSubRegion_t")==0) ADDRESS4SINGLE_ALLOC(cgns_subreg, data_class) else if (strcmp(posit->label,"ParticleZone_t")==0) ADDRESS4SINGLE_ALLOC(cgns_pzone, data_class) else { cgi_error("DataClass_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (cg->mode == CG_MODE_MODIFY && local_mode == CG_MODE_WRITE) { if (cgi_get_nodes(parent_id, "DataClass_t", &nnod, &id)) return CG_OK; if (nnod>0) { if (cgi_delete_node (parent_id, id[0])) { (*ier) = CG_ERROR; return CG_OK; } CGNS_FREE(id); } } return data_class; } cgns_units *cgi_units_address(int local_mode, int *ier) { cgns_units *units=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of DimensionalUnits_t node: * CGNSBase_t, Zone_t, GridCoordinates_t, FlowSolution_t, DiscreteData_t, * ZoneBC_t, BC_t, BCDataSet_t, BCData_t, FlowEquationSet_t, GasModel_t, * ViscosityModel_t, ThermalConductivityModel_t, TurbulenceClosure_t, * TurbulenceModel_t, ThermalRelaxationModel_t, ChemicalKineticsModel_t, * EMElectricFieldModel_t, EMMagneticFieldModel_t, ParticleEquationSet_t, * ParticleCollisionModel_t, ParticleBreakupModel_t, ParticleForceModel_t, * ParticleWallInteractionModel_t, ParticlePhaseChangeModel_t, * ConvergenceHistory_t, IntegralData_t, ReferenceState_t, * DataArray_t, RigidGridMotion_t, ArbitraryGridMotion_t, BaseIterativeData_t, * ZoneIterativeData_t, UserDefinedData_t, Gravity_t, Axisymmetry_t * RotatingCoordinates_t, Periodic_t, FamilyBCDataSet_t, ParticleZone_t * ParticleCoordinates_t, ParticleSolution_t, ParticleIterativeData_t, * ParticleEquationSet_t, ParticleCollisionModel_t, ParticleBreakupModel_t, * ParticleForceModel_t, ParticleWallInteractionModel_t, ParticleWallInteractionModel_t, * ParticlePhaseChangeModel_t */ if (strcmp(posit->label,"CGNSBase_t")==0) ADDRESS4SINGLE(cgns_base, units, cgns_units, 1) else if (strcmp(posit->label,"Zone_t")==0) ADDRESS4SINGLE(cgns_zone, units, cgns_units, 1) else if (strcmp(posit->label,"GridCoordinates_t")==0) ADDRESS4SINGLE(cgns_zcoor, units, cgns_units, 1) else if (strcmp(posit->label,"ParticleCoordinates_t")==0) ADDRESS4SINGLE(cgns_pcoor, units, cgns_units, 1) else if (strcmp(posit->label,"FlowSolution_t")==0) ADDRESS4SINGLE(cgns_sol, units, cgns_units, 1) else if (strcmp(posit->label,"ParticleSolution_t")==0) ADDRESS4SINGLE(cgns_psol, units, cgns_units, 1) else if (strcmp(posit->label,"DiscreteData_t")==0) ADDRESS4SINGLE(cgns_discrete, units, cgns_units, 1) else if (strcmp(posit->label,"ZoneBC_t")==0) ADDRESS4SINGLE(cgns_zboco, units, cgns_units, 1) else if (strcmp(posit->label,"BC_t")==0) ADDRESS4SINGLE(cgns_boco, units, cgns_units, 1) else if (strcmp(posit->label,"BCDataSet_t")==0 || strcmp(posit->label,"FamilyBCDataSet_t")==0) ADDRESS4SINGLE(cgns_dataset, units, cgns_units, 1) else if (strcmp(posit->label,"BCData_t")==0) ADDRESS4SINGLE(cgns_bcdata, units, cgns_units, 1) else if (strcmp(posit->label,"FlowEquationSet_t")==0) ADDRESS4SINGLE(cgns_equations, units, cgns_units, 1) else if (strcmp(posit->label,"GasModel_t")==0 || strcmp(posit->label,"ViscosityModel_t")==0 || strcmp(posit->label,"ThermalConductivityModel_t")==0 || strcmp(posit->label,"TurbulenceModel_t")==0 || strcmp(posit->label,"TurbulenceClosure_t")==0 || strcmp(posit->label,"ThermalRelaxationModel_t")==0 || strcmp(posit->label,"ChemicalKineticsModel_t")==0 || strcmp(posit->label,"EMElectricFieldModel_t")==0 || strcmp(posit->label,"EMMagneticFieldModel_t")==0 || strcmp(posit->label,"EMConductivityModel_t")==0) ADDRESS4SINGLE(cgns_model, units, cgns_units, 1) else if (strcmp(posit->label,"ParticleEquationSet_t")==0) ADDRESS4SINGLE(cgns_pequations, units, cgns_units, 1) else if (strcmp(posit->label,"ParticleCollisionModel_t")==0 || strcmp(posit->label,"ParticleBreakupModel_t")==0 || strcmp(posit->label,"ParticleForceModel_t")==0 || strcmp(posit->label,"ParticleWallInteractionModel_t")==0 || strcmp(posit->label,"ParticlePhaseChangeModel_t")==0) ADDRESS4SINGLE(cgns_pmodel, units, cgns_units, 1) else if (strcmp(posit->label,"ConvergenceHistory_t")==0) ADDRESS4SINGLE(cgns_converg, units, cgns_units, 1) else if (strcmp(posit->label,"IntegralData_t")==0) ADDRESS4SINGLE(cgns_integral, units, cgns_units, 1) else if (strcmp(posit->label,"ReferenceState_t")==0) ADDRESS4SINGLE(cgns_state, units, cgns_units, 1) else if (strcmp(posit->label,"DataArray_t")==0) ADDRESS4SINGLE(cgns_array, units, cgns_units, 1) else if (strcmp(posit->label,"RigidGridMotion_t")==0) ADDRESS4SINGLE(cgns_rmotion, units, cgns_units, 1) else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) ADDRESS4SINGLE(cgns_amotion, units, cgns_units, 1) else if (strcmp(posit->label,"BaseIterativeData_t")==0) ADDRESS4SINGLE(cgns_biter, units, cgns_units, 1) else if (strcmp(posit->label,"ZoneIterativeData_t")==0 || strcmp(posit->label,"ParticleIterativeData_t")==0) ADDRESS4SINGLE(cgns_ziter, units, cgns_units, 1) else if (strcmp(posit->label,"UserDefinedData_t")==0) ADDRESS4SINGLE(cgns_user_data, units, cgns_units, 1) else if (strcmp(posit->label,"Gravity_t")==0) ADDRESS4SINGLE(cgns_gravity, units, cgns_units, 1) else if (strcmp(posit->label,"Axisymmetry_t")==0) ADDRESS4SINGLE(cgns_axisym, units, cgns_units, 1) else if (strcmp(posit->label,"RotatingCoordinates_t")==0) ADDRESS4SINGLE(cgns_rotating, units, cgns_units, 1) else if (strcmp(posit->label,"Periodic_t")==0) ADDRESS4SINGLE(cgns_cperio, units, cgns_units, 1) else if (strcmp(posit->label,"ZoneSubRegion_t")==0) ADDRESS4SINGLE(cgns_subreg, units, cgns_units, 1) else if (strcmp(posit->label,"ParticleZone_t")==0) ADDRESS4SINGLE(cgns_pzone, units, cgns_units, 1) else { cgi_error("DimensionalUnits_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("DimensionalUnits_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!units && local_mode == CG_MODE_READ) { cgi_error("DimensionalUnits_t Node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, units->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_units(units); } return units; } int *cgi_ordinal_address(int local_mode, int *ier) { double *id; int nnod; int *ordinal; double parent_id; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of Ordinal_t node: * Zone_t, GridConnectivity1to1_t, GridConnectivity_t, BC_t, Family_t, * UserDefinedData_t */ if (strcmp(posit->label,"Zone_t")==0) ADDRESS4SINGLE_ALLOC(cgns_zone, ordinal) else if (strcmp(posit->label,"GridConnectivity1to1_t")==0) ADDRESS4SINGLE_ALLOC(cgns_1to1, ordinal) else if (strcmp(posit->label,"GridConnectivity_t")==0) ADDRESS4SINGLE_ALLOC(cgns_conn, ordinal) else if (strcmp(posit->label,"BC_t")==0) ADDRESS4SINGLE_ALLOC(cgns_boco, ordinal) else if (strcmp(posit->label,"Family_t")==0) ADDRESS4SINGLE_ALLOC(cgns_family, ordinal) else if (strcmp(posit->label,"UserDefinedData_t")==0) ADDRESS4SINGLE_ALLOC(cgns_user_data, ordinal) else { cgi_error("Ordinal_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (cg->mode == CG_MODE_MODIFY && local_mode == CG_MODE_WRITE) { if (cgi_get_nodes(parent_id, "Ordinal_t", &nnod, &id)) return CG_OK; if (nnod>0) { if (cgi_delete_node (parent_id, id[0])) { (*ier) = CG_ERROR; return CG_OK; } CGNS_FREE(id); } } /* if ((*ordinal)==0) (*ier)= CG_NODE_NOT_FOUND;*/ return ordinal; } int *cgi_rind_address(int local_mode, int *ier) { int *rind_planes=0, nnod; double parent_id=0, *id; int error1, index_dim; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can't find IndexDimension in cgi_rind_address"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of Rind_t: * GridCoordinates_t, FlowSolution_t,DiscreteData_t, ArbitraryGridMotion_t */ if (strcmp(posit->label,"GridCoordinates_t")==0) ADDRESS4SINGLE(cgns_zcoor, rind_planes, int, 2*index_dim) else if (strcmp(posit->label,"FlowSolution_t")==0) ADDRESS4SINGLE(cgns_sol, rind_planes, int, 2*index_dim) else if (strcmp(posit->label,"DiscreteData_t")==0) ADDRESS4SINGLE(cgns_discrete, rind_planes, int, 2*index_dim) else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) ADDRESS4SINGLE(cgns_amotion, rind_planes, int, 2*index_dim) else if (strcmp(posit->label,"Elements_t")==0) ADDRESS4SINGLE(cgns_section, rind_planes, int, 2*index_dim) else if (strcmp(posit->label,"ZoneSubRegion_t")==0) ADDRESS4SINGLE(cgns_subreg, rind_planes, int, 2*index_dim) else { cgi_error("Rind_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } /* Corrected on July 27 2001 by Diane Poirier if (error1==1) { cgi_error("Rind_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } */ if (!rind_planes && local_mode == CG_MODE_READ) { cgi_error("Rind_t node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id && cg->mode==CG_MODE_MODIFY) { if (cgi_get_nodes(parent_id, "Rind_t", &nnod, &id)) return CG_OK; if (nnod>0) { if (cgi_delete_node (parent_id, id[0])) { (*ier) = CG_ERROR; return CG_OK; } CGNS_FREE(id); } } return rind_planes; } CGNS_ENUMT(GridLocation_t) *cgi_location_address(int local_mode, int *ier) { double *id, parent_id; CGNS_ENUMV( GridLocation_t ) *location=0; int nnod; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents for GridLocation_t: * FlowSolution_t, DiscreteData_t, GridConnectivity_t, OversetHoles_t, BC_t, * ArbitraryGridMotion_t, UserDefinedData_t */ if (strcmp(posit->label,"FlowSolution_t")==0) ADDRESS4SINGLE_ALLOC(cgns_sol, location) else if (strcmp(posit->label,"DiscreteData_t")==0) ADDRESS4SINGLE_ALLOC(cgns_discrete, location) else if (strcmp(posit->label,"GridConnectivity_t")==0) ADDRESS4SINGLE_ALLOC(cgns_conn, location) else if (strcmp(posit->label,"OversetHoles_t")==0) ADDRESS4SINGLE_ALLOC(cgns_hole, location) else if (strcmp(posit->label,"BC_t")==0) ADDRESS4SINGLE_ALLOC(cgns_boco, location) else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) ADDRESS4SINGLE_ALLOC(cgns_amotion, location) else if (strcmp(posit->label,"UserDefinedData_t")==0) ADDRESS4SINGLE_ALLOC(cgns_user_data, location) else if (strcmp(posit->label,"BCDataSet_t")==0) ADDRESS4SINGLE_ALLOC(cgns_dataset, location) else if (strcmp(posit->label,"ZoneSubRegion_t")==0) ADDRESS4SINGLE_ALLOC(cgns_subreg, location) else { cgi_error("GridLocation_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (cg->mode == CG_MODE_MODIFY && local_mode == CG_MODE_WRITE) { if (cgi_get_nodes(parent_id, "GridLocation_t", &nnod, &id)) return CG_OK; if (nnod>0) { if (cgi_delete_node (parent_id, id[0])) { (*ier) = CG_ERROR; return CG_OK; } CGNS_FREE(id); } } return location; } cgns_conversion *cgi_conversion_address(int local_mode, int *ier) { cgns_conversion *convert=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parent: DataArray_t */ if (strcmp(posit->label,"DataArray_t")==0) ADDRESS4SINGLE(cgns_array,convert, cgns_conversion, 1) else { cgi_error("DataConversion_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("DataConversion_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!convert && local_mode == CG_MODE_READ) { cgi_error("DataConversion_t node does not exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, convert->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_convert(convert); } return convert; } cgns_exponent *cgi_exponent_address(int local_mode, int *ier) { cgns_exponent *exponents=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parent: DataArray_t */ if (strcmp(posit->label,"DataArray_t")==0) ADDRESS4SINGLE(cgns_array, exponents, cgns_exponent, 1) else { cgi_error("DimensionalExponents_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("DimensionalExponents_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!exponents && local_mode == CG_MODE_READ) { cgi_error("DimensionalExponents_t node does not exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, exponents->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_exponents(exponents); } return exponents; } cgns_integral *cgi_integral_address(int local_mode, int given_no, char const *given_name, int *ier) { cgns_integral *integral=0; int n, allow_dup=0, error1=0, error2=0; double parent_id=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of IntegralData_t node: * CGNSBase_t, Zone_t, ParticleZone_t */ if (strcmp(posit->label,"CGNSBase_t")==0) ADDRESS4MULTIPLE(cgns_base, nintegrals, integral, cgns_integral) else if (strcmp(posit->label,"Zone_t")==0) ADDRESS4MULTIPLE(cgns_zone, nintegrals, integral, cgns_integral) else if (strcmp(posit->label,"ParticleZone_t")==0) ADDRESS4MULTIPLE(cgns_pzone, nintegrals, integral, cgns_integral) else { cgi_error("IntegralData_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1) { cgi_error("Duplicate child name found (%s) found under %s", given_name, posit->label); (*ier) = CG_ERROR; return CG_OK; } if (error2) { cgi_error("IntegralData index number %d doesn't exist under %s", given_no, posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { /* parent_id!=0 only when overwriting */ if (cgi_delete_node (parent_id, integral->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_integral(integral); } return integral; } cgns_equations *cgi_equations_address(int local_mode, int *ier) { cgns_equations *equations=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents: CGNSBase_t, Zone_t */ if (strcmp(posit->label,"CGNSBase_t")==0) ADDRESS4SINGLE(cgns_base, equations, cgns_equations, 1) else if (strcmp(posit->label,"Zone_t")==0) ADDRESS4SINGLE(cgns_zone, equations, cgns_equations, 1) else { cgi_error("FlowEquationSet_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("FlowEquationSet_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!equations && local_mode == CG_MODE_READ) { cgi_error("FlowEquationSet_t Node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, equations->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_equations(equations); } return equations; } cgns_state *cgi_state_address(int local_mode, int *ier) { cgns_state *state=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents: CGNSBase_t, Zone_t, ZoneBC_t, BC_t * BCDataSet_t, FamilyBCDataSet_t, ParticleZone_t */ if (strcmp(posit->label,"CGNSBase_t")==0) ADDRESS4SINGLE(cgns_base, state, cgns_state, 1) else if (strcmp(posit->label,"Zone_t")==0) ADDRESS4SINGLE(cgns_zone, state, cgns_state, 1) else if (strcmp(posit->label,"ZoneBC_t")==0) ADDRESS4SINGLE(cgns_zboco, state, cgns_state, 1) else if (strcmp(posit->label,"BC_t")==0) ADDRESS4SINGLE(cgns_boco, state, cgns_state, 1) else if (strcmp(posit->label,"BCDataSet_t")==0 || strcmp(posit->label,"FamilyBCDataSet_t")==0) ADDRESS4SINGLE(cgns_dataset, state, cgns_state, 1) else if (strcmp(posit->label,"ParticleZone_t")==0) ADDRESS4SINGLE(cgns_pzone, state, cgns_state, 1) else { cgi_error("ReferenceState_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("ReferenceState_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!state && local_mode == CG_MODE_READ) { cgi_error("ReferenceState_t Node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, state->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_state(state); } return state; } cgns_converg *cgi_converg_address(int local_mode, int *ier) { cgns_converg *converg=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents for xxxConvergenceHistory_t node: CGNSBase_t, Zone_t */ if (strcmp(posit->label,"CGNSBase_t")==0) { ADDRESS4SINGLE(cgns_base, converg, cgns_converg, 1) if (local_mode==CG_MODE_WRITE) strcpy(converg->name,"GlobalConvergenceHistory"); } else if (strcmp(posit->label,"Zone_t")==0) { ADDRESS4SINGLE(cgns_zone, converg, cgns_converg, 1) if (local_mode==CG_MODE_WRITE) strcpy(converg->name,"ZoneConvergenceHistory"); } else { cgi_error("ConvergenceHistory_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("ConvergenceHistory_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!converg && local_mode == CG_MODE_READ) { cgi_error("ConvergenceHistory_t Node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, converg->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_converg(converg); } return converg; } cgns_governing *cgi_governing_address(int local_mode, int *ier) { cgns_governing *governing; int error1=0; double parent_id=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents for GoverningEquations_t: FlowEquationSet_t */ if (strcmp(posit->label,"FlowEquationSet_t")==0) ADDRESS4SINGLE(cgns_equations, governing, cgns_governing,1) else { cgi_error("GoverningEquations_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("GoverningEquations_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!governing && local_mode == CG_MODE_READ) { cgi_error("ConvergenceHistory_t Node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, governing->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_governing(governing); } return governing; } int *cgi_diffusion_address(int local_mode, int *ier) { int *diffusion_model=0, error1=0, nnod; double parent_id=0, *id; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* possible parents for DiffusionModel: GoverningEquations_t, TurbulenceModel_t */ if (strcmp(posit->label,"GoverningEquations_t")==0) ADDRESS4SINGLE(cgns_governing, diffusion_model, int, 6) else if (strcmp(posit->label,"TurbulenceModel_t")==0) ADDRESS4SINGLE(cgns_model, diffusion_model, int, 6) else { cgi_error("Diffusion Model node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("Diffusion Model already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!diffusion_model && local_mode == CG_MODE_READ) { cgi_error("Diffusion Model Node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_get_nodes(parent_id, "\"int[1+...+IndexDimension]\"", &nnod, &id)) return CG_OK; if (nnod>0) { if (cgi_delete_node (parent_id, id[0])) { (*ier) = CG_ERROR; return CG_OK; } CGNS_FREE(id); } CGNS_FREE(diffusion_model); } return diffusion_model; } cgns_array *cgi_array_address(int local_mode, int allow_dup, int given_no, char const *given_name, int* have_dup, int *ier) { cgns_array *array=0, *coord=0; int n, error1=0, error2=0; double parent_id=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of DataArray_t node: * GridCoordinates_t, Elements_t, FlowSolution_t, DiscreteData_t, GridConnectivity_t, BC_t, * BCData_t, GasModel_t, ViscosityModel_t, ThermalConductivityModel_t, TurbulenceClosure_t, * TurbulenceModel_t, ThermalRelaxationModel_t, ChemicalKineticsModel_t, * EMElectricFieldModel_t, EMMagneticFieldModel_t, ParticleCollisionModel_t, * ParticleBreakupModel_t, ParticleForceModel_t, ParticleWallInteractionModel_t, * ParticlePhaseChangeModel_t, ConvergenceHistory_t, IntegralData_t, ReferenceState_t, * RigidGridMotion_t, ArbitraryGridMotion_t, BaseIterativeData_t, ZoneIterativeData_t, * UserDefinedData_t, Gravity_t, Axisymmetry_t, RotatingCoordinates_t * Area_t, Periodic_t, ZoneSubRegion_t, ParticleSolution_t, ParticleCoordinates_t, * ParticleIterativeData_t */ /* 0,N DataArray_t under GridCoordinates_t */ if (strcmp(posit->label,"GridCoordinates_t")==0) { ADDRESS4MULTIPLE(cgns_zcoor, ncoords, coord, cgns_array) array = coord; /* 0,N DataArray_t under ParticleCoordinates_t */ } else if (strcmp(posit->label,"ParticleCoordinates_t")==0) { ADDRESS4MULTIPLE(cgns_pcoor, ncoords, coord, cgns_array) array = coord; /* 2 DataArray_t under Elements_t: connect and parent */ } else if (strcmp(posit->label,"Elements_t")==0) { cgns_section *section= (cgns_section *)posit->posit; if (local_mode==CG_MODE_WRITE) { if (strcmp(given_name,"ElementStartOffset") && strcmp(given_name,"ElementConnectivity") && strcmp(given_name,"ParentElements") && strcmp(given_name,"ParentElementsPosition") && strcmp(given_name,"ParentData")) { cgi_error("User defined DataArray_t node not supported under '%s' type node",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (section->connect==0 && strcmp(given_name,"ElementConnectivity")==0) { section->connect = CGNS_NEW(cgns_array, 1); array = section->connect; } else if (section->parelem==0 && (strcmp(given_name,"ParentElements")==0 || 0 == strcmp(given_name, "ParentData"))) { section->parelem = CGNS_NEW(cgns_array, 1); array = section->parelem; } else if (section->parface==0 && strcmp(given_name,"ParentElementsPosition")==0) { section->parface = CGNS_NEW(cgns_array, 1); array = section->parface; } else { if (cg->mode == CG_MODE_WRITE) error1=1; else { parent_id = section->id; if (section->connect && strcmp(given_name,"ElementConnectivity")==0) array = section->connect; else if (section->parelem && (strcmp(given_name,"ParentElements")==0 || 0 == strcmp(given_name,"ParentData"))) array = section->parelem; else if (section->parface && strcmp(given_name,"ParentElementsPosition")==0) array = section->parface; } } } else if (local_mode == CG_MODE_READ) { if (section->connect && strcmp(given_name,"ElementConnectivity")==0) array = section->connect; else if (section->parelem && (strcmp(given_name,"ParentElements")==0 || 0 == strcmp(given_name,"ParentData"))) array = section->parelem; else if (section->parface && strcmp(given_name,"ParentElementsPosition")==0) array = section->parface; } /* 0,N DataArray_t under FlowSolution_t */ } else if (strcmp(posit->label,"FlowSolution_t")==0) { cgns_array *field; ADDRESS4MULTIPLE(cgns_sol, nfields, field, cgns_array) array = field; /* 0,N DataArray_t under ParticleSolution_t */ } else if (strcmp(posit->label,"ParticleSolution_t")==0) { cgns_array *field; ADDRESS4MULTIPLE(cgns_psol, nfields, field, cgns_array) array = field; /* 0,N DataArray_t under DiscreteData_t */ } else if (strcmp(posit->label,"DiscreteData_t")==0) { ADDRESS4MULTIPLE(cgns_discrete, narrays, array, cgns_array) /* 0,1 DataArray_t under GridConnectivity_t */ } else if (strcmp(posit->label,"GridConnectivity_t")==0) { cgns_array *interpolants; if (local_mode==CG_MODE_WRITE && strcmp(given_name,"InterpolantsDonor")) { cgi_error("User defined DataArray_t node not supported under '%s' type node",posit->label); (*ier) = CG_ERROR; return CG_OK; } ADDRESS4SINGLE(cgns_conn, interpolants, cgns_array, 1) array = interpolants; /* 0,1 DataArray_t (in SIDS is IndexArray_t) for InwardNormalList */ } else if (strcmp(posit->label,"BC_t")==0) { cgns_array *normal; ADDRESS4SINGLE(cgns_boco, normal, cgns_array, 1) array = normal; /* 0,N DataArray_t under BCData_t */ } else if (strcmp(posit->label,"BCData_t")==0) { ADDRESS4MULTIPLE(cgns_bcdata, narrays, array, cgns_array) /* 0,N DataArray_t under all Model_t */ } else if (strcmp(posit->label,"GasModel_t")==0 || strcmp(posit->label,"ViscosityModel_t")==0 || strcmp(posit->label,"ThermalConductivityModel_t")==0 || strcmp(posit->label,"TurbulenceModel_t")==0 || strcmp(posit->label,"TurbulenceClosure_t")==0 || strcmp(posit->label,"ThermalRelaxationModel_t")==0 || strcmp(posit->label,"ChemicalKineticsModel_t")==0 || strcmp(posit->label,"EMElectricFieldModel_t")==0 || strcmp(posit->label,"EMMagneticFieldModel_t")==0 || strcmp(posit->label,"EMConductivityModel_t")==0) { ADDRESS4MULTIPLE(cgns_model, narrays, array, cgns_array) /* 0,N DataArray_t under all ParticleModel_t */ } else if (strcmp(posit->label,"ParticleCollisionModel_t")==0 || strcmp(posit->label,"ParticleBreakupModel_t")==0 || strcmp(posit->label,"ParticleForceModel_t")==0 || strcmp(posit->label,"ParticleWallInteractionModel_t")==0 || strcmp(posit->label,"ParticlePhaseChangeModel_t")==0) { ADDRESS4MULTIPLE(cgns_pmodel, narrays, array, cgns_array) /* 0,N DataArray_t under ConvergenceHistory_t */ } else if (strcmp(posit->label,"ConvergenceHistory_t")==0) { ADDRESS4MULTIPLE(cgns_converg, narrays, array, cgns_array) /* 0,N DataArray_t under IntegralData_t */ } else if (strcmp(posit->label,"IntegralData_t")==0) { ADDRESS4MULTIPLE(cgns_integral, narrays, array, cgns_array) /* 0,N DataArray_t under ReferenceState_t */ } else if (strcmp(posit->label,"ReferenceState_t")==0) { ADDRESS4MULTIPLE(cgns_state, narrays, array, cgns_array) /* 0,N DataArray_t under RigidGridMotion_t: */ } else if (strcmp(posit->label, "RigidGridMotion_t")==0) { ADDRESS4MULTIPLE(cgns_rmotion, narrays, array, cgns_array) /* 0,N DataArray_t under ArbitraryGridMotion_t: */ } else if (strcmp(posit->label, "ArbitraryGridMotion_t")==0) { ADDRESS4MULTIPLE(cgns_amotion, narrays, array, cgns_array) /* 0,N DataArray_t under BaseIterativeData_t: */ } else if (strcmp(posit->label, "BaseIterativeData_t")==0) { ADDRESS4MULTIPLE(cgns_biter, narrays, array, cgns_array) /* 0,N DataArray_t under ZoneIterativeData_t: */ } else if (strcmp(posit->label, "ZoneIterativeData_t")==0 || strcmp(posit->label, "ParticleIterativeData_t")==0) { ADDRESS4MULTIPLE(cgns_ziter, narrays, array, cgns_array) /* 0,N DataArray_t under UserDefinedData_t: */ } else if (strcmp(posit->label, "UserDefinedData_t")==0) { ADDRESS4MULTIPLE(cgns_user_data, narrays, array, cgns_array) /* 0,1 DataArray_t for GravityVector */ } else if (strcmp(posit->label,"Gravity_t")==0) { cgns_array *vector; if (local_mode==CG_MODE_WRITE && strcmp(given_name,"GravityVector")) { cgi_error("User defined DataArray_t node not supported under '%s' type node",posit->label); (*ier) = CG_ERROR; return CG_OK; } ADDRESS4SINGLE(cgns_gravity, vector, cgns_array, 1) array = vector; /* 2,4 DataArray_t for Axisymmetry_t */ } else if (strcmp(posit->label,"Axisymmetry_t")==0) { if (local_mode==CG_MODE_WRITE && strcmp(given_name,"AxisymmetryReferencePoint") && strcmp(given_name,"AxisymmetryAxisVector") && strcmp(given_name,"AxisymmetryAngle") && strcmp(given_name,"CoordinateNames")) { cgi_error("User defined DataArray_t node not supported under '%s' type node",posit->label); (*ier) = CG_ERROR; return CG_OK; } ADDRESS4MULTIPLE(cgns_axisym, narrays, array, cgns_array) /* 2 DataArray_t for RotatingCoordinates_t */ } else if (strcmp(posit->label,"RotatingCoordinates_t")==0) { if (local_mode==CG_MODE_WRITE && strcmp(given_name,"RotationCenter") && strcmp(given_name,"RotationRateVector")) { cgi_error("User defined DataArray_t node not supported under '%s' type node",posit->label); (*ier) = CG_ERROR; return CG_OK; } ADDRESS4MULTIPLE(cgns_rotating, narrays, array, cgns_array) /* 2 DataArray_t for Area_t: SurfaceArea, RegionName */ } else if (strcmp(posit->label,"Area_t")==0) { if (local_mode==CG_MODE_WRITE && strcmp(given_name,"SurfaceArea") && strcmp(given_name,"RegionName")) { cgi_error("User defined DataArray_t node not supported under '%s' type node",posit->label); (*ier) = CG_ERROR; return CG_OK; } ADDRESS4MULTIPLE(cgns_bcarea, narrays, array, cgns_array) /* 3 DataArray_t for Periodic_t: RotationCenter, RotationAngle, Translation */ } else if (strcmp(posit->label,"Periodic_t")==0) { if (local_mode==CG_MODE_WRITE && strcmp(given_name,"RotationCenter") && strcmp(given_name,"RotationAngle") && strcmp(given_name,"Translation")) { cgi_error("User defined DataArray_t node not supported under '%s' type node",posit->label); (*ier) = CG_ERROR; return CG_OK; } ADDRESS4MULTIPLE(cgns_cperio, narrays, array, cgns_array) /* 0,N DataArray_t under ZoneSubRegion_t */ } else if (strcmp(posit->label, "ZoneSubRegion_t")==0) { ADDRESS4MULTIPLE(cgns_subreg, narrays, array, cgns_array) } else { cgi_error("DataArray_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1) { *have_dup = 1; if (!allow_dup) { cgi_error("Duplicate child name found (%s) found under %s", given_name, posit->label); (*ier) = CG_ERROR; return CG_OK; } } if (error2) { cgi_error("DataArray_t index number %d doesn't exist under %s", given_no, posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id && !allow_dup) { /* parent_id!=0 only when overwriting */ if (cgi_delete_node (parent_id, array->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_array(array); } return array; } cgns_model *cgi_model_address(int local_mode, char const *ModelLabel, int *ier) { cgns_model *model=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents for all xxxModel_t and TurbulenceClosure_t: FlowEquationSet_t */ if (strcmp(posit->label,"FlowEquationSet_t")==0) { if (strcmp(ModelLabel, "GasModel_t")==0) { cgns_model *gas; ADDRESS4SINGLE(cgns_equations, gas, cgns_model, 1) model = gas; } else if (strcmp(ModelLabel, "ViscosityModel_t")==0) { cgns_model *visc; ADDRESS4SINGLE(cgns_equations, visc, cgns_model, 1) model = visc; } else if (strcmp(ModelLabel, "ThermalConductivityModel_t")==0) { cgns_model *conduct; ADDRESS4SINGLE(cgns_equations, conduct, cgns_model, 1) model = conduct; } else if (strcmp(ModelLabel, "TurbulenceClosure_t")==0) { cgns_model *closure; ADDRESS4SINGLE(cgns_equations, closure, cgns_model, 1) model = closure; } else if (strcmp(ModelLabel, "TurbulenceModel_t")==0) { cgns_model *turbulence; ADDRESS4SINGLE(cgns_equations, turbulence, cgns_model, 1) model = turbulence; } else if (strcmp(ModelLabel, "ThermalRelaxationModel_t")==0) { cgns_model *relaxation; ADDRESS4SINGLE(cgns_equations, relaxation, cgns_model, 1) model = relaxation; } else if (strcmp(ModelLabel, "ChemicalKineticsModel_t")==0) { cgns_model *chemkin; ADDRESS4SINGLE(cgns_equations, chemkin, cgns_model, 1) model = chemkin; } else if (strcmp(ModelLabel, "EMElectricFieldModel_t")==0) { cgns_model *elecfield; ADDRESS4SINGLE(cgns_equations, elecfield, cgns_model, 1) model = elecfield; } else if (strcmp(ModelLabel, "EMMagneticFieldModel_t")==0) { cgns_model *magnfield; ADDRESS4SINGLE(cgns_equations, magnfield, cgns_model, 1) model = magnfield; } else if (strcmp(ModelLabel, "EMConductivityModel_t")==0) { cgns_model *emconduct; ADDRESS4SINGLE(cgns_equations, emconduct, cgns_model, 1) model = emconduct; } else { cgi_error("Incorrect model type %s",ModelLabel); (*ier) = CG_ERROR; return CG_OK; } } else { cgi_error("%s node not supported under '%s' type node",ModelLabel,posit->label); (*ier)=CG_INCORRECT_PATH; return CG_OK; } if (!model && local_mode == CG_MODE_READ) { cgi_error("%s node doesn't exist under %s",ModelLabel,posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (error1) { cgi_error("%s node already defined under %s",ModelLabel,posit->label); (*ier) = CG_ERROR; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, model->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_model(model); } return model; } cgns_user_data *cgi_user_data_address(int local_mode, int given_no, char const *given_name, int *ier) { cgns_user_data *user_data=0; int n, allow_dup=0, error1=0, error2=0; double parent_id=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of UserDefinedData_t node: * IntegralData_t, DiscreteData_t, ConvergenceHistory_t, ReferenceState_t, * xxxModel_t, GoverningEquations_t, FlowEquationSet_t, BCData_t, BCDataSet_t, * Elements_t, BC_t, ZoneBC_t, OversetHoles_t, GridConnectivity_t, * GridConnectivity1to1_t, ZoneGridConnectivity_t, FlowSolution_t, * GridCoordinates_t, RigidGridMotion_t, ArbitraryGridMotion_t, * ZoneIterativeData_t, BaseIterativeData_t, Zone_t, GeometryReference_t, * Family_t, CGNSBase_t, Gravity_t, Axisymmetry_t, RotatingCoordinates_t * BCProperty_t, WallFunction_t, Area_t, * GridConnectivityProperty_t, Periodic_t, AverageInterface_t, * UserDefinedData_t, ZoneSubRegion_t, FamilyBCDataSet_t, * ParticleZone_t, ParticleCoordinates_t, ParticleSolution_t, ParticleIterativeData_t, * ParticleEquationSet_t, ParticleGoverningEquations_t, ParticleCollisionModel_t, * ParticleBreakupModel_t, ParticleForceModel_t, ParticleWallInteractionModel_t, * ParticlePhaseChangeModel_t, ParticleGoverningEquations_t */ if (strcmp(posit->label,"IntegralData_t")==0) ADDRESS4MULTIPLE(cgns_integral, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"DiscreteData_t")==0) ADDRESS4MULTIPLE(cgns_discrete, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ConvergenceHistory_t")==0) ADDRESS4MULTIPLE(cgns_converg, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ReferenceState_t")==0) ADDRESS4MULTIPLE(cgns_state, nuser_data, user_data, cgns_user_data) else if ( (strcmp(posit->label,"GasModel_t")==0) || (strcmp(posit->label,"ViscosityModel_t")==0) || (strcmp(posit->label,"ThermalConductivityModel_t")==0) || (strcmp(posit->label,"TurbulenceModel_t")==0) || (strcmp(posit->label,"TurbulenceClosureModel_t")==0) || (strcmp(posit->label,"ThermalRelaxationModel_t")==0) || (strcmp(posit->label,"ChemicalKineticsModel_t")==0) || (strcmp(posit->label,"EMElectricFieldModel_t")==0) || (strcmp(posit->label,"EMMagneticFieldModel_t")==0) || (strcmp(posit->label,"EMConductivityModel_t")==0) ) ADDRESS4MULTIPLE(cgns_model, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ParticleCollisionModel_t")==0 || strcmp(posit->label,"ParticleBreakupModel_t")==0 || strcmp(posit->label,"ParticleForceModel_t")==0 || strcmp(posit->label,"ParticleWallInteractionModel_t")==0 || strcmp(posit->label,"ParticlePhaseChangeModel_t")==0) ADDRESS4MULTIPLE(cgns_pmodel, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"GoverningEquations_t")==0) ADDRESS4MULTIPLE(cgns_governing, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"FlowEquationSet_t")==0) ADDRESS4MULTIPLE(cgns_equations, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ParticleGoverningEquations_t")==0) ADDRESS4MULTIPLE(cgns_pgoverning, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ParticleEquationSet_t")==0) ADDRESS4MULTIPLE(cgns_pequations, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"BCData_t")==0) ADDRESS4MULTIPLE(cgns_bcdata, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"BCDataSet_t")==0 || strcmp(posit->label,"FamilyBCDataSet_t")==0) ADDRESS4MULTIPLE(cgns_dataset, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"Elements_t")==0) ADDRESS4MULTIPLE(cgns_section, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"BC_t")==0) ADDRESS4MULTIPLE(cgns_boco, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ZoneBC_t")==0) ADDRESS4MULTIPLE(cgns_zboco, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"OversetHoles_t")==0) ADDRESS4MULTIPLE(cgns_hole, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"GridConnectivity_t")==0) ADDRESS4MULTIPLE(cgns_conn, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"GridConnectivity1to1_t")==0) ADDRESS4MULTIPLE(cgns_1to1, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ZoneGridConnectivity_t")==0) ADDRESS4MULTIPLE(cgns_zconn, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"FlowSolution_t")==0) ADDRESS4MULTIPLE(cgns_sol, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ParticleSolution_t")==0) ADDRESS4MULTIPLE(cgns_psol, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"GridCoordinates_t")==0) ADDRESS4MULTIPLE(cgns_zcoor, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ParticleCoordinates_t")==0) ADDRESS4MULTIPLE(cgns_pcoor, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"RigidGridMotion_t")==0) ADDRESS4MULTIPLE(cgns_rmotion, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) ADDRESS4MULTIPLE(cgns_amotion, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ZoneIterativeData_t")==0 || strcmp(posit->label,"ParticleIterativeData_t")==0) ADDRESS4MULTIPLE(cgns_ziter, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"BaseIterativeData_t")==0) ADDRESS4MULTIPLE(cgns_biter, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"Zone_t")==0) ADDRESS4MULTIPLE(cgns_zone, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ParticleZone_t")==0) ADDRESS4MULTIPLE(cgns_pzone, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"GeometryReference_t")==0) ADDRESS4MULTIPLE(cgns_geo, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"Family_t")==0) ADDRESS4MULTIPLE(cgns_family, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"CGNSBase_t")==0) ADDRESS4MULTIPLE(cgns_base, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"Gravity_t")==0) ADDRESS4MULTIPLE(cgns_gravity, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"Axisymmetry_t")==0) ADDRESS4MULTIPLE(cgns_axisym, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"RotatingCoordinates_t")==0) ADDRESS4MULTIPLE(cgns_rotating, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"BCProperty_t")==0) ADDRESS4MULTIPLE(cgns_bprop, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"WallFunction_t")==0) ADDRESS4MULTIPLE(cgns_bcwall, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"Area_t")==0) ADDRESS4MULTIPLE(cgns_bcarea, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"GridConnectivityProperty_t")==0) ADDRESS4MULTIPLE(cgns_cprop, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"Periodic_t")==0) ADDRESS4MULTIPLE(cgns_cperio, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"AverageInterface_t")==0) ADDRESS4MULTIPLE(cgns_caverage, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"UserDefinedData_t")==0) ADDRESS4MULTIPLE(cgns_user_data, nuser_data, user_data, cgns_user_data) else if (strcmp(posit->label,"ZoneSubRegion_t")==0) ADDRESS4MULTIPLE(cgns_subreg, nuser_data, user_data, cgns_user_data) else { cgi_error("UserDefinedData_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1) { cgi_error("Duplicate child name found (%s) found under %s", given_name, posit->label); (*ier) = CG_ERROR; return CG_OK; } if (error2) { cgi_error("UserDefinedData index number %d doesn't exist under %s", given_no, posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { /* parent_id!=0 only when overwriting */ if (cgi_delete_node (parent_id, user_data->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_user_data(user_data); } return user_data; } /* ** FAMILY TREE ** */ cgns_family *cgi_family_address(int local_mode, int given_no, char const *given_name, int *ier) { cgns_family *family=0; int n, allow_dup=0, error1=0, error2=0; double parent_id=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of Family_t node: * Family_t, CGNSBase_t */ if (strcmp(posit->label,"Family_t")==0) ADDRESS4MULTIPLE(cgns_family, nfamilies, family, cgns_family) else if (strcmp(posit->label,"CGNSBase_t")==0) ADDRESS4MULTIPLE(cgns_base, nfamilies, family, cgns_family) else { cgi_error("Family_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1) { cgi_error("Duplicate child name found (%s) found under %s", given_name, posit->label); (*ier) = CG_ERROR; return CG_OK; } if (error2) { cgi_error("UserDefinedData index number %d doesn't exist under %s", given_no, posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { /* parent_id!=0 only when overwriting */ if (cgi_delete_node (parent_id, family->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_family(family); } return family; } cgns_rotating *cgi_rotating_address(int local_mode, int *ier) { cgns_rotating *rotating=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents: CGNSBase_t, Zone_t, Family_t */ if (strcmp(posit->label,"CGNSBase_t")==0) ADDRESS4SINGLE(cgns_base, rotating, cgns_rotating, 1) else if (strcmp(posit->label,"Zone_t")==0) ADDRESS4SINGLE(cgns_zone, rotating, cgns_rotating, 1) else if (strcmp(posit->label,"Family_t")==0) ADDRESS4SINGLE(cgns_family, rotating, cgns_rotating, 1) else { cgi_error("RotatingCoordinates_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("RotatingCoordinates_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!rotating && local_mode == CG_MODE_READ) { cgi_error("RotatingCoordinates_t Node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, rotating->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_rotating(rotating); } return rotating; } cgns_dataset *cgi_bcdataset_address(int local_mode, int given_no, char const *given_name, int *ier) { cgns_dataset *dataset=0; int n, allow_dup=0, error1=0, error2=0; double parent_id=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of FamilyBCDataSet_t node: * FamilyBC_t */ if (strcmp(posit->label,"FamilyBC_t")==0) ADDRESS4MULTIPLE(cgns_fambc, ndataset, dataset, cgns_dataset) else { cgi_error("FamilyBCDataSet_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1) { cgi_error("Duplicate child name found (%s) found under %s", given_name, posit->label); (*ier) = CG_ERROR; return CG_OK; } if (error2) { cgi_error("BCDataSet index number %d doesn't exist under %s", given_no, posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { /* parent_id!=0 only when overwriting */ if (cgi_delete_node (parent_id, dataset->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_dataset(dataset); } return dataset; } cgns_ptset *cgi_ptset_address(int local_mode, int *ier) { cgns_ptset *ptset = 0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents of a PointSet (i.e., either an IndexArray_t or * IndexRange_t) node: * UserDefinedData_t, BCDataSet_t, BC_t, OversetHoles_t, GridConnectivity_t * GridConnectivity1to1_t */ if (strcmp(posit->label,"UserDefinedData_t")==0) ADDRESS4SINGLE(cgns_user_data, ptset, cgns_ptset, 1) else if (strcmp(posit->label,"BCDataSet_t")==0) ADDRESS4SINGLE(cgns_dataset, ptset, cgns_ptset, 1) else if (strcmp(posit->label,"BC_t")==0) ADDRESS4SINGLE(cgns_boco, ptset, cgns_ptset, 1) else if (strcmp(posit->label,"OversetHoles_t")==0) ADDRESS4SINGLE(cgns_hole, ptset, cgns_ptset, 1) else if (strcmp(posit->label,"GridConnectivity_t")==0) ADDRESS4SINGLE_ALLOC(cgns_conn, ptset) else if (strcmp(posit->label,"GridConnectivity1to1_t")==0) ADDRESS4SINGLE_ALLOC(cgns_1to1, ptset) else if (strcmp(posit->label,"ZoneSubRegion_t")==0) ADDRESS4SINGLE(cgns_subreg, ptset, cgns_ptset, 1) else if (strcmp(posit->label,"FlowSolution_t")==0) ADDRESS4SINGLE(cgns_sol, ptset, cgns_ptset, 1) else if (strcmp(posit->label,"ParticleSolution_t")==0) ADDRESS4SINGLE(cgns_psol, ptset, cgns_ptset, 1) else if (strcmp(posit->label,"DiscreteData_t")==0) ADDRESS4SINGLE(cgns_discrete, ptset, cgns_ptset, 1) else { cgi_error("PointSet node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("IndexArray/Range_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!ptset && local_mode == CG_MODE_READ) { cgi_error("IndexArray/Range_t Node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, ptset->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_ptset(ptset); } return ptset; } cgns_pequations *cgi_particle_equations_address(int local_mode, int *ier) { cgns_pequations *equations=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents: CGNSBase_t, ParticleZone_t */ if (strcmp(posit->label,"CGNSBase_t")==0) { cgns_pequations *pequations = equations; ADDRESS4SINGLE(cgns_base, pequations, cgns_pequations, 1) } else if (strcmp(posit->label,"ParticleZone_t")==0) ADDRESS4SINGLE(cgns_pzone, equations, cgns_pequations, 1) else { cgi_error("ParticleEquationSet_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("ParticleEquationSet_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (!equations && local_mode == CG_MODE_READ) { cgi_error("ParticleEquationSet_t Node doesn't exist under %s",posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, equations->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_particle_equations(equations); } return equations; } cgns_pgoverning *cgi_particle_governing_address(int local_mode, int *ier) { cgns_pgoverning *governing; int error1=0; double parent_id=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents for ParticleGoverningEquations_t: ParticleEquationSet_t */ if (strcmp(posit->label,"ParticleEquationSet_t")==0) ADDRESS4SINGLE(cgns_pequations, governing, cgns_pgoverning,1) else { cgi_error("ParticleGoverningEquations_t node not supported under '%s' type node",posit->label); (*ier) = CG_INCORRECT_PATH; return CG_OK; } if (error1==1) { cgi_error("ParticleGoverningEquations_t already defined under %s",posit->label); (*ier) = CG_ERROR; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, governing->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_particle_governing(governing); } return governing; } cgns_pmodel *cgi_particle_model_address(int local_mode, char const *ModelLabel, int *ier) { cgns_pmodel *model=0; double parent_id=0; int error1=0; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ier) = CG_ERROR; return CG_OK; } /* Possible parents for all xxxParticleModel_t */ if (strcmp(posit->label,"ParticleEquationSet_t")==0) { if (strcmp(ModelLabel, "ParticleCollisionModel_t")==0) { cgns_pmodel *collision; ADDRESS4SINGLE(cgns_pequations, collision, cgns_pmodel, 1) model = collision; } else if (strcmp(ModelLabel, "ParticleBreakupModel_t")==0) { cgns_pmodel *breakup; ADDRESS4SINGLE(cgns_pequations, breakup, cgns_pmodel, 1) model = breakup; } else if (strcmp(ModelLabel, "ParticleForceModel_t")==0) { cgns_pmodel *force; ADDRESS4SINGLE(cgns_pequations, force, cgns_pmodel, 1) model = force; } else if (strcmp(ModelLabel, "ParticleWallInteractionModel_t")==0) { cgns_pmodel *wallinteract; ADDRESS4SINGLE(cgns_pequations, wallinteract, cgns_pmodel, 1) model = wallinteract; } else if (strcmp(ModelLabel, "ParticlePhaseChangeModel_t")==0) { cgns_pmodel *phasechange; ADDRESS4SINGLE(cgns_pequations, phasechange, cgns_pmodel, 1) model = phasechange; } else { cgi_error("Incorrect model type %s",ModelLabel); (*ier) = CG_ERROR; return CG_OK; } } else { cgi_error("%s node not supported under '%s' type node",ModelLabel,posit->label); (*ier)=CG_INCORRECT_PATH; return CG_OK; } if (!model && local_mode == CG_MODE_READ) { cgi_error("%s node doesn't exist under %s",ModelLabel,posit->label); (*ier) = CG_NODE_NOT_FOUND; return CG_OK; } if (error1) { cgi_error("%s node already defined under %s",ModelLabel,posit->label); (*ier) = CG_ERROR; return CG_OK; } if (parent_id) { if (cgi_delete_node (parent_id, model->id)) { (*ier) = CG_ERROR; return CG_OK; } cgi_free_particle_model(model); } return model; } void cgi_free_particle_governing(cgns_pgoverning *governing) { int n; if (governing->link) CGNS_FREE(governing->link); if (governing->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&governing->descr[n]); CGNS_FREE(governing->descr); } if (governing->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&governing->user_data[n]); CGNS_FREE(governing->user_data); } } /***********************************************************************\ * Free memory * \***********************************************************************/ void cgi_free_file(cgns_file *cg) { int b; CGNS_FREE(cg->filename); if (cg->nbases) { for (b=0; bnbases; b++) cgi_free_base(&cg->base[b]); CGNS_FREE(cg->base); } } void cgi_free_base(cgns_base *base) { int n; if (base->nzones) { for (n=0; nnzones; n++) cgi_free_zone(&base->zone[n]); CGNS_FREE(base->zone); } if (base->zonemap) { cgi_hashmap_clear(base->zonemap); CGNS_FREE(base->zonemap); } if (base->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&base->descr[n]); CGNS_FREE(base->descr); } if (base->state) { cgi_free_state(base->state); CGNS_FREE(base->state); } if (base->units) { cgi_free_units(base->units); CGNS_FREE(base->units); } if (base->equations) { cgi_free_equations(base->equations); CGNS_FREE(base->equations); } if (base->converg) { cgi_free_converg(base->converg); CGNS_FREE(base->converg); } if (base->nintegrals) { for (n=0; nnintegrals; n++) cgi_free_integral(&base->integral[n]); CGNS_FREE(base->integral); } if (base->nfamilies) { for (n=0; nnfamilies; n++) cgi_free_family(&base->family[n]); CGNS_FREE(base->family); } if (base->biter) { cgi_free_biter(base->biter); CGNS_FREE(base->biter); } if (base->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&base->user_data[n]); CGNS_FREE(base->user_data); } if (base->gravity) { cgi_free_gravity(base->gravity); CGNS_FREE(base->gravity); } if (base->axisym) { cgi_free_axisym(base->axisym); CGNS_FREE(base->axisym); } if (base->rotating) { cgi_free_rotating(base->rotating); CGNS_FREE(base->rotating); } if (base->pzone) { for(n=0; nnpzones; n++) cgi_free_particle(&base->pzone[n]); CGNS_FREE(base->pzone); } if (base->pzonemap) { cgi_hashmap_clear(base->pzonemap); CGNS_FREE(base->pzonemap); } } void cgi_free_zone(cgns_zone *zone) { int n; if (zone->link) CGNS_FREE(zone->link); CGNS_FREE(zone->nijk); if (zone->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&zone->descr[n]); CGNS_FREE(zone->descr); } if (zone->nzcoor) { for (n=0; nnzcoor; n++) cgi_free_zcoor(&zone->zcoor[n]); CGNS_FREE(zone->zcoor); } if (zone->nsections) { for (n=0; nnsections; n++) cgi_free_section(&zone->section[n]); CGNS_FREE(zone->section); } if (zone->nsols) { for (n=0; nnsols; n++) cgi_free_sol(&zone->sol[n]); CGNS_FREE(zone->sol); } if (zone->ndiscrete) { for (n=0; nndiscrete; n++) cgi_free_discrete(&zone->discrete[n]); CGNS_FREE(zone->discrete); } if (zone->nintegrals) { for (n=0; nnintegrals; n++) cgi_free_integral(&zone->integral[n]); CGNS_FREE(zone->integral); } if (zone->nzconn) { for (n=0; nnzconn; n++) cgi_free_zconn(&zone->zconn[n]); CGNS_FREE(zone->zconn); } if (zone->zboco) { cgi_free_zboco(zone->zboco); CGNS_FREE(zone->zboco); } if (zone->state) { cgi_free_state(zone->state); CGNS_FREE(zone->state); } if (zone->units) { cgi_free_units(zone->units); CGNS_FREE(zone->units); } if (zone->equations) { cgi_free_equations(zone->equations); CGNS_FREE(zone->equations); } if (zone->converg) { cgi_free_converg(zone->converg); CGNS_FREE(zone->converg); } if (zone->nrmotions) { for (n=0; nnrmotions; n++) cgi_free_rmotion(&zone->rmotion[n]); CGNS_FREE(zone->rmotion); } if (zone->namotions) { for (n=0; nnamotions; n++) cgi_free_amotion(&zone->amotion[n]); CGNS_FREE(zone->amotion); } if (zone->ziter) { cgi_free_ziter(zone->ziter); CGNS_FREE(zone->ziter); } if (zone->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&zone->user_data[n]); CGNS_FREE(zone->user_data); } if (zone->rotating) { cgi_free_rotating(zone->rotating); CGNS_FREE(zone->rotating); } if (zone->nsubreg) { for (n=0; nnsubreg; n++) cgi_free_subreg(&zone->subreg[n]); CGNS_FREE(zone->subreg); } if (zone->nfamname) { for (n = 0; n < zone->nfamname; n++) cgi_free_famname(&zone->famname[n]); CGNS_FREE(zone->famname); } } void cgi_free_section(cgns_section *section) { int n; if (section->link) CGNS_FREE(section->link); if (section->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(§ion->descr[n]); CGNS_FREE(section->descr); } if (section->rind_planes) CGNS_FREE(section->rind_planes); if (section->connect) { cgi_free_array(section->connect); CGNS_FREE(section->connect); } if (section->connect_offset) { cgi_free_array(section->connect_offset); CGNS_FREE(section->connect_offset); } if (section->parelem) { cgi_free_array(section->parelem); CGNS_FREE(section->parelem); } if (section->parface) { cgi_free_array(section->parface); CGNS_FREE(section->parface); } if (section->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(§ion->user_data[n]); CGNS_FREE(section->user_data); } } void cgi_free_family(cgns_family *family) /* ** FAMILY TREE ** */ { int n; if (family->link) CGNS_FREE(family->link); if (family->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&family->descr[n]); CGNS_FREE(family->descr); } if (family->nfambc) { for (n=0; nnfambc; n++) cgi_free_fambc(&family->fambc[n]); CGNS_FREE(family->fambc); } if (family->ngeos) { for (n=0; nngeos; n++) cgi_free_geo(&family->geo[n]); CGNS_FREE(family->geo); } /* FAMILY TREE : Free Family_t nodes */ if ( family->nfamilies ) { for( n = 0; n < family->nfamilies; n++ ) cgi_free_family( &family->family[n] ); CGNS_FREE( family->family ); } if (family->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&family->user_data[n]); CGNS_FREE(family->user_data); } if (family->rotating) { cgi_free_rotating(family->rotating); CGNS_FREE(family->rotating); } if (family->nfamname) { for (n = 0; n < family->nfamname; n++) cgi_free_famname(&family->famname[n]); CGNS_FREE(family->famname); } } void cgi_free_fambc(cgns_fambc *fambc) { if (fambc->link) CGNS_FREE(fambc->link); if (fambc->ndataset) { int n; for (n=0; nndataset; n++) cgi_free_dataset(&fambc->dataset[n]); CGNS_FREE(fambc->dataset); } } /* currently here only to support delete */ void cgi_free_famname(cgns_famname *famname) { famname->name[0] = 0; famname->family[0] = 0; } void cgi_free_geo(cgns_geo *geo) { int n; if (geo->link) CGNS_FREE(geo->link); if (geo->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&geo->descr[n]); CGNS_FREE(geo->descr); } if (geo->file) CGNS_FREE(geo->file); if (geo->npart) { for (n=0; nnpart; n++) cgi_free_part(&geo->part[n]); CGNS_FREE(geo->part); } if (geo->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&geo->user_data[n]); CGNS_FREE(geo->user_data); } } void cgi_free_part(cgns_part *part) { if (part->link) CGNS_FREE(part->link); } void cgi_free_zcoor(cgns_zcoor *zcoor) { int n; if (zcoor->link) CGNS_FREE(zcoor->link); if (zcoor->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&zcoor->descr[n]); CGNS_FREE(zcoor->descr); } if (zcoor->rind_planes) CGNS_FREE(zcoor->rind_planes); if (zcoor->ncoords) { for (n=0; nncoords; n++) cgi_free_array(&zcoor->coord[n]); CGNS_FREE(zcoor->coord); } if (zcoor->units) { cgi_free_units(zcoor->units); CGNS_FREE(zcoor->units); } if (zcoor->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&zcoor->user_data[n]); CGNS_FREE(zcoor->user_data); } } void cgi_free_zboco(cgns_zboco *zboco) { int n; if (zboco->link) CGNS_FREE(zboco->link); if (zboco->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&zboco->descr[n]); CGNS_FREE(zboco->descr); } if (zboco->nbocos) { for (n=0; nnbocos; n++) cgi_free_boco(&zboco->boco[n]); CGNS_FREE(zboco->boco); } if (zboco->state) { cgi_free_state(zboco->state); CGNS_FREE(zboco->state); } if (zboco->units) { cgi_free_units(zboco->units); CGNS_FREE(zboco->units); } if (zboco->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&zboco->user_data[n]); CGNS_FREE(zboco->user_data); } } void cgi_free_zconn(cgns_zconn *zconn) { int n; if (zconn->link) CGNS_FREE(zconn->link); if (zconn->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&zconn->descr[n]); CGNS_FREE(zconn->descr); } if (zconn->n1to1) { for (n=0; nn1to1; n++) cgi_free_1to1(&zconn->one21[n]); CGNS_FREE(zconn->one21); } if (zconn->nconns) { for (n=0; nnconns; n++) cgi_free_conn(&zconn->conn[n]); CGNS_FREE(zconn->conn); } if (zconn->nholes) { for (n=0; nnholes; n++) cgi_free_hole(&zconn->hole[n]); CGNS_FREE(zconn->hole); } if (zconn->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&zconn->user_data[n]); CGNS_FREE(zconn->user_data); } } void cgi_free_sol(cgns_sol *sol) { int n; if (sol->link) CGNS_FREE(sol->link); if (sol->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&sol->descr[n]); CGNS_FREE(sol->descr); } if (sol->nfields) { for (n=0; nnfields; n++) cgi_free_array(&sol->field[n]); CGNS_FREE(sol->field); } if (sol->rind_planes) CGNS_FREE(sol->rind_planes); if (sol->units) { cgi_free_units(sol->units); CGNS_FREE(sol->units); } if (sol->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&sol->user_data[n]); CGNS_FREE(sol->user_data); } if (sol->ptset) { cgi_free_ptset(sol->ptset); CGNS_FREE(sol->ptset); } } void cgi_free_1to1(cgns_1to1 *one21) { int n; if (one21->link) CGNS_FREE(one21->link); CGNS_FREE(one21->transform); if (one21->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&one21->descr[n]); CGNS_FREE(one21->descr); } if (one21->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&one21->user_data[n]); CGNS_FREE(one21->user_data); } if (one21->cprop) { cgi_free_cprop(one21->cprop); CGNS_FREE(one21->cprop); } } void cgi_free_hole(cgns_hole *hole) { int n; if (hole->link) CGNS_FREE(hole->link); if (hole->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&hole->descr[n]); CGNS_FREE(hole->descr); } if (hole->nptsets) { for (n=0; nnptsets; n++) cgi_free_ptset(&hole->ptset[n]); CGNS_FREE(hole->ptset); } if (hole->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&hole->user_data[n]); CGNS_FREE(hole->user_data); } } void cgi_free_conn(cgns_conn *conn) { int n; if (conn->link) CGNS_FREE(conn->link); if (conn->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&conn->descr[n]); CGNS_FREE(conn->descr); } if (conn->interpolants) { cgi_free_array(conn->interpolants); CGNS_FREE(conn->interpolants); } if (conn->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&conn->user_data[n]); CGNS_FREE(conn->user_data); } if (conn->cprop) { cgi_free_cprop(conn->cprop); CGNS_FREE(conn->cprop); } } void cgi_free_boco(cgns_boco *boco) { int n; if (boco->link) CGNS_FREE(boco->link); if (boco->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&boco->descr[n]); CGNS_FREE(boco->descr); } if (boco->ptset) { cgi_free_ptset(boco->ptset); CGNS_FREE(boco->ptset); } if (boco->Nindex) CGNS_FREE(boco->Nindex); if (boco->normal) { cgi_free_array(boco->normal); CGNS_FREE(boco->normal); } if (boco->ndataset) { for (n=0; nndataset; n++) { /* If dataset[n].ptset came from boco->ptset, don't want to * attempt to free it. This is stuff Ken put in here. I don't * think this every happens - but just in case */ if(boco->dataset[n].ptset == boco->ptset) boco->dataset[n].ptset = 0; cgi_free_dataset(&boco->dataset[n]); } CGNS_FREE(boco->dataset); } if (boco->state) { cgi_free_state(boco->state); CGNS_FREE(boco->state); } if (boco->units) { cgi_free_units(boco->units); CGNS_FREE(boco->units); } if (boco->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&boco->user_data[n]); CGNS_FREE(boco->user_data); } if (boco->bprop) { cgi_free_bprop(boco->bprop); CGNS_FREE(boco->bprop); } if (boco->nfamname) { for (n = 0; n < boco->nfamname; n++) cgi_free_famname(&boco->famname[n]); CGNS_FREE(boco->famname); } } void cgi_free_dataset(cgns_dataset *dataset) { int n; if (dataset->link) CGNS_FREE(dataset->link); if (dataset->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&dataset->descr[n]); CGNS_FREE(dataset->descr); } if (dataset->dirichlet) { cgi_free_bcdata(dataset->dirichlet); CGNS_FREE(dataset->dirichlet); } if (dataset->neumann) { cgi_free_bcdata(dataset->neumann); CGNS_FREE(dataset->neumann); } if (dataset->state) { cgi_free_state(dataset->state); CGNS_FREE(dataset->state); } if (dataset->units) { cgi_free_units(dataset->units); CGNS_FREE(dataset->units); } if (dataset->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&dataset->user_data[n]); CGNS_FREE(dataset->user_data); } if (dataset->ptset) { cgi_free_ptset(dataset->ptset); CGNS_FREE(dataset->ptset); } } void cgi_free_bcdata(cgns_bcdata *bcdata) { int n; if (bcdata->link) CGNS_FREE(bcdata->link); if (bcdata->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&bcdata->descr[n]); CGNS_FREE(bcdata->descr); } if (bcdata->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&bcdata->array[n]); CGNS_FREE(bcdata->array); } if (bcdata->units) { cgi_free_units(bcdata->units); CGNS_FREE(bcdata->units); } if (bcdata->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&bcdata->user_data[n]); CGNS_FREE(bcdata->user_data); } } void cgi_free_ptset(cgns_ptset *ptset) { if (ptset->link) CGNS_FREE(ptset->link); if (ptset->data) CGNS_FREE(ptset->data); } void cgi_free_equations(cgns_equations *equations) { int n; if (equations->link) CGNS_FREE(equations->link); if (equations->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&equations->descr[n]); CGNS_FREE(equations->descr); } if (equations->governing) { cgi_free_governing(equations->governing); CGNS_FREE(equations->governing); } if (equations->gas) { cgi_free_model(equations->gas); CGNS_FREE(equations->gas); } if (equations->visc) { cgi_free_model(equations->visc); CGNS_FREE(equations->visc); } if (equations->conduct) { cgi_free_model(equations->conduct); CGNS_FREE(equations->conduct); } if (equations->closure) { cgi_free_model(equations->closure); CGNS_FREE(equations->closure); } if (equations->turbulence) { if (equations->turbulence->diffusion_model) CGNS_FREE(equations->turbulence->diffusion_model); cgi_free_model(equations->turbulence); CGNS_FREE(equations->turbulence); } if (equations->relaxation) { cgi_free_model(equations->relaxation); CGNS_FREE(equations->relaxation); } if (equations->chemkin) { cgi_free_model(equations->chemkin); CGNS_FREE(equations->chemkin); } if (equations->units) { cgi_free_units(equations->units); CGNS_FREE(equations->units); } if (equations->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&equations->user_data[n]); CGNS_FREE(equations->user_data); } if (equations->elecfield) { cgi_free_model(equations->elecfield); CGNS_FREE(equations->elecfield); } if (equations->magnfield) { cgi_free_model(equations->magnfield); CGNS_FREE(equations->magnfield); } if (equations->emconduct) { cgi_free_model(equations->emconduct); CGNS_FREE(equations->emconduct); } } void cgi_free_governing(cgns_governing *governing) { int n; if (governing->link) CGNS_FREE(governing->link); if (governing->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&governing->descr[n]); CGNS_FREE(governing->descr); } if (governing->diffusion_model) CGNS_FREE(governing->diffusion_model); if (governing->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&governing->user_data[n]); CGNS_FREE(governing->user_data); } } void cgi_free_model(cgns_model *model) { int n; if (model->link) CGNS_FREE(model->link); if (model->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&model->descr[n]); CGNS_FREE(model->descr); } if (model->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&model->array[n]); CGNS_FREE(model->array); } if (model->units) { cgi_free_units(model->units); CGNS_FREE(model->units); } if (model->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&model->user_data[n]); CGNS_FREE(model->user_data); } } void cgi_free_state(cgns_state *state) { int n; if (state->link) CGNS_FREE(state->link); if (state->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&state->descr[n]); CGNS_FREE(state->descr); } if (state->StateDescription) { cgi_free_descr(state->StateDescription); CGNS_FREE(state->StateDescription); } if (state->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&state->array[n]); CGNS_FREE(state->array); } if (state->units) { cgi_free_units(state->units); CGNS_FREE(state->units); } if (state->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&state->user_data[n]); CGNS_FREE(state->user_data); } } void cgi_free_converg(cgns_converg *converg) { int n; if (converg->link) CGNS_FREE(converg->link); if (converg->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&converg->descr[n]); CGNS_FREE(converg->descr); } if (converg->NormDefinitions) { cgi_free_descr(converg->NormDefinitions); CGNS_FREE(converg->NormDefinitions); } if (converg->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&converg->array[n]); CGNS_FREE(converg->array); } if (converg->units) { cgi_free_units(converg->units); CGNS_FREE(converg->units); } if (converg->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&converg->user_data[n]); CGNS_FREE(converg->user_data); } } void cgi_free_discrete(cgns_discrete *discrete) { int n; if (discrete->link) CGNS_FREE(discrete->link); if (discrete->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&discrete->descr[n]); CGNS_FREE(discrete->descr); } if (discrete->rind_planes) CGNS_FREE(discrete->rind_planes); if (discrete->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&discrete->array[n]); CGNS_FREE(discrete->array); } if (discrete->units) { cgi_free_units(discrete->units); CGNS_FREE(discrete->units); } if (discrete->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&discrete->user_data[n]); CGNS_FREE(discrete->user_data); } if (discrete->ptset) { cgi_free_ptset(discrete->ptset); CGNS_FREE(discrete->ptset); } } void cgi_free_integral(cgns_integral *integral) { int n; if (integral->link) CGNS_FREE(integral->link); if (integral->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&integral->descr[n]); CGNS_FREE(integral->descr); } if (integral->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&integral->array[n]); CGNS_FREE(integral->array); } if (integral->units) { cgi_free_units(integral->units); CGNS_FREE(integral->units); } if (integral->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&integral->user_data[n]); CGNS_FREE(integral->user_data); } } void cgi_free_array(cgns_array *array) { int n; if (array->link) CGNS_FREE(array->link); if (array->data) CGNS_FREE(array->data); if (array->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&array->descr[n]); CGNS_FREE(array->descr); } if (array->units) { cgi_free_units(array->units); CGNS_FREE(array->units); } if (array->exponents) { cgi_free_exponents(array->exponents); CGNS_FREE(array->exponents); } if (array->convert) { cgi_free_convert(array->convert); CGNS_FREE(array->convert); } } void cgi_free_convert(cgns_conversion *convert) { if (convert->link) CGNS_FREE(convert->link); CGNS_FREE(convert->data); } void cgi_free_exponents(cgns_exponent *exponents) { if (exponents->link) CGNS_FREE(exponents->link); CGNS_FREE(exponents->data); } void cgi_free_units(cgns_units *units) { if (units->link) CGNS_FREE(units->link); } void cgi_free_descr(cgns_descr *descr) { if (descr->link) CGNS_FREE(descr->link); if (descr->text) CGNS_FREE(descr->text); } void cgi_free_rmotion(cgns_rmotion *rmotion) { int n; if (rmotion->link) CGNS_FREE(rmotion->link); if (rmotion->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&rmotion->descr[n]); CGNS_FREE(rmotion->descr); } if (rmotion->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&rmotion->array[n]); CGNS_FREE(rmotion->array); } if (rmotion->units) { cgi_free_units(rmotion->units); CGNS_FREE(rmotion->units); } if (rmotion->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&rmotion->user_data[n]); CGNS_FREE(rmotion->user_data); } } void cgi_free_amotion(cgns_amotion *amotion) { int n; if (amotion->link) CGNS_FREE(amotion->link); if (amotion->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&amotion->descr[n]); CGNS_FREE(amotion->descr); } if (amotion->rind_planes) CGNS_FREE(amotion->rind_planes); if (amotion->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&amotion->array[n]); CGNS_FREE(amotion->array); } if (amotion->units) { cgi_free_units(amotion->units); CGNS_FREE(amotion->units); } if (amotion->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&amotion->user_data[n]); CGNS_FREE(amotion->user_data); } } void cgi_free_biter(cgns_biter *biter) { int n; if (biter->link) CGNS_FREE(biter->link); if (biter->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&biter->descr[n]); CGNS_FREE(biter->descr); } if (biter->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&biter->array[n]); CGNS_FREE(biter->array); } if (biter->units) { cgi_free_units(biter->units); CGNS_FREE(biter->units); } if (biter->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&biter->user_data[n]); CGNS_FREE(biter->user_data); } } void cgi_free_ziter(cgns_ziter *ziter) { int n; if (ziter->link) CGNS_FREE(ziter->link); if (ziter->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&ziter->descr[n]); CGNS_FREE(ziter->descr); } if (ziter->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&ziter->array[n]); CGNS_FREE(ziter->array); } if (ziter->units) { cgi_free_units(ziter->units); CGNS_FREE(ziter->units); } if (ziter->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&ziter->user_data[n]); CGNS_FREE(ziter->user_data); } } void cgi_free_gravity(cgns_gravity *gravity) { int n; if (gravity->link) CGNS_FREE(gravity->link); if (gravity->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&gravity->descr[n]); CGNS_FREE(gravity->descr); } if (gravity->vector) { cgi_free_array(gravity->vector); CGNS_FREE(gravity->vector); } if (gravity->units) { cgi_free_units(gravity->units); CGNS_FREE(gravity->units); } if (gravity->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&gravity->user_data[n]); CGNS_FREE(gravity->user_data); } } void cgi_free_axisym(cgns_axisym *axisym) { int n; if (axisym->link) CGNS_FREE(axisym->link); if (axisym->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&axisym->descr[n]); CGNS_FREE(axisym->descr); } if (axisym->units) { cgi_free_units(axisym->units); CGNS_FREE(axisym->units); } if (axisym->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&axisym->array[n]); CGNS_FREE(axisym->array); } if (axisym->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&axisym->user_data[n]); CGNS_FREE(axisym->user_data); } } void cgi_free_rotating(cgns_rotating *rotating) { int n; if (rotating->link) CGNS_FREE(rotating->link); if (rotating->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&rotating->descr[n]); CGNS_FREE(rotating->descr); } if (rotating->units) { cgi_free_units(rotating->units); CGNS_FREE(rotating->units); } if (rotating->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&rotating->array[n]); CGNS_FREE(rotating->array); } if (rotating->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&rotating->user_data[n]); CGNS_FREE(rotating->user_data); } } void cgi_free_bprop(cgns_bprop *bprop) { int n; if (bprop->link) CGNS_FREE(bprop->link); if (bprop->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&bprop->descr[n]); CGNS_FREE(bprop->descr); } if (bprop->bcwall) { cgi_free_bcwall(bprop->bcwall); CGNS_FREE(bprop->bcwall); } if (bprop->bcarea) { cgi_free_bcarea(bprop->bcarea); CGNS_FREE(bprop->bcarea); } if (bprop->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&bprop->user_data[n]); CGNS_FREE(bprop->user_data); } } void cgi_free_cprop(cgns_cprop *cprop) { int n; if (cprop->link) CGNS_FREE(cprop->link); if (cprop->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&cprop->descr[n]); CGNS_FREE(cprop->descr); } if (cprop->cperio) { cgi_free_cperio(cprop->cperio); CGNS_FREE(cprop->cperio); } if (cprop->caverage) { cgi_free_caverage(cprop->caverage); CGNS_FREE(cprop->caverage); } if (cprop->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&cprop->user_data[n]); CGNS_FREE(cprop->user_data); } } void cgi_free_bcwall(cgns_bcwall *bcwall) { int n; if (bcwall->link) CGNS_FREE(bcwall->link); if (bcwall->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&bcwall->descr[n]); CGNS_FREE(bcwall->descr); } if (bcwall->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&bcwall->user_data[n]); CGNS_FREE(bcwall->user_data); } } void cgi_free_bcarea(cgns_bcarea *bcarea) { int n; if (bcarea->link) CGNS_FREE(bcarea->link); if (bcarea->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&bcarea->descr[n]); CGNS_FREE(bcarea->descr); } if (bcarea->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&bcarea->array[n]); CGNS_FREE(bcarea->array); } if (bcarea->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&bcarea->user_data[n]); CGNS_FREE(bcarea->user_data); } } void cgi_free_cperio(cgns_cperio *cperio) { int n; if (cperio->link) CGNS_FREE(cperio->link); if (cperio->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&cperio->descr[n]); CGNS_FREE(cperio->descr); } if (cperio->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&cperio->array[n]); CGNS_FREE(cperio->array); } if (cperio->units) { cgi_free_units(cperio->units); CGNS_FREE(cperio->units); } if (cperio->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&cperio->user_data[n]); CGNS_FREE(cperio->user_data); } } void cgi_free_caverage(cgns_caverage *caverage) { int n; if (caverage->link) CGNS_FREE(caverage->link); if (caverage->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&caverage->descr[n]); CGNS_FREE(caverage->descr); } if (caverage->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&caverage->user_data[n]); CGNS_FREE(caverage->user_data); } } void cgi_free_user_data(cgns_user_data *user_data) { int n; if (user_data->link) CGNS_FREE(user_data->link); if (user_data->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&user_data->descr[n]); CGNS_FREE(user_data->descr); } if (user_data->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&user_data->array[n]); CGNS_FREE(user_data->array); } if (user_data->ptset) { cgi_free_ptset(user_data->ptset); CGNS_FREE(user_data->ptset); } if (user_data->units) { cgi_free_units(user_data->units); CGNS_FREE(user_data->units); } if (user_data->nuser_data) { for (n=0; n < user_data->nuser_data; n++) cgi_free_user_data(&user_data->user_data[n]); CGNS_FREE(user_data->user_data); } if (user_data->nfamname) { for (n = 0; n < user_data->nfamname; n++) cgi_free_famname(&user_data->famname[n]); CGNS_FREE(user_data->famname); } } void cgi_free_subreg(cgns_subreg *subreg) { int n; if (subreg->link) CGNS_FREE(subreg->link); if (subreg->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&subreg->descr[n]); CGNS_FREE(subreg->descr); } if (subreg->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&subreg->array[n]); CGNS_FREE(subreg->array); } if (subreg->ptset) { cgi_free_ptset(subreg->ptset); CGNS_FREE(subreg->ptset); } if (subreg->bcname){ cgi_free_descr(subreg->bcname); CGNS_FREE(subreg->bcname); } if (subreg->gcname){ cgi_free_descr(subreg->gcname); CGNS_FREE(subreg->gcname); } if (subreg->units) { cgi_free_units(subreg->units); CGNS_FREE(subreg->units); } if (subreg->rind_planes) CGNS_FREE(subreg->rind_planes); if (subreg->nuser_data) { for (n=0; n < subreg->nuser_data; n++) cgi_free_user_data(&subreg->user_data[n]); CGNS_FREE(subreg->user_data); } if (subreg->nfamname) { for (n = 0; n < subreg->nfamname; n++) cgi_free_famname(&subreg->famname[n]); CGNS_FREE(subreg->famname); } } void cgi_free_particle(cgns_pzone *pzone) { int n; if (pzone->link) CGNS_FREE(pzone->link); if (pzone->nfamname) { for (n=0; nnfamname; n++) cgi_free_famname(pzone->famname); CGNS_FREE(pzone->famname); } if (pzone->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&pzone->descr[n]); CGNS_FREE(pzone->descr); } if (pzone->npcoor) { for (n=0; nnpcoor; n++) cgi_free_pcoor(&pzone->pcoor[n]); CGNS_FREE(pzone->pcoor); } if (pzone->nsols) { for (n=0; nnsols; n++) cgi_free_psol(&pzone->sol[n]); CGNS_FREE(pzone->sol); } if (pzone->nintegrals) { for (n=0; nnintegrals; n++) cgi_free_integral(pzone->integral); CGNS_FREE(pzone->integral); } if (pzone->state) { cgi_free_state(pzone->state); CGNS_FREE(pzone->state); } if (pzone->units) { cgi_free_units(pzone->units); CGNS_FREE(pzone->units); } if (pzone->equations) { cgi_free_particle_equations(pzone->equations); CGNS_FREE(pzone->equations); } if (pzone->piter) { cgi_free_ziter(pzone->piter); CGNS_FREE(pzone->piter); } if (pzone->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&pzone->user_data[n]); CGNS_FREE(pzone->user_data) } } void cgi_free_pcoor(cgns_pcoor *pcoor) { int n; if (pcoor->link) CGNS_FREE(pcoor->link); if (pcoor->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&pcoor->descr[n]); CGNS_FREE(pcoor->descr); } if (pcoor->ncoords) { for (n=0; nncoords; n++) cgi_free_array(&pcoor->coord[n]); CGNS_FREE(pcoor->coord); } if (pcoor->units) { cgi_free_units(pcoor->units); CGNS_FREE(pcoor->units); } if (pcoor->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&pcoor->user_data[n]); CGNS_FREE(pcoor->user_data); } } void cgi_free_psol(cgns_psol *sol) { int n; if (sol->link) CGNS_FREE(sol->link); if (sol->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&sol->descr[n]); CGNS_FREE(sol->descr); } if (sol->nfields) { for (n=0; nnfields; n++) cgi_free_array(&sol->field[n]); CGNS_FREE(sol->field); } if (sol->units) { cgi_free_units(sol->units); CGNS_FREE(sol->units); } if (sol->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&sol->user_data[n]); CGNS_FREE(sol->user_data); } if (sol->ptset) { cgi_free_ptset(sol->ptset); CGNS_FREE(sol->ptset); } } void cgi_free_particle_model(cgns_pmodel *model) { int n; if (model->link) CGNS_FREE(model->link); if (model->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&model->descr[n]); CGNS_FREE(model->descr); } if (model->narrays) { for (n=0; nnarrays; n++) cgi_free_array(&model->array[n]); CGNS_FREE(model->array); } if (model->units) { cgi_free_units(model->units); CGNS_FREE(model->units); } if (model->nuser_data) { for (n=0; nnuser_data; n++) cgi_free_user_data(&model->user_data[n]); CGNS_FREE(model->user_data); } } void cgi_free_particle_equations(cgns_pequations *equations) { int n; if (equations->link) CGNS_FREE(equations->link); if (equations->ndescr) { for (n=0; nndescr; n++) cgi_free_descr(&equations->descr[n]); CGNS_FREE(equations->descr); } if (equations->governing) { cgi_free_particle_governing(equations->governing); CGNS_FREE(equations->governing); } if (equations->collision) { cgi_free_particle_model(equations->collision); CGNS_FREE(equations->collision); } if (equations->breakup) { cgi_free_particle_model(equations->breakup); CGNS_FREE(equations->breakup); } if (equations->force) { cgi_free_particle_model(equations->force); CGNS_FREE(equations->force); } if (equations->wallinteract) { cgi_free_particle_model(equations->wallinteract); CGNS_FREE(equations->wallinteract); } if (equations->phasechange) { cgi_free_particle_model(equations->phasechange); CGNS_FREE(equations->phasechange); } } /***********************************************************************\ * Return the string from enumeration * \***********************************************************************/ int cgi_GridLocation(char *LocationName, CGNS_ENUMT(GridLocation_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( GridLocationUserDefined ); cgi_warning("Unrecognized Grid Location Type '%s' replaced with 'UserDefined'",LocationName); return CG_OK; } cgi_error("Unrecognized GridLocation: %s", LocationName); return CG_ERROR; } int cgi_GridConnectivityType(char *GridConnectivityName, CGNS_ENUMT(GridConnectivityType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( GridConnectivityTypeUserDefined ); cgi_warning("Unrecognized Grid Connectivity Type '%s' replaced with 'UserDefined'",GridConnectivityName); return CG_OK; } cgi_error("Unrecognized GridConnectivityType: %s", GridConnectivityName); return CG_ERROR; } int cgi_PointSetType(char *PointSetName, CGNS_ENUMT(PointSetType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( PointSetTypeUserDefined ); cgi_warning("Unrecognized Point Set Type '%s' replaced with 'UserDefined'",PointSetName); return CG_OK; } cgi_error("Unrecognized PointSetType: %s", PointSetName); return CG_ERROR; } int cgi_BCType(char *BCName, CGNS_ENUMT(BCType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( BCTypeUserDefined ); cgi_warning("Unrecognized BCType '%s' replaced with 'UserDefined'",BCName); return CG_OK; } cgi_error("Unrecognized BCType: %s", BCName); return CG_ERROR; } int cgi_DataClass(char *Name, CGNS_ENUMT(DataClass_t) *data_class) { int i; for (i=0; iversion > CGNSLibVersion) { (*data_class) = CGNS_ENUMV( DataClassUserDefined ); cgi_warning("Unrecognized Data Class '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Data Class: %s",Name); return CG_ERROR; } int cgi_MassUnits(char *Name, CGNS_ENUMT(MassUnits_t) *mass_unit) { int i; for (i=31; i>=0 && Name[i]==' '; i--); Name[i+1]='\0'; for (i=0; iversion > CGNSLibVersion) { (*mass_unit) = CGNS_ENUMV( MassUnitsUserDefined ); cgi_warning("Unrecognized Mass Unit '%s' replaced with 'UserDefined'",Name); return CG_OK; } (*mass_unit) = CGNS_ENUMV( MassUnitsNull ); cgi_error("Unrecognized Mass Units Name: %s", Name); return CG_ERROR; } int cgi_LengthUnits(char *Name, CGNS_ENUMT(LengthUnits_t) *length_unit) { int i; for (i=31; i>=0 && Name[i]==' '; i--); Name[i+1]='\0'; for (i=0; iversion > CGNSLibVersion) { (*length_unit) = CGNS_ENUMV( LengthUnitsUserDefined ); cgi_warning("Unrecognized Length Unit '%s' replaced with 'UserDefined'",Name); return CG_OK; } (*length_unit) = CGNS_ENUMV( LengthUnitsNull ); cgi_error("Unrecognized Length Units Name: %s", Name); return CG_ERROR; } int cgi_TimeUnits(char *Name, CGNS_ENUMT(TimeUnits_t) *time_unit) { int i; for (i=31; i>=0 && Name[i]==' '; i--); Name[i+1]='\0'; for (i=0; iversion > CGNSLibVersion) { (*time_unit) = CGNS_ENUMV( TimeUnitsUserDefined ); cgi_warning("Unrecognized Time Unit '%s' replaced with 'UserDefined'",Name); return CG_OK; } (*time_unit) = CGNS_ENUMV( TimeUnitsNull ); cgi_error("Unrecognized Time Units Name: %s", Name); return CG_ERROR; } int cgi_TemperatureUnits(char *Name, CGNS_ENUMT(TemperatureUnits_t) *temperature_unit) { int i; for (i=31; i>=0 && Name[i]==' '; i--); Name[i+1]='\0'; if (0 == strcmp(Name, "Celcius")) { *temperature_unit = CGNS_ENUMV( Celsius ); return CG_OK; } for (i=0; iversion > CGNSLibVersion) { (*temperature_unit) = CGNS_ENUMV( TemperatureUnitsUserDefined ); cgi_warning("Unrecognized Temperature Unit '%s' replaced with 'UserDefined'",Name); return CG_OK; } (*temperature_unit) = CGNS_ENUMV( TemperatureUnitsNull ); cgi_error("Unrecognized Temperature Units Name: %s", Name); return CG_ERROR; } int cgi_AngleUnits(char *Name, CGNS_ENUMT(AngleUnits_t) *angle_unit) { int i; for (i=31; i>=0 && Name[i]==' '; i--); Name[i+1]='\0'; for (i=0; iversion > CGNSLibVersion) { (*angle_unit) = CGNS_ENUMV( AngleUnitsUserDefined ); cgi_warning("Unrecognized Angle Unit '%s' replaced with 'UserDefined'",Name); return CG_OK; } (*angle_unit) = CGNS_ENUMV( AngleUnitsNull ); cgi_error("Unrecognized Angle Units Name: %s", Name); return CG_ERROR; } int cgi_ElectricCurrentUnits(char *Name, CGNS_ENUMT(ElectricCurrentUnits_t) *unit) { int i; for (i=31; i>=0 && Name[i]==' '; i--); Name[i+1]='\0'; for (i=0; iversion > CGNSLibVersion) { (*unit) = CGNS_ENUMV( ElectricCurrentUnitsUserDefined ); cgi_warning("Unrecognized ElectricCurrent Unit '%s' replaced with 'UserDefined'",Name); return CG_OK; } (*unit) = CGNS_ENUMV( ElectricCurrentUnitsNull ); cgi_error("Unrecognized ElectricCurrent Units Name: %s", Name); return CG_ERROR; } int cgi_SubstanceAmountUnits(char *Name, CGNS_ENUMT(SubstanceAmountUnits_t) *unit) { int i; for (i=31; i>=0 && Name[i]==' '; i--); Name[i+1]='\0'; for (i=0; iversion > CGNSLibVersion) { (*unit) = CGNS_ENUMV( SubstanceAmountUnitsUserDefined ); cgi_warning("Unrecognized SubstanceAmount Unit '%s' replaced with 'UserDefined'",Name); return CG_OK; } (*unit) = CGNS_ENUMV( SubstanceAmountUnitsNull ); cgi_error("Unrecognized SubstanceAmount Units Name: %s", Name); return CG_ERROR; } int cgi_LuminousIntensityUnits(char *Name, CGNS_ENUMT(LuminousIntensityUnits_t) *unit) { int i; for (i=31; i>=0 && Name[i]==' '; i--); Name[i+1]='\0'; for (i=0; iversion > CGNSLibVersion) { (*unit) = CGNS_ENUMV( LuminousIntensityUnitsUserDefined ); cgi_warning("Unrecognized LuminousIntensity Unit '%s' replaced with 'UserDefined'",Name); return CG_OK; } (*unit) = CGNS_ENUMV( LuminousIntensityUnitsNull ); cgi_error("Unrecognized LuminousIntensity Units Name: %s", Name); return CG_ERROR; } int cgi_GoverningEquationsType(char *Name, CGNS_ENUMT(GoverningEquationsType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( GoverningEquationsUserDefined ); cgi_warning("Unrecognized Governing Equations Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Governing Equations Type: %s", Name); return CG_ERROR; } int cgi_ModelType(char *Name, CGNS_ENUMT(ModelType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( ModelTypeUserDefined ); cgi_warning("Unrecognized Model Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Model Type : %s", Name); return CG_ERROR; } int cgi_ParticleGoverningEquationsType(char *Name, CGNS_ENUMT(ParticleGoverningEquationsType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( ParticleGoverningEquationsUserDefined ); cgi_warning("Unrecognized Governing Equations Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Governing Equations Type: %s", Name); return CG_ERROR; } int cgi_ParticleModelType(char *Name, CGNS_ENUMT(ParticleModelType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( ParticleModelTypeUserDefined ); cgi_warning("Unrecognized Particle Model Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Particle Model Type : %s", Name); return CG_ERROR; } int cgi_ZoneType(char *Name, CGNS_ENUMT(ZoneType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( ZoneTypeUserDefined ); cgi_warning("Unrecognized Zone Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Zone Type : %s", Name); return CG_ERROR; } int cgi_RigidGridMotionType(char *Name, CGNS_ENUMT(RigidGridMotionType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( RigidGridMotionTypeUserDefined ); cgi_warning("Unrecognized Rigid Grid Motion Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Rigid Grid Motion Type: %s", Name); return CG_ERROR; } int cgi_ArbitraryGridMotionType(char *Name, CGNS_ENUMT(ArbitraryGridMotionType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( ArbitraryGridMotionTypeUserDefined ); cgi_warning("Unrecognized Arbitrary Grid Motion Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Arbitrary Grid Motion Type: %s", Name); return CG_ERROR; } int cgi_SimulationType(char *Name, CGNS_ENUMT(SimulationType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( SimulationTypeUserDefined ); cgi_warning("Unrecognized Simulation Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Simulation Type: %s", Name); return CG_ERROR; } int cgi_WallFunctionType(char *Name, CGNS_ENUMT(WallFunctionType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( WallFunctionTypeUserDefined ); cgi_warning("Unrecognized Wall Function Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Wall Function Type: %s", Name); return CG_ERROR; } int cgi_AreaType(char *Name, CGNS_ENUMT(AreaType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( AreaTypeUserDefined ); cgi_warning("Unrecognized Area Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Area Type: %s", Name); return CG_ERROR; } int cgi_AverageInterfaceType(char *Name, CGNS_ENUMT(AverageInterfaceType_t) *type) { int i; for (i=0; iversion > CGNSLibVersion) { (*type) = CGNS_ENUMV( AverageInterfaceTypeUserDefined ); cgi_warning("Unrecognized Average Interface Type '%s' replaced with 'UserDefined'",Name); return CG_OK; } cgi_error("Unrecognized Average Interface Type: %s", Name); return CG_ERROR; } void cgi_array_print(char *routine, cgns_array *array) { int n; printf("In %s:\n", routine); printf("\t array->name='%s'\n",array->name); printf("\t array->dim_vals="); for (n=0; ndata_dim; n++) printf("%" PRIdCGSIZE " ",array->dim_vals[n]); printf("\n"); printf("\t array->data_type='%s'\n",DataTypeName[cgi_datatype(array->data_type)]); printf("\t array->id=%13.6e\n",array->id); printf("\t array->ndescr=%d\n",array->ndescr); for (n=0; nndescr; n++) printf("%s\n",array->descr->text); if (array->data_class) printf("\t array->data_class=%s\n",DataClassName[array->data_class]); for (n=0; n<(array->dim_vals[0]*array->dim_vals[1]); n++) printf("%d ", *((int *)array->data+n)); return; } CGNS-4.5.0/src/cgns_io.c000066400000000000000000001573061474000356600146470ustar00rootroot00000000000000/*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ #ifndef __SUNPRO_C #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 600 #endif #endif #ifndef _WIN32 #define _POSIX_C_SOURCE 200112L #endif #include #include #include #include #include #include #if defined(_WIN32) && !defined(__NUTC__) # include # define ACCESS _access # define UNLINK _unlink #else # include # define ACCESS access # define UNLINK unlink #endif #include #include "cgns_io.h" #include "cgnslib.h" #include "adf/ADF.h" #if CG_BUILD_PARALLEL #include #endif #if CG_BUILD_HDF5 #include "adfh/ADFH.h" #if CG_BUILD_PARALLEL #include "hdf5.h" #endif #include "cgio_internal_type.h" /* for cgns_io_ctx_t */ #endif #ifdef MEM_DEBUG #include "cg_malloc.h" #endif #if CG_BUILD_HDF5 cgns_io_ctx_t ctx_cgio = { .hdf5_access = "NATIVE", #if CG_BUILD_PARALLEL .pcg_mpi_comm = MPI_COMM_NULL, .pcg_mpi_comm_size=1, .pcg_mpi_comm_rank=0, .pcg_mpi_initialized=0, .pcg_mpi_info=MPI_INFO_NULL, .default_pio_mode=H5FD_MPIO_COLLECTIVE #endif }; #endif #if CG_HAVE_STAT64_STRUCT #ifdef _WIN32 #define cgns_stat _stat64 #else #define cgns_stat stat64 #endif #else #define cgns_stat stat #endif /* Flag for contiguous or compact HDF5 storage */ extern int HDF5storage_type; typedef struct { int type; int mode; double rootid; } cgns_io; static int num_open = 0; static int num_iolist = 0; static cgns_io *iolist; static char *cgio_ErrorMessage[] = { "no error", "invalid cgio index", "malloc/realloc failed", "unknown file open mode", "invalid file type", "filename is NULL or empty", "character string is too small", "file was not found", "pathname is NULL or empty", "no match for pathname", "error opening file for reading", "file opened in read-only mode", "NULL or empty string", "invalid configure option", "rename of tempfile file failed", "too many open files", "dimensions exceed that for a 32-bit integer", "file has the wrong specified type", "not a HDF5 file - required for parallel" }; #define CGIO_MAX_ERRORS ((int)(sizeof(cgio_ErrorMessage)/sizeof(char *))) #define get_error() last_err static int last_err = CGIO_ERR_NONE; static int last_type = CGIO_FILE_NONE; static int abort_on_error = 0; static int cgio_n_paths = 0; static char **cgio_paths = 0; /*========================================================= * support routines *=========================================================*/ static int set_error (int errcode) { last_err = errcode; if (last_err && abort_on_error) cgio_error_exit(NULL); return last_err; } static cgns_io *get_cgnsio (int cgio_num, int write) { if (--cgio_num < 0 || cgio_num >= num_iolist) { last_err = CGIO_ERR_BAD_CGIO; return NULL; } if (write && iolist[cgio_num].mode == CGIO_MODE_READ) { last_err = CGIO_ERR_READ_ONLY; return NULL; } last_type = iolist[cgio_num].type; last_err = CGIO_ERR_NONE; return &iolist[cgio_num]; } /*---------------------------------------------------------*/ static cglong_t compute_data_size (const char *data_type, int ndims, const cgsize_t *dims) { int size; cglong_t count; size = cgio_compute_data_size (data_type, ndims, dims, &count); return (cglong_t)size * count; } /*---------------------------------------------------------*/ static int recurse_nodes (int input, double InputID, int output, double OutputID, int follow_links, int depth) { int n, nchild, cnt, name_len, file_len; char name[CGIO_MAX_NAME_LENGTH+1]; char *link_name, *link_file; double childID, newID; /* Copy the data from the current input node to the output node */ if (depth && cgio_copy_node(input, InputID, output, OutputID)) return CG_ERROR; /* Loop through the children of the current node */ if (cgio_number_children(input, InputID, &nchild)) return CG_ERROR; for (n = 1; n <= nchild; n++) { if (cgio_children_ids(input, InputID, n, 1, &cnt, &childID) || cgio_get_name(input, childID, name) || cgio_is_link(input, childID, &name_len)) return CG_ERROR; if (name_len) { if (cgio_link_size(input, childID, &file_len, &name_len)) return CG_ERROR; } if (name_len && (file_len == 0 || follow_links == 0)) { link_file = (char *) malloc (file_len + name_len + 2); if (link_file == NULL) { set_error(CGIO_ERR_MALLOC); return CG_ERROR; } link_name = link_file + file_len + 1; if (cgio_get_link(input, childID, link_file, link_name)) { free (link_file); return CG_ERROR; } link_file[file_len] = 0; link_name[name_len] = 0; if (cgio_create_link(output, OutputID, name, link_file, link_name, &newID)) { free (link_file); return CG_ERROR; } free (link_file); } else { if (cgio_create_node(output, OutputID, name, &newID) || recurse_nodes(input, childID, output, newID, follow_links, ++depth)) return CG_ERROR; } } return CG_OK; } /*---------------------------------------------------------*/ static int rewrite_file (int cginp, const char *filename) { int cgout, ierr; cgns_io *input, *output; char *tmpfile, *linkfile = NULL; #ifdef S_IFLNK struct cgns_stat st; #endif input = get_cgnsio(cginp, 0); if (input->mode != CGIO_MODE_READ && cgio_flush_to_disk(cginp)) return get_error(); #ifdef S_IFLNK if (!lstat(filename, &st) && (st.st_mode & S_IFLNK) == S_IFLNK) { int len; linkfile = (char *)malloc(st.st_size + 1); if (linkfile == NULL) return set_error(CGIO_ERR_MALLOC); len = readlink(filename, linkfile, st.st_size + 1); if (len < 0 || len > st.st_size) { free(linkfile); linkfile = NULL; } else { linkfile[len] = 0; } } #endif if (linkfile == NULL) { tmpfile = (char *)malloc(strlen(filename) + 6); if (tmpfile == NULL) return set_error(CGIO_ERR_MALLOC); sprintf(tmpfile, "%s.temp", filename); } else { tmpfile = (char *)malloc(strlen(linkfile) + 6); if (tmpfile == NULL) { free(linkfile); return set_error(CGIO_ERR_MALLOC); } sprintf(tmpfile, "%s.temp", linkfile); } UNLINK(tmpfile); if (cgio_open_file(tmpfile, CGIO_MODE_WRITE, input->type, &cgout)) { UNLINK(tmpfile); free(tmpfile); if (linkfile != NULL) free(linkfile); return get_error(); } output = get_cgnsio(cgout, 0); ierr = recurse_nodes(cginp, input->rootid, cgout, output->rootid, 0, 0); cgio_close_file (cgout); if (ierr) { UNLINK(tmpfile); free(tmpfile); if (linkfile != NULL) free(linkfile); return set_error(ierr); } ierr = CGIO_ERR_NONE; cgio_close_file (cginp); if (linkfile == NULL) { UNLINK(filename); if (rename(tmpfile, filename)) ierr = CGIO_ERR_FILE_RENAME; } else { UNLINK(linkfile); if (rename(tmpfile, linkfile)) ierr = CGIO_ERR_FILE_RENAME; free(linkfile); } free(tmpfile); return set_error(ierr); } /*========================================================= * paths for searching for linked-to files *=========================================================*/ int cgio_path_add (const char *path) { if (path == NULL || !*path) return set_error(CGIO_ERR_NULL_FILE); if (cgio_n_paths) cgio_paths = (char **) realloc (cgio_paths, (cgio_n_paths+1) * sizeof(char *)); else cgio_paths = (char **) malloc (sizeof(char *)); if (cgio_paths == NULL) { cgio_n_paths = 0; return set_error(CGIO_ERR_MALLOC); } cgio_paths[cgio_n_paths] = (char *) malloc (strlen(path)+1); if (cgio_paths[cgio_n_paths] == NULL) return set_error(CGIO_ERR_MALLOC); strcpy(cgio_paths[cgio_n_paths], path); cgio_n_paths++; return set_error(CGIO_ERR_NONE); } /*---------------------------------------------------------*/ int cgio_path_delete (const char *path) { int n; if (cgio_n_paths == 0) { if (path != NULL) return set_error(CGIO_ERR_NO_MATCH); return set_error(CGIO_ERR_NONE); } if (path != NULL) { for (n = 0; n < cgio_n_paths; n++) { if (cgio_paths[n] != NULL && 0 == strcmp(path, cgio_paths[n])) { free(cgio_paths[n]); cgio_paths[n] = NULL; return set_error(CGIO_ERR_NONE); } } return set_error(CGIO_ERR_NO_MATCH); } for (n = 0; n < cgio_n_paths; n++) { if (cgio_paths[n] != NULL) free(cgio_paths[n]); } free(cgio_paths); cgio_n_paths = 0; cgio_paths = NULL; return set_error(CGIO_ERR_NONE); } /*---------------------------------------------------------*/ int cgio_find_file (const char *parentfile, const char *filename, int file_type, int max_path_len, char *pathname) { int n, size, len, type; char *p, *s; if (filename == NULL || !*filename) return set_error(CGIO_ERR_NULL_FILE); size = max_path_len - 1 - (int)strlen(filename); if (size < 0) return set_error(CGIO_ERR_TOO_SMALL); /* full path */ if (*filename == '/' #ifdef _WIN32 || *filename == '\\' || *(filename+1) == ':' #endif ) { if (cgio_check_file(filename, &type) == CGIO_ERR_NONE && (file_type == CGIO_FILE_NONE || file_type == type)) { strcpy(pathname, filename); return set_error(CGIO_ERR_NONE); } if (get_error() == CGIO_ERR_TOO_MANY) return CGIO_ERR_TOO_MANY; return set_error(CGIO_ERR_NOT_FOUND); } /* check relative to parent's directory */ if (parentfile != NULL && *parentfile && (int)strlen(parentfile) < max_path_len-1) { strcpy(pathname, parentfile); p = strrchr(pathname, '/'); #ifdef _WIN32 if (p == NULL) p = strrchr(pathname, '\\'); #endif if (p != NULL) { *++p = 0; if ((int)strlen(pathname) <= size) { strcpy(p, filename); if (cgio_check_file(pathname, &type) == CGIO_ERR_NONE && (file_type == CGIO_FILE_NONE || file_type == type)) return set_error(CGIO_ERR_NONE); } } } /* check current directory */ if (cgio_check_file(filename, &type) == CGIO_ERR_NONE && (file_type == CGIO_FILE_NONE || file_type == type)) { strcpy(pathname, filename); return set_error(CGIO_ERR_NONE); } if (get_error() == CGIO_ERR_TOO_MANY) return CGIO_ERR_TOO_MANY; size -= 1; /* check file type environment variable */ if (file_type == CGIO_FILE_ADF || file_type == CGIO_FILE_ADF2) p = getenv ("ADF_LINK_PATH"); #if CG_BUILD_HDF5 else if (file_type == CGIO_FILE_HDF5) p = getenv ("HDF5_LINK_PATH"); #endif else p = NULL; while (p != NULL && *p) { #ifdef _WIN32 if (NULL == (s = strchr (p, ';'))) #else if (NULL == (s = strchr (p, ':'))) #endif len = (int)strlen(p); else len = (int)(s++ - p); if (len) { if (len > size) return set_error(CGIO_ERR_TOO_SMALL); strncpy (pathname, p, len); #ifdef _WIN32 for (n = 0; n < len; n++) { if (*p == '\\') *p = '/'; } #endif p = pathname + len; if (*(p-1) != '/') *p++ = '/'; strcpy (p, filename); if (cgio_check_file(pathname, &type) == CGIO_ERR_NONE && (file_type == CGIO_FILE_NONE || file_type == type)) return set_error(CGIO_ERR_NONE); } p = s; } /* check $CGNS_LINK_PATH environment variable */ p = getenv ("CGNS_LINK_PATH"); while (p != NULL && *p) { #ifdef _WIN32 if (NULL == (s = strchr (p, ';'))) #else if (NULL == (s = strchr (p, ':'))) #endif len = (int)strlen(p); else len = (int)(s++ - p); if (len) { if (len > size) return set_error(CGIO_ERR_TOO_SMALL); strncpy (pathname, p, len); #ifdef _WIN32 for (n = 0; n < len; n++) { if (*p == '\\') *p = '/'; } #endif p = pathname + len; if (*(p-1) != '/') *p++ = '/'; strcpy (p, filename); if (cgio_check_file(pathname, &type) == CGIO_ERR_NONE && (file_type == CGIO_FILE_NONE || file_type == type)) return set_error(CGIO_ERR_NONE); } p = s; } /* check list of search paths */ for (n = 0; n < cgio_n_paths; n++) { for (p = cgio_paths[n]; p != NULL && *p; ) { #ifdef _WIN32 if (NULL == (s = strchr (p, ';'))) #else if (NULL == (s = strchr (p, ':'))) #endif len = (int)strlen(p); else len = (int)(s++ - p); if (len) { if (len > size) return set_error(CGIO_ERR_TOO_SMALL); strncpy (pathname, p, len); #ifdef _WIN32 for (n = 0; n < len; n++) { if (*p == '\\') *p = '/'; } #endif p = pathname + len; if (*(p-1) != '/') *p++ = '/'; strcpy (p, filename); if (cgio_check_file(pathname, &type) == CGIO_ERR_NONE && (file_type == CGIO_FILE_NONE || file_type == type)) return set_error(CGIO_ERR_NONE); } p = s; } } return set_error(CGIO_ERR_NOT_FOUND); } /*========================================================= * utility routines independent of open files *=========================================================*/ int cgio_is_supported (int file_type) { if (file_type == CGIO_FILE_ADF) return set_error(CGIO_ERR_NONE); #if CG_SIZEOF_SIZE == 32 if (file_type == CGIO_FILE_ADF2) return set_error(CGIO_ERR_NONE); #endif #if CG_BUILD_HDF5 if (file_type == CGIO_FILE_HDF5) return set_error(CGIO_ERR_NONE); #endif last_err = CGIO_ERR_FILE_TYPE; return last_err; } /*---------------------------------------------------------*/ int cgio_configure (int what, void *value) { int ierr = CGIO_ERR_BAD_OPTION; if (what > 200) { #if CG_BUILD_HDF5 ADFH_Configure(what-200, value, &ierr); #endif } /* nothing here yet else if (what > 100) { } */ return set_error(ierr); } /*---------------------------------------------------------*/ void cgio_cleanup () { if (num_open) { int n; num_open++; for (n = 0; n < num_iolist; n++) { if (iolist[n].type != CGIO_FILE_NONE) cgio_close_file(n + 1); } free(iolist); num_iolist = 0; num_open = 0; } cgio_path_delete(NULL); } /*---------------------------------------------------------*/ int cgio_check_file (const char *filename, int *file_type) { int n; char buf[32]; FILE *fp; double rootid; static char *HDF5sig = "\211HDF\r\n\032\n"; struct cgns_stat st; int mpibuf[2], err = CGIO_ERR_NONE; *file_type = CGIO_FILE_NONE; #if 0 /* ACCESS call deactivated file open try-error strategy used instead */ if (ACCESS (filename, 0) || cgns_stat (filename, &st) || S_IFREG != (st.st_mode & S_IFREG)) { last_err = CGIO_ERR_NOT_FOUND; return last_err; } #endif #if CG_BUILD_PARALLEL /* don't overload the file system by having all the processors doing a read */ if(ctx_cgio.pcg_mpi_comm_rank == 0) { #endif #if CG_BUILD_HDF5 /* First try to open with HDF5 */ ADFH_Database_Open(filename, "READ_ONLY", ctx_cgio.hdf5_access, &rootid, &err); if (err == 0) { ADFH_Database_Close(rootid, &err); if (err > 0) return set_error(err); *file_type = CGIO_FILE_HDF5; } else { /* HDF5 did not work now try other cases */ #endif fp = fopen(filename, "rb"); if (NULL == fp) { if (errno == EMFILE) { err = set_error(CGIO_ERR_TOO_MANY); } else { err = set_error(CGIO_ERR_FILE_OPEN); } return err; } if (sizeof(buf) != fread (buf, 1, sizeof(buf), fp)) { buf[4] = 0; } buf[sizeof(buf)-1] = 0; fclose (fp); /* check for ADF */ if (0 == strncmp (&buf[4], "ADF Database Version", 20)) { *file_type = CGIO_FILE_ADF; err = set_error(CGIO_ERR_NONE); } else { /* check for HDF5 */ for (n = 0; n < 8; n++) { if (buf[n] != HDF5sig[n]) break; } if (n == 8) { *file_type = CGIO_FILE_HDF5; err = set_error(CGIO_ERR_NONE); } } #if CG_BUILD_HDF5 } /* endif case not hdf5 */ #endif #if CG_BUILD_PARALLEL } if(ctx_cgio.pcg_mpi_initialized) { mpibuf[0] = err; mpibuf[1] = *file_type; MPI_Bcast(mpibuf, 2, MPI_INT, 0, ctx_cgio.pcg_mpi_comm); err = mpibuf[0]; *file_type = mpibuf[1]; } #endif if(err == set_error(CGIO_ERR_NONE)) return err; last_err = CGIO_ERR_FILE_TYPE; return last_err; } /*---------------------------------------------------------*/ int cgio_compute_data_size (const char *data_type, int ndims, const cgsize_t *dims, cglong_t *count) { if (ndims > 0) { int i; *count = (cglong_t)dims[0]; for (i = 1; i < ndims; i++) *count *= (cglong_t)dims[i]; } else { *count = 0; } switch (*data_type) { case 'B': case 'C': return CG_ERROR; case 'I': case 'U': if (data_type[1] == '4') return sizeof(int); if (data_type[1] == '8') return sizeof(cglong_t); break; case 'R': if (data_type[1] == '4') return sizeof(float); if (data_type[1] == '8') return sizeof(double); break; case 'X': if (data_type[1] == '4') return (2 * sizeof(float)); if (data_type[1] == '8') return (2 * sizeof(double)); break; } return CG_OK; } /*---------------------------------------------------------*/ int cgio_check_dimensions (int ndims, const cglong_t *dims) { int n; for (n = 0; n < ndims; n++) { if (dims[n] > CG_MAX_INT32) return set_error(CGIO_ERR_DIMENSIONS); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_copy_dimensions (int ndims, const cglong_t *dims64, cgsize_t *dims) { int n; #if CG_SIZEOF_SIZE == 32 if (cgio_check_dimensions(ndims, dims64)) return get_error(); #endif for (n = 0; n < ndims; n++) dims[n] = (cgsize_t)dims64[n]; return CGIO_ERR_NONE; } /*========================================================= * file operations *=========================================================*/ int cgio_open_file (const char *filename, int file_mode, int file_type, int *cgio_num) { int n, ierr; int type; char *fmode; double rootid; *cgio_num = 0; switch(file_mode) { case CGIO_MODE_READ: case 'r': case 'R': fmode = "READ_ONLY"; file_mode = CGIO_MODE_READ; /* skip file checking if HDF5 requested */ if (file_type == CGIO_FILE_HDF5) break; if (cgio_check_file(filename, &type)) return get_error(); file_type = type; break; case CGIO_MODE_WRITE: case 'w': case 'W': UNLINK(filename); type = file_type; file_mode = CGIO_MODE_WRITE; fmode = "NEW"; break; case CGIO_MODE_MODIFY: case 'm': case 'M': fmode = "OLD"; file_mode = CGIO_MODE_MODIFY; /* skip file checking if HDF5 requested */ if (file_type == CGIO_FILE_HDF5) break; if (cgio_check_file(filename, &type)) return get_error(); file_type = type; break; default: return set_error(CGIO_ERR_FILE_MODE); } last_type = file_type; if (file_type == CGIO_FILE_NONE) { last_type = file_type = CGIO_FILE_ADF; ADF_Database_Open(filename, fmode, "NATIVE", &rootid, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_SIZEOF_SIZE == 32 else if (file_type == CGIO_FILE_ADF || file_type == CGIO_FILE_ADF2) { ADF_Database_Open(filename, fmode, "LEGACY", &rootid, &ierr); if (ierr > 0) return set_error(ierr); } #else else if (file_type == CGIO_FILE_ADF) { ADF_Database_Open(filename, fmode, "NATIVE", &rootid, &ierr); if (ierr > 0) return set_error(ierr); } #endif #if CG_BUILD_HDF5 else if (file_type == CGIO_FILE_HDF5) { ADFH_Database_Open(filename, fmode, ctx_cgio.hdf5_access, &rootid, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } if (num_iolist == 0) { num_iolist = 5; iolist = (cgns_io *) malloc (num_iolist * sizeof(cgns_io)); if (iolist == NULL) { fprintf(stderr, "malloc failed for IO list\n"); exit(1); } for (n = 0; n < num_iolist; n++) iolist[n].type = CGIO_FILE_NONE; } for (n = 0; n < num_iolist; n++) { if (iolist[n].type == CGIO_FILE_NONE) break; } if (n == num_iolist) { num_iolist++; iolist = (cgns_io *) realloc (iolist, num_iolist * sizeof(cgns_io)); if (iolist == NULL) { fprintf(stderr, "realloc failed for IO list\n"); exit(1); } } iolist[n].type = file_type; iolist[n].mode = file_mode; iolist[n].rootid = rootid; *cgio_num = n + 1; num_open++; return set_error(CGIO_ERR_NONE); } /*---------------------------------------------------------*/ int cgio_close_file (int cgio_num) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Database_Close(cgio->rootid, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Database_Close(cgio->rootid, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } cgio->type = CGIO_FILE_NONE; if (--num_open == 0) { free(iolist); num_iolist = 0; } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_compress_file (int cgio_num, const char *filename) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { if (rewrite_file (cgio_num, filename)) { ierr = get_error(); cgio_close_file(cgio_num); return set_error(ierr); } } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { if (rewrite_file (cgio_num, filename)) { ierr = get_error(); cgio_close_file(cgio_num); return set_error(ierr); } } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_copy_file (int cgio_num_inp, int cgio_num_out, int follow_links) { cgns_io *input, *output; if ((input = get_cgnsio(cgio_num_inp, 0)) == NULL || (output = get_cgnsio(cgio_num_out, 1)) == NULL) return get_error(); if (input->mode != CGIO_MODE_READ && cgio_flush_to_disk(cgio_num_inp)) return get_error(); if (recurse_nodes(cgio_num_inp, input->rootid, cgio_num_out, output->rootid, follow_links, 0)) return get_error(); return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_flush_to_disk (int cgio_num) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->mode == CGIO_MODE_READ) return CGIO_ERR_NONE; if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Flush_to_Disk(cgio->rootid, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Flush_to_Disk(cgio->rootid, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*========================================================= * file information *=========================================================*/ int cgio_library_version (int cgio_num, char *version) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Library_Version(version, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Library_Version(version, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_file_version (int cgio_num, char *file_version, char *creation_date, char *modified_date) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Database_Version(cgio->rootid, file_version, creation_date, modified_date, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Database_Version(cgio->rootid, file_version, creation_date, modified_date, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_get_root_id (int cgio_num, double *rootid) { cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); *rootid = cgio->rootid; return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_get_file_type (int cgio_num, int *file_type) { cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); *file_type = cgio->type; return CGIO_ERR_NONE; } /*========================================================= * error handling *=========================================================*/ void cgio_error_code (int *errcode, int *file_type) { *errcode = last_err; if (last_err <= 0) *file_type = CGIO_FILE_NONE; else *file_type = last_type; } /*---------------------------------------------------------*/ int cgio_error_message (char *error_msg) { char msg[ADF_MAX_ERROR_STR_LENGTH+1]; if (last_err <= 0) { int errcode = -last_err; if (errcode >= CGIO_MAX_ERRORS) strcpy(msg, "unknown cgio error message"); else strcpy(msg, cgio_ErrorMessage[errcode]); } else if (last_type == CGIO_FILE_ADF || last_type == CGIO_FILE_ADF2) { ADF_Error_Message(last_err, msg); } #if CG_BUILD_HDF5 else if (last_type == CGIO_FILE_HDF5) { ADFH_Error_Message(last_err, msg); } #endif else { strcpy(msg, "unknown error message"); } strcpy(error_msg, msg); return last_err; } /*---------------------------------------------------------*/ void cgio_error_exit (const char *msg) { fflush(stdout); if (msg != NULL && *msg) fprintf(stderr, "%s:", msg); if (last_err) { char errmsg[81]; cgio_error_message(errmsg); fprintf(stderr, "%s", errmsg); } putc('\n', stderr); cgio_cleanup(); exit(abort_on_error ? abort_on_error : -1); } /*---------------------------------------------------------*/ void cgio_error_abort (int abort_flag) { abort_on_error = abort_flag; } /*========================================================= * basic node operations *=========================================================*/ int cgio_create_node (int cgio_num, double pid, const char *name, double *id) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Create(pid, name, id, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Create(pid, name, id, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_new_node (int cgio_num, double pid, const char *name, const char *label, const char *data_type, int ndims, const cgsize_t *dims, const void *data, double *id) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Create(pid, name, id, &ierr); if (ierr > 0) return set_error(ierr); ADF_Set_Label(*id, label, &ierr); if (ierr > 0) return set_error(ierr); if (data_type != NULL && strcmp(data_type, "MT")) { ADF_Put_Dimension_Information(*id, data_type, ndims, dims, &ierr); if (ierr > 0) return set_error(ierr); if (data != NULL) { ADF_Write_All_Data(*id, (const char *)data, &ierr); if (ierr > 0) return set_error(ierr); } } } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Create(pid, name, id, &ierr); if (ierr > 0) return set_error(ierr); ADFH_Set_Label(*id, label, &ierr); if (ierr > 0) return set_error(ierr); if (data_type != NULL && strcmp(data_type, "MT")) { ADFH_Put_Dimension_Information(*id, data_type, ndims, dims, HDF5storage_type, &ierr); if (ierr > 0) return set_error(ierr); if (data != NULL) { ADFH_Write_All_Data(*id, NULL, (const char *)data, &ierr); if (ierr > 0) return set_error(ierr); } } } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_delete_node (int cgio_num, double pid, double id) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Delete(pid, id, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Delete(pid, id, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_move_node (int cgio_num, double pid, double id, double new_pid) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Move_Child(pid, id, new_pid, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Move_Child(pid, id, new_pid, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_copy_node (int cgio_num_inp, double id_inp, int cgio_num_out, double id_out) { cgns_io *input, *output; char label[CGIO_MAX_NAME_LENGTH+1]; char data_type[CGIO_MAX_NAME_LENGTH+1]; int ierr = 0, ndims; cgsize_t dims[CGIO_MAX_DIMENSIONS]; cglong_t data_size = 0; void *data = NULL; if ((input = get_cgnsio(cgio_num_inp, 0)) == NULL || (output = get_cgnsio(cgio_num_out, 1)) == NULL) return get_error(); /* read the input node data */ if (input->type == CGIO_FILE_ADF || input->type == CGIO_FILE_ADF2) { ADF_Get_Label(id_inp, label, &ierr); if (ierr > 0) return set_error(ierr); ADF_Get_Data_Type(id_inp, data_type, &ierr); if (ierr > 0) return set_error(ierr); ADF_Get_Number_of_Dimensions(id_inp, &ndims, &ierr); if (ierr > 0) return set_error(ierr); if (ndims > 0) { ADF_Get_Dimension_Values(id_inp, dims, &ierr); if (ierr > 0) return set_error(ierr); data_size = compute_data_size(data_type, ndims, dims); if (data_size) { data = malloc((size_t)data_size); if (data == NULL) return set_error(CGIO_ERR_MALLOC); ADF_Read_All_Data(id_inp, data_type, (char *)data, &ierr); if (ierr > 0) { free(data); return set_error(ierr); } } } } #if CG_BUILD_HDF5 else if (input->type == CGIO_FILE_HDF5) { ADFH_Get_Label(id_inp, label, &ierr); if (ierr > 0) return set_error(ierr); ADFH_Get_Data_Type(id_inp, data_type, &ierr); if (ierr > 0) return set_error(ierr); ADFH_Get_Number_of_Dimensions(id_inp, &ndims, &ierr); if (ierr > 0) return set_error(ierr); if (ndims > 0) { ADFH_Get_Dimension_Values(id_inp, dims, &ierr); if (ierr > 0) return set_error(ierr); data_size = compute_data_size(data_type, ndims, dims); if (data_size) { data = malloc((size_t)data_size); if (data == NULL) return set_error(CGIO_ERR_MALLOC); ADFH_Read_All_Data(id_inp, data_type, (char *)data, &ierr); if (ierr > 0) { free(data); return set_error(ierr); } } } } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } /* write data to output node */ if (output->type == CGIO_FILE_ADF || output->type == CGIO_FILE_ADF2) { ADF_Set_Label(id_out, label, &ierr); if (ierr <= 0) { ADF_Put_Dimension_Information(id_out, data_type, ndims, dims, &ierr); if (ierr <= 0 && data_size) ADF_Write_All_Data(id_out, (const char *)data, &ierr); } if (data_size) free(data); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (output->type == CGIO_FILE_HDF5) { ADFH_Set_Label(id_out, label, &ierr); if (ierr <= 0) { ADFH_Put_Dimension_Information(id_out, data_type, ndims, dims, HDF5storage_type, &ierr); if (ierr <= 0 && data_size) ADFH_Write_All_Data(id_out, NULL, (const char *)data, &ierr); } if (data_size) free(data); if (ierr > 0) return set_error(ierr); } #endif else { if (data_size) free(data); set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_release_id (int cgio_num, double id) { #if CG_BUILD_HDF5 cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_HDF5) { ADFH_Release_ID(id); } #endif return CGIO_ERR_NONE; } /*========================================================= * links *=========================================================*/ int cgio_is_link (int cgio_num, double id, int *link_len) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Is_Link(id, link_len, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Is_Link(id, link_len, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_link_size (int cgio_num, double id, int *file_len, int *name_len) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Link_Size(id, file_len, name_len, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Link_Size(id, file_len, name_len, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_create_link (int cgio_num, double pid, const char *name, const char *filename, const char *name_in_file, double *id) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Link(pid, name, filename, name_in_file, id, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Link(pid, name, filename, name_in_file, id, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_get_link (int cgio_num, double id, char *filename, char *name_in_file) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Get_Link_Path(id, filename, name_in_file, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Get_Link_Path(id, filename, name_in_file, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*========================================================= * node children *=========================================================*/ int cgio_number_children (int cgio_num, double id, int *num_children) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Number_of_Children(id, num_children, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Number_of_Children(id, num_children, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_children_ids (int cgio_num, double pid, int start, int max_ret, int *num_ret, double *ids) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Children_IDs(pid, start, max_ret, num_ret, ids, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Children_IDs(pid, start, max_ret, num_ret, ids, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_children_names (int cgio_num, double pid, int start, int max_ret, int name_len, int *num_ret, char *names) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Children_Names(pid, start, max_ret, name_len-1, num_ret, names, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Children_Names(pid, start, max_ret, name_len, num_ret, names, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*========================================================= * read nodes *=========================================================*/ int cgio_get_node_id (int cgio_num, double pid, const char *name, double *id) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Get_Node_ID(pid, name, id, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Get_Node_ID(pid, name, id, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_get_name (int cgio_num, double id, char *name) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Get_Name(id, name, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Get_Name(id, name, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_get_label (int cgio_num, double id, char *label) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Get_Label(id, label, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Get_Label(id, label, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_get_data_type (int cgio_num, double id, char *data_type) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Get_Data_Type(id, data_type, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Get_Data_Type(id, data_type, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_get_data_size (int cgio_num, double id, cglong_t *data_size) { int byte, ndims; cgsize_t dims[CGIO_MAX_DIMENSIONS]; char data_type[CGIO_MAX_NAME_LENGTH]; *data_size = 0; if (cgio_get_dimensions(cgio_num, id, &ndims, dims) || cgio_get_data_type(cgio_num, id, data_type)) return get_error(); byte = cgio_compute_data_size(data_type, ndims, dims, data_size); *data_size *= byte; return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_get_dimensions (int cgio_num, double id, int *num_dims, cgsize_t *dims) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Get_Number_of_Dimensions(id, num_dims, &ierr); if (NULL != dims && ierr <= 0 && *num_dims > 0) { ADF_Get_Dimension_Values(id, dims, &ierr); } if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Get_Number_of_Dimensions(id, num_dims, &ierr); if (NULL != dims && ierr <= 0 && *num_dims > 0) { ADFH_Get_Dimension_Values(id, dims, &ierr); } if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_read_all_data_type (int cgio_num, double id, const char *m_data_type, void *data) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { /* m_data_type is ignored since changing type when reading is not supported with adf files. In practice, we convert first and call cgio_read_all_data_type */ ADF_Read_All_Data(id, m_data_type, (char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Read_All_Data(id, m_data_type, data, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_read_block_data_type (int cgio_num, double id, cgsize_t b_start, cgsize_t b_end, const char *m_data_type, void *data) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Read_Block_Data(id, b_start, b_end, (char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Read_Block_Data(id, b_start, b_end, m_data_type, data, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_read_data_type (int cgio_num, double id, const cgsize_t *s_start, const cgsize_t *s_end, const cgsize_t *s_stride, const char *m_data_type, int m_num_dims, const cgsize_t *m_dims, const cgsize_t *m_start, const cgsize_t *m_end, const cgsize_t *m_stride, void *data) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Read_Data(id, s_start, s_end, s_stride, m_num_dims, m_dims, m_start, m_end, m_stride, m_data_type, (char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Read_Data(id, s_start, s_end, s_stride, m_num_dims, m_dims, m_start, m_end, m_stride, m_data_type, data, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*========================================================= * write nodes *=========================================================*/ int cgio_set_name (int cgio_num, double pid, double id, const char *name) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Put_Name(pid, id, name, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Put_Name(pid, id, name, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_set_label (int cgio_num, double id, const char *label) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Set_Label(id, label, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Set_Label(id, label, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_set_dimensions (int cgio_num, double id, const char *data_type, int num_dims, const cgsize_t *dims) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Put_Dimension_Information(id, data_type, num_dims, dims, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Put_Dimension_Information(id, data_type, num_dims, dims, HDF5storage_type, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_write_all_data (int cgio_num, double id, const void *data) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Write_All_Data(id, (const char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Write_All_Data(id, NULL, (const char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_write_all_data_type (int cgio_num, double id, const char *m_data_type, const void *data) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { /* Changing type when writing is not supported with adf files. In practice, we convert first and call cgio_write_all_data */ return set_error(CGIO_ERR_NOT_HDF5); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Write_All_Data(id, m_data_type, (const char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_write_block_data (int cgio_num, double id, cgsize_t b_start, cgsize_t b_end, void *data) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 0)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Write_Block_Data(id, b_start, b_end, (char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Write_Block_Data(id, b_start, b_end, (char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_write_data (int cgio_num, double id, const cgsize_t *s_start, const cgsize_t *s_end, const cgsize_t *s_stride, int m_num_dims, const cgsize_t *m_dims, const cgsize_t *m_start, const cgsize_t *m_end, const cgsize_t *m_stride, const void *data) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { ADF_Write_Data(id, s_start, s_end, s_stride, m_num_dims, m_dims, m_start, m_end, m_stride, (const char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Write_Data(id, s_start, s_end, s_stride, NULL, m_num_dims, m_dims, m_start, m_end, m_stride, (const char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } /*---------------------------------------------------------*/ int cgio_write_data_type (int cgio_num, double id, const cgsize_t *s_start, const cgsize_t *s_end, const cgsize_t *s_stride, const char *m_data_type, int m_num_dims, const cgsize_t *m_dims, const cgsize_t *m_start, const cgsize_t *m_end, const cgsize_t *m_stride, const void *data) { int ierr; cgns_io *cgio; if ((cgio = get_cgnsio(cgio_num, 1)) == NULL) return get_error(); if (cgio->type == CGIO_FILE_ADF || cgio->type == CGIO_FILE_ADF2) { /* Changing type when writing is not supported with adf files. In practice, we convert first and call cgio_write_data */ return set_error(CGIO_ERR_NOT_HDF5); } #if CG_BUILD_HDF5 else if (cgio->type == CGIO_FILE_HDF5) { ADFH_Write_Data(id, s_start, s_end, s_stride, m_data_type, m_num_dims, m_dims, m_start, m_end, m_stride, (const char *)data, &ierr); if (ierr > 0) return set_error(ierr); } #endif else { return set_error(CGIO_ERR_FILE_TYPE); } return CGIO_ERR_NONE; } CGNS-4.5.0/src/cgns_io.h000066400000000000000000000226321474000356600146450ustar00rootroot00000000000000/* ------------------------------------------------------------------------- * * CGNS - CFD General Notation System (http://www.cgns.org) * * CGNS/MLL - Mid-Level Library header file * * Please see cgnsconfig.h file for this local installation configuration * * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- * This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. * ------------------------------------------------------------------------- */ #ifndef CGNS_IO_H #define CGNS_IO_H #include "cgnstypes.h" #if defined(_WIN32) && defined(BUILD_DLL) # define CGEXTERN extern __declspec(dllexport) #else # define CGEXTERN extern #endif /* these should be the same as in cgnslib.h but are included here for completeness */ #define CGIO_MODE_READ 0 #define CGIO_MODE_WRITE 1 #define CGIO_MODE_MODIFY 2 #define CGIO_FILE_NONE 0 #define CGIO_FILE_ADF 1 #define CGIO_FILE_HDF5 2 #define CGIO_FILE_ADF2 3 #define CGIO_CONTIGUOUS 0 #define CGIO_COMPACT 1 #define CGIO_CHUNKED 2 /* currently these are the same as for ADF */ #define CGIO_MAX_DATATYPE_LENGTH 2 #define CGIO_MAX_DIMENSIONS 12 #define CGIO_MAX_NAME_LENGTH 32 #define CGIO_MAX_LABEL_LENGTH 32 #define CGIO_MAX_VERSION_LENGTH 32 #define CGIO_MAX_DATE_LENGTH 32 #define CGIO_MAX_ERROR_LENGTH 80 #define CGIO_MAX_LINK_DEPTH 100 #define CGIO_MAX_FILE_LENGTH 1024 #define CGIO_MAX_LINK_LENGTH 4096 /* these are the cgio error codes */ #define CGIO_ERR_NONE 0 #define CGIO_ERR_BAD_CGIO -1 #define CGIO_ERR_MALLOC -2 #define CGIO_ERR_FILE_MODE -3 #define CGIO_ERR_FILE_TYPE -4 #define CGIO_ERR_NULL_FILE -5 #define CGIO_ERR_TOO_SMALL -6 #define CGIO_ERR_NOT_FOUND -7 #define CGIO_ERR_NULL_PATH -8 #define CGIO_ERR_NO_MATCH -9 #define CGIO_ERR_FILE_OPEN -10 #define CGIO_ERR_READ_ONLY -11 #define CGIO_ERR_NULL_STRING -12 #define CGIO_ERR_BAD_OPTION -13 #define CGIO_ERR_FILE_RENAME -14 #define CGIO_ERR_TOO_MANY -15 #define CGIO_ERR_DIMENSIONS -16 #define CGIO_ERR_BAD_TYPE -17 #define CGIO_ERR_NOT_HDF5 -18 #ifdef __cplusplus extern "C" { #endif /*---------------------------------------------------------*/ CGEXTERN int cgio_path_add ( const char *path ); CGEXTERN int cgio_path_delete ( const char *path ); CGEXTERN int cgio_find_file ( const char *parentfile, const char *filename, int file_type, int max_path_len, char *pathname ); /*---------------------------------------------------------*/ CGEXTERN int cgio_is_supported ( int file_type ); CGEXTERN int cgio_configure ( int what, void *value ); CGEXTERN void cgio_cleanup (void); CGEXTERN int cgio_check_file ( const char *filename, int *file_type ); CGEXTERN int cgio_compute_data_size ( const char *data_type, int num_dims, const cgsize_t *dim_vals, cglong_t *count ); CGEXTERN int cgio_check_dimensions ( int ndims, const cglong_t *dims ); CGEXTERN int cgio_copy_dimensions ( int ndims, const cglong_t *dims64, cgsize_t *dims ); /*---------------------------------------------------------*/ CGEXTERN int cgio_open_file ( const char *filename, int file_mode, int file_type, int *cgio_num ); CGEXTERN int cgio_close_file ( int cgio_num ); CGEXTERN int cgio_compress_file ( int cgio_num, const char *filename ); CGEXTERN int cgio_copy_file ( int cgio_num_inp, int cgio_num_out, int follow_links ); CGEXTERN int cgio_flush_to_disk ( int cgio_num ); /*---------------------------------------------------------*/ CGEXTERN int cgio_library_version ( int cgio_num, char *version ); CGEXTERN int cgio_file_version ( int cgio_num, char *file_version, char *creation_date, char *modified_date ); CGEXTERN int cgio_get_root_id ( int cgio_num, double *rootid ); CGEXTERN int cgio_get_file_type ( int cgio_num, int *file_type ); /*---------------------------------------------------------*/ CGEXTERN void cgio_error_code ( int *errcode, int *file_type ); CGEXTERN int cgio_error_message ( char *error_msg ); CGEXTERN void cgio_error_exit ( const char *msg ); CGEXTERN void cgio_error_abort ( int abort_flag ); /*---------------------------------------------------------*/ CGEXTERN int cgio_create_node ( int cgio_num, double pid, const char *name, double *id ); CGEXTERN int cgio_new_node ( int cgio_num, double pid, const char *name, const char *label, const char *data_type, int ndims, const cgsize_t *dims, const void *data, double *id ); CGEXTERN int cgio_delete_node ( int cgio_num, double pid, double id ); CGEXTERN int cgio_move_node ( int cgio_num, double pid, double id, double new_pid ); CGEXTERN int cgio_copy_node ( int cgio_num_inp, double id_inp, int cgio_num_out, double id_out ); CGEXTERN int cgio_release_id ( int cgio_num, double id ); /*---------------------------------------------------------*/ CGEXTERN int cgio_is_link ( int cgio_num, double id, int *link_len ); CGEXTERN int cgio_link_size ( int cgio_num, double id, int *file_len, int *name_len ); CGEXTERN int cgio_create_link ( int cgio_num, double pid, const char *name, const char *filename, const char *name_in_file, double *id ); CGEXTERN int cgio_get_link ( int cgio_num, double id, char *filename, char *name_in_file ); /*---------------------------------------------------------*/ CGEXTERN int cgio_number_children ( int cgio_num, double id, int *num_children ); CGEXTERN int cgio_children_ids ( int cgio_num, double pid, int start, int max_ret, int *num_ret, double *ids ); CGEXTERN int cgio_children_names ( int cgio_num, double pid, int start, int max_ret, int name_len, int *num_ret, char *names ); /*---------------------------------------------------------*/ CGEXTERN int cgio_get_node_id ( int cgio_num, double pid, const char *name, double *id ); CGEXTERN int cgio_get_name ( int cgio_num, double id, char *name ); CGEXTERN int cgio_get_label ( int cgio_num, double id, char *label ); CGEXTERN int cgio_get_data_type ( int cgio_num, double id, char *data_type ); CGEXTERN int cgio_get_data_size ( int cgio_num, double id, cglong_t *data_size ); CGEXTERN int cgio_get_dimensions ( int cgio_num, double id, int *num_dims, cgsize_t *dims ); CGEXTERN int cgio_read_all_data_type ( int cgio_num, double id, const char *m_data_type, void *data ); CGEXTERN int cgio_read_block_data_type ( int cgio_num, double id, cgsize_t b_start, cgsize_t b_end, const char *m_data_type, void *data ); CGEXTERN int cgio_read_data_type ( int cgio_num, double id, const cgsize_t *s_start, const cgsize_t *s_end, const cgsize_t *s_stride, const char *m_data_type, int m_num_dims, const cgsize_t *m_dims, const cgsize_t *m_start, const cgsize_t *m_end, const cgsize_t *m_stride, void *data ); /*---------------------------------------------------------*/ CGEXTERN int cgio_set_name ( int cgio_num, double pid, double id, const char *name ); CGEXTERN int cgio_set_label ( int cgio_num, double id, const char *label ); CGEXTERN int cgio_set_dimensions ( int cgio_num, double id, const char *data_type, int num_dims, const cgsize_t *dims ); CGEXTERN int cgio_write_all_data ( int cgio_num, double id, const void *data ); CGEXTERN int cgio_write_all_data_type ( int cgio_num, double id, const char *m_data_type, const void *data ); CGEXTERN int cgio_write_block_data ( int cgio_num, double id, cgsize_t b_start, cgsize_t b_end, void *data ); CGEXTERN int cgio_write_data ( int cgio_num, double id, const cgsize_t *s_start, const cgsize_t *s_end, const cgsize_t *s_stride, int m_num_dims, const cgsize_t *m_dims, const cgsize_t *m_start, const cgsize_t *m_end, const cgsize_t *m_stride, const void *data ); CGEXTERN int cgio_write_data_type ( int cgio_num, double id, const cgsize_t *s_start, const cgsize_t *s_end, const cgsize_t *s_stride, const char *m_data_type, int m_num_dims, const cgsize_t *m_dims, const cgsize_t *m_start, const cgsize_t *m_end, const cgsize_t *m_stride, const void *data ); #ifdef __cplusplus } #endif #undef CGEXTERN #endif CGNS-4.5.0/src/cgns_io_f.h000066400000000000000000000051241474000356600151470ustar00rootroot00000000000000c * ------------------------------------------------------------------------- * c * CGNS - CFD General Notation System (http://www.cgns.org) * c * CGNS/MLL - Mid-Level Library header file * c * Please see cgnsconfig.h file for this local installation configuration * c * ------------------------------------------------------------------------- * c c * ------------------------------------------------------------------------- * c c This software is provided 'as-is', without any express or implied warranty. c In no event will the authors be held liable for any damages arising from c the use of this software. c c Permission is granted to anyone to use this software for any purpose, c including commercial applications, and to alter it and redistribute it c freely, subject to the following restrictions: c c 1. The origin of this software must not be misrepresented; you must not c claim that you wrote the original software. If you use this software c in a product, an acknowledgment in the product documentation would be c appreciated but is not required. c c 2. Altered source versions must be plainly marked as such, and must not c be misrepresented as being the original software. c c 3. This notice may not be removed or altered from any source distribution. c c * ------------------------------------------------------------------------- * c c c file open modes c integer CGIO_MODE_READ, CGIO_MODE_WRITE, CGIO_MODE_MODIFY parameter (CGIO_MODE_READ = 0) parameter (CGIO_MODE_WRITE = 1) parameter (CGIO_MODE_MODIFY = 2) c c database file types c integer CGIO_FILE_NONE, CGIO_FILE_ADF, CGIO_FILE_HDF5, & CGIO_FILE_ADF2 parameter (CGIO_FILE_NONE = 0) parameter (CGIO_FILE_ADF = 1) parameter (CGIO_FILE_HDF5 = 2) parameter (CGIO_FILE_ADF2 = 3) c c dimension limits c integer CGIO_MAX_DATATYPE_LENGTH, CGIO_MAX_DIMENSIONS, & CGIO_MAX_NAME_LENGTH, CGIO_MAX_LABEL_LENGTH, & CGIO_MAX_VERSION_LENGTH, CGIO_MAX_ERROR_LENGTH, & CGIO_MAX_LINK_DEPTH, CGIO_MAX_FILE_LENGTH, & CGIO_MAX_LINK_LENGTH parameter (CGIO_MAX_DATATYPE_LENGTH = 2) parameter (CGIO_MAX_DIMENSIONS = 12) parameter (CGIO_MAX_NAME_LENGTH = 32) parameter (CGIO_MAX_LABEL_LENGTH = 32) parameter (CGIO_MAX_VERSION_LENGTH = 32) parameter (CGIO_MAX_ERROR_LENGTH = 80) parameter (CGIO_MAX_LINK_DEPTH = 100) parameter (CGIO_MAX_FILE_LENGTH = 1024) parameter (CGIO_MAX_LINK_LENGTH = 4096) CGNS-4.5.0/src/cgnsconfig.h.in000066400000000000000000000044731474000356600157540ustar00rootroot00000000000000/* ------------------------------------------------------------------------- * * CGNS - CFD General Notation System (http://www.cgns.org) * * CGNS/MLL - Mid-Level Library header file * * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- * This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- * This file has been generated during the CGNS/MLL installation. This is a snapshot of the parameters used for CGNS/MLL production and some PATHS parameters (headers or shared libs) may change or disappear (for example in case of cross-compilation). * ------------------------------------------------------------------------- */ #ifndef CGNSCONFIG_H #define CGNSCONFIG_H #define CG_BUILD_DEBUG @BUILDDEBUG@ #define CG_BUILD_FORTRAN @BUILDFORTRAN@ #define CG_BUILD_BASESCOPE @BUILDBASESCOPE@ #define HDF5_INCLUDE_PATH "@HDF5INC@" #define HDF5_LIBRARY "@HDF5LIB@" #define HDF5_NEED_MPI @H5NEEDMPI@ #define HDF5_NEED_SZIP @H5NEEDSZIP@ #define HDF5_NEED_ZLIB @H5NEEDZLIB@ #define MPI_INCLUDE_PATH "@MPIINC@" #define MPI_LIBRARY "@MPILIBS@" #define SZIP_LIBRARY "@SZIPLIB@" #define ZLIB_LIBRARY "@ZLIBLIB@" #define MPI_INC "@MPIINC@" #define MPI_LIBS "@MPILIBS@" #include "cgnstypes.h" #endif CGNS-4.5.0/src/cgnslib.c000066400000000000000000027434021474000356600146470ustar00rootroot00000000000000/*------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ /*------------------------------------------------------------------------- * _____ _____ _ _ _____ * / ____/ ____| \ | |/ ____| * | | | | __| \| | (___ * | | | | |_ | . ` |\___ \ * | |___| |__| | |\ |____) | * \_____\_____|_| \_|_____/ * * PURPOSE: * Provides Mid-Level Library (MLL) CGNS interfaces and * various supporting APIs. * * DOCUMENTATION DESIGN * * Document all new public APIs with Doxygen entries. * * Keep descriptive text line lengths between 60-75 characters optimally, * with a maximum of 90 characters. * * Consider using Doxygen aliases for recurring entries. */ /** * \defgroup AccessingANode Accessing a node * \defgroup ArbitraryGridMotion Arbitrary Grid Motion * \defgroup AuxiliaryModel Auxiliary Model * \defgroup Axisymmetry Axisymmetry * \defgroup BCData Boundary Condition Data * \defgroup BaseIterativeData Base Iterative Data * \defgroup BoundaryConditionDatasets Boundary Condition Datasets * \defgroup BoundaryConditionType Boundary Condition Type and Location * \defgroup CGNSBaseInformation CGNS Base Information * \defgroup CGNSFamilyBoundaryCondition Family Boundary Condition * \defgroup CGNSFamilyDefinition Family Definition * \defgroup CGNSFamilyHierarchyTreeDefinition Family Hierarchy Tree * \defgroup CGNSFile File Operations * \defgroup CGNSGeometryReference Geometry Reference * \defgroup CGNSInterfaceCGIO Interfacing with CGIO * \defgroup CGNSInternals Configuring CGNS Internals * \defgroup CGNSInternals_FNC_CG_CONFIG Configuring CGNS Internals * \defgroup CGNSZoneInformation CGNS Zone Information * \defgroup ConvergenceHistory Convergence History * \defgroup DataArrays Data Arrays * \defgroup DataClass Data Class * \defgroup DataConversionFactors Data Conversion Factors * \defgroup DeletingANode Deleting a node * \defgroup DescriptiveText Descriptive Text * \defgroup DimensionalExponents Dimensional Exponents * \defgroup DimensionalUnits Dimensional Units * \defgroup DiscreteData Discrete Data * \defgroup ElementConnectivity Element Connectivity * \defgroup FamilyName Family Name * \defgroup FlowEquationSet Flow Equation Set * \defgroup FlowSolution Flow Solution * \defgroup FlowSolutionData Flow Solution Data * \defgroup FreeingMemory Freeing Memory * \defgroup GeneralizedConnectivity Generalized Connectivity * \defgroup GoverningEquations Governing Equations * \defgroup Gravity Gravity * \defgroup GridLocation Grid Location * \defgroup IntegralData Integral Data * \defgroup Links Links * \defgroup OneToOneConnectivity One-to-One Connectivity * \defgroup OrdinalValue Ordinal Value * \defgroup OversetHoles Overset Holes * \defgroup PointSets Point Sets * \defgroup ReferenceState Reference State * \defgroup RigidGridMotion Rigid Grid Motion * \defgroup RindLayers Rind Layers * \defgroup RotatingCoordinates Rotating Coordinates * \defgroup SimulationType Simulation Type * \defgroup SpecialBoundaryConditionProperty Special Boundary Condition Property * \defgroup SpecialGridConnectivityProperty Special Grid Connectivity Property * \defgroup UserDefinedData User Defined Data * \defgroup ZoneGridConnectivity Zone Grid Connectivity * \defgroup ZoneGridCoordinates Zone Grid Coordinates * \defgroup ZoneIterativeData Zone Iterative Data * \defgroup ZoneSubregions Zone Subregions * \defgroup CGNS_Navigation Explanation of Navigation of a CGNS File * \defgroup ParticleIterativeData Particle Iterative Data * \defgroup ParticleZoneInformation Particle Zone Information * \defgroup ParticleCoordinates Particle Coordinates * \defgroup ParticleSolution Particle Solution * \defgroup ParticleSolutionData Particle Solution Data * \defgroup ParticleEquationSet Particle Equation Set * \defgroup ParticleGoverningEquations Particle Governing Equations * \defgroup ParticleModel Particle Model * */ #ifndef _WIN32 #define _POSIX_C_SOURCE 200112L #endif #include #include #include #include #include #include #include #include #if defined(_WIN32) && !defined(__NUTC__) # include /* suggested by MTI */ # ifndef F_OK # define R_OK 004 /* Test for Read permission */ # define W_OK 002 /* Test for Write permission */ # define X_OK 001 /* Test for eXecute permission */ # define F_OK 000 /* Test for existence of File */ # endif # define ACCESS _access # define UNLINK _unlink #else # include # define ACCESS access # define UNLINK unlink #endif #include "cgnslib.h" #include "cgns_header.h" #include "cgns_io.h" #include "cg_hashmap.h" /* to determine default file type */ #if CG_BUILD_HDF5 # include "hdf5.h" #endif /* fix for unresolved reference to __ftol2 when using VC7 with VC6 libs */ /* see http://www.manusoft.com/Resources/ARXTips/Main.stm */ #ifdef NEED_FTOL2 #ifdef __cplusplus extern "C" { #endif long _ftol(double); long _ftol2(double dValue) {return _ftol(dValue);} #ifdef __cplusplus } #endif #endif #ifdef MEM_DEBUG #include "cg_malloc.h" #endif #define IS_FIXED_SIZE(type) ((type >= CGNS_ENUMV(NODE) && \ type <= CGNS_ENUMV(HEXA_27)) || \ type == CGNS_ENUMV(PYRA_13) || \ (type >= CGNS_ENUMV(BAR_4) && \ type <= CGNS_ENUMV(HEXA_125))) #define CHECK_FILE_OPEN if (cg == NULL) {\ cgi_error("no current CGNS file open");\ return CG_ERROR;\ } /*********************************************************************** * external variable declarations ***********************************************************************/ cgns_file *cgns_files = NULL; cgns_file *cg = NULL; int n_cgns_files = 0; cgns_posit *posit = 0; int posit_file, posit_base, posit_zone; int CGNSLibVersion=CGNS_VERSION;/* Version of the CGNSLibrary*1000 */ int cgns_compress = 0; int cgns_filetype = CG_FILE_NONE; void* cgns_rindindex = CG_CONFIG_RIND_CORE; /* Flag for contiguous (0) or compact storage (1) */ int HDF5storage_type = CG_COMPACT; extern void (*cgns_error_handler)(int, char *); /*********************************************************************** * Name strings ***********************************************************************/ const char * MassUnitsName[NofValidMassUnits] = {"Null", "UserDefined", "Kilogram", "Gram", "Slug", "PoundMass" }; const char * LengthUnitsName[NofValidLengthUnits] = {"Null", "UserDefined", "Meter", "Centimeter", "Millimeter", "Foot", "Inch" }; const char * TimeUnitsName[NofValidTimeUnits] = {"Null", "UserDefined", "Second" }; const char * TemperatureUnitsName[NofValidTemperatureUnits] = {"Null", "UserDefined", "Kelvin", "Celsius", "Rankine", "Fahrenheit" }; const char * AngleUnitsName[NofValidAngleUnits] = {"Null", "UserDefined", "Degree", "Radian" }; const char * ElectricCurrentUnitsName[NofValidElectricCurrentUnits] = {"Null", "UserDefined", "Ampere", "Abampere", "Statampere", "Edison", "a.u." }; const char * SubstanceAmountUnitsName[NofValidSubstanceAmountUnits] = {"Null", "UserDefined", "Mole", "Entities", "StandardCubicFoot", "StandardCubicMeter" }; const char * LuminousIntensityUnitsName[NofValidLuminousIntensityUnits] = {"Null", "UserDefined", "Candela", "Candle", "Carcel", "Hefner", "Violle" }; const char * DataClassName[NofValidDataClass] = {"Null", "UserDefined", "Dimensional", "NormalizedByDimensional", "NormalizedByUnknownDimensional", "NondimensionalParameter", "DimensionlessConstant" }; const char * GridLocationName[NofValidGridLocation] = {"Null", "UserDefined", "Vertex", "CellCenter", "FaceCenter", "IFaceCenter", "JFaceCenter", "KFaceCenter", "EdgeCenter" }; const char * BCDataTypeName[NofValidBCDataTypes] = {"Null", "UserDefined", "Dirichlet", "Neumann" }; const char * GridConnectivityTypeName[NofValidGridConnectivityTypes] = {"Null", "UserDefined", "Overset", "Abutting", "Abutting1to1" }; const char * PointSetTypeName[NofValidPointSetTypes] = {"Null", "UserDefined", "PointList", "PointListDonor", "PointRange", "PointRangeDonor", "ElementRange", "ElementList", "CellListDonor" }; const char * GoverningEquationsTypeName[NofValidGoverningEquationsTypes]= {"Null", "UserDefined", "FullPotential", "Euler", "NSLaminar", "NSTurbulent", "NSLaminarIncompressible", "NSTurbulentIncompressible", "LatticeBoltzmann" }; const char * ModelTypeName[NofValidModelTypes]= {"Null", "UserDefined", "Ideal", "VanderWaals", "Constant", "PowerLaw", "SutherlandLaw", "ConstantPrandtl", "EddyViscosity", "ReynoldsStress", "ReynoldsStressAlgebraic", "Algebraic_BaldwinLomax", "Algebraic_CebeciSmith", "HalfEquation_JohnsonKing", "OneEquation_BaldwinBarth", "OneEquation_SpalartAllmaras", "TwoEquation_JonesLaunder", "TwoEquation_MenterSST", "TwoEquation_Wilcox", "CaloricallyPerfect", "ThermallyPerfect", "ConstantDensity", "RedlichKwong", "Frozen", "ThermalEquilib", "ThermalNonequilib", "ChemicalEquilibCurveFit", "ChemicalEquilibMinimization", "ChemicalNonequilib", "EMElectricField", "EMMagneticField", "EMConductivity", "Voltage", "Interpolated", "Equilibrium_LinRessler", "Chemistry_LinRessler" }; const char * ParticleGoverningEquationsTypeName[NofValidParticleGoverningEquationsTypes]= {"Null", "UserDefined", "DEM", "DSMC", "SPH" }; const char * ParticleModelTypeName[NofValidParticleModelTypes]= {"Null", "UserDefined", "Linear", "NonLinear", "HardSphere", "SoftSphere", "LinearSpringDashpot", "Pair", "HertzMindlin", "HertzKuwabaraKono", "ORourke", "Stochastic", "NonStochastic", "NTC", "KelvinHelmholtz", "KelvinHelmholtzACT", "RayleighTaylor", "KelvinHelmholtzRayleighTaylor", "ReitzKHRT", "TAB", "ETAB", "LISA", "SHF", "PilchErdman", "ReitzDiwakar", "Sphere", "NonSphere", "Tracer", "BeetstraVanDerHoefKuipers", "Ergun", "CliftGrace", "Gidaspow", "HaiderLevenspiel", "PlessisMasliyah", "SyamlalOBrien", "SaffmanMei", "TennetiGargSubramaniam", "Tomiyama", "Stokes", "StokesCunningham", "WenYu", "BaiGosman", "Kunkhe", "Boil", "Condense", "Flash", "Nucleate", "Chiang", "Frossling", "FuchsKnudsen" }; const char * BCTypeName[NofValidBCTypes] = {"Null", "UserDefined", "BCAxisymmetricWedge", "BCDegenerateLine", "BCDegeneratePoint", "BCDirichlet", "BCExtrapolate", "BCFarfield", "BCGeneral", "BCInflow", "BCInflowSubsonic", "BCInflowSupersonic", "BCNeumann", "BCOutflow", "BCOutflowSubsonic", "BCOutflowSupersonic", "BCSymmetryPlane", "BCSymmetryPolar", "BCTunnelInflow", "BCTunnelOutflow", "BCWall", "BCWallInviscid", "BCWallViscous", "BCWallViscousHeatFlux", "BCWallViscousIsothermal", "FamilySpecified" }; const char * DataTypeName[NofValidDataTypes] = {"Null", "UserDefined", "Integer", "RealSingle", "RealDouble", "Character", "LongInteger", "ComplexSingle", "ComplexDouble" }; const char * ElementTypeName[NofValidElementTypes] = {"Null", "UserDefined", "NODE", "BAR_2", "BAR_3", "TRI_3", "TRI_6", "QUAD_4", "QUAD_8", "QUAD_9", "TETRA_4", "TETRA_10", "PYRA_5", "PYRA_14", "PENTA_6", "PENTA_15", "PENTA_18", "HEXA_8", "HEXA_20", "HEXA_27", "MIXED", "PYRA_13", "NGON_n", "NFACE_n", "BAR_4", "TRI_9", "TRI_10", "QUAD_12", "QUAD_16", "TETRA_16", "TETRA_20", "PYRA_21", "PYRA_29", "PYRA_30", "PENTA_24", "PENTA_38", "PENTA_40", "HEXA_32", "HEXA_56", "HEXA_64", "BAR_5", "TRI_12", "TRI_15", "QUAD_P4_16", "QUAD_25", "TETRA_22", "TETRA_34", "TETRA_35", "PYRA_P4_29", "PYRA_50", "PYRA_55", "PENTA_33", "PENTA_66", "PENTA_75", "HEXA_44", "HEXA_98", "HEXA_125" }; const char * ZoneTypeName[NofValidZoneTypes] = {"Null", "UserDefined", "Structured", "Unstructured" }; const char * RigidGridMotionTypeName[NofValidRigidGridMotionTypes] = {"Null", "UserDefined", "ConstantRate", "VariableRate" }; const char * ArbitraryGridMotionTypeName[NofValidArbitraryGridMotionTypes] = {"Null", "UserDefined", "NonDeformingGrid", "DeformingGrid" }; const char * SimulationTypeName[NofValidSimulationTypes] = {"Null", "UserDefined", "TimeAccurate", "NonTimeAccurate" }; const char * WallFunctionTypeName[NofValidWallFunctionTypes] = {"Null", "UserDefined", "Generic" }; const char * AreaTypeName[NofValidAreaTypes] = {"Null", "UserDefined", "BleedArea", "CaptureArea" }; const char * AverageInterfaceTypeName[NofValidAverageInterfaceTypes] = {"Null", "UserDefined", "AverageAll", "AverageCircumferential", "AverageRadial", "AverageI", "AverageJ", "AverageK" }; /*********************************************************************** * global variable definitions ***********************************************************************/ int n_open = 0; int cgns_file_size = 0; int file_number_offset = 0; int VersionList[] = {4500, 4400, 4300, 4200, 4110, 4100, 4000, 3210, 3200, 3140, 3130, 3110, 3100, 3080, 3000, 2550, 2540, 2530, 2520, 2510, 2500, 2460, 2420, 2400, 2300, 2200, 2100, 2000, 1270, 1200, 1100, 1050}; #define nVersions ((int)(sizeof(VersionList)/sizeof(int))) #ifdef DEBUG_HDF5_OBJECTS_CLOSE void objlist_status(char *tag) { int n,sname; char oname[256]; hid_t o,idlist[1024]; H5O_info_t objinfo; n=H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_ALL); printf("{%s} HDF5 OBJ COUNT [%d] \n",tag,n);fflush(stdout); n=H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_GROUP); printf("{%s} HDF5 GROUP [%d] \n",tag,n);fflush(stdout); n=H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_DATASET); printf("{%s} HDF5 DATASET [%d] \n",tag,n);fflush(stdout); n=H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_DATATYPE); printf("{%s} HDF5 DATATYPE [%d] \n",tag,n);fflush(stdout); n=H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_ATTR); printf("{%s} HDF5 ATTR [%d] \n",tag,n);fflush(stdout); for (n=0;n<1024;n++) { idlist[n]=-1; } H5Fget_obj_ids(H5F_OBJ_ALL,H5F_OBJ_ALL,1024,idlist); for (n=0;n<1024;n++) { if (idlist[n]!=-1) { if (H5Iis_valid(idlist[n])) { printf("{%s} track %d INVALID\n",tag,idlist[n]); } else { H5Oget_info(idlist[n],&objinfo); memset(oname,'\0',256); sname=H5Iget_name(idlist[n],oname,0); sname=H5Iget_name(idlist[n],oname,sname+1); printf("{%s} track %d ALIVE (%s:%d)\n",tag,idlist[n],oname,objinfo.rc); } } } } #endif /*********************************************************************** * library functions ***********************************************************************/ /** * \ingroup CGNSFile * * \brief Check for a valid CGNS file. * * \param[in] filename \FILE_filename * \param[out] file_type \FILE_file_type * \return \ier * * \details For existing files, the function cg_is_cgns() may be used to determine if a file * is a CGNS file or not, and the type of file (`CG_FILE_ADF` or `CG_FILE_HDF5`). If * the file is a CGNS file, cg_is_cgns() returns `CG_OK`, otherwise, `CG_ERROR` is * returned and file_type is set to `CG_FILE_NONE`. * */ int cg_is_cgns(const char *filename, int *file_type) { int cgio, ierr; double rootid, childid; *file_type = CG_FILE_NONE; if (cgio_open_file(filename, CG_MODE_READ, CG_FILE_NONE, &cgio)) return CG_ERROR; cgio_get_root_id(cgio, &rootid); cgio_get_file_type(cgio, file_type); ierr = cgio_get_node_id(cgio, rootid, "CGNSLibraryVersion", &childid); cgio_close_file(cgio); return ierr ? CG_ERROR : CG_OK; } /** * \ingroup CGNSFile * * \brief Open a CGNS file. * * \param[in] filename \FILE_filename * \param[in] mode \FILE_mode * \param[out] fn \FILE_fn * \return \ier * * \details The function cg_open() must always be called first. It opens a CGNS file for * reading and/or writing and returns an index number \e file_number. The index number * serves to identify the CGNS file in subsequent function calls. Several CGNS files * can be opened simultaneously. The current limit on the number of files opened simultaneously * depends on the platform. On an SGI workstation, this limit is set at 100 (parameter * FOPEN_MAX in stdio.h). * * The file can be opened in one of the following modes: * * | | | * |---|---| * |__CG_MODE_READ__ | Read only mode. | * |__CG_MODE_WRITE__| Write only mode. | * |__CG_MODE_MODIFY__| Reading and/or writing is allowed.| * * When the file is opened, if no \e CGNSLibraryVersion_t node is found, a default value * of 1.05 is assumed for the CGNS version number. Note that this corresponds to an old * version of the CGNS standard that doesn't include many data structures supported by * the current standard. * * To reduce memory usage and improve execution speed, large arrays such as grid * coordinates or flow solutions are not stored in memory. Instead, only basic * information about the node is kept, while reads and writes of the data are direct to * and from the application's memory. An attempt is made to do the same with * unstructured mesh element data. * * \note CGNS maintains one-way forward compatibility insofar as any file open and modified by, * for example, version major.minor.patch will be readable with major.minor.patch\b +. * It can't be guaranteed the reverse major.minor.patch\b - compatibility for that file * will be true. * */ int cg_open(const char *filename, int mode, int *fn) { int cgio, filetype; cgsize_t dim_vals; double dummy_id; float FileVersion; #ifdef __CG_MALLOC_H__ fprintf(stderr, "CGNS MEM_DEBUG: before open:files %d/%d: memory %d/%d: calls %d/%d\n", n_open, cgns_file_size, cgmemnow(), cgmemmax(), cgalloccalls(), cgfreecalls()); #endif /* check file mode */ switch(mode) { case CG_MODE_READ: case CG_MODE_MODIFY: /* ACCESS is now done in cgio_open_file which call cgio_check_file */ break; case CG_MODE_WRITE: /* unlink is now done in cgio_open_file */ /* set default file type if not done */ if (cgns_filetype == CG_FILE_NONE) cg_set_file_type(CG_FILE_NONE); break; default: cgi_error("Unknown opening file mode: %d ??",mode); return CG_ERROR; } /* Open CGNS file */ if (cgio_open_file(filename, mode, cgns_filetype, &cgio)) { cg_io_error("cgio_open_file"); return CG_ERROR; } n_open++; /* make sure there is enough space in the cgns_files array */ if (cgns_file_size == 0) { cgns_file_size = 1; cgns_files = CGNS_NEW(cgns_file,cgns_file_size); } else if (n_cgns_files == cgns_file_size) { cgns_file_size *= 2; cgns_files = CGNS_RENEW(cgns_file,cgns_file_size, cgns_files); } cg = &(cgns_files[n_cgns_files]); n_cgns_files++; (*fn) = n_cgns_files + file_number_offset; if (cgio_get_file_type(cgio, &filetype)) { cg_io_error("cgio_get_file_type"); return CG_ERROR; } /* Keep in-memory copy of cgns file 'header' information */ cg->mode = mode; int filename_length = strlen(filename) + 1; cg->filename = CGNS_NEW(char,filename_length); snprintf(cg->filename, filename_length, "%s", filename); cg->filetype = filetype; cg->cgio = cgio; cgio_get_root_id(cgio, &cg->rootid); cg->file_number = (*fn); cg->version = 0; cg->deleted = 0; cg->added = 0; /* CGNS-Library Version */ if (mode == CG_MODE_WRITE) { dim_vals = 1; /* FileVersion = (float) CGNS_DOTVERS; */ /* Jiao: Changed to use older compatible version */ if (filetype == CG_FILE_ADF2) { FileVersion = (float) CGNS_COMPATDOTVERS; cg->version = CGNS_COMPATVERSION; } else { FileVersion = (float) CGNS_DOTVERS; cg->version = CGNSLibVersion; } if (cgi_new_node(cg->rootid, "CGNSLibraryVersion", "CGNSLibraryVersion_t", &dummy_id, "R4", 1, &dim_vals, (void *)&FileVersion)) return CG_ERROR; } else { /* read file version from file and set cg->version = FileVersion*1000 */ if (cg_version(cg->file_number, &FileVersion)) return CG_ERROR; /* Check that the library version is at least as recent as the one used to create the file being read */ if (cg->version > CGNSLibVersion) { /* This code allows reading versions newer than the lib, as long as the 1st digit of the versions are equal */ if ((cg->version / 1000) > (CGNSLibVersion / 1000)) { cgi_error("A more recent version of the CGNS library created the file. Therefore, the CGNS library needs updating before reading the file '%s'.",filename); return CG_ERROR; } /* warn only if different in second digit */ if ((cg->version / 100) > (CGNSLibVersion / 100)) { cgi_warning("The file being read is more recent that the CGNS library used"); } } #if CG_SIZEOF_SIZE == 32 if (mode == CG_MODE_MODIFY && cgns_filetype == CG_FILE_ADF2 && filetype == CG_FILE_ADF && cg->version < 3000) { filetype = cg->filetype = CG_FILE_ADF2; } #endif } /* Get ADF Database version & dates, and ADF Library version */ if (cgio_file_version(cg->cgio, cg->dtb_version, cg->creation_date, cg->modify_date)) { cg_io_error("cgio_file_version"); return CG_ERROR; } if (cgio_library_version(cg->cgio, cg->adf_lib_version)) { cg_io_error("cgio_library_version"); return CG_ERROR; } /* read CGNS file */ if (mode == CG_MODE_READ || mode == CG_MODE_MODIFY) { int nnod; double *id; if (cgi_read()) return CG_ERROR; /* update version number in modify mode */ if (cg->version < CGNSLibVersion && mode == CG_MODE_MODIFY && (cg->filetype != CG_FILE_ADF2 || cg->version < CGNS_COMPATVERSION)) { /* FileVersion = (float) CGNS_DOTVERS; */ /* Jiao: Changed to use older compatible version */ if (cg->filetype == CG_FILE_ADF2) { FileVersion = (float) CGNS_COMPATDOTVERS; cg->version = CGNS_COMPATVERSION; } else { FileVersion = (float) CGNS_DOTVERS; cg->version = CGNSLibVersion; } if (cgi_get_nodes(cg->rootid, "CGNSLibraryVersion_t", &nnod, &id)) return CG_ERROR; if (nnod) { if (cgio_write_all_data(cg->cgio, id[0], &FileVersion)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } free(id); } else { dim_vals = 1; if (cgi_new_node(cg->rootid, "CGNSLibraryVersion", "CGNSLibraryVersion_t", &dummy_id, "R4", 1, &dim_vals, (void *)&FileVersion)) return CG_ERROR; } } } else { cg->nbases=0; cg->base = 0; } #ifdef __CG_MALLOC_H__ fprintf(stderr, "CGNS MEM_DEBUG: after open:files %d/%d: memory %d/%d: calls %d/%d\n", n_open, cgns_file_size, cgmemnow(), cgmemmax(), cgalloccalls(), cgfreecalls()); #endif return CG_OK; } /** * \ingroup CGNSFile * * \brief Get CGNS file version. * * \param[in] fn \FILE_fn * \param[out] version \FILE_version * \return \ier * * \details The function cg_version() returns the CGNS version number. * */ int cg_version(int fn, float *version) { int nnod; double *id; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* if open in CG_MODE_WRITE */ if (cg->version) { (*version)=(float)(cg->version)/1000; return CG_OK; } /* if open in MODE_READ or MODE_MODIFY */ /* get number of CGNSLibraryVersion_t nodes and their ID */ if (cgi_get_nodes(cg->rootid, "CGNSLibraryVersion_t", &nnod, &id)) return CG_ERROR; if (nnod==0) { cg->version=3200; *version= (float) 3.20; } else if (nnod!=1) { cgi_error("More then one CGNSLibraryVersion_t node found under ROOT."); return CG_ERROR; } else { int vers, ndim, temp_version; cgsize_t dim_vals[12]; char_33 node_name; char_33 data_type; void *data; if (cgi_read_node(id[0], node_name, data_type, &ndim, dim_vals, &data, 1)) { cgi_error("Error reading CGNS-Library-Version"); return CG_ERROR; } /* check data type */ if (strcmp(data_type,"R4")!=0) { cgi_error("Unexpected data type for CGNS-Library-Version='%s'",data_type); return CG_ERROR; } /* check data dim */ if (ndim != 1 || (dim_vals[0]!=1)) { cgi_error("Wrong data dimension for CGNS-Library-Version"); return CG_ERROR; } /* save data */ *version = *((float *)data); free(data); cg->version = (int)(1000.0*(*version)+0.5); /* To prevent round-off errors in version number for files of older or current version */ temp_version = cg->version; /* cg->version = 0; Commented for fwd compatibility */ for (vers=0; vers (VersionList[vers]-2) && temp_version < (VersionList[vers]+2)) { cg->version = VersionList[vers]; break; } } if (cg->version == 0) { cgi_error("Error: Unable to determine the version number"); return CG_ERROR; } free(id); } #if DEBUG_VERSION printf("version=%f\n",*version); printf("cg->version=%d\n",cg->version); #endif return CG_OK; } /** * \ingroup CGNSFile * * \brief Get CGNS file precision. * * \param[in] fn \FILE_fn * \param[out] precision \FILE_precision * \return \ier * * \details Precision used to write the CGNS file. The \c precision value will be one of * 32 (32-bit), 64 (64-bit), or 0 if unknown. * */ int cg_precision(int fn, int *precision) { int nb, nz; char_33 data_type; *precision = 0; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* if open in CG_MODE_WRITE */ if (cg->mode == CG_MODE_WRITE) { *precision = CG_SIZEOF_SIZE; return CG_OK; } for (nb = 0; nb < cg->nbases; nb++) { for (nz = 0; nz < cg->base[nb].nzones; nz++) { if (0 == cgio_get_data_type (cg->cgio, cg->base[nb].zone[nz].id, data_type) && 0 == strcmp (data_type, "I8")) { *precision = 64; return CG_OK; } } } *precision = 32; return CG_OK; } /** * \ingroup CGNSFile * * \brief Close a CGNS file. * * \param[in] fn \FILE_fn * \return \ier * * \details The function cg_close() must always be called last. It closes the CGNS file * designated by the index number \e fn and frees the memory where the CGNS data was * kept. When a file is opened for writing, cg_close() writes all the CGNS data in * memory onto disk before closing the file. Consequently, if omitted, the CGNS file * will not be written properly. * */ int cg_close(int fn) { cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; #ifdef __CG_MALLOC_H__ fprintf(stderr, "CGNS MEM_DEBUG: before close:files %d/%d: memory %d/%d: calls %d/%d\n", n_open, cgns_file_size, cgmemnow(), cgmemmax(), cgalloccalls(), cgfreecalls()); #endif if (cgns_compress && cg->mode == CG_MODE_MODIFY && (cg->deleted >= cgns_compress || cgns_compress < 0)) { if (cgio_compress_file (cg->cgio, cg->filename)) { cg_io_error("cgio_compress_file"); return CG_ERROR; } } else { if (cgio_close_file(cg->cgio)) { cg_io_error("cgio_close_file"); return CG_ERROR; } } n_open--; /* Free the in-memory copy of the CGNS file */ cgi_free_file(cg); cg->mode = CG_MODE_CLOSED; /* if all files are closed, free up memory */ if (n_open == 0) { file_number_offset = n_cgns_files; free (cgns_files); cg = NULL; cgns_files = NULL; cgns_file_size = 0; n_cgns_files = 0; } #ifdef __CG_MALLOC_H__ fprintf(stderr, "CGNS MEM_DEBUG: after close:files %d/%d: memory %d/%d: calls %d/%d\n", n_open, cgns_file_size, cgmemnow(), cgmemmax(), cgalloccalls(), cgfreecalls()); #endif #ifdef DEBUG_HDF5_OBJECTS_CLOSE objlist_status("close"); #endif return CG_OK; } /** * \ingroup CGNSFile * * \brief Save the open CGNS file. * * \param[in] fn \FILE_fn * \param[in] filename \FILE_filename * \param[in] file_type \FILE_file_type * \param[in] follow_links \FILE_follow_links * \return \ier * * \details The CGNS file identified by \c fn may be saved to a different filename and type * using cg_save_as(). To save as an HDF5 file, the library must have been * built with HDF5 support. ADF support is always built. The function cg_set_file_type() * sets the default file type for newly created CGNS files. The function * cg_get_file_type() returns the file type for the CGNS file identified by \c fn. * If the CGNS library is built as 32-bit, the additional file type, `CG_FILE_ADF2`, is * available. This allows the creation of a 2.5-compatible CGNS file. * */ int cg_save_as(int fn, const char *filename, int file_type, int follow_links) { int output; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (file_type == CG_FILE_NONE) file_type = cgns_filetype; if (cgio_is_supported(file_type)) { cgi_error("file type unknown or not supported"); return CG_ERROR; } if (cgio_open_file(filename, CG_MODE_WRITE, file_type, &output)) { cg_io_error ("cgio_open_file"); return CG_ERROR; } if (cgio_copy_file(cg->cgio, output, follow_links)) { cg_io_error("cgio_copy_file"); return CG_ERROR; } if (cgio_close_file(output)) { cg_io_error("cgio_close_file"); return CG_ERROR; } return CG_OK; } /** * \ingroup CGNSFile * * \brief Set default file type. * * \param[in] file_type \FILE_file_type * \return \ier * * \details When a CGNS file is newly created using `CG_MODE_WRITE`, the default type of database * manager used is determined at compile time. If the CGNS library was built with HDF5 * version 1.8 or later support, the file type will be `CG_FILE_HDF5`, otherwise * `CG_FILE_ADF` is used. This may be changed either by setting an environment variable, * `CGNS_FILETYPE`, to one of \e adf, \e hdf5, or \e adf2, or by calling the routine * cg_set_file_type() prior to the cg_open() call. Calling cg_set_file_type() with the * argument `CG_FILE_NONE` will reset the library to use the default file type. * * \note If the environment variable `CGNS_FILETYPE` is set, it takes precedence. * */ int cg_set_file_type(int file_type) { if (file_type == CG_FILE_NONE) { char *type = getenv("CGNS_FILETYPE"); if (type == NULL || !*type) { #if CG_BUILD_HDF5 cgns_filetype = CG_FILE_HDF5; #else cgns_filetype = CG_FILE_ADF; #endif } #if CG_BUILD_HDF5 else if (*type == '2' || *type == 'h' || *type == 'H') { cgns_filetype = CG_FILE_HDF5; } #endif else if (*type == '3' || ((*type == 'a' || *type == 'A') && strchr(type, '2') != NULL)) { #if CG_SIZEOF_SIZE == 64 cgi_error("ADF2 not supported in 64-bit mode"); return CG_ERROR; #else cgns_filetype = CG_FILE_ADF2; #endif } else cgns_filetype = CG_FILE_ADF; } else { if (cgio_is_supported(file_type)) { cgi_error("file type unknown or not supported"); return CG_ERROR; } cgns_filetype = file_type; } return CG_OK; } /** * \ingroup CGNSFile * * \brief Get file type for open CGNS file. * * \param[in] fn \FILE_fn * \param[out] file_type \FILE_file_type * \return \ier * * \details The function cg_get_file_type() gets the file type (\e adf, \e hdf5, or \e adf2) * for an open CGNS file. * */ int cg_get_file_type(int fn, int *file_type) { cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgio_get_file_type(cg->cgio, file_type)) { cg_io_error("cgio_get_file_type"); return CG_ERROR; } return CG_OK; } /** * \ingroup CGNSInterfaceCGIO * * \brief Get the CGIO root node identifier for the CGNS file. * * \param[in] fn \FILE_fn * \param[out] rootid Root node identifier for the CGNS file * \return \ier * * \details The function cg_root_id() allows the use of the low-level CGIO function in conjunction * with the Mid Level Library. It returns the root node identifier for the CGNS file. * */ int cg_root_id(int fn, double *rootid) { cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgio_get_root_id(cg->cgio, rootid)) { cg_io_error("cgio_get_root_id"); return CG_ERROR; } return CG_OK; } /** * \ingroup CGNSInterfaceCGIO * * \brief Get the CGIO database identifier for the specified CGNS file. * * \param[in] fn \FILE_fn * \param[out] cgio_num CGIO identifier for the CGNS file * \return \ier * * \details The function cg_get_cgio() allows using the low-level CGIO function in * conjunction with the Mid Level Library. It returns the CGIO database identifier * for the CGNS file. * */ int cg_get_cgio(int fn, int *cgio_num) { cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; *cgio_num = cg->cgio; return CG_OK; } /* configure stuff */ /** * \ingroup CGNSInternals_FNC_CG_CONFIG * * \brief Configure CGNS library internal options. * * \param[in] option The configuration options are defined in \e cgnslib.h. For the list, please refer to * the list below. * \param[in] value The value to set, type cast as \e void * . In Fortran, the type is \e TYPE(C_PTR), or * \e TYPE(C_FUNPTR) for \e CG_CONFIG_ERROR. * \return \ier * * \details The function cg_configure() allows particular CGNS library internal options to be * configured. The currently supported options and expected values are listed below. * */ int cg_configure(int option, void *value) { /* cgio options */ if (option > 100) { if( cgio_configure(option, value) != CG_OK) { cg_io_error("cgio_configure"); return CG_ERROR; } } /* error message handler */ else if (option == CG_CONFIG_ERROR) { cgns_error_handler = (void (*)(int, char *))value; } /* file compression */ else if (option == CG_CONFIG_COMPRESS) { cgns_compress = (int)((size_t)value); } /* initialize link search path */ else if (option == CG_CONFIG_SET_PATH) { return cg_set_path((const char *)value); } /* add to link search path */ else if (option == CG_CONFIG_ADD_PATH) { return cg_set_path((const char *)value); } /* default file type */ else if (option == CG_CONFIG_FILE_TYPE) { return cg_set_file_type((int)((size_t)value)); } /* allow pre v3.4 rind-plane indexing */ else if (option == CG_CONFIG_RIND_INDEX) { if (value != CG_CONFIG_RIND_ZERO && value != CG_CONFIG_RIND_CORE) { cgi_error("unknown config setting"); return CG_ERROR; } cgns_rindindex = value; } else { cgi_error("unknown config setting"); return CG_ERROR; } return CG_OK; } /** * \ingroup CGNSInternals * * \brief Set CGNS error handler * * \param[in] func error handler function * * \note The routine cg_error_handler() is a convenience function built on top of cg_configure(). * * \note There is no Fortran counterpart for function cg_error_handler(). The Fortran function * cg_exit_on_error_f() routine can be used instead of cg_error_handler(). If `flag` is * non-zero, the library will print the error message and exit with a code of 1 when an * error is encountered. Setting `flag` to zero (the default) prevents this, and the error * is returned to the user code. * * \return \ier */ int cg_error_handler(void (*func)(int, char *)) { cgns_error_handler = func; return CG_OK; } /** * \ingroup CGNSInternals * * \brief Set CGNS compression mode * * \param[in] compress CGNS compress (rewrite) setting * \return \ier * * \note The routine cg_set_compress() is a convenience function built on top of cg_configure(). */ int cg_set_compress(int compress) { cgns_compress = compress; return CG_OK; } /** * \ingroup CGNSInternals * * \brief Get CGNS compression mode * * \param[out] compress CGNS compress (rewrite) setting * \return \ier */ int cg_get_compress(int *compress) { *compress = cgns_compress; return CG_OK; } /** * \ingroup CGNSInternals * * \brief Set the CGNS link search path * * \param[in] path Path to search for links to files when opening a file with external links. * \return \ier * * \note The routine cg_set_path() is a convenience function built on top of cg_configure(). */ int cg_set_path(const char *path) { cgio_path_delete(NULL); if (path && *path) { if (cgio_path_add(path)) { cg_io_error("cgio_path_add"); return CG_ERROR; } } return CG_OK; } /** * \ingroup CGNSInternals * * \brief Add to the CGNS link search path * * \param[in] path Path to search for links to files when opening a file with external links. * \return \ier * * \note The routine cg_add_path() is a convenience function built on top of cg_configure(). */ int cg_add_path(const char *path) { if (cgio_path_add(path)) { cg_io_error("cgio_path_add"); return CG_ERROR; } return CG_OK; } /*****************************************************************************\ * utility functions \*****************************************************************************/ /* get type name with bounds checking */ const char *cg_get_name(int nnames, const char **names, int type) { if (type < 0 || type >= nnames) return ""; return names[type]; } const char *cg_MassUnitsName(CGNS_ENUMT( MassUnits_t ) type) { return cg_get_name(NofValidMassUnits,MassUnitsName,(int)type); } const char *cg_LengthUnitsName(CGNS_ENUMT( LengthUnits_t ) type) { return cg_get_name(NofValidLengthUnits,LengthUnitsName,(int)type); } const char *cg_TimeUnitsName(CGNS_ENUMT( TimeUnits_t ) type) { return cg_get_name(NofValidTimeUnits,TimeUnitsName,(int)type); } const char *cg_TemperatureUnitsName(CGNS_ENUMT( TemperatureUnits_t ) type) { return cg_get_name(NofValidTemperatureUnits,TemperatureUnitsName,(int)type); } const char *cg_AngleUnitsName(CGNS_ENUMT( AngleUnits_t ) type) { return cg_get_name(NofValidAngleUnits,AngleUnitsName,(int)type); } const char *cg_ElectricCurrentUnitsName(CGNS_ENUMT( ElectricCurrentUnits_t ) type) { return cg_get_name(NofValidElectricCurrentUnits,ElectricCurrentUnitsName,(int)type); } const char *cg_SubstanceAmountUnitsName(CGNS_ENUMT( SubstanceAmountUnits_t ) type) { return cg_get_name(NofValidSubstanceAmountUnits,SubstanceAmountUnitsName,(int)type); } const char *cg_LuminousIntensityUnitsName(CGNS_ENUMT( LuminousIntensityUnits_t ) type) { return cg_get_name(NofValidLuminousIntensityUnits,LuminousIntensityUnitsName,(int)type); } const char *cg_DataClassName(CGNS_ENUMT( DataClass_t ) type) { return cg_get_name(NofValidDataClass,DataClassName,(int)type); } const char *cg_GridLocationName(CGNS_ENUMT( GridLocation_t ) type) { return cg_get_name(NofValidGridLocation,GridLocationName,(int)type); } const char *cg_BCDataTypeName(CGNS_ENUMT( BCDataType_t ) type) { return cg_get_name(NofValidBCDataTypes,BCDataTypeName,(int)type); } const char *cg_GridConnectivityTypeName(CGNS_ENUMT( GridConnectivityType_t ) type) { return cg_get_name(NofValidGridConnectivityTypes,GridConnectivityTypeName,(int)type); } const char *cg_PointSetTypeName(CGNS_ENUMT( PointSetType_t ) type) { return cg_get_name(NofValidPointSetTypes,PointSetTypeName,(int)type); } const char *cg_GoverningEquationsTypeName(CGNS_ENUMT( GoverningEquationsType_t ) type) { return cg_get_name(NofValidGoverningEquationsTypes,GoverningEquationsTypeName,(int)type); } const char *cg_ModelTypeName(CGNS_ENUMT( ModelType_t ) type) { return cg_get_name(NofValidModelTypes,ModelTypeName,(int)type); } const char *cg_BCTypeName(CGNS_ENUMT( BCType_t ) type) { return cg_get_name(NofValidBCTypes,BCTypeName,(int)type); } const char *cg_DataTypeName(CGNS_ENUMT( DataType_t ) type) { return cg_get_name(NofValidDataTypes,DataTypeName,(int)type); } const char *cg_ElementTypeName(CGNS_ENUMT( ElementType_t ) type) { return cg_get_name(NofValidElementTypes,ElementTypeName,(int)type); } const char *cg_ZoneTypeName(CGNS_ENUMT( ZoneType_t ) type) { return cg_get_name(NofValidZoneTypes,ZoneTypeName,(int)type); } const char *cg_RigidGridMotionTypeName(CGNS_ENUMT( RigidGridMotionType_t ) type) { return cg_get_name(NofValidRigidGridMotionTypes,RigidGridMotionTypeName,(int)type); } const char *cg_ArbitraryGridMotionTypeName(CGNS_ENUMT( ArbitraryGridMotionType_t ) type) { return cg_get_name(NofValidArbitraryGridMotionTypes,ArbitraryGridMotionTypeName,(int)type); } const char *cg_SimulationTypeName(CGNS_ENUMT( SimulationType_t ) type) { return cg_get_name(NofValidSimulationTypes,SimulationTypeName,(int)type); } const char *cg_WallFunctionTypeName(CGNS_ENUMT( WallFunctionType_t ) type) { return cg_get_name(NofValidWallFunctionTypes,WallFunctionTypeName,(int)type); } const char *cg_AreaTypeName(CGNS_ENUMT( AreaType_t ) type) { return cg_get_name(NofValidAreaTypes,AreaTypeName,(int)type); } const char *cg_AverageInterfaceTypeName(CGNS_ENUMT( AverageInterfaceType_t ) type) { return cg_get_name(NofValidAverageInterfaceTypes,AverageInterfaceTypeName,(int)type); } const char *cg_ParticleGoverningEquationsTypeName(CGNS_ENUMT( ParticleGoverningEquationsType_t ) type) { return cg_get_name(NofValidParticleGoverningEquationsTypes, ParticleGoverningEquationsTypeName,(int)type); } const char *cg_ParticleModelTypeName(CGNS_ENUMT( ParticleModelType_t ) type) { return cg_get_name(NofValidParticleModelTypes,ParticleModelTypeName,(int)type); } /*****************************************************************************\ * Read and Write CGNSBase_t Nodes \*****************************************************************************/ /** * \ingroup CGNSBaseInformation * * \brief Get the number of CGNS base nodes in the file * * \param[in] fn \FILE_fn * \param[out] nbases Number of bases in the CGNS file \p fn. * \return \ier * */ int cg_nbases(int fn, int *nbases) { cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; *nbases = cg->nbases; return CG_OK; } /** * \ingroup CGNSBaseInformation * * \brief Read CGNS base information * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] basename Name of the base * \param[out] cell_dim Dimension of the cells; 3 for volume cells, 2 for surface cells and 1 for * line cells. * \param[out] phys_dim Number of coordinates required to define a vector in the field. * \return \ier * */ int cg_base_read(int fn, int B, char *basename, int *cell_dim, int *phys_dim) { cgns_base *base; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; *cell_dim = base->cell_dim; *phys_dim = base->phys_dim; strcpy(basename, base->name); return CG_OK; } /** * \ingroup CGNSBaseInformation * * \brief Get the CGIO identifier of the CGNS base * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] base_id CGIO node identifier for the base. * \return \ier * */ int cg_base_id(int fn, int B, double *base_id) { cgns_base *base; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; *base_id = base->id; return CG_OK; } /** * \ingroup CGNSBaseInformation * * \brief Get the cell dimension for the CGNS base * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] cell_dim Dimension of the cells; 3 for volume cells, 2 for surface cells and 1 for * line cells. * \return \ier * */ int cg_cell_dim(int fn, int B, int *cell_dim) { cgns_base *base; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; *cell_dim = base->cell_dim; return CG_OK; } /** * \ingroup CGNSBaseInformation * * \brief Create and/or write to a CGNS base node * * \param[in] fn \FILE_fn * \param[in] basename Name of the base. * \param[in] cell_dim Dimension of the cells; 3 for volume cells, 2 for surface cells and 1 for * line cells. * \param[in] phys_dim Number of coordinates required to define a vector in the field. * \param[out] B \B_Base * \return \ier * */ int cg_base_write(int fn, const char * basename, int cell_dim, int phys_dim, int *B) { cgns_base *base = NULL; int index; cgsize_t dim_vals; int data[2]; /* verify input */ if (cgi_check_strlen(basename)) return CG_ERROR; if (cell_dim<1 || cell_dim>3 || phys_dim<1 || phys_dim>3) { cgi_error("Invalid input: cell_dim=%d, phys_dim=%d",cell_dim,phys_dim); return CG_ERROR; } /* get memory address for base */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* Overwrite a CGNSBase_t Node: */ for (index=0; indexnbases; index++) { if (strcmp(basename, cg->base[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",basename); return CG_ERROR; } /* overwrite an existing base */ /* delete the existing base from file */ if (cgi_delete_node(cg->rootid, cg->base[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ base = &(cg->base[index]); /* free memory */ cgi_free_base(base); break; } } /* ... or add a CGNSBase_t Node: */ if (index==cg->nbases) { if (cg->nbases == 0) { cg->base = CGNS_NEW(cgns_base, cg->nbases+1); } else { cg->base = CGNS_RENEW(cgns_base, cg->nbases+1, cg->base); } base = &(cg->base[cg->nbases]); cg->nbases ++; } (*B) = index+1; /* save data in memory and initialize base data structure */ memset(base, 0, sizeof(cgns_base)); snprintf(base->name, sizeof(base->name), "%s", basename); base->cell_dim = cell_dim; base->phys_dim = phys_dim; /* save data in file */ data[0] = cell_dim; data[1] = phys_dim; dim_vals=2; if (cgi_new_node(cg->rootid, base->name, "CGNSBase_t", &base->id, "I4", 1, &dim_vals, (void *)data)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and Write Zone_t Nodes \*****************************************************************************/ /** * \ingroup CGNSZoneInformation * * \brief Get the number of zones in the base * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] nzones Number of zones present in base B. * \return \ier * */ int cg_nzones(int fn, int B, int *nzones) { cgns_base *base; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; *nzones = base->nzones; return CG_OK; } /** * \ingroup CGNSZoneInformation * * \brief Get type of zone (structured or unstructured) * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] zonetype Type of the zone. The admissible types are \e Structured and \e * Unstructured. * \return \ier * */ int cg_zone_type(int fn, int B, int Z, CGNS_ENUMT(ZoneType_t) *zonetype) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; *zonetype = zone->type; return CG_OK; } /** * \ingroup CGNSZoneInformation * * \brief Read zone information * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] zonename Name of the zone * \param[out] size Number of vertices, cells, and boundary vertices in each (index)-dimension. * For structured grids, the dimensions have unit stride in the array (e.g., * `[NVertexI', `NVertexJ`, `NVertexK`, `NCellI`, `NCellJ`, `NCellK`, * `NBoundVertexI`, `NBoundVertexJ`, `NBoundVertexK]`). Note that for * unstructured grids, the number of cells is the number of highest order * elements. Thus, in three dimensions, it's the number of 3-D cells; in two * dimensions, it's the number of 2-D cells. Also, for unstructured grids, if the * nodes are sorted between internal nodes and boundary nodes, the optional parameter * `NBoundVertex` must be set equal to the number of boundary nodes. By * default, `NBoundVertex` equals zero, meaning that the nodes are unsorted. * Note that a non-zero `NBoundVertex` value only applies to unstructured * grids. For structured grids, the `NBoundVertex` parameter always equals 0 in * all directions. * |Mesh Type | Size| * |---------------|-----| * | 3D structured | `NVertexI`, `NVertexJ`, `NVertexK` * | ^ | `NCellI`, `NCellJ`, `NCellK` * | ^ | `NBoundVertexI = 0`,`NBoundVertexJ = 0`,`NBoundVertexK = 0` * | 2D structured | `NVertexI`, `NVertexJ` * | ^ | `NCellI`, `NCellJ` * | ^ | `NBoundVertexI = 0`, `NBoundVertexJ = 0` * |3D unstructured| `NVertex`, `NCell3D`, `NBoundVertex` * |2D unstructured| `NVertex`, `NCell2D`, `NBoundVertex` * \return \ier * */ int cg_zone_read(int fn, int B, int Z, char *zonename, cgsize_t *size) { cgns_zone *zone; int i; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; strcpy(zonename, zone->name); for (i=0; i<3*(zone->index_dim); i++) size[i] = zone->nijk[i]; return CG_OK; } /** * \ingroup CGNSZoneInformation * * \brief Get the CGIO identifier of the CGNS zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] zone_id CGIO node identifier for the zone * \return \ier */ int cg_zone_id(int fn, int B, int Z, double *zone_id) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; *zone_id = zone->id; return CG_OK; } /** * \ingroup CGNSZoneInformation * * \brief Get the index dimension of the CGNS zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] index_dim Index dimension for the zone. For Structured zones, this will be the base * cell dimension, and for Unstructured zones, it will be 1. * \return \ier */ int cg_index_dim(int fn, int B, int Z, int *index_dim) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; *index_dim = zone->index_dim; return CG_OK; } /** * \ingroup CGNSZoneInformation * * \brief Create and/or write to a CGNS zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] zonename Name of the zone. * \param[in] size Number of vertices, cells, and boundary vertices in each (index)-dimension. * For structured grids, the dimensions have unit stride in the array (e.g., * `[NVertexI`, `NVertexJ`, `NVertexK`, `NCellI`, `NCellJ`, `NCellK`, `NBoundVertexI`, * `NBoundVertexJ`, `NBoundVertexK]`). Note that for unstructured grids, the number * of cells is the number of highest-order elements. Thus, in three dimensions, * it's the number of 3-D cells; in two dimensions, it's the number of 2-D * cells. Also, for unstructured grids, if the nodes are sorted between internal * nodes and boundary nodes, the optional parameter NBoundVertex must be set * equal to the number of boundary nodes. By default, NBoundVertex equals zero, * meaning that the nodes are unsorted. Note that a non-zero value for * NBoundVertex only applies to unstructured grids. For structured grids, the * NBoundVertex parameter always equals 0 in all directions. * |Mesh Type | Size| * |---------------|-----| * | 3D structured | `NVertexI`, `NVertexJ`, `NVertexK` * | | `NCellI`, `NCellJ`, `NCellK` * | | `NBoundVertexI = 0`, `NBoundVertexJ = 0`, `NBoundVertexK = 0` * |2D structured | `NVertexI`, `NVertexJ` * | | `NCellI`, `NCellJ` * | | `NBoundVertexI = 0`, `NBoundVertexJ = 0` * |3D unstructured| `NVertex`, `NCell3D`, `NBoundVertex` * |2D unstructured| `NVertex`, `NCell2D`, `NBoundVertex` * \param[in] zonetype Type of the zone. The admissible types are \e Structured and \e Unstructured. * \param[out] Z \Z_Zone * * \return \ier */ int cg_zone_write(int fn, int B, const char *zonename, const cgsize_t * size, CGNS_ENUMT( ZoneType_t ) zonetype, int *Z) { cgns_base *base; cgns_zone *zone = NULL; int index, i, index_dim; cgsize_t dim_vals[2]; double dummy_id; /* verify input */ if (cgi_check_strlen(zonename)) return CG_ERROR; /* get memory address file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for base */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* Set index dimension */ if (zonetype == CGNS_ENUMV( Structured )) index_dim = base->cell_dim; else if (zonetype == CGNS_ENUMV( Unstructured )) index_dim = 1; else { cgi_error("Invalid zone type - not Structured or Unstructured"); return CG_ERROR; } for (i=0; izonemap == 0) { base->zonemap = cgi_new_presized_hashmap(base->nzones); if (base->zonemap == NULL) { cgi_error("Could not allocate zonemap"); return CG_ERROR; } for (index = 0; index < base->nzones; index++) { if (cgi_map_set_item(base->zonemap, base->zone[index].name, index) != 0) { cgi_error("Can not set zone %s into hashmap", base->zone[index].name); return CG_ERROR; } } } index = (int) cgi_map_get_item(base->zonemap, zonename); /* */ if (index != -1) { zone = &(base->zone[index]); /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode == CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s", zone->name); return CG_ERROR; } /* overwrite an existing zone */ /* delete the existing zone from file */ if (cgi_delete_node(base->id, zone->id)) return CG_ERROR; cgi_free_zone(zone); } else { /* ... or add a Zone_t Node: */ // This breaks everything if (base->nzones == 0) { base->zone = CGNS_NEW(cgns_zone, base->nzones + 1); } else { base->zone = CGNS_RENEW(cgns_zone, base->nzones + 1, base->zone); } zone = &(base->zone[base->nzones]); index = base->nzones; if (cgi_map_set_item(base->zonemap, zonename, index) != 0) { cgi_error("Error while adding zonename %s to zonemap hashtable", zonename); return CG_ERROR; } base->nzones++; } (*Z) = index + 1; /* save data to zone */ memset(zone, 0, sizeof(cgns_zone)); snprintf(zone->name, sizeof(zone->name), "%s", zonename); if ((zone->nijk = (cgsize_t *)malloc((size_t)(index_dim*3*sizeof(cgsize_t))))==NULL) { cgi_error("Error allocating zone->nijk"); return CG_ERROR; } for (i=0; i<3*index_dim; i++) zone->nijk[i] = size[i]; zone->index_dim = index_dim; zone->type = zonetype; /* save data in file */ dim_vals[0]=zone->index_dim; dim_vals[1]=3; if (cgi_new_node(base->id, zone->name, "Zone_t", &zone->id, CG_SIZE_DATATYPE, 2, dim_vals, (void *)zone->nijk)) return CG_ERROR; dim_vals[0] = (cgsize_t)strlen(ZoneTypeName[zonetype]); if (cgi_new_node(zone->id, "ZoneType", "ZoneType_t", &dummy_id, "C1", 1, dim_vals, ZoneTypeName[zonetype])) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and Write Family_t Nodes \*****************************************************************************/ /** * \ingroup CGNSFamilyDefinition * * \brief Get number of \e Family_t node at \e CGNSBase_t level * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] nfamilies Number of families in base \p B * \return \ier * */ int cg_nfamilies(int fn, int B, int *nfamilies) { cgns_base *base; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; *nfamilies = base->nfamilies; return CG_OK; } /** * \ingroup CGNSFamilyDefinition * * \brief Read family information (CGNSBase_t level) * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[out] family_name \family_name * \param[out] nboco Number of boundary conditions for this family. This should be * either 0 or 1. * \param[out] ngeos Number of geometry references for this family. * \return \ier * */ int cg_family_read(int fn, int B, int Fam, char *family_name, int *nboco, int *ngeos) { cgns_family *family; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; strcpy(family_name, family->name); *nboco = family->nfambc; *ngeos = family->ngeos; return CG_OK; } /* ** FAMILY TREE ** */ /** * \ingroup CGNSFamilyDefinition * * \brief Read family information (CGNSBase_t level) * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] family_name \family_name * \param[out] Fam \Fam * \return \ier * */ int cg_family_write(int fn, int B, const char * family_name, int *Fam) { int index; cgns_base *base; cgns_family *family = NULL; char family_name_path[(CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH+1]; char *pch, *tok; int skip = 0; /* Check file access */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* Check family name validity */ if ( strlen( family_name ) == 0 ){ cgi_error( "Family name is empty" ); return CG_ERROR; } if ( strlen( family_name ) > (CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH ){ cgi_error( "Family name is too long" ); return CG_ERROR; } /* get memory address for base */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* check if family_name is actually a family tree path instead */ pch = strchr( family_name, '/' ); if( pch != 0 ) { /* Check that family tree path is absolute */ if( pch != family_name ) { cgi_error( "Family tree path must be absolute (including base)"); return CG_ERROR; } /* Check that the specified base's name matches the beginning of the family tree path */ pch = strstr( family_name, base->name ); if( pch != family_name+1 ) { cgi_error( "Incompatible basename (%s) and family tree (%s)", base->name, family_name ); return CG_ERROR; } /* points to base level instead of root in family tree path*/ pch += strlen( base->name ); } else { pch = (char*) family_name; } /* Make a copy of the family tree path (need non-const string for tokenization loop) */ strcpy( family_name_path, pch ); /* Init tokenization loop: * We work with pointer to variables to simplify switch from cgns_base structure * variables to cgns_family structure variables. * */ int* nfamilies_p = &(base->nfamilies); cgns_family** family_p = &(base->family); double parent_id = base->id; /* Start loop over token */ pch = strtok( family_name_path, "/" ); while( pch ) { tok = pch; pch = strtok (NULL, "/"); /* when pch is null, we are at leaf (last token)*/ /* Check token size, should be max 32 */ if (cgi_check_strlen(tok)) { cgi_error( "Invalid Family_t node %s", tok ); return CG_ERROR; } skip = 0; /* Flag to skip node creation */ /* Look for token in existing Family_t childs */ for( index=0; index < (*nfamilies_p); index++ ) { /* If found existing Family_t named as token within the Family_t childs */ if( strcmp( tok, (*family_p)[index].name) == 0 ) { /* If last token, then overwriting action */ if( !pch ) { /* Overwriting action not allowed on pure write mode */ if( cg->mode == CG_MODE_WRITE ) { cgi_error( "Duplicate child name found: %s", tok ); return CG_ERROR; } /* Modify mode : overwrite an existing family */ if( cgi_delete_node( parent_id, (*family_p)[index].id )) { return CG_ERROR; } /* Save the old in-memory address to overwrite */ family = &( (*family_p)[index] ); /* free memory */ cgi_free_family(family); break; /* quit "for" loop */ } /* else, progressing in family tree path */ else { family = &( (*family_p)[index] ); /* ?? */ skip = 1; /* intermediate node exists and should not be created or overwritten */ break; } } } /* ... or add a Family_t Node */ if( index == *nfamilies_p ) { if( *nfamilies_p == 0 ) { *family_p = CGNS_NEW( cgns_family, (*nfamilies_p)+1 ); } else { *family_p = CGNS_RENEW( cgns_family, (*nfamilies_p)+1, *family_p ); } family = &( (*family_p)[*nfamilies_p] ); (*nfamilies_p)++; } (*Fam) = index+1; if( ! skip ) { /* If not an existing intermediate family node */ memset( family, 0, sizeof(cgns_family) ); strcpy( family->name, tok ); /* Save data in file */ if( cgi_new_node( parent_id, tok, "Family_t", &family->id, "MT", 0, 0, 0) ) { return CG_ERROR; } } /* Update variables for next token */ nfamilies_p = &(family->nfamilies); family_p = &(family->family); parent_id = family->id; } /* End of tokenization loop */ return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup CGNSFamilyDefinition * * \brief Get number of family names under \e Family_t (CGNSBase_t level) * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[out] nnames Number of \e FamilyName_t nodes for this family. * \return \ier * */ int cg_nfamily_names(int fn, int B, int Fam, int *nnames) { cgns_family *fam; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; fam = cgi_get_family(cg, B, Fam); if (fam == 0) return CG_ERROR; *nnames = fam->nfamname; return CG_OK; } /** * \ingroup CGNSFamilyDefinition * * \brief Read multiple family names under \e Family_t (CGNSBase_t level) * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[in] N Family name index number, where 1 ≤ N ≤ nNames. * \param[out] node_name Name of the \e FamilyName_t node. FamilyParent is used to refer to the parent * family of the \e Family_t node. * \param[out] family_name \family_name * \return \ier * */ int cg_family_name_read(int fn, int B, int Fam, int N, char *node_name, char *family_name) { cgns_family *fam; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; fam = cgi_get_family(cg, B, Fam); if (fam == 0) return CG_ERROR; if (N < 1 || N > fam->nfamname) { cgi_error("family name index out of range\n"); return CG_ERROR; } strcpy(node_name, fam->famname[N-1].name); strcpy(family_name, fam->famname[N-1].family); return CG_OK; } /* ** FAMILY TREE ** */ /** * \ingroup CGNSFamilyDefinition * * \brief Write multiple family names under \e Family_t (CGNSBase_t level) * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[out] node_name Name of the \e FamilyName_t node. FamilyParent refers to the parent * family of the \e Family_t node. * \param[out] family_name \family_name * \return \ier * */ int cg_family_name_write(int fn, int B, int Fam, const char *node_name, const char *family_name) { int index; cgsize_t dim; cgns_family *fam; cgns_famname *famname = 0; /* verify input */ if (cgi_check_strlen(node_name)) return CG_ERROR; if ( strlen(family_name) > (CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH ) { cgi_error( "Family path too long (%s, size %ld)", family_name, strlen(family_name) ); return CG_ERROR; } cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; fam = cgi_get_family(cg, B, Fam); if (fam == 0) return CG_ERROR; for (index = 0; index < fam->nfamname; index++) { if (0 == strcmp(node_name, fam->famname[index].name)) { if (cg->mode == CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s", node_name); return CG_ERROR; } if (cgi_delete_node(fam->id, fam->famname[index].id)) return CG_ERROR; famname = &(fam->famname[index]); break; } } if (index == fam->nfamname) { if (0 == fam->nfamname) fam->famname = CGNS_NEW(cgns_famname, 1); else fam->famname = CGNS_RENEW(cgns_famname, fam->nfamname+1, fam->famname); famname = &fam->famname[fam->nfamname]; fam->nfamname++; } strcpy(famname->name, node_name); strcpy(famname->family, family_name); dim = (cgsize_t)strlen(famname->family); if (cgi_new_node(fam->id, famname->name, "FamilyName_t", &famname->id, "C1", 1, &dim, famname->family)) return CG_ERROR; return CG_OK; } /** * \ingroup CGNSFamilyHierarchyTreeDefinition * * \brief Create a \e Family_t node (\e Family_t level) * * \param[in] family_name \family_name * \param[out] Fam \Fam * \return \ier * */ int cg_node_family_write( const char* family_name, int* Fam) { int ier=0, n, nfamilies; cgns_family* family; double posit_id; CHECK_FILE_OPEN /* verify input */ if( strchr( family_name, '/' ) != 0 ) { cgi_error( "Path not allowed to create Family_t locally\n"); return CG_ERROR; } if( cgi_check_strlen( family_name ) ) return CG_ERROR; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*Fam) = 0; return CG_ERROR; } family = cgi_family_address( CG_MODE_WRITE, 0, family_name, &ier ); if( family==0 ) return ier; memset( family, 0, sizeof( cgns_family ) ); strcpy( family->name, family_name ); /* save data in file */ if( cgi_posit_id( &posit_id ) ) return CG_ERROR; if( cgi_new_node( posit_id, family_name, "Family_t", &family->id, "MT", 0, 0, 0)) return CG_ERROR; /* retrieve index */ family = 0; if( strcmp( posit->label, "CGNSBase_t" ) == 0 ) { family = ((cgns_base*)posit->posit)->family; nfamilies = ((cgns_base*)posit->posit)->nfamilies; } else if (strcmp(posit->label,"Family_t")==0) { family = ((cgns_family *)posit->posit)->family; nfamilies = ((cgns_family *)posit->posit)->nfamilies; } else { cgi_error("Family_t node not supported under '%s' type node",posit->label); (*Fam) = -1; return CG_INCORRECT_PATH; } if( family ) { for( n=0; nlabel,"CGNSBase_t")==0 ) (*nfamilies) = ((cgns_base *)posit->posit)->nfamilies; else if (strcmp(posit->label,"Family_t")==0) (*nfamilies) = ((cgns_family *)posit->posit)->nfamilies; else { cgi_error("Family_t node not supported under '%s' type node",posit->label); (*nfamilies) = 0; return CG_INCORRECT_PATH; } return CG_OK; } /** * \ingroup CGNSFamilyHierarchyTreeDefinition * * \brief Read family info (Family_t level) * * \param[in] Fam \Fam * \param[out] family_name \family_name. * \param[out] nFamBC Number of boundary conditions for this family. * This should be either 0 or 1. * \param[out] nGeo Number of geometry references for this family. * \return \ier * */ int cg_node_family_read( int Fam, char* family_name, int* nFamBC, int *nGeo ) { int ier = 0; cgns_family* family; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; family = cgi_family_address( CG_MODE_READ, Fam, "dummy", &ier ); if( family == 0 ) return ier; strcpy( family_name, family->name ); (*nFamBC) = family->nfambc; (*nGeo) = family->ngeos; return CG_OK; } /** * \ingroup CGNSFamilyHierarchyTreeDefinition * * \brief Write multiple family names under \e Family_t (\e Family_t level) * * \param[in] node_name Name of the \e FamilyName_t node. FamilyParent refers to the parent * family of the \e Family_t node. * \param[in] family_name \family_name. * \return \ier * */ int cg_node_family_name_write( const char* node_name, const char* family_name ) { int index; cgns_family* family = 0; cgns_famname* famname = 0; cgsize_t dim; CHECK_FILE_OPEN /* verify input */ if( cgi_check_strlen( node_name )) return CG_ERROR; if ( strlen(family_name) > (CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH ) { cgi_error( "Family path too long (%s, size %ld)", family_name, strlen(family_name) ); return CG_ERROR; } /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return CG_ERROR; } if (strcmp(posit->label,"Family_t")==0) family = ((cgns_family *)posit->posit); if( family==0 ) { cgi_error( "cg_node_family_name_write not called at a Family_t position" ); return CG_ERROR; } for( index = 0; index < family->nfamname; index++ ) { if( 0 == strcmp( node_name, family->famname[index].name )) { if( cg->mode == CG_MODE_WRITE ) { cgi_error("Duplicate child name found: %s", node_name ); return CG_ERROR; } if( cgi_delete_node( family->id, family->famname[index].id)) return CG_ERROR; famname = &(family->famname[index]); break; } } if (index == family->nfamname) { if (0 == family->nfamname) family->famname = CGNS_NEW(cgns_famname, 1); else family->famname = CGNS_RENEW(cgns_famname, family->nfamname+1, family->famname); famname = &family->famname[family->nfamname]; family->nfamname++; } strcpy(famname->name, node_name); strcpy(famname->family, family_name); dim = (cgsize_t)strlen(famname->family); if (cgi_new_node(family->id, famname->name, "FamilyName_t", &famname->id, "C1", 1, &dim, famname->family)) return CG_ERROR; return CG_OK; } /** * \ingroup CGNSFamilyHierarchyTreeDefinition * * \brief Get number of family names under \e Family_t (\e Family_t level) * * \param[out] nnames Number of \e FamilyName_t nodes for this family. * \return \ier * */ int cg_node_nfamily_names( int* nnames ) { /* This is valid and used during write as well as read mode. */ CHECK_FILE_OPEN /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*nnames) = 0; return CG_ERROR; } if (strcmp(posit->label,"Family_t")==0) (*nnames) = ((cgns_family *)posit->posit)->nfamname; else { cgi_error("No array of FamilyName_t supported under '%s' type node",posit->label); (*nnames) = 0; return CG_INCORRECT_PATH; } return CG_OK; } /** * \ingroup CGNSFamilyHierarchyTreeDefinition * * \brief Read family info (\e Family_t level) * * \param[in] N Family name index number, where 1 ≤ N ≤ nNames. * \param[out] node_name Name of the \e FamilyName_t node. FamilyParent refers to the parent * family of the \e Family_t node. * \param[out] family_name \family_name. * \return \ier * */ int cg_node_family_name_read(int N, char* node_name, char* family_name ) { cgns_famname *famname; int ier = 0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; famname = cgi_multfam_address(CG_MODE_READ, N, "", &ier); if (famname==0) return ier; strcpy(node_name, famname->name); strcpy(family_name, famname->family); return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup CGNSFamilyBoundaryCondition * * \brief Read boundary condition type for a family * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[in] BC_idx \BC_idx * \param[out] fambc_name Name of the \e FamilyBC_t node. * \param[out] bocotype Boundary condition type for the family. See the eligible types for \e BCType_t * in the Typedefs section. * \return \ier */ int cg_fambc_read(int fn, int B, int Fam, int BC_idx, char *fambc_name, CGNS_ENUMT(BCType_t) *bocotype) { cgns_family *family; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; if (BC_idx<=0 || BC_idx>family->nfambc) { cgi_error("Invalid family b.c. number"); return CG_ERROR; } strcpy(fambc_name,family->fambc[BC_idx-1].name); *bocotype = family->fambc[BC_idx-1].type; return CG_OK; } /** * \ingroup CGNSFamilyBoundaryCondition * * \brief Write boundary condition type for a family * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[in] fambc_name Name of the \e FamilyBC_t node. * \param[in] bocotype Boundary condition type for the family. See the eligible types for \e BCType_t * in the Typedefs section. * \param[out] BC_idx \BC_idx * \return \ier * */ int cg_fambc_write(int fn, int B, int Fam, const char * fambc_name, CGNS_ENUMT( BCType_t ) bocotype, int *BC_idx) { int index; cgsize_t length; cgns_family *family; cgns_fambc *fambc = NULL; /* verify input */ if (cgi_check_strlen(fambc_name)) return CG_ERROR; if (INVALID_ENUM(bocotype,NofValidBCTypes)) { cgi_error("Invalid BCType: %d",bocotype); return CG_ERROR; } cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for family */ family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; /* Overwrite a FamilyBC_t Node: */ for (index=0; indexnfambc; index++) { if (strcmp(fambc_name, family->fambc[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",fambc_name); return CG_ERROR; } /* overwrite an existing zone */ /* delete the existing fambc from file */ if (cgi_delete_node(family->id, family->fambc[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ fambc = &(family->fambc[index]); /* free memory */ cgi_free_fambc(fambc); break; } } /* ... or add a FamilyBC_t Node: */ if (index==family->nfambc) { if (family->nfambc == 0) { family->fambc = CGNS_NEW(cgns_fambc, family->nfambc+1); } else { family->fambc = CGNS_RENEW(cgns_fambc, family->nfambc+1, family->fambc); } fambc = &(family->fambc[family->nfambc]); family->nfambc++; } (*BC_idx) = index+1; memset(fambc, 0, sizeof(cgns_fambc)); strcpy(fambc->name, fambc_name); fambc->type = bocotype; /* save data in file */ length = (cgsize_t)strlen(BCTypeName[bocotype]); if (cgi_new_node(family->id, fambc->name, "FamilyBC_t", &fambc->id, "C1", 1, &length, BCTypeName[bocotype])) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup CGNSFamilyBoundaryCondition * * \brief Read boundary condition information (\e Family_t level) * * \param[in] BC_idx \BC_idx * \param[out] fambc_name Name of the \e FamilyBC_t node. * \param[out] bocotype Boundary condition type for the family. See the eligible types for \e BCType_t * in the Typedefs section. * \return \ier * */ int cg_node_fambc_read( int BC_idx, char* fambc_name, CGNS_ENUMT(BCType_t) *bocotype) { cgns_family* family = 0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return CG_ERROR; } if (strcmp(posit->label,"Family_t")==0) family = ((cgns_family *)posit->posit); if( family==0 ) { cgi_error( "cg_node_fambc_read not called at a Family_t position" ); return CG_ERROR; } if (BC_idx<=0 || BC_idx>family->nfambc) { cgi_error("Invalid family b.c. number"); return CG_ERROR; } strcpy(fambc_name,family->fambc[BC_idx-1].name); *bocotype = family->fambc[BC_idx-1].type; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup CGNSFamilyBoundaryCondition * * \brief Write boundary condition information (\e Family_t level) * * \param[in] fambc_name Name of the \e FamilyBC_t node. * \param[in] bocotype Boundary condition type for the family. See the eligible types for \e BCType_t * in the Typedefs section. * \param[out] BC_idx \BC_idx * \return \ier * */ int cg_node_fambc_write( const char* fambc_name, CGNS_ENUMT(BCType_t) bocotype, int *BC_idx ) { int index; cgsize_t length; cgns_family *family = 0; cgns_fambc *fambc = NULL; /* verify input */ /* if (cgi_check_strlen(fambc_name)) return CG_ERROR; */ if (INVALID_ENUM(bocotype,NofValidBCTypes)) { cgi_error("Invalid BCType: %d",bocotype); return CG_ERROR; } CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return CG_ERROR; } if (strcmp(posit->label,"Family_t")==0) family = ((cgns_family *)posit->posit); if( family==0 ) { cgi_error( "cg_node_fambc_write not called at a Family_t position" ); return CG_ERROR; } /* Overwrite a FamilyBC_t Node: */ for (index=0; indexnfambc; index++) { if (strcmp(fambc_name, family->fambc[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",fambc_name); return CG_ERROR; } /* overwrite an existing zone */ /* delete the existing fambc from file */ if (cgi_delete_node(family->id, family->fambc[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ fambc = &(family->fambc[index]); /* free memory */ cgi_free_fambc(fambc); break; } } /* ... or add a FamilyBC_t Node: */ if (index==family->nfambc) { if (family->nfambc == 0) { family->fambc = CGNS_NEW(cgns_fambc, family->nfambc+1); } else { family->fambc = CGNS_RENEW(cgns_fambc, family->nfambc+1, family->fambc); } fambc = &(family->fambc[family->nfambc]); family->nfambc++; } (*BC_idx) = index+1; memset(fambc, 0, sizeof(cgns_fambc)); strcpy(fambc->name, fambc_name); fambc->type = bocotype; /* save data in file */ length = (cgsize_t)strlen(BCTypeName[bocotype]); if (cgi_new_node(family->id, fambc->name, "FamilyBC_t", &fambc->id, "C1", 1, &length, BCTypeName[bocotype])) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup CGNSGeometryReference * * \brief Read geometry reference information * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. * \param[out] geo_name Name of \e GeometryReference_t node. * \param[out] geo_file Name of geometry file. * \param[out] CAD_name Geometry format. * \param[out] npart Number of geometry entities. * \return \ier * */ int cg_geo_read(int fn, int B, int Fam, int G, char *geo_name, char **geo_file, char *CAD_name, int *npart) { cgns_family *family; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; if (G<=0 || G>family->ngeos) { cgi_error("Invalid geometry reference number"); return CG_ERROR; } strcpy(geo_name,family->geo[G-1].name); strcpy(CAD_name,family->geo[G-1].format); /* This string is not limited to 32 characters and can't be pre-allocated in the application */ geo_file[0]=CGNS_NEW(char,strlen(family->geo[G-1].file)+1); strcpy(geo_file[0],family->geo[G-1].file); *npart=family->geo[G-1].npart; return CG_OK; } /** * \ingroup CGNSGeometryReference * * \brief Create a \e GeometryReference_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[in] geo_name Name of \e GeometryReference_t node. * \param[in] geo_file Name of geometry file. * \param[in] CAD_name Geometry format. * \param[out] G Geometry reference index number, where 1 ≤ G ≤ nGeo. * \return \ier * */ int cg_geo_write(int fn, int B, int Fam, const char * geo_name, const char *geo_file, const char * CAD_name, int *G) { int index; cgsize_t length; cgns_family *family; cgns_geo *geo = NULL; double dummy_id; /* verify input */ if (cgi_check_strlen(geo_name)) return CG_ERROR; if (cgi_check_strlen(CAD_name)) return CG_ERROR; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for family */ family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; /* Overwrite a GeometryReference_t Node: */ for (index=0; indexngeos; index++) { if (strcmp(geo_name, family->geo[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",geo_name); return CG_ERROR; } /* overwrite an existing zone */ /* delete the existing geo from file */ if (cgi_delete_node(family->id, family->geo[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ geo = &(family->geo[index]); /* free memory */ cgi_free_geo(geo); break; } } /* ... or add a GeometryReference_t Node: */ if (index==family->ngeos) { if (family->ngeos == 0) { family->geo = CGNS_NEW(cgns_geo, family->ngeos+1); } else { family->geo = CGNS_RENEW(cgns_geo, family->ngeos+1, family->geo); } geo = &(family->geo[family->ngeos]); family->ngeos++; } (*G) = index+1; memset(geo, 0, sizeof(cgns_geo)); strcpy(geo->name, geo_name); strcpy(geo->format, CAD_name); length = (int)strlen(geo_file); if (length<=0) { cgi_error("filename undefined for GeometryReference node!"); return CG_ERROR; } geo->file = (char *)malloc((size_t)((length+1)*sizeof(char))); if (geo->file == NULL) { cgi_error("Error allocation geo->file"); return CG_ERROR; } strcpy(geo->file, geo_file); /* save data in file */ if (cgi_new_node(family->id, geo->name, "GeometryReference_t", &geo->id, "MT", 0, 0, 0)) return CG_ERROR; length = (cgsize_t)strlen(geo->file); if (cgi_new_node(geo->id, "GeometryFile", "GeometryFile_t", &dummy_id, "C1", 1, &length, geo->file)) return CG_ERROR; length = (cgsize_t)strlen(geo->format); if (cgi_new_node(geo->id, "GeometryFormat", "GeometryFormat_t", &dummy_id, "C1", 1, &length, geo->format)) return CG_ERROR; return CG_OK; } /* FamilyTree extension */ /* ** FAMILY TREE ** */ /*----------------------------------------------------------------------*/ /** * \ingroup CGNSGeometryReference * * \brief Read geometry reference information (Family_t level) * * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. * \param[out] geo_name Name of \e GeometryReference_t node. * \param[out] geo_file Name of geometry file. * \param[out] CAD_name Geometry format. * \param[out] npart Number of geometry entities. * \return \ier * */ int cg_node_geo_read( int G, char *geo_name, char **geo_file, char *CAD_name, int *npart ) { cgns_family* family = 0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return CG_ERROR; } if (strcmp(posit->label,"Family_t")==0) family = ((cgns_family *)posit->posit); if( family==0 ) { cgi_error( "cg_node_geo_read not called at a Family_t position" ); return CG_ERROR; } if (G<=0 || G>family->ngeos) { cgi_error("Invalid geometry reference number"); return CG_ERROR; } strcpy(geo_name,family->geo[G-1].name); strcpy(CAD_name,family->geo[G-1].format); /* This string is not limited to 32 characters and can't be pre-allocated in the application */ geo_file[0]=CGNS_NEW(char,strlen(family->geo[G-1].file)+1); strcpy(geo_file[0],family->geo[G-1].file); *npart=family->geo[G-1].npart; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup CGNSGeometryReference * * \brief Create GeometryReference_t node (Family_t level) * * \param[in] geo_name Name of GeometryReference_t node. * \param[in] geo_file Name of geometry file. * \param[in] CAD_name Geometry format. * \param[out] G Geometry reference index number, where 1 ≤ G ≤ nGeo. * * \return \ier * */ int cg_node_geo_write( const char *geo_name, const char *geo_file, const char *CAD_name, int *G) { int index; cgsize_t length; cgns_family *family = 0; cgns_geo *geo = NULL; double dummy_id; /* verify input */ if (cgi_check_strlen(geo_name)) return CG_ERROR; if (cgi_check_strlen(CAD_name)) return CG_ERROR; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return CG_ERROR; } if (strcmp(posit->label,"Family_t")==0) family = ((cgns_family *)posit->posit); if( family==0 ) { cgi_error( "cg_node_geo_write not called at a Family_t position" ); return CG_ERROR; } /* Overwrite a GeometryReference_t Node: */ for (index=0; indexngeos; index++) { if (strcmp(geo_name, family->geo[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",geo_name); return CG_ERROR; } /* overwrite an existing zone */ /* delete the existing geo from file */ if (cgi_delete_node(family->id, family->geo[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ geo = &(family->geo[index]); /* free memory */ cgi_free_geo(geo); break; } } /* ... or add a GeometryReference_t Node: */ if (index==family->ngeos) { if (family->ngeos == 0) { family->geo = CGNS_NEW(cgns_geo, family->ngeos+1); } else { family->geo = CGNS_RENEW(cgns_geo, family->ngeos+1, family->geo); } geo = &(family->geo[family->ngeos]); family->ngeos++; } (*G) = index+1; memset(geo, 0, sizeof(cgns_geo)); strcpy(geo->name, geo_name); strcpy(geo->format, CAD_name); length = (int)strlen(geo_file); if (length<=0) { cgi_error("filename undefined for GeometryReference node!"); return CG_ERROR; } geo->file = (char *)malloc((size_t)((length+1)*sizeof(char))); if (geo->file == NULL) { cgi_error("Error allocation geo->file"); return CG_ERROR; } strcpy(geo->file, geo_file); /* save data in file */ if (cgi_new_node(family->id, geo->name, "GeometryReference_t", &geo->id, "MT", 0, 0, 0)) return CG_ERROR; length = (cgsize_t)strlen(geo->file); if (cgi_new_node(geo->id, "GeometryFile", "GeometryFile_t", &dummy_id, "C1", 1, &length, geo->file)) return CG_ERROR; length = (cgsize_t)strlen(geo->format); if (cgi_new_node(geo->id, "GeometryFormat", "GeometryFormat_t", &dummy_id, "C1", 1, &length, geo->format)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup CGNSGeometryReference * * \brief Get geometry entity name * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. * \param[in] P Geometry entity index number, where 1 ≤ P ≤ nparts. * \param[out] part_name Name of a geometry entity in the file FileName. * \return \ier * */ int cg_part_read(int fn, int B, int Fam, int G, int P, char *part_name) { cgns_family *family; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; if (P<=0 || P>family->geo[G-1].npart) { cgi_error("Invalid part number"); return CG_ERROR; } strcpy(part_name,family->geo[G-1].part[P-1].name); return CG_OK; } /** * \ingroup CGNSGeometryReference * * \brief Write geometry entity name * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Fam \Fam * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. * \param[in] part_name Name of a geometry entity in the file FileName. * \param[out] P Geometry entity index number, where 1 ≤ P ≤ nparts. * \return \ier * */ int cg_part_write(int fn, int B, int Fam, int G, const char * part_name, int *P) { int index; cgns_geo *geo; cgns_part *part = NULL; cgns_family *family; /* verify input */ if (cgi_check_strlen(part_name)) return CG_ERROR; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for geo */ family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; if (G > family->ngeos || G <=0) { cgi_error("Invalid index for GeometryEntity_t node"); return CG_ERROR; } geo = &family->geo[G-1]; /* Overwrite a GeometryEntity_t Node: */ for (index=0; indexnpart; index++) { if (strcmp(part_name, geo->part[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",part_name); return CG_ERROR; } /* overwrite an existing zone */ /* delete the existing geo from file */ if (cgi_delete_node(geo->id, geo->part[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ part = &(geo->part[index]); /* free memory */ cgi_free_part(part); break; } } /* ... or add a GeometryReference_t Node: */ if (index==geo->npart) { if (geo->npart == 0) { geo->part = CGNS_NEW(cgns_part, geo->npart+1); } else { geo->part = CGNS_RENEW(cgns_part, geo->npart+1, geo->part); } part = &(geo->part[geo->npart]); geo->npart++; } (*P) = index+1; memset(part, 0, sizeof(cgns_part)); strcpy(part->name, part_name); /* save data in file */ if (cgi_new_node(geo->id, part->name, "GeometryEntity_t", &part->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /* FamilyTree extension */ /* ** FAMILY TREE ** */ /*----------------------------------------------------------------------*/ /** * \ingroup CGNSGeometryReference * * \brief Get geometry entity name (Family_t level) * * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. * \param[in] P Geometry entity index number, where 1 ≤ P ≤ nparts. * \param[out] part_name Name of a geometry entity in the file FileName. * \return \ier * */ int cg_node_part_read(int G, int P, char *part_name) { cgns_family* family = 0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return CG_ERROR; } if (strcmp(posit->label,"Family_t")==0) family = ((cgns_family *)posit->posit); if( family==0 ) { cgi_error( "cg_node_part_read not called at a Family_t position" ); return CG_ERROR; } if (P<=0 || P>family->geo[G-1].npart) { cgi_error("Invalid part number"); return CG_ERROR; } strcpy(part_name,family->geo[G-1].part[P-1].name); return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup CGNSGeometryReference * * \brief Write geometry entity name (Family_t level) * * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. * \param[in] part_name Name of a geometry entity in the file FileName. * \param[out] P Geometry entity index number, where 1 ≤ P ≤ nparts. * \return \ier * */ int cg_node_part_write(int G, const char * part_name, int *P) { int index; cgns_geo *geo; cgns_part *part = NULL; cgns_family *family = 0; /* verify input */ if (cgi_check_strlen(part_name)) return CG_ERROR; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return CG_ERROR; } if (strcmp(posit->label,"Family_t")==0) family = ((cgns_family *)posit->posit); if( family==0 ) { cgi_error( "cg_node_part_write not called at a Family_t position" ); return CG_ERROR; } if (G > family->ngeos || G <=0) { cgi_error("Invalid index for GeometryEntity_t node"); return CG_ERROR; } geo = &family->geo[G-1]; /* Overwrite a GeometryEntity_t Node: */ for (index=0; indexnpart; index++) { if (strcmp(part_name, geo->part[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",part_name); return CG_ERROR; } /* overwrite an existing zone */ /* delete the existing geo from file */ if (cgi_delete_node(geo->id, geo->part[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ part = &(geo->part[index]); /* free memory */ cgi_free_part(part); break; } } /* ... or add a GeometryReference_t Node: */ if (index==geo->npart) { if (geo->npart == 0) { geo->part = CGNS_NEW(cgns_part, geo->npart+1); } else { geo->part = CGNS_RENEW(cgns_part, geo->npart+1, geo->part); } part = &(geo->part[geo->npart]); geo->npart++; } (*P) = index+1; memset(part, 0, sizeof(cgns_part)); strcpy(part->name, part_name); /* save data in file */ if (cgi_new_node(geo->id, part->name, "GeometryEntity_t", &part->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and Write DiscreteData_t Nodes \*****************************************************************************/ /** * \ingroup DiscreteData * * \brief Get the number of `DiscreteData_t` nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] ndiscrete Number of `DiscreteData_t` data structures under zone Z. * \return \ier * */ int cg_ndiscrete(int fn, int B, int Z, int *ndiscrete) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; (*ndiscrete) = zone->ndiscrete; return CG_OK; } /** * \ingroup DiscreteData * * \brief Get the name of `DiscreteData_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. * \param[out] discrete_name Name of `DiscreteData_t` data structures. * \return \ier * */ int cg_discrete_read(int fn, int B, int Z, int D, char *discrete_name) { cgns_discrete *discrete; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; discrete = cgi_get_discrete(cg, B, Z, D); if (discrete==0) return CG_ERROR; strcpy(discrete_name, discrete->name); return CG_OK; } /** * \ingroup DiscreteData * * \brief Create a `DiscreteData_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] discrete_name Name of `DiscreteData_t` data structures. * \param[out] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. * \return \ier * */ int cg_discrete_write(int fn, int B, int Z, const char * discrete_name, int *D) { cgns_zone *zone; cgns_discrete *discrete = NULL; int index; /* verify input */ if (cgi_check_strlen(discrete_name)) return CG_ERROR; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* Overwrite a DiscreteData_t node: */ for (index=0; indexndiscrete; index++) { if (strcmp(discrete_name, zone->discrete[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",discrete_name); return CG_ERROR; } /* overwrite an existing solution */ /* delete the existing solution from file */ if (cgi_delete_node(zone->id, zone->discrete[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ discrete = &(zone->discrete[index]); /* free memory */ cgi_free_discrete(discrete); break; } } /* ... or add a FlowSolution_t Node: */ if (index==zone->ndiscrete) { if (zone->ndiscrete == 0) { zone->discrete = CGNS_NEW(cgns_discrete, zone->ndiscrete+1); } else { zone->discrete = CGNS_RENEW(cgns_discrete, zone->ndiscrete+1, zone->discrete); } discrete = &zone->discrete[zone->ndiscrete]; zone->ndiscrete++; } (*D) = index+1; /* save data in memory */ memset(discrete, 0, sizeof(cgns_discrete)); strcpy(discrete->name, discrete_name); discrete->location=CGNS_ENUMV(Vertex); /* save data in file */ if (cgi_new_node(zone->id, discrete->name, "DiscreteData_t", &discrete->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /** * \ingroup DiscreteData * * \brief Get the dimensions of `DiscreteData_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. * \param[out] data_dim Number of dimensions defining the discrete data. If a point set has been * defined, this will be 1, otherwise this will be the current zone index * dimension. * \param[out] dim_vals The array of data_dim dimensions for the discrete data. * \return \ier * */ int cg_discrete_size(int fn, int B, int Z, int D, int *data_dim, cgsize_t *dim_vals) { cgns_discrete *discrete; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; discrete = cgi_get_discrete(cg, B, Z, D); if (discrete==0) return CG_ERROR; if (discrete->ptset == NULL) { cgns_zone *zone = &cg->base[B-1].zone[Z-1]; *data_dim = zone->index_dim; if (cgi_datasize(zone->index_dim, zone->nijk, discrete->location, discrete->rind_planes, dim_vals)) return CG_ERROR; } else { *data_dim = 1; dim_vals[0] = discrete->ptset->size_of_patch; } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup DiscreteData * * \brief Get info about a point set `DiscreteData_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. * \param[out] ptset_type Type of point set defining the interface for the discrete data; either * PointRange or PointList. * \param[out] npnts Number of points defining the interface for the discrete data. For a * ptset_type of PointRange, \p npnts is always two. For a ptset_type of * PointList, \p npnts is the number of points in the list. * \return \ier * */ int cg_discrete_ptset_info(int fn, int B, int Z, int D, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts) { cgns_discrete *discrete; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; discrete = cgi_get_discrete(cg, B, Z, D); if (discrete==0) return CG_ERROR; if (discrete->ptset == NULL) { *ptset_type = CGNS_ENUMV(PointSetTypeNull); *npnts = 0; } else { *ptset_type = discrete->ptset->type; *npnts = discrete->ptset->npts; } return CG_OK; } /** * \ingroup DiscreteData * * \brief Read a point set `DiscreteData_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. * \param[out] pnts Array of points defining the interface for the discrete data. * \return \ier * */ int cg_discrete_ptset_read(int fn, int B, int Z, int D, cgsize_t *pnts) { int dim = 0; cgns_discrete *discrete; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; discrete = cgi_get_discrete(cg, B, Z, D); if (discrete==0) return CG_ERROR; if (discrete->ptset == 0 || discrete->ptset->npts <= 0) { cgi_error("PointSet not defined for Discrete node %d\n", D); return CG_ERROR; } cg_index_dim(fn, B, Z, &dim); if (cgi_read_int_data(discrete->ptset->id, discrete->ptset->data_type, discrete->ptset->npts * dim, pnts)) return CG_ERROR; return CG_OK; } /** * \ingroup DiscreteData * * \brief Create a point set `DiscreteData_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] discrete_name Name of `DiscreteData_t` data structures. * \param[in] location Grid location where the discrete data is recorded. The permissible * locations are \e Vertex, \e CellCenter, \e IFaceCenter, \e JFaceCenter, and \e KFaceCenter. * \param[in] ptset_type Type of point set defining the interface for the discrete data; either * \e PointRange or \e PointList. * \param[in] npnts Number of points defining the interface for the discrete data. For a * \p ptset_type of \e PointRange, \p npnts is always two. For a \p ptset_type of * \e PointList, \p npnts is the number of points in the list. * \param[in] pnts Array of points defining the interface for the discrete data. * \param[out] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. * \return \ier * */ int cg_discrete_ptset_write(int fn, int B, int Z, const char *discrete_name, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts, int *D) { int i, index_dim = 0; cgsize_t cnt, dim_vals = 1; cgns_discrete *discrete; char_33 PointSetName; double id; /* verify input */ if (!((ptset_type == CGNS_ENUMV(PointList) && npnts > 0) || (ptset_type == CGNS_ENUMV(PointRange) && npnts == 2))) { cgi_error("Invalid input: npoint=%ld, point set type=%s", (long)npnts, PointSetTypeName[ptset_type]); return CG_ERROR; } if (cg_index_dim(fn, B, Z, &index_dim)) return CG_ERROR; if (cgi_check_location(cg->base[B-1].cell_dim, cg->base[B-1].zone[Z-1].type, location)) return CG_ERROR; if (cg_discrete_write(fn, B, Z, discrete_name, D)) return CG_ERROR; discrete = cgi_get_discrete(cg, B, Z, *D); if (discrete == 0) return CG_ERROR; discrete->location = location; discrete->ptset = CGNS_NEW(cgns_ptset, 1); discrete->ptset->type = ptset_type; strcpy(discrete->ptset->data_type,CG_SIZE_DATATYPE); discrete->ptset->npts = npnts; if (ptset_type == CGNS_ENUMV(PointList)) { discrete->ptset->size_of_patch = npnts; } else { discrete->ptset->size_of_patch = 1; for (i = 0; i < index_dim; i++) { cnt = pnts[i+index_dim] - pnts[i]; if (cnt < 0) cnt = -cnt; discrete->ptset->size_of_patch *= (cnt + 1); } } strcpy(PointSetName, PointSetTypeName[ptset_type]); if (cgi_write_ptset(discrete->id, PointSetName, discrete->ptset, index_dim, (void *)pnts)) return CG_ERROR; if (location != CGNS_ENUMV(Vertex)) { dim_vals = (cgsize_t)strlen(GridLocationName[location]); if (cgi_new_node(discrete->id, "GridLocation", "GridLocation_t", &id, "C1", 1, &dim_vals, (void *)GridLocationName[location])) return CG_ERROR; } return CG_OK; } /*****************************************************************************\ * Read and Write GridCoordinates_t Nodes \*****************************************************************************/ /** * \ingroup ZoneGridCoordinates * * \brief Get the number of `GridCoordinates_t` nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] ngrids Number of `GridCoordinates_t` nodes for zone Z. * \return \ier * */ int cg_ngrids(int fn, int B, int Z, int *ngrids) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for zone */ zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; (*ngrids) = zone->nzcoor; return CG_OK; } /** * \ingroup ZoneGridCoordinates * * \brief Get Name of a `GridCoordinates_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] G \G_Grid * \param[out] grid_coord_name Name of the GridCoordinates_t node. Note that the name "GridCoordinates" is * reserved for the original grid and must be the first GridCoordinates_t node * to be defined. * \return \ier * */ int cg_grid_read(int fn, int B, int Z, int G, char *grid_coord_name) { cgns_zcoor *zcoor; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for GridCoordinates_t node */ zcoor = cgi_get_zcoor(cg, B, Z, G); if (zcoor==0) return CG_ERROR; /* Return ADF name for the GridCoordinates_t node */ strcpy(grid_coord_name,zcoor->name); return CG_OK; } /** * \ingroup ZoneGridCoordinates * * \brief Create a `GridCoordinates_t` nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] grid_coord_name Name of the GridCoordinates_t node. Note that the name "GridCoordinates" is * reserved for the original grid and must be the first GridCoordinates_t node * to be defined. * \param[out] G \G_Grid * \return \ier * */ int cg_grid_write(int fn, int B, int Z, const char * grid_coord_name, int *G) { cgns_zone *zone; cgns_zcoor *zcoor = NULL; int index, n, index_dim; /* verify input */ if (cgi_check_strlen(grid_coord_name)) return CG_ERROR; /* get memory address */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* Overwrite a GridCoordinates_t Node: */ for (index=0; indexnzcoor; index++) { if (strcmp(grid_coord_name, zone->zcoor[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",grid_coord_name); return CG_ERROR; } /* overwrite an existing GridCoordinates_t node */ /* delete the existing GridCoordinates_t from file */ if (cgi_delete_node(zone->id, zone->zcoor[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ zcoor = &(zone->zcoor[index]); /* free memory */ cgi_free_zcoor(zcoor); break; } } /* ... or add a GridCoordinates_t Node: */ if (index==zone->nzcoor) { if (zone->nzcoor == 0) { zone->zcoor = CGNS_NEW(cgns_zcoor, 1); } else { zone->zcoor = CGNS_RENEW(cgns_zcoor, zone->nzcoor+1, zone->zcoor); } zcoor = &(zone->zcoor[zone->nzcoor]); zone->nzcoor++; } (*G) = index+1; /* save data in memory */ memset(zcoor, 0, sizeof(cgns_zcoor)); strcpy(zcoor->name,grid_coord_name); index_dim = zone->index_dim; zcoor->rind_planes = (int *)malloc(index_dim*2*sizeof(int)); if (zcoor->rind_planes == NULL) { cgi_error("Error allocating zcoor->rind_plane."); return CG_ERROR; } for (n=0; nrind_planes[2*n]=zcoor->rind_planes[2*n+1]=0; /* save data in file */ if (cgi_new_node(zone->id, zcoor->name, "GridCoordinates_t", &zcoor->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and Write GridCoordinates_t bounding box \*****************************************************************************/ /** * \ingroup ZoneGridCoordinates * * \brief Get bounding box associated with a `GridCoordinates_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] G \G_Grid * \param[in] datatype Data type of the bounding box array written to the file or read. Admissible * data types for a coordinate bounding box are \e RealSingle and \e RealDouble. * \param[out] boundingbox Data Array with bounding box values. * \return \ier * * \details When reading a bounding box, if the information is missing from the file, the \p boundingbox * array will remain untouched, and the CG_NODE_NOT_FOUND status will be returned. The CGNS MLL * relies on the user to compute the bounding box and ensure that the bounding box being * stored is coherent with the coordinates under the GridCoordinates_t node. * */ int cg_grid_bounding_box_read(int fn, int B, int Z, int G, CGNS_ENUMT(DataType_t) datatype, void* boundingbox) { cgns_zcoor *zcoor; cgns_base *base; char_33 name; char_33 data_type; int ndim; void * vdata; cgsize_t dim_vals[12]; cgsize_t num; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for GridCoordinates_t node */ zcoor = cgi_get_zcoor(cg, B, Z, G); if (zcoor==0) return CG_ERROR; /* Read Bounding box from GridCoordinates node data */ if (cgi_read_node(zcoor->id, name, data_type, &ndim, dim_vals, &vdata, READ_DATA)){ cgi_error("Error reading node GridCoordinates_t"); return CG_ERROR; } /* check bounding box is not an empty array*/ if (strcmp(data_type,"MT")==0) { cgi_error("No bounding box found for reading"); return CG_NODE_NOT_FOUND; } if (strcmp(data_type,"R4") && strcmp(data_type,"R8")) { cgi_error("Datatype %s not supported for coordinates bounding box", data_type); return CG_ERROR; } if (ndim != 2) { cgi_error("Grid coordinates bounding box is %d dimensional. It should be 2.", ndim); return CG_ERROR; } base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; num = 2*base->phys_dim; if (dim_vals[0]*dim_vals[1] != num){ cgi_error("Grid coordinates bounding box is not coherent with physical dimension."); return CG_ERROR; } /* verify input */ if (datatype != CGNS_ENUMV(RealSingle) && datatype != CGNS_ENUMV(RealDouble)) { cgi_error("Invalid data type for bounding box array: %d", datatype); return CG_ERROR; } /* transfer small bounding box data to user with correct data type */ cgi_convert_data(num, cgi_datatype(data_type), vdata, datatype, boundingbox); CGNS_FREE(vdata); return CG_OK; } /** * \ingroup ZoneGridCoordinates * * \brief Write bounding box associated with a `GridCoordinates_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] G \G_Grid * \param[in] datatype Data type of the bounding box array written to the file or read. Admissible * data types for a coordinate bounding box are RealSingle and RealDouble. * \param[in] boundingbox Data Array with bounding box values. * \return \ier * * \details The CGNS MLL relies on the user to compute the bounding box and ensure that the bounding * box being stored is coherent with the coordinates under the GridCoordinates_t node. */ int cg_grid_bounding_box_write(int fn, int B, int Z, int G, CGNS_ENUMT(DataType_t) datatype, void* boundingbox) { cgns_base *base; cgns_zcoor *zcoor; cgsize_t dim_vals[2]; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* Get memory address for GridCoordinates_t node */ zcoor = cgi_get_zcoor(cg, B, Z, G); if (zcoor==0) return CG_ERROR; if ((cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) && zcoor->id == 0) { cgi_error("Impossible to write coordinates bounding box to unwritten node"); return CG_ERROR; } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(zcoor->id, hid); if (hid == 0) { cgi_error("Impossible to write coordinates bounding box to unwritten node HDF5"); return CG_ERROR; } } #endif base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; dim_vals[0] = base->phys_dim; dim_vals[1] = 2; /* Check input */ if (boundingbox == NULL) return CG_OK; if (datatype != CGNS_ENUMV(RealSingle) && datatype != CGNS_ENUMV(RealDouble)) { cgi_error("Invalid data type for bounding box array: %d", datatype); return CG_ERROR; } /* Write Bounding box into existing GridCoordinates_t node */ if (cgio_set_dimensions(cg->cgio, zcoor->id, cgi_adf_datatype(datatype), 2, dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } if (cgio_write_all_data(cg->cgio, zcoor->id, boundingbox)){ cg_io_error("cgio_write_all_data"); return CG_ERROR; } return CG_OK; } /*****************************************************************************\ * Read and Write GridCoordinates_t/DataArray_t Nodes \*****************************************************************************/ /** * \ingroup ZoneGridCoordinates * * \brief Get the number of coordinate arrays * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] ncoords Number of coordinate arrays for zone Z. * \return \ier * */ int cg_ncoords(int fn, int B, int Z, int *ncoords) { cgns_zcoor *zcoor; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for node "GridCoordinates" */ zcoor = cgi_get_zcoorGC(cg, B, Z); if (zcoor==0) *ncoords = 0; /* if ZoneGridCoordinates_t is undefined */ else *ncoords = zcoor->ncoords; return CG_OK; } /** * \ingroup ZoneGridCoordinates * * \brief Get info about a coordinate array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] C \C_Coordinate * \param[out] datatype Data type of the coordinate array written to the file. Admissible data types * for a coordinate array are RealSingle and RealDouble. * \param[out] coordname Name of the coordinate array. It is strongly advised to use the SIDS * nomenclature conventions when naming the coordinate arrays to ensure file * compatibility. * \return \ier * */ int cg_coord_info(int fn, int B, int Z, int C, CGNS_ENUMT(DataType_t) *datatype, char *coordname) { cgns_zcoor *zcoor; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for node "GridCoordinates" */ zcoor = cgi_get_zcoorGC(cg, B, Z); if (zcoor==0) return CG_ERROR; if (C>zcoor->ncoords || C<=0) { cgi_error("coord number %d invalid",C); return CG_ERROR; } *datatype = cgi_datatype(zcoor->coord[C-1].data_type); strcpy(coordname, zcoor->coord[C-1].name); return CG_OK; } /** * \ingroup ZoneGridCoordinates * * \brief Read grid coordinate array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] coordname Name of the coordinate array. It is strongly advised to use the SIDS * nomenclature conventions when naming the coordinate arrays to ensure file * compatibility. * \param[in] mem_datatype Data type of an array in memory. Admissible data types for a coordinate * array are RealSingle and RealDouble. * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). * \param[out] coord_array Array of coordinate values. * \return \ier * */ int cg_coord_read(int fn, int B, int Z, const char *coordname, CGNS_ENUMT(DataType_t) mem_datatype, const cgsize_t *s_rmin, const cgsize_t *s_rmax, void *coord_array) { cgns_zone *zone; int n, m_numdim; /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone == 0) return CG_ERROR; m_numdim = zone->index_dim; /* verify that range requested is not NULL */ if (s_rmin == NULL || s_rmax == NULL) { cgi_error("NULL range value."); return CG_ERROR; } cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; for (n = 0; nfilename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for node "GridCoordinates" */ zcoor = cgi_get_zcoorGC(cg, B, Z); if (zcoor == 0) return CG_ERROR; /* find the coord address in the database */ coord = 0; for (c=0; cncoords; c++) { if (strcmp(zcoor->coord[c].name, coordname) == 0) { coord = &zcoor->coord[c]; break; } } if (coord==0) { cgi_error("Coordinate %s not found.",coordname); return CG_NODE_NOT_FOUND; } /* zcoor implies zone exists */ s_numdim = cg->base[B-1].zone[Z-1].index_dim; return cgi_array_general_read(coord, cgns_rindindex, zcoor->rind_planes, s_numdim, s_rmin, s_rmax, m_type, m_numdim, m_dimvals, m_rmin, m_rmax, coord_ptr); } /** * \ingroup ZoneGridCoordinates * * \brief Get coordinate id * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] C \C_Coordinate * \param[out] coord_id Coordinate id. * \return \ier * */ int cg_coord_id(int fn, int B, int Z, int C, double *coord_id) { cgns_zcoor *zcoor; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for node "GridCoordinates" */ zcoor = cgi_get_zcoorGC(cg, B, Z); if (zcoor==0) return CG_ERROR; if (C>zcoor->ncoords || C<=0) { cgi_error("coord number %d invalid",C); return CG_ERROR; } *coord_id = zcoor->coord[C-1].id; return CG_OK; } /** * \ingroup ZoneGridCoordinates * * \brief Write grid coordinates * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] datatype Data type of the coordinate array written to the file. Admissible data types * for a coordinate array are RealSingle and RealDouble. * \param[in] coordname Name of the coordinate array. It is strongly advised to use the SIDS * nomenclature conventions when naming the coordinate arrays to ensure file * compatibility. * \param[in] coord_ptr Array of coordinate values. * \param[out] C \C_Coordinate * \return \ier * */ int cg_coord_write(int fn, int B, int Z, CGNS_ENUMT(DataType_t) datatype, const char *coordname, const void *coord_ptr, int *C) { cgns_zone *zone; cgns_zcoor *zcoor; int n, m_numdim; int status; HDF5storage_type = CG_CONTIGUOUS; /* verify input */ if (cgi_check_strlen(coordname)) return CG_ERROR; if (datatype!=CGNS_ENUMV( RealSingle ) && datatype!=CGNS_ENUMV( RealDouble )) { cgi_error("Invalid datatype for coord. array: %d", datatype); return CG_ERROR; } /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone == 0) return CG_ERROR; /* Get memory address for node "GridCoordinates" */ zcoor = cgi_get_zcoorGC(cg, B, Z); if (zcoor == 0) return CG_ERROR; m_numdim = zone->index_dim; cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t s_rmin[CGIO_MAX_DIMENSIONS], s_rmax[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; for (n = 0; nnijk[n] + zcoor->rind_planes[2*n] + zcoor->rind_planes[2*n+1]; if (cgns_rindindex == CG_CONFIG_RIND_ZERO) { /* old obsolete behavior (versions < 3.4) */ s_rmin[n] = 1; } else { /* new behavior consistent with SIDS */ s_rmin[n] = 1 - zcoor->rind_planes[2*n]; } s_rmax[n] = s_rmin[n] + m_dimvals[n] - 1; m_rmin[n] = 1; m_rmax[n] = m_dimvals[n]; } status = cg_coord_general_write(fn, B, Z, coordname, datatype, s_rmin, s_rmax, datatype, m_numdim, m_dimvals, m_rmin, m_rmax, coord_ptr, C); HDF5storage_type = CG_COMPACT; return status; } /** * \ingroup ZoneGridCoordinates * * \brief Write subset of grid coordinates * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] datatype Data type of the coordinate array written to the file. Admissible data types * for a coordinate array are RealSingle and RealDouble. * \param[in] coordname Name of the coordinate array. It is strongly advised to use the SIDS * nomenclature conventions when naming the coordinate arrays to ensure file * compatibility. * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). * \param[in] coord_ptr Array of coordinate values. * \param[out] C \C_Coordinate * \return \ier * */ int cg_coord_partial_write(int fn, int B, int Z, CGNS_ENUMT(DataType_t) datatype, const char *coordname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, const void *coord_ptr, int *C) { cgns_zone *zone; int n, m_numdim; int status; /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone == 0) return CG_ERROR; m_numdim = zone->index_dim; if (s_rmin == NULL || s_rmax == NULL) { cgi_error("NULL range value."); return CG_ERROR; } cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; for (n = 0; nfilename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone == 0) return CG_ERROR; /* Get memory address for node "GridCoordinates" */ zcoor = cgi_get_zcoorGC(cg, B, Z); if (zcoor == 0) return CG_ERROR; cgsize_t s_dimvals[CGIO_MAX_DIMENSIONS]; s_numdim = zone->index_dim; for (n = 0; nnijk[n] + zcoor->rind_planes[2*n] + zcoor->rind_planes[2*n+1]; } /* Create GridCoordinates_t node if not already created */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (zcoor->id == 0) { if (cgi_new_node(zone->id, "GridCoordinates", "GridCoordinates_t", &zcoor->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(zcoor->id, hid); if (hid == 0) { if (cgi_new_node(zone->id, "GridCoordinates", "GridCoordinates_t", &zcoor->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } status = cgi_array_general_write(zcoor->id, &(zcoor->ncoords), &(zcoor->coord), coordname, cgns_rindindex, zcoor->rind_planes, s_type, s_numdim, s_dimvals, s_rmin, s_rmax, m_type, m_numdim, m_dimvals, m_rmin, m_rmax, coord_ptr, C); HDF5storage_type = CG_COMPACT; return status; } /*****************************************************************************\ * Read and Write Elements_t Nodes \*****************************************************************************/ static int adf2_check_elems(CGNS_ENUMT(ElementType_t) type, cgsize_t nelems, const cgsize_t *elems) { if (type < CGNS_ENUMV(NODE) || type > CGNS_ENUMV(MIXED)) { cgi_error("Element type %s not supported in ADF2.", cg_ElementTypeName(type)); return CG_ERROR; } if (type == CGNS_ENUMV(MIXED)) { int npe; cgsize_t n; for (n = 0; n < nelems; n++) { type = (CGNS_ENUMT(ElementType_t))*elems++; if (type < CGNS_ENUMV(NODE) || type >= CGNS_ENUMV(MIXED)) { cgi_error("Element type %s not supported in ADF2.", cg_ElementTypeName(type)); return CG_ERROR; } if (cg_npe(type, &npe) || npe <= 0) return CG_ERROR; elems += npe; } } return CG_OK; } static void free_element_data(cgns_section *section) { if (section->connect->data != NULL) { free(section->connect->data); section->connect->data = NULL; } } static int read_element_data(cgns_section *section) { if (section->connect->data == NULL) { cgsize_t cnt = section->connect->dim_vals[0]; section->connect->data = malloc(cnt * sizeof(cgsize_t)); if (section->connect->data == NULL) { cgi_error("malloc failed for element data"); return CG_ERROR; } if (cgi_read_int_data(section->connect->id, section->connect->data_type, cnt, section->connect->data)) { free_element_data(section); return CG_ERROR; } } return CG_OK; } static void free_offset_data(cgns_section *section) { if (section->connect_offset->data != NULL) { free(section->connect_offset->data); section->connect_offset->data = NULL; } } static int read_offset_data(cgns_section *section) { if (section->connect_offset->data == NULL) { cgsize_t cnt = section->connect_offset->dim_vals[0]; section->connect_offset->data = malloc(cnt * sizeof(cgsize_t)); if (section->connect_offset->data == NULL) { cgi_error("malloc failed for element connectivity offset data"); return CG_ERROR; } if (cgi_read_int_data(section->connect_offset->id, section->connect_offset->data_type, cnt, section->connect_offset->data)) { free_offset_data(section); return CG_ERROR; } } return CG_OK; } static void free_parent_data(cgns_section *section) { if (section->parelem && section->parelem->data != NULL) { free(section->parelem->data); section->parelem->data = NULL; } if (section->parface && section->parface->data != NULL) { free(section->parface->data); section->parface->data = NULL; } } static int read_parent_data(cgns_section *section) { cgsize_t cnt; if (0 == strcmp(section->parelem->name, "ParentData")) { if (section->parelem->data == NULL) { cnt = section->parelem->dim_vals[0] * 4; section->parelem->data = malloc(cnt * sizeof(cgsize_t)); if (section->parelem->data == NULL) { cgi_error("malloc failed for ParentData data"); return CG_ERROR; } if (cgi_read_int_data(section->parelem->id, section->parelem->data_type, cnt, section->parelem->data)) { free_parent_data(section); return CG_ERROR; } } return CG_OK; } if (section->parelem->dim_vals[0] != section->parface->dim_vals[0] || section->parelem->dim_vals[1] != 2 || section->parface->dim_vals[1] != 2) { cgi_error("mismatch in ParentElements and ParentElementsPosition data sizes"); return CG_ERROR; } cnt = section->parelem->dim_vals[0] * 2; if (section->parelem->data == NULL) { section->parelem->data = malloc(cnt * sizeof(cgsize_t)); if (section->parelem->data == NULL) { cgi_error("malloc failed for ParentElements data"); return CG_ERROR; } if (cgi_read_int_data(section->parelem->id, section->parelem->data_type, cnt, section->parelem->data)) { free_parent_data(section); return CG_ERROR; } } if (section->parface->data == NULL) { section->parface->data = malloc(cnt * sizeof(cgsize_t)); if (section->parface->data == NULL) { cgi_error("malloc failed for ParentElementsPosition data"); return CG_ERROR; } if (cgi_read_int_data(section->parface->id, section->parface->data_type, cnt, section->parface->data)) { free_parent_data(section); return CG_ERROR; } } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Get the number of element sections * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] nsections Number of element sections. * \return \ier * */ int cg_nsections(int fn, int B, int Z, int *nsections) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; (*nsections) = zone->nsections; return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Get info for an element section * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs * section. * \param[out] SectionName Name of the Elements_t node. * \param[out] start Index of the first element in the section. * \param[out] end Index of the last element in the section. * \param[out] nbndry Index of last boundary element in the section. Set to zero if the elements * are unsorted. * \param[out] parent_flag Flag indicating if the parent data are defined. If the parent data exists, * parent_flag is set to 1; otherwise, it is set to 0. * \return \ier * */ int cg_section_read(int fn, int B, int Z, int S, char *SectionName, CGNS_ENUMT(ElementType_t) *type, cgsize_t *start, cgsize_t *end, int *nbndry, int *parent_flag) { cgns_section *section; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; strcpy(SectionName, section->name); *type = section->el_type; *start = section->range[0]; *end = section->range[1]; *nbndry = section->el_bound; *parent_flag=0; if (section->parelem && (section->parface || 0 == strcmp(section->parelem->name, "ParentData"))) *parent_flag=1; return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Write fixed-size element data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs * section. * \param[in] SectionName Name of the Elements_t node. * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] nbndry Index of last boundary element in the section. Set to zero if the elements * are unsorted. * \param[in] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \param[out] S \CONN_S * \return \ier * * \details This writing function only works with fixed-size elements. * */ int cg_section_write(int fn, int B, int Z, const char * SectionName, CGNS_ENUMT(ElementType_t)type, cgsize_t start, cgsize_t end, int nbndry, const cgsize_t * elements, int *S) { cgns_zone *zone; cgns_section *section = NULL; if (!IS_FIXED_SIZE(type)) { cgi_error("Element must be a fixed size"); return CG_ERROR; } if (cg_section_general_write(fn, B, Z, SectionName, type, cgi_datatype(CG_SIZE_DATATYPE), start, end, 0, nbndry, S)){ return CG_ERROR; } zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; section = &(zone->section[*S-1]); if (cgio_write_all_data(cg->cgio, section->connect->id, elements)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Write element data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs * section. * \param[in] SectionName Name of the Elements_t node. * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] nbndry Index of last boundary element in the section. Set to zero if the elements * are unsorted. * \param[in] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \param[in] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and * MIXED according to Elements_t Structure Definition. * \param[out] S \CONN_S * \return \ier * */ int cg_poly_section_write(int fn, int B, int Z, const char * SectionName, CGNS_ENUMT(ElementType_t)type, cgsize_t start, cgsize_t end, int nbndry, const cgsize_t * elements, const cgsize_t * connect_offset, int *S) { cgns_zone *zone; cgns_section *section = NULL; cgsize_t num, ElementDataSize=0; /* get file and check mode */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; num = end - start + 1; if (num <= 0) { cgi_error("Invalid element range defined for section '%s'",SectionName); return CG_ERROR; } if (cg->filetype == CG_FILE_ADF2 && adf2_check_elems(type, num, elements)) return CG_ERROR; /* Compute ElementDataSize */ ElementDataSize = cgi_element_data_size(type, num, elements, connect_offset); if (ElementDataSize < 0) return CG_ERROR; /* Create empty section */ if (cg_section_general_write(fn, B, Z, SectionName, type, cgi_datatype(CG_SIZE_DATATYPE), start, end, ElementDataSize, nbndry, S)){ return CG_ERROR; } /* Now fill the section connectivity */ zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; section = &(zone->section[*S-1]); if (connect_offset && ! IS_FIXED_SIZE(type)) { /* Write element start offset connectivity */ if (cgio_write_all_data(cg->cgio, section->connect_offset->id, connect_offset)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } } /* Write element connectivity */ if (cgio_write_all_data(cg->cgio, section->connect->id, elements)) { cg_io_error("cgio_write_all_data"); return CG_ERROR; } return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Write subset of element data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs * section. * \param[in] SectionName Name of the Elements_t node. * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] nbndry Index of last boundary element in the section. Set to zero if the elements * are unsorted. * \param[out] S \CONN_S * \return \ier * */ int cg_section_partial_write(int fn, int B, int Z, const char * SectionName, CGNS_ENUMT(ElementType_t) type, cgsize_t start, cgsize_t end, int nbndry, int *S) { int elemsize; cgsize_t num, ElementDataSize=0; num = end - start + 1; if (cg_npe(type, &elemsize)) return CG_ERROR; if (elemsize <= 0) elemsize=2; ElementDataSize = num * elemsize; /* create empty section */ if (cg_section_general_write(fn, B, Z, SectionName, type, cgi_datatype(CG_SIZE_DATATYPE), start, end, ElementDataSize, nbndry, S)){ return CG_ERROR; } /* if not fixed element size, need to create valid data for sizing */ if (cg_section_initialize(fn, B, Z, *S)) { return CG_ERROR; } return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Write section data without element data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs * section. * \param[in] elementDataType Data type of an array. Admissible data types are Integer and LongInteger. * \param[in] SectionName Name of the Elements_t node. * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] elementDataSize Number of element connectivity data values. * \param[in] nbndry Index of last boundary element in the section. Set to zero if the elements * are unsorted. * \param[out] S \CONN_S * \return \ier * */ int cg_section_general_write(int fn, int B, int Z, const char * SectionName, const CGNS_ENUMT(ElementType_t) type, const CGNS_ENUMT(DataType_t) elementDataType, cgsize_t start, cgsize_t end, cgsize_t elementDataSize, int nbndry, int *S) { cgns_zone *zone; cgns_section *section = NULL; int data[2]; int index, elemsize; cgsize_t num; cgsize_t dim_vals; const char * data_type; double dummy_id; void *prange; /* verify input */ if (cgi_check_strlen(SectionName)) return CG_ERROR; if (INVALID_ENUM(type,NofValidElementTypes)) { cgi_error("Invalid element type defined for section '%s'",SectionName); return CG_ERROR; } /* If elementDataType provided is not correct fallback to default CG_SIZE_DATATYPE */ if (elementDataType != CGNS_ENUMV(Integer) && elementDataType != CGNS_ENUMV(LongInteger)) { cgi_warning("Invalid datatype for Elements array in section %s: %d", SectionName, elementDataType); data_type = CG_SIZE_DATATYPE; } else { data_type = cgi_adf_datatype(elementDataType); } num = end - start + 1; if (num <= 0) { cgi_error("Invalid element range defined for section '%s'",SectionName); return CG_ERROR; } if (nbndry > num) { cgi_error("Invalid boundary element number for section '%s'",SectionName); return CG_ERROR; } /* Compute ElementDataSize */ if (IS_FIXED_SIZE(type)) { if (cg_npe(type, &elemsize)) return CG_ERROR; if (elemsize <= 0) return CG_ERROR; elementDataSize = num * elemsize; } else { if (elementDataSize < 2*num) { cgi_error("Invalid elementDataSize for section '%s'",SectionName); return CG_ERROR; } } /* get file and check mode */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; if (cg->filetype == CG_FILE_ADF2 && (type < CGNS_ENUMV(NODE) || type > CGNS_ENUMV(MIXED))) { /* Jiao: Changed to use older compatible version */ cgi_error("Element type %s not supported in ADF2.", cg_ElementTypeName(type)); return CG_ERROR; } zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* Overwrite a Elements_t Node: */ for (index=0; indexnsections; index++) { if (strcmp(SectionName, zone->section[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",SectionName); return CG_ERROR; } /* overwrite an existing section */ /* delete the existing section from file */ if (cgi_delete_node(zone->id, zone->section[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ section = &(zone->section[index]); /* free memory */ cgi_free_section(section); break; } } /* ... or add a Elements_t Node: */ if (index==zone->nsections) { if (zone->nsections == 0) { zone->section = CGNS_NEW(cgns_section, zone->nsections+1); } else { zone->section = CGNS_RENEW(cgns_section, zone->nsections+1, zone->section); } section = &(zone->section[zone->nsections]); zone->nsections++; } (*S) = index+1; /* initialize ... */ snprintf(section->name, sizeof(section->name), "%s", SectionName); section->el_type = type; section->range[0] = start; section->range[1] = end; section->el_bound = nbndry; section->connect = CGNS_NEW(cgns_array, 1); section->connect->data = 0; strcpy(section->connect->name,"ElementConnectivity"); strcpy(section->connect->data_type, data_type); section->connect->data_dim=1; section->connect->dim_vals[0]=elementDataSize; section->id=0; section->link=0; section->ndescr=0; section->parelem = section->parface = NULL; section->nuser_data=0; section->rind_planes=0; section->connect_offset=0; /* initialize other fields */ section->connect->id=0; section->connect->link=0; section->connect->ndescr=0; section->connect->data_class=CGNS_ENUMV(DataClassNull); section->connect->units=0; section->connect->exponents=0; section->connect->convert=0; /* if not fixed element size, need to create valid data for sizing */ if (!IS_FIXED_SIZE(type)) { section->connect_offset = CGNS_NEW(cgns_array, 1); section->connect_offset->data = 0; strcpy(section->connect_offset->name,"ElementStartOffset"); strcpy(section->connect_offset->data_type, data_type); section->connect_offset->data_dim=1; section->connect_offset->dim_vals[0]=(num+1); section->connect_offset->id=0; section->connect_offset->link=0; section->connect_offset->ndescr=0; section->connect_offset->data_class=CGNS_ENUMV(DataClassNull); section->connect_offset->units=0; section->connect_offset->exponents=0; section->connect_offset->convert=0; } /* Elements_t */ dim_vals = 2; data[0]=section->el_type; data[1]=section->el_bound; if (cgi_new_node(zone->id, section->name, "Elements_t", §ion->id, "I4", 1, &dim_vals, data)) return CG_ERROR; /* Check node for 32/64bit elements and write */ if (data_type[1] == CG_SIZE_DATATYPE[1]) { /* Same type as cgsize_t */ prange = (void *) section->range; } else if (data_type[1] == '4') { /* Element type is 32bit in 64bit library */ data[0] = (int) section->range[0]; data[1] = (int) section->range[1]; prange = (void *) data; } else { /* Do not write I8 in library that is not 64bit */ return CG_ERROR; } HDF5storage_type = CG_CONTIGUOUS; /* ElementRange */ if (cgi_new_node(section->id, "ElementRange", "IndexRange_t", &dummy_id, data_type, 1, &dim_vals, prange)) return CG_ERROR; /* ElementStartOffset */ if (section->connect_offset && cgi_new_node(section->id, section->connect_offset->name, "DataArray_t", §ion->connect_offset->id, section->connect_offset->data_type, section->connect_offset->data_dim, section->connect_offset->dim_vals, NULL)) return CG_ERROR; /* ElementConnectivity */ if (cgi_new_node(section->id, section->connect->name, "DataArray_t", §ion->connect->id, section->connect->data_type, section->connect->data_dim, section->connect->dim_vals, NULL)) return CG_ERROR; HDF5storage_type = CG_COMPACT; return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Initialize element data for not fixed size elements * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] S \CONN_S * \return \ier * * \details This function is a kind of helper to be used after a cg_section_general_write(). * cg_section_general_write() reserves enough space while this function puts coherent * init data. Then cg_poly_elements_partial_write() would run safely. */ int cg_section_initialize(int fn, int B, int Z, int S) { cgsize_t nm, nn, num, val; cgsize_t s_start, s_end, s_stride; cgsize_t m_start, m_end, m_stride, m_dim; cgsize_t *data; cgsize_t *data_offset; cgns_section *section = NULL; /* get file and check mode */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; /* only initialize not fixed size type */ if (IS_FIXED_SIZE(section->el_type)) return CG_OK; num = section->range[1] - section->range[0] + 1; if (num <= 0) { return CG_OK; } /* check that connectivity and offset are here */ if (section->connect == 0 || section->connect_offset == 0) return CG_ERROR; /* check if enough space is reserved to initialize */ if (section->connect->dim_vals[0]<2*num) return CG_ERROR; data = CGNS_NEW(cgsize_t, num*2); data_offset = CGNS_NEW(cgsize_t, (size_t)(num+1)); val = (section->el_type == CGNS_ENUMV(MIXED) ? (cgsize_t)CGNS_ENUMV(NODE) : 0); for (nn = 0, nm = 0; nm < num; nm++) { data[nn++] = val; data[nn++] = 0; } data_offset[0] = 0; for (nm = 0; nm < num; nm++) { data_offset[nm+1] = data_offset[nm]+2; } /* transfer ownership */ section->connect_offset->data = data_offset; /* write to disk */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { /* need to do convert in memory for ADF */ #if CG_SIZEOF_SIZE == 64 if (0 == strcmp(section->connect_offset->data_type, "I4")) { int *tmp = CGNS_NEW(int, 2*num); for (nm = 0; nm < num+1; nm++){ tmp[nm] = (int) data_offset[nm]; } s_start = 1; s_end = num + 1; s_stride = 1; m_start = 1; m_end = num + 1; m_dim = num + 1; m_stride = 1; if (cgio_write_data(cg->cgio, section->connect_offset->id, &s_start, &s_end, &s_stride, 1, &m_dim, &m_start, &m_end, &m_stride, tmp)) { CGNS_FREE(data); CGNS_FREE(tmp); cg_io_error("cgio_write_data"); return CG_ERROR; } for (nm = 0; nm < 2*num; nm++){ tmp[nm] = (int) data[nm]; } s_start = 1; s_end = 2*num; s_stride = 1; m_start = 1; m_end = 2*num; m_dim = 2*num; m_stride = 1; if (cgio_write_data(cg->cgio, section->connect->id, &s_start, &s_end, &s_stride, 1, &m_dim, &m_start, &m_end, &m_stride, tmp)) { CGNS_FREE(data); CGNS_FREE(tmp); cg_io_error("cgio_write_data"); return CG_ERROR; } CGNS_FREE(tmp); } #else if (0 == strcmp(section->connect_offset->data_type, "I8")) { cglong_t *tmp = CGNS_NEW(cglong_t, 2*num); for (nm = 0; nm < num+1; nm++){ tmp[nm] = (cglong_t) data_offset[nm]; } s_start = 1; s_end = num + 1; s_stride = 1; m_start = 1; m_end = num + 1; m_dim = num + 1; m_stride = 1; if (cgio_write_data(cg->cgio, section->connect_offset->id, &s_start, &s_end, &s_stride, 1, &m_dim, &m_start, &m_end, &m_stride, tmp)) { CGNS_FREE(data); CGNS_FREE(tmp); cg_io_error("cgio_write_data"); return CG_ERROR; } for (nm = 0; nm < 2*num; nm++){ tmp[nm] = (cglong_t) data[nm]; } s_start = 1; s_end = 2*num; s_stride = 1; m_start = 1; m_end = 2*num; m_dim = 2*num; m_stride = 1; if (cgio_write_data(cg->cgio, section->connect->id, &s_start, &s_end, &s_stride, 1, &m_dim, &m_start, &m_end, &m_stride, tmp)) { CGNS_FREE(data); CGNS_FREE(tmp); cg_io_error("cgio_write_data"); return CG_ERROR; } CGNS_FREE(tmp); } #endif else { s_start = 1; s_end = num + 1; s_stride = 1; m_start = 1; m_end = num + 1; m_dim = num + 1; m_stride = 1; if (cgio_write_data(cg->cgio, section->connect_offset->id, &s_start, &s_end, &s_stride, 1, &m_dim, &m_start, &m_end, &m_stride, data_offset)) { CGNS_FREE(data); cg_io_error("cgio_write_data"); return CG_ERROR; } s_start = 1; s_end = 2*num; s_stride = 1; m_start = 1; m_end = 2*num; m_dim = 2*num; m_stride = 1; if (cgio_write_data(cg->cgio, section->connect->id, &s_start, &s_end, &s_stride, 1, &m_dim, &m_start, &m_end, &m_stride, data)) { CGNS_FREE(data); cg_io_error("cgio_write_data"); return CG_ERROR; } } } else if (cg->filetype == CGIO_FILE_HDF5) { /* in-situ conversion */ s_start = 1; s_end = num + 1; s_stride = 1; m_start = 1; m_end = num + 1; m_dim = num + 1; m_stride = 1; if (cgio_write_data_type(cg->cgio, section->connect_offset->id, &s_start, &s_end, &s_stride, CG_SIZE_DATATYPE, 1, &m_dim, &m_start, &m_end, &m_stride, data_offset)) { CGNS_FREE(data); cg_io_error("cgio_write_all_data_type"); return CG_ERROR; } s_start = 1; s_end = 2*num; s_stride = 1; m_start = 1; m_end = 2*num; m_dim = 2*num; m_stride = 1; if (cgio_write_data_type(cg->cgio, section->connect->id, &s_start, &s_end, &s_stride, CG_SIZE_DATATYPE, 1, &m_dim, &m_start, &m_end, &m_stride, data)) { CGNS_FREE(data); cg_io_error("cgio_write_all_data_type"); return CG_ERROR; } } CGNS_FREE(data); return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Get size of element connectivity data array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[out] ElementDataSize Number of element connectivity data values. * \return \ier * * \details This function was created for revision 1.2 to return the size of the * connectivity vector, which can't be known without it *when type=MIXED*. */ int cg_ElementDataSize(int fn, int B, int Z, int S, cgsize_t *ElementDataSize) { cgns_section *section; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; *ElementDataSize = section->connect->dim_vals[0]; return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Get size of element connectivity data array for partial read * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[out] ElementDataSize Number of element connectivity data values. * \return \ier * * \details This function was created for revision 1.2 to return the size of the * connectivity vector, which can't be known without it *when type=MIXED*. */ int cg_ElementPartialSize(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *ElementDataSize) { cgns_section *section; cgsize_t size, cnt, *offset_data; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; if (start > end || start < section->range[0] || end > section->range[1]) { cgi_error("Invalid range for section '%s'", section->name); return CG_ERROR; } if (start == section->range[0] && end == section->range[1]) { *ElementDataSize = section->connect->dim_vals[0]; return CG_OK; } if (IS_FIXED_SIZE(section->el_type)) { size = cgi_element_data_size(section->el_type, end - start + 1, NULL, NULL); if (size < 0) return CG_ERROR; *ElementDataSize = size; return CG_OK; } if (section->connect_offset->data == NULL) { // Only read a slice of the ElementStartOffset array cnt = end - start + 2; // Handle different compilation configurations for cgsize_t #if CG_SIZEOF_SIZE == 64 if (0 == strcmp(section->connect_offset->data_type, "I4")) { int* offsets = (int*)malloc((size_t)(cnt * sizeof(int))); if (NULL == offsets) { cgi_error("Error allocating I4->I8 data array..."); return CG_ERROR; } if (cgi_read_offset_data_type(section->connect_offset->id, "I4", start - section->range[0] + 1, end - section->range[0] + 2, "I4", offsets)) { CGNS_FREE(offsets); return CG_ERROR; } size = (cgsize_t)(offsets[cnt - 1] - offsets[0]); CGNS_FREE(offsets); } #else if (0 == strcmp(section->connect_offset->data_type, "I8")) { cglong_t* offsets = (cglong_t*)malloc((size_t)(cnt * sizeof(cglong_t))); if (NULL == offsets) { cgi_error("Error allocating I8->I4 data array..."); return CG_ERROR; } if (cgi_read_offset_data_type(section->connect_offset->id, "I8", start - section->range[0] + 1, end - section->range[0] + 2, "I8", offsets)) { CGNS_FREE(offsets); return CG_ERROR; } size = (cgsize_t)(offsets[cnt - 1] - offsets[0]); CGNS_FREE(offsets); } #endif else { cgsize_t* offsets = malloc(cnt * sizeof(cgsize_t)); if (NULL == offsets) { cgi_error("Error allocating data array..."); return CG_ERROR; } if (cgi_read_offset_data_type(section->connect_offset->id, CG_SIZE_DATATYPE, start - section->range[0] + 1, end - section->range[0] + 2, CG_SIZE_DATATYPE, offsets)) { CGNS_FREE(offsets); return CG_ERROR; } size = (cgsize_t)(offsets[cnt - 1] - offsets[0]); CGNS_FREE(offsets); } } else { // if ElementStartOffset is already fully loaded offset_data = (cgsize_t*)section->connect_offset->data; if (offset_data == 0) return CG_ERROR; size = offset_data[end - section->range[0] + 1] - offset_data[start - section->range[0]]; } if (size < 0) return CG_ERROR; *ElementDataSize = size; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Read fixed size element data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[out] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \param[out] parent_data For boundary or interface elements, this array contains information on the * cell(s) and cell face(s) sharing the element. If you do not need to read the * ParentData when reading the ElementData, you may set the value to NULL. * \return \ier * */ int cg_elements_read(int fn, int B, int Z, int S, cgsize_t *elements, cgsize_t *parent_data) { cgns_section *section; cgsize_t count, num, ElementDataSize=0; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; if (!IS_FIXED_SIZE(section->el_type)) { cgi_error("element must be a fixed size"); return CG_ERROR; } /* cgns_internals takes care of adjusting for version */ ElementDataSize = section->connect->dim_vals[0]; num = section->range[1] - section->range[0] +1; count = cgi_element_data_size(section->el_type, num, section->connect->data, NULL); if (count < 0) return CG_ERROR; if (count && count != ElementDataSize) { cgi_error("Error in recorded element connectivity array..."); return CG_ERROR; } if (section->connect->data && 0 == strcmp(CG_SIZE_DATATYPE, section->connect->data_type)) { memcpy(elements, section->connect->data, (size_t)(ElementDataSize*sizeof(cgsize_t))); } else { if (cgi_read_int_data(section->connect->id, section->connect->data_type, ElementDataSize, elements)) return CG_ERROR; } if (parent_data && section->parelem && (section->parface || 0 == strcmp(section->parelem->name, "ParentData"))) { if (0 == strcmp(section->parelem->name, "ParentData")) { if (cgi_read_int_data(section->parelem->id, section->parelem->data_type, num << 2, parent_data)) return CG_ERROR; } else { if (cgi_read_int_data(section->parelem->id, section->parelem->data_type, num << 1, parent_data) || cgi_read_int_data(section->parface->id, section->parface->data_type, num << 1, &parent_data[num << 1])) return CG_ERROR; } } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Read element data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[out] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \param[out] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and * MIXED according to Elements_t Structure Definition. * \param[out] parent_data For boundary or interface elements, this array contains information on the * cell(s) and cell face(s) sharing the element. If you do not need to read the * ParentData when reading the ElementData, you may set the value to NULL. * \return \ier * */ int cg_poly_elements_read(int fn, int B, int Z, int S, cgsize_t *elements, cgsize_t *connect_offset, cgsize_t *parent_data) { cgns_section *section; cgsize_t count, num, ElementDataSize=0, ConnectOffsetSize=0; cgsize_t *offset_data=0; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; /* cgns_internals takes care of adjusting for version */ ElementDataSize = section->connect->dim_vals[0]; /* Double check ElementDataSize (not necessary) */ if (section->connect_offset && section->connect_offset->data && 0 == strcmp(CG_SIZE_DATATYPE, section->connect_offset->data_type)) { offset_data = section->connect_offset->data; } num = section->range[1] - section->range[0] +1; count = cgi_element_data_size(section->el_type, num, section->connect->data, offset_data); if (count < 0) return CG_ERROR; if (count && count != ElementDataSize) { cgi_error("Error in recorded element connectivity array..."); return CG_ERROR; } if (section->connect->data && 0 == strcmp(CG_SIZE_DATATYPE, section->connect->data_type)) { memcpy(elements, section->connect->data, (size_t)(ElementDataSize*sizeof(cgsize_t))); } else { if (cgi_read_int_data(section->connect->id, section->connect->data_type, ElementDataSize, elements)) return CG_ERROR; } if (connect_offset && section->connect_offset) { ConnectOffsetSize = section->connect_offset->dim_vals[0]; if (section->connect_offset->data && 0 == strcmp(CG_SIZE_DATATYPE, section->connect_offset->data_type)) { memcpy(connect_offset, section->connect_offset->data, (size_t)(ConnectOffsetSize*sizeof(cgsize_t))); } else { if (cgi_read_int_data(section->connect_offset->id, section->connect_offset->data_type, ConnectOffsetSize, connect_offset)) return CG_ERROR; } } if (parent_data && section->parelem && (section->parface || 0 == strcmp(section->parelem->name, "ParentData"))) { if (0 == strcmp(section->parelem->name, "ParentData")) { if (cgi_read_int_data(section->parelem->id, section->parelem->data_type, num << 2, parent_data)) return CG_ERROR; } else { if (cgi_read_int_data(section->parelem->id, section->parelem->data_type, num << 1, parent_data) || cgi_read_int_data(section->parface->id, section->parface->data_type, num << 1, &parent_data[num << 1])) return CG_ERROR; } } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Read subset of fixed size element data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[out] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \param[out] parent_data For boundary or interface elements, this array contains information on the * cell(s) and cell face(s) sharing the element. If you do not need to read the * ParentData when reading the ElementData, you may set the value to NULL. * \return \ier * */ int cg_elements_partial_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *elements, cgsize_t *parent_data) { cgns_section *section; cgsize_t offset, size, n; cgsize_t i, j, nn, *data; cgsize_t s_start[2], s_end[2], s_stride[2]; cgsize_t m_start[2], m_end[2], m_stride[2], m_dim[2]; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; if (!IS_FIXED_SIZE(section->el_type)) { cgi_error("Element must be a fixed size"); return CG_ERROR; } /* check the requested element range against the stored element range, * and the validity of the requested range */ if(start > end || start < section->range[0] || end > section->range[1]) { cgi_error("Error in requested element data range."); return CG_ERROR; } /* if the elements are fixed size, read directly into user memory */ if (section->connect->data == 0 && 0 == strcmp(CG_SIZE_DATATYPE, section->connect->data_type)) { size = cgi_element_data_size(section->el_type, end - start + 1, NULL, NULL); if (size < 0) return CG_ERROR; s_start[0] = cgi_element_data_size(section->el_type, start - section->range[0], NULL, NULL) + 1; s_end[0] = cgi_element_data_size(section->el_type, end - section->range[0] + 1, NULL, NULL); s_stride[0] = 1; m_start[0] = 1; m_end[0] = size; m_stride[0] = 1; m_dim[0] = size; if (cgio_read_data_type(cg->cgio, section->connect->id, s_start, s_end, s_stride, CG_SIZE_DATATYPE, 1, m_dim, m_start, m_end, m_stride, elements)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } else { /* need to get the elements to compute locations */ if (read_element_data(section)) return CG_ERROR; data = (cgsize_t *)section->connect->data; offset = cgi_element_data_size(section->el_type, start - section->range[0], data, NULL); size = cgi_element_data_size(section->el_type, end - start + 1, &data[offset], NULL); memcpy(elements, &data[offset], (size_t)(size*sizeof(cgsize_t))); } if (parent_data && section->parelem && (section->parface || 0 == strcmp(section->parelem->name, "ParentData"))) { offset = start - section->range[0]; size = section->range[1] - section->range[0] + 1; /* read from ParentData */ if (0 == strcmp(section->parelem->name, "ParentData")) { if (0 == strcmp(CG_SIZE_DATATYPE, section->parelem->data_type)) { s_start[0] = start - section->range[0] + 1; s_end[0] = end - section->range[0] + 1; s_stride[0]= 1; s_start[1] = 1; s_end[1] = 4; s_stride[1]= 1; m_start[0] = 1; m_end[0] = end - start + 1; m_stride[0]= 1; m_start[1] = 1; m_end[1] = 4; m_stride[1]= 1; m_dim[0] = m_end[0]; m_dim[1] = 4; if (cgio_read_data_type(cg->cgio, section->parelem->id, s_start, s_end, s_stride, CG_SIZE_DATATYPE, 2, m_dim, m_start, m_end, m_stride, parent_data)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } else { nn = section->parelem->dim_vals[0] * 4; data = (cgsize_t *)malloc((size_t)(nn * sizeof(cgsize_t))); if (data == NULL) { cgi_error("malloc failed for temporary ParentData array"); return CG_ERROR; } if (cgi_read_int_data(section->parelem->id, section->parelem->data_type, nn, data)) { free(data); return CG_ERROR; } for (n = 0, j = 0; j < 4; j++) { nn = j * size + offset; for (i = start; i <= end; i++) parent_data[n++] = data[nn++]; } free(data); } } /* read from ParentElements and ParentElementsPosition */ else if (0 == strcmp(CG_SIZE_DATATYPE, section->parelem->data_type) && 0 == strcmp(CG_SIZE_DATATYPE, section->parface->data_type)) { s_start[0] = start - section->range[0] + 1; s_end[0] = end - section->range[0] + 1; s_stride[0]= 1; s_start[1] = 1; s_end[1] = 2; s_stride[1]= 1; m_start[0] = 1; m_end[0] = end - start + 1; m_stride[0]= 1; m_start[1] = 1; m_end[1] = 2; m_stride[1]= 1; m_dim[0] = m_end[0]; m_dim[1] = 4; if (cgio_read_data_type(cg->cgio, section->parelem->id, s_start, s_end, s_stride, CG_SIZE_DATATYPE, 2, m_dim, m_start, m_end, m_stride, parent_data)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } m_start[1] = 3; m_end[1] = 4; if (cgio_read_data_type(cg->cgio, section->parface->id, s_start, s_end, s_stride, CG_SIZE_DATATYPE, 2, m_dim, m_start, m_end, m_stride, parent_data)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } /* read into memory and copy */ else { if (read_parent_data(section)) return CG_ERROR; n = 0; data = (cgsize_t *)section->parelem->data; for (j = 0; j < 2; j++) { nn = j * size + offset; for (i = start; i <= end; i++) parent_data[n++] = data[nn++]; } data = (cgsize_t *)section->parface->data; for (j = 0; j < 2; j++) { nn = j * size + offset; for (i = start; i <= end; i++) parent_data[n++] = data[nn++]; } } } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Read subset of fixed size element data to a typed array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and * LongInteger. * \param[out] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \return \ier * */ int cg_elements_general_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* elements) { cgns_section* section; cgsize_t size; cgsize_t s_start[1], s_end[1], s_stride[1]; cgsize_t m_start[1], m_end[1], m_stride[1], m_dim[1]; CGNS_ENUMT(DataType_t) s_type; int ier = CG_OK; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; if (!IS_FIXED_SIZE(section->el_type)) { cgi_error("Element must be a fixed size"); return CG_ERROR; } /* If elementDataType provided is not correct fallback to default CG_SIZE_DATATYPE */ if (m_type != CGNS_ENUMV(Integer) && m_type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid datatype requested for Elements array in section %s: %d", section->name, m_type); return CG_ERROR; } /* check the requested element range against the stored element range, * and the validity of the requested range */ if (start > end || start < section->range[0] || end > section->range[1]) { cgi_error("Error in requested element data range."); return CG_ERROR; } s_type = cgi_datatype(section->connect->data_type); size = cgi_element_data_size(section->el_type, end - start + 1, NULL, NULL); if (size < 0) return CG_ERROR; s_start[0] = cgi_element_data_size(section->el_type, start - section->range[0], NULL, NULL) + 1; s_end[0] = cgi_element_data_size(section->el_type, end - section->range[0] + 1, NULL, NULL); s_stride[0] = 1; m_start[0] = 1; m_end[0] = size; m_stride[0] = 1; m_dim[0] = size; if (m_type == s_type) { /* quick transfer of data if same data types */ if (section->connect->dim_vals[0] == size) { if (cgio_read_all_data_type(cg->cgio, section->connect->id, cgi_adf_datatype(m_type), elements)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->connect->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 1, m_dim, m_start, m_end, m_stride, elements)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } else if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { void* conv_data = NULL; conv_data = malloc(((size_t)size) * size_of(cgi_adf_datatype(s_type))); if (conv_data == NULL) { cgi_error("Error allocating conv_data"); return CG_ERROR; } if (section->connect->dim_vals[0] == size) { if (cgio_read_all_data_type(cg->cgio, section->connect->id, section->connect->data_type, conv_data)) { free(conv_data); cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->connect->id, s_start, s_end, s_stride, section->connect->data_type, 1, m_dim, m_start, m_end, m_stride, conv_data)) { free(conv_data); cg_io_error("cgio_read_data_type"); return CG_ERROR; } } ier = cgi_convert_data(size, s_type, conv_data, m_type, elements); free(conv_data); if (ier) return CG_ERROR; } else { /* in-situ conversion */ if (section->connect->dim_vals[0] == size) { if (cgio_read_all_data_type(cg->cgio, section->connect->id, cgi_adf_datatype(m_type), elements)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->connect->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 1, m_dim, m_start, m_end, m_stride, elements)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Read parent info for an element section * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and * LongInteger. * \param[out] ParentElement For boundary or interface elements, this array contains information on the * cell(s) sharing the element. * \return \ier * */ int cg_parent_elements_general_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* ParentElement) { cgns_section* section; cgsize_t s_start[2], s_end[2], s_stride[2]; cgsize_t m_start[2], m_end[2], m_stride[2], m_dim[2]; CGNS_ENUMT(DataType_t) s_type; int ier = CG_OK; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; if (m_type != CGNS_ENUMV(Integer) && m_type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid datatype requested for ParentElements array in section %s: %d", section->name, m_type); return CG_ERROR; } /* check the requested element range against the stored element range, * and the validity of the requested range */ if (start > end || start < section->range[0] || end > section->range[1]) { cgi_error("Error in requested element data range."); return CG_ERROR; } if (ParentElement == NULL || section->parelem == NULL) { cgi_error("Error reading ParentElementsPosition."); return CG_ERROR; } s_type = cgi_datatype(section->parelem->data_type); s_start[0] = start - section->range[0] + 1; s_end[0] = end - section->range[0] + 1; s_stride[0] = 1; s_start[1] = 1; s_end[1] = 2; s_stride[1] = 1; m_start[0] = 1; m_end[0] = end - start + 1; m_stride[0] = 1; m_start[1] = 1; m_end[1] = 2; m_stride[1] = 1; m_dim[0] = m_end[0]; m_dim[1] = 2; if (m_type == s_type) { /* quick transfer of data if same data types */ if (section->connect->dim_vals[0] == m_end[0] && section->connect->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parelem->id, cgi_adf_datatype(m_type), ParentElement)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->parelem->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 2, m_dim, m_start, m_end, m_stride, ParentElement)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } else if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { void* conv_data = NULL; conv_data = malloc(((size_t)(m_dim[0] * 2)) * size_of(cgi_adf_datatype(s_type))); if (conv_data == NULL) { cgi_error("Error allocating conv_data"); return CG_ERROR; } if (section->parelem->dim_vals[0] == m_dim[0] && section->parelem->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parelem->id, section->connect->data_type, conv_data)) { free(conv_data); cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->parelem->id, s_start, s_end, s_stride, section->connect->data_type, 2, m_dim, m_start, m_end, m_stride, conv_data)) { free(conv_data); cg_io_error("cgio_read_data_type"); return CG_ERROR; } } ier = cgi_convert_data(2*m_dim[0], s_type, conv_data, m_type, ParentElement); free(conv_data); if (ier) return CG_ERROR; } else { /* in-situ conversion */ if (section->parelem->dim_vals[0] == m_dim[0] && section->parelem->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parelem->id, cgi_adf_datatype(m_type), ParentElement)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->parelem->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 2, m_dim, m_start, m_end, m_stride, ParentElement)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Read parent position info for an element section * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and * LongInteger. * \param[out] ParentFace For boundary or interface elements, this array contains information on the * cell face(s) sharing the element. * \return \ier * */ int cg_parent_elements_position_general_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* ParentFace) { cgns_section* section; cgsize_t s_start[2], s_end[2], s_stride[2]; cgsize_t m_start[2], m_end[2], m_stride[2], m_dim[2]; CGNS_ENUMT(DataType_t) s_type; int ier = CG_OK; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; if (m_type != CGNS_ENUMV(Integer) && m_type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid datatype requested for ParentElementsPosition array in section %s: %d", section->name, m_type); return CG_ERROR; } /* check the requested element range against the stored element range, * and the validity of the requested range */ if (start > end || start < section->range[0] || end > section->range[1]) { cgi_error("Error in requested element data range."); return CG_ERROR; } if (ParentFace == NULL || section->parface == NULL) { cgi_error("Error reading ParentElementsPosition."); return CG_ERROR; } s_type = cgi_datatype(section->parface->data_type); s_start[0] = start - section->range[0] + 1; s_end[0] = end - section->range[0] + 1; s_stride[0] = 1; s_start[1] = 1; s_end[1] = 2; s_stride[1] = 1; m_start[0] = 1; m_end[0] = end - start + 1; m_stride[0] = 1; m_start[1] = 1; m_end[1] = 2; m_stride[1] = 1; m_dim[0] = m_end[0]; m_dim[1] = 2; if (m_type == s_type) { /* quick transfer of data if same data types */ if (section->connect->dim_vals[0] == m_end[0] && section->connect->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parface->id, cgi_adf_datatype(m_type), ParentFace)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->parface->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 2, m_dim, m_start, m_end, m_stride, ParentFace)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } else if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { void* conv_data = NULL; conv_data = malloc(((size_t)(m_dim[0] * 2)) * size_of(cgi_adf_datatype(s_type))); if (conv_data == NULL) { cgi_error("Error allocating conv_data"); return CG_ERROR; } if (section->connect->dim_vals[0] == m_dim[0] && section->connect->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parface->id, section->connect->data_type, conv_data)) { free(conv_data); cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->parface->id, s_start, s_end, s_stride, section->connect->data_type, 2, m_dim, m_start, m_end, m_stride, conv_data)) { free(conv_data); cg_io_error("cgio_read_data_type"); return CG_ERROR; } } ier = cgi_convert_data(m_dim[0]*2, s_type, conv_data, m_type, ParentFace); free(conv_data); if (ier) return CG_ERROR; } else { /* in-situ conversion */ if (section->connect->dim_vals[0] == m_dim[0] && section->connect->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parface->id, cgi_adf_datatype(m_type), ParentFace)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->parface->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 2, m_dim, m_start, m_end, m_stride, ParentFace)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Read subset of element data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[out] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \param[out] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and * MIXED according to Elements_t Structure Definition. * \param[out] parent_data For boundary or interface elements, this array contains information on the * cell(s) and cell face(s) sharing the element. If you do not need to read the * ParentData when reading the ElementData, you may set the value to NULL. * \return \ier * */ int cg_poly_elements_partial_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *elements, cgsize_t *connect_offset, cgsize_t *parent_data) { cgns_section *section; cgsize_t offset, size, n; cgsize_t i, j, nn, *data; cgsize_t s_start[2], s_end[2], s_stride[2]; cgsize_t m_start[2], m_end[2], m_stride[2], m_dim[2]; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; /* check the requested element range against the stored element range, * and the validity of the requested range */ if(start > end || start < section->range[0] || end > section->range[1]) { cgi_error("Error in requested element data range."); return CG_ERROR; } /* need to get the connectivity offset to compute locations */ if (read_offset_data(section)) return CG_ERROR; cgsize_t *tmp_connect_offset = (cgsize_t *) section->connect_offset->data; offset = tmp_connect_offset[start - section->range[0]]; size = tmp_connect_offset[end-section->range[0]+1] - offset; if (section->connect->data == 0 && 0 == strcmp(CG_SIZE_DATATYPE, section->connect->data_type)) { s_start[0] = offset+1; s_end[0] = tmp_connect_offset[end-section->range[0]+1]; s_stride[0] = 1; m_start[0] = 1; m_end[0] = size; m_stride[0] = 1; m_dim[0] = size; if (cgio_read_data_type(cg->cgio, section->connect->id, s_start, s_end, s_stride, CG_SIZE_DATATYPE, 1, m_dim, m_start, m_end, m_stride, elements)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } else { /* need to get the elements */ if (read_element_data(section)) return CG_ERROR; data = (cgsize_t *)section->connect->data; memcpy(elements, &data[offset], (size_t)(size*sizeof(cgsize_t))); } if (connect_offset == 0) { cgi_error("missing connectivity offset for reading"); return CG_ERROR; } memcpy(connect_offset, &tmp_connect_offset[start-section->range[0]],(size_t)((end-start+2)*sizeof(cgsize_t))); offset = connect_offset[0]; for (n=0; n< (end-start+2); n++) { connect_offset[n] -= offset; } if (parent_data && section->parelem && (section->parface || 0 == strcmp(section->parelem->name, "ParentData"))) { offset = start - section->range[0]; size = section->range[1] - section->range[0] + 1; /* read from ParentData */ if (0 == strcmp(section->parelem->name, "ParentData")) { if (0 == strcmp(CG_SIZE_DATATYPE, section->parelem->data_type)) { s_start[0] = start - section->range[0] + 1; s_end[0] = end - section->range[0] + 1; s_stride[0]= 1; s_start[1] = 1; s_end[1] = 4; s_stride[1]= 1; m_start[0] = 1; m_end[0] = end - start + 1; m_stride[0]= 1; m_start[1] = 1; m_end[1] = 4; m_stride[1]= 1; m_dim[0] = m_end[0]; m_dim[1] = 4; if (cgio_read_data_type(cg->cgio, section->parelem->id, s_start, s_end, s_stride, CG_SIZE_DATATYPE, 2, m_dim, m_start, m_end, m_stride, parent_data)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } else { nn = section->parelem->dim_vals[0] * 4; data = (cgsize_t *)malloc((size_t)(nn * sizeof(cgsize_t))); if (data == NULL) { cgi_error("malloc failed for temporary ParentData array"); return CG_ERROR; } if (cgi_read_int_data(section->parelem->id, section->parelem->data_type, nn, data)) { free(data); return CG_ERROR; } for (n = 0, j = 0; j < 4; j++) { nn = j * size + offset; for (i = start; i <= end; i++) parent_data[n++] = data[nn++]; } free(data); } } /* read from ParentElements and ParentElementsPosition */ else if (0 == strcmp(CG_SIZE_DATATYPE, section->parelem->data_type) && 0 == strcmp(CG_SIZE_DATATYPE, section->parface->data_type)) { s_start[0] = start - section->range[0] + 1; s_end[0] = end - section->range[0] + 1; s_stride[0]= 1; s_start[1] = 1; s_end[1] = 2; s_stride[1]= 1; m_start[0] = 1; m_end[0] = end - start + 1; m_stride[0]= 1; m_start[1] = 1; m_end[1] = 2; m_stride[1]= 1; m_dim[0] = m_end[0]; m_dim[1] = 4; if (cgio_read_data_type(cg->cgio, section->parelem->id, s_start, s_end, s_stride, CG_SIZE_DATATYPE, 2, m_dim, m_start, m_end, m_stride, parent_data)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } m_start[1] = 3; m_end[1] = 4; if (cgio_read_data_type(cg->cgio, section->parface->id, s_start, s_end, s_stride, CG_SIZE_DATATYPE, 2, m_dim, m_start, m_end, m_stride, parent_data)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } /* read into memory and copy */ else { if (read_parent_data(section)) return CG_ERROR; n = 0; data = (cgsize_t *)section->parelem->data; for (j = 0; j < 2; j++) { nn = j * size + offset; for (i = start; i <= end; i++) parent_data[n++] = data[nn++]; } data = (cgsize_t *)section->parface->data; for (j = 0; j < 2; j++) { nn = j * size + offset; for (i = start; i <= end; i++) parent_data[n++] = data[nn++]; } } } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Read subset of element data to typed arrays * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and * LongInteger. * \param[out] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \param[out] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and * MIXED according to Elements_t Structure Definition. * \return \ier * */ int cg_poly_elements_general_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* elements, void* connect_offset) { cgns_section* section; cgsize_t size = 0, n = 0; cgsize_t s_start[1], s_end[1], s_stride[1]; cgsize_t m_start[1], m_end[2], m_stride[1], m_dim[1]; CGNS_ENUMT(DataType_t) s_type; int ier = CG_OK; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; /* If elementDataType provided is not correct fallback to default CG_SIZE_DATATYPE */ if (m_type != CGNS_ENUMV(Integer) && m_type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid datatype requested for Elements array in section %s: %d", section->name, m_type); return CG_ERROR; } /* check the requested element range against the stored element range, * and the validity of the requested range */ if (start > end || start < section->range[0] || end > section->range[1]) { cgi_error("Error in requested element data range."); return CG_ERROR; } if (connect_offset == 0) { cgi_error("missing connectivity offset for reading"); return CG_ERROR; } /* need to get the connectivity offset to compute locations */ if (cgi_read_offset_data_type(section->connect_offset->id, section->connect_offset->data_type, start - section->range[0] + 1, end - section->range[0] + 2, cgi_adf_datatype(m_type), connect_offset)) { return CG_ERROR; } if (m_type == CGNS_ENUMV(Integer)) { int* tmp_connect_offset = (int*)connect_offset; int offset = tmp_connect_offset[0]; size = tmp_connect_offset[end - start + 1] - offset; if (size < 1) return CG_ERROR; s_start[0] = (cgsize_t)(offset + 1); s_end[0] = (cgsize_t)(tmp_connect_offset[end - start + 1]); m_end[0] = (cgsize_t)size; m_dim[0] = (cgsize_t)size; for (n = 0; n < (end - start + 2); n++) { tmp_connect_offset[n] -= offset; } } else if (m_type == CGNS_ENUMV(LongInteger)) { cglong_t* tmp_connect_offset = (cglong_t*)connect_offset; cglong_t offset = tmp_connect_offset[0]; cglong_t size_long = tmp_connect_offset[end - start + 1] - offset; if (size_long < 1) return CG_ERROR; size = (cgsize_t)size_long; s_start[0] = (cgsize_t)(offset + 1); s_end[0] = (cgsize_t)(tmp_connect_offset[end - start + 1]); m_end[0] = size; m_dim[0] = size; for (n = 0; n < (end - start + 2); n++) { tmp_connect_offset[n] -= offset; } } s_stride[0] = 1; m_start[0] = 1; m_stride[0] = 1; s_type = cgi_datatype(section->connect->data_type); if (m_type == s_type) { /* quick transfer of data if same data types */ if (section->connect->dim_vals[0] == size) { if (cgio_read_all_data_type(cg->cgio, section->connect->id, cgi_adf_datatype(m_type), elements)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } else { if (cgio_read_data_type(cg->cgio, section->connect->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 1, m_dim, m_start, m_end, m_stride, elements)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } } else if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { void* conv_data = NULL; conv_data = malloc(((size_t)size) * size_of(cgi_adf_datatype(s_type))); if (conv_data == NULL) { cgi_error("Error allocating conv_data"); return CG_ERROR; } if (cgio_read_data_type(cg->cgio, section->connect->id, s_start, s_end, s_stride, section->connect->data_type, 1, m_dim, m_start, m_end, m_stride, conv_data)) { free(conv_data); cg_io_error("cgio_read_data_type"); return CG_ERROR; } ier = cgi_convert_data(size, s_type, conv_data, m_type, elements); free(conv_data); if (ier) return CG_ERROR; } else { /* in-situ conversion */ if (cgio_read_data_type(cg->cgio, section->connect->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 1, m_dim, m_start, m_end, m_stride, elements)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Write element data for a fixed-size element section * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \return \ier * */ int cg_elements_partial_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *elements) { if (cg_elements_general_write(fn, B, Z, S, start, end, cgi_datatype(CG_SIZE_DATATYPE), elements)) { return CG_ERROR; } return CG_OK; } /*---------------------* * Helper write MACROs *---------------------*/ #define WRITE_1D_INT_DATA(ARRAY, DATA, STATUS) \ STATUS = CG_OK; \ if (0 == strcmp(ARRAY->data_type, CG_SIZE_DATATYPE)) { \ if (cgio_write_data(cg->cgio, ARRAY->id, \ &s_start, &s_end, &s_stride, 1, &m_dim, \ &m_start, &m_end, &m_stride, DATA)) { \ cg_io_error("cgio_write_data"); \ STATUS = CG_ERROR; \ } \ } \ else if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2){ \ void *conv_data=NULL; \ conv_data = malloc(((size_t)(m_end-m_start+1)) \ *size_of(ARRAY->data_type)); \ if (conv_data == NULL) { \ cgi_error("Error allocating conv_data"); \ STATUS = CG_ERROR; \ } \ if ((STATUS == CG_OK) && cgi_convert_data((m_end-m_start+1), \ cgi_datatype(CG_SIZE_DATATYPE), DATA, \ cgi_datatype(ARRAY->data_type), conv_data)) { \ STATUS = CG_ERROR; \ } \ if ((STATUS == CG_OK) && cgio_write_data(cg->cgio, ARRAY->id, \ &s_start, &s_end, &s_stride, 1, &m_dim, \ &m_start, &m_end, &m_stride, conv_data)) { \ cg_io_error("cgio_write_data"); \ STATUS = CG_ERROR; \ } \ if (conv_data) free(conv_data); \ } \ else { \ if (cgio_write_data_type(cg->cgio, ARRAY->id, \ &s_start, &s_end, &s_stride, \ CG_SIZE_DATATYPE, 1, &m_dim, \ &m_start, &m_end, &m_stride, DATA)) { \ cg_io_error("cgio_write_all_data_type"); \ STATUS = CG_ERROR; \ } \ } #define WRITE_2D_INT_DATA(ARRAY, DATA) \ if (0 == strcmp(ARRAY->data_type, CG_SIZE_DATATYPE)) { \ if (cgio_write_data(cg->cgio, ARRAY->id, \ s_start, s_end, s_stride, 2, m_dim, \ m_start, m_end, m_stride, DATA)) { \ cg_io_error("cgio_write_data"); \ return CG_ERROR; \ } \ } \ else if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2){ \ void *conv_data; \ conv_data = malloc((size_t)((m_end[0]-m_start[0]+1)*(m_end[1]-m_start[1]+1)) \ *size_of(ARRAY->data_type)); \ if (conv_data == NULL) { \ cgi_error("Error allocating conv_data"); \ return CG_ERROR; \ } \ if (cgi_convert_data((m_end[0]-m_start[0]+1)*(m_end[1]-m_start[1]+1), \ cgi_datatype(CG_SIZE_DATATYPE), DATA, \ cgi_datatype(ARRAY->data_type), conv_data)) { \ free(conv_data); \ return CG_ERROR; \ } \ if (cgio_write_data(cg->cgio, ARRAY->id, \ s_start, s_end, s_stride, 2, m_dim, \ m_start, m_end, m_stride, conv_data)) { \ free(conv_data); \ cg_io_error("cgio_write_data"); \ return CG_ERROR; \ } \ free(conv_data); \ } \ else { \ if (cgio_write_data_type(cg->cgio, ARRAY->id, \ s_start, s_end, s_stride, CG_SIZE_DATATYPE, 2, m_dim, \ m_start, m_end, m_stride, DATA)) { \ cg_io_error("cgio_write_all_data_type"); \ return CG_ERROR; \ } \ } #define WRITE_ALL_INT_DATA(S_DIM, ARRAY, DATA) \ if (ARRAY->data_dim != S_DIM) return CG_ERROR; \ if (0 == strcmp(ARRAY->data_type, CG_SIZE_DATATYPE)) { \ if (cgio_write_all_data(cg->cgio, ARRAY->id, DATA)) { \ cg_io_error("cgio_write_data"); \ return CG_ERROR; \ } \ } \ else if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2){ \ void *conv_data; \ cgsize_t conv_size=1; \ for (int ii=0; iidim_vals[ii]; } \ conv_data = malloc(((size_t)conv_size) \ *size_of(ARRAY->data_type)); \ if (conv_data == NULL) { \ cgi_error("Error allocating conv_data"); \ return CG_ERROR; \ } \ if (cgi_convert_data(conv_size, \ cgi_datatype(CG_SIZE_DATATYPE), DATA, \ cgi_datatype(ARRAY->data_type), conv_data)) { \ free(conv_data); \ return CG_ERROR; \ } \ if (cgio_write_all_data(cg->cgio, ARRAY->id, conv_data)) { \ free(conv_data); \ cg_io_error("cgio_write_data"); \ return CG_ERROR; \ } \ free(conv_data); \ } \ else { \ if (cgio_write_all_data_type(cg->cgio, ARRAY->id, \ CG_SIZE_DATATYPE, DATA)) { \ cg_io_error("cgio_write_all_data_type"); \ return CG_ERROR; \ } \ } #define WRITE_PART_1D_DATA(ID, SIZE, M_TYPE, S_TYPE, DATA, STATUS) \ STATUS = CG_OK; \ if (M_TYPE == S_TYPE) { \ if (cgio_write_data(cg->cgio, ID, \ &s_start, &s_end, &s_stride, 1, &m_dim, \ &m_start, &m_end, &m_stride, DATA)) { \ cg_io_error("cgio_write_data"); \ ier = CG_ERROR; \ } \ } else if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { \ void *conv_data = NULL; \ conv_data = malloc(((size_t)SIZE)*size_of(cgi_adf_datatype(S_TYPE))); \ if (conv_data==NULL){ \ cgi_error("Error allocating conv_data"); \ STATUS = CG_ERROR; \ } \ if ((STATUS == CG_OK) && cgi_convert_data(SIZE, M_TYPE, DATA, S_TYPE, conv_data)) { \ STATUS = CG_ERROR; \ } \ if ((STATUS == CG_OK) && cgio_write_data(cg->cgio, ID, \ &s_start, &s_end, &s_stride, 1, &m_dim, \ &m_start, &m_end, &m_stride, conv_data)) { \ if (STATUS == CG_OK) cg_io_error("cgio_write_data"); \ STATUS = CG_ERROR; \ } \ if (conv_data) free(conv_data); \ } else { \ if (cgio_write_data_type(cg->cgio, ID, \ &s_start, &s_end, &s_stride, \ cgi_adf_datatype(M_TYPE), 1, &m_dim, \ &m_start, &m_end, &m_stride, DATA)) { \ cg_io_error("cgio_write_data"); \ STATUS = CG_ERROR; \ } \ } /** * \ingroup ElementConnectivity * * \brief Write element data for a fixed-size element section * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and * LongInteger. * \param[in] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \return \ier * */ int cg_elements_general_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const CGNS_ENUMT(DataType_t) m_type, const void *elements) { cgns_section *section; CGNS_ENUMT(ElementType_t) type; int i, elemsize; cgsize_t oldsize; cgsize_t num, size, offset; cgsize_t n, j, newsize, ElementDataSize; cgsize_t *oldelems, *newelems; CGNS_ENUMT(DataType_t) s_type; cgns_array tmp_range; /* temporary interface for section range */ int ier = CG_OK; /* get file and check mode */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0 || section->connect == 0) return CG_ERROR; /* If elementDataType provided is not correct fallback to default CG_SIZE_DATATYPE */ if (m_type != CGNS_ENUMV(Integer) && m_type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid datatype for Elements array in section %s: %d", section->name, m_type); return CG_ERROR; } s_type = cgi_datatype(section->connect->data_type); num = end - start + 1; type = section->el_type; if (!IS_FIXED_SIZE(type)) { cgi_error("Element must be a fixed size"); return CG_ERROR; } /* check input range */ if (num <= 0) { cgi_error("Invalid element range for section '%s' elements", section->name); return CG_ERROR; } if (cg->filetype == CG_FILE_ADF2 && (type < CGNS_ENUMV(NODE) || type > CGNS_ENUMV(MIXED))) { cgi_error("Element type %s not supported in ADF2.", cg_ElementTypeName(type)); return CG_ERROR; } /* get fill-in element type */ if (cg_npe(type, &elemsize)) return CG_ERROR; if (elemsize <= 0) return CG_ERROR; offset = start < section->range[0] ? section->range[0] - start : 0; oldsize = section->range[1] - section->range[0] + 1; ElementDataSize = elemsize *(end - start + 1); if (ElementDataSize < 0) return CG_ERROR; /* can we just use the user's data ? */ if (start >= section->range[0] && end <= section->range[1] && section->connect->data == 0) { cgsize_t s_start, s_end, s_stride; cgsize_t m_start, m_end, m_stride, m_dim; s_start = cgi_element_data_size(type, start - section->range[0], 0, 0) + 1; s_end = cgi_element_data_size(type, end - section->range[0] + 1, 0, 0); s_stride = 1; m_start = 1; m_end = ElementDataSize; m_dim = ElementDataSize; m_stride = 1; /* take care of data conversion */ WRITE_PART_1D_DATA(section->connect->id, ElementDataSize, m_type, s_type, elements, ier) if (ier) { return CG_ERROR; } } else { /* got to do it in memory */ if (read_element_data(section)) return CG_ERROR; oldelems = (cgsize_t *)section->connect->data; oldsize = section->connect->dim_vals[0]; newsize = ElementDataSize; if (end < section->range[0]) { newsize += oldsize; num = section->range[0] - end - 1; if (num > 0) newsize += (elemsize * num); } else if (start > section->range[1]) { newsize += oldsize; num = start - section->range[1] - 1; if (num > 0) newsize += (elemsize * num); } else { /* overlap */ if (start >= section->range[0]) { num = start - section->range[0]; size = cgi_element_data_size(type, num, oldelems, NULL); if (size < 0) return CG_ERROR; newsize += size; } if (end <= section->range[1]) { num = end - section->range[0] + 1; offset = cgi_element_data_size(type, num, oldelems, NULL); if (offset < 0) return CG_ERROR; size = oldsize - offset; newsize += size; } } /* create new element connectivity array */ if (newsize > CG_SIZE_MAX / sizeof(cgsize_t)) { cgi_error("Error in allocation size for new connectivity data"); return CG_ERROR; } newelems = (cgsize_t *) malloc ((size_t)(newsize * sizeof(cgsize_t))); if (NULL == newelems) { cgi_error("Error allocating new connectivity data"); return CG_ERROR; } n = 0; if (start <= section->range[0]) { memcpy(newelems, elements, (size_t)(ElementDataSize*sizeof(cgsize_t))); n += ElementDataSize; if (end < section->range[0]) { num = section->range[0] - end - 1; while (num-- > 0) { for (i = 0; i < elemsize; i++) newelems[n++] = 0; } memcpy(&newelems[n], oldelems, (size_t)(oldsize*sizeof(cgsize_t))); n += oldsize; } else if (end < section->range[1]) { num = end - section->range[0] + 1; offset = cgi_element_data_size(type, num, oldelems, NULL); if (offset < 0) return CG_ERROR; size = oldsize - offset; memcpy(&newelems[n], &oldelems[offset], (size_t)(size*sizeof(cgsize_t))); n += size; } } else if (start > section->range[1]) { memcpy(newelems, oldelems, (size_t)(oldsize*sizeof(cgsize_t))); n += oldsize; num = start - section->range[1] - 1; while (num-- > 0) { for (i = 0; i < elemsize; i++) newelems[n++] = 0; } memcpy(&newelems[n], elements, (size_t)(ElementDataSize*sizeof(cgsize_t))); n += ElementDataSize; } else { num = start - section->range[0]; size = cgi_element_data_size(type, num, oldelems, NULL); memcpy(newelems, oldelems, (size_t)(size*sizeof(cgsize_t))); n += size; memcpy(&newelems[n], elements, (size_t)(ElementDataSize*sizeof(cgsize_t))); n += ElementDataSize; if (end < section->range[1]) { num = end - section->range[0] + 1; offset = cgi_element_data_size(type, num, oldelems, NULL); if (offset < 0) { free(newelems); return CG_ERROR; } size = oldsize - offset; memcpy(&newelems[n], &oldelems[offset], (size_t)(size*sizeof(cgsize_t))); n += size; } } if (n != newsize) { free(newelems); cgi_error("my counting is off !!!\n"); return CG_ERROR; } /* save these before updating for parent data */ offset = start < section->range[0] ? section->range[0] - start : 0; oldsize = section->range[1] - section->range[0] + 1; free(section->connect->data); section->connect->dim_vals[0] = newsize; section->connect->data = newelems; /* update ranges */ if (start < section->range[0]) section->range[0] = start; if (end > section->range[1]) section->range[1] = end; /* update ElementRange */ cgns_array *sec_range = &tmp_range; sec_range->data_dim = 1; sec_range->dim_vals[0] = 2; if (cgio_get_node_id(cg->cgio, section->id, "ElementRange", &(sec_range->id))) { cg_io_error("cgio_get_node_id"); return CG_ERROR; } if (cgio_get_data_type(cg->cgio, sec_range->id, sec_range->data_type)){ cg_io_error("cgio_get_data_type"); return CG_ERROR; } WRITE_ALL_INT_DATA(1, sec_range, section->range); /* update ElementConnectivity */ if (cgio_set_dimensions(cg->cgio, section->connect->id, section->connect->data_type, 1, section->connect->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } WRITE_ALL_INT_DATA(1, section->connect, newelems); } /* update the parent data array if it exists */ newsize = section->range[1] - section->range[0] + 1; if (section->parelem && 0 == strcmp(section->parelem->name, "ParentData")) { cgi_error("Deprecated ParentData node, impossible to do partial writing"); return CG_ERROR; } if (section->parelem && section->parface && newsize != section->parelem->dim_vals[0]) { int cnt = section->parelem->dim_vals[1]; if (read_parent_data(section)) return CG_ERROR; if((cnt*newsize) > CG_SIZE_MAX/sizeof(cgsize_t) ) { cgi_error("Error in allocation size for new ParentElements data"); return CG_ERROR; } newelems = (cgsize_t *)malloc((size_t)(cnt * newsize * sizeof(cgsize_t))); if (NULL == newelems) { cgi_error("Error allocating new ParentElements data"); return CG_ERROR; } offset = start - section->range[0]; for (n = 0; n < cnt*newsize; n++) newelems[n] = 0; oldelems = (cgsize_t *)section->parelem->data; for (num = 0, i = 0; i < cnt; i++) { j = i * newsize + offset; for (n = 0; n < oldsize; n++) newelems[j++] = oldelems[num++]; } for (i = 0; i < cnt; i++) { j = i * newsize + offset; for (n = start; n <= end; n++) newelems[j++] = 0; } free(section->parelem->data); section->parelem->data = newelems; section->parelem->dim_vals[0] = newsize; if (cgio_set_dimensions(cg->cgio, section->parelem->id, section->parelem->data_type, 2, section->parelem->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } WRITE_ALL_INT_DATA(2, section->parelem, newelems) for (n = 0; n < 2*newsize; n++) newelems[n] = 0; oldelems = (cgsize_t *)section->parface->data; for (num = 0, i = 0; i < 2; i++) { j = i * newsize + offset; for (n = 0; n < oldsize; n++) newelems[j++] = oldelems[num++]; } for (i = 0; i < 2; i++) { j = i * newsize + offset; for (n = start; n <= end; n++) newelems[j++] = 0; } free(section->parface->data); section->parface->data = newelems; section->parface->dim_vals[0] = newsize; section->parelem->data = NULL; if (cgio_set_dimensions(cg->cgio, section->parface->id, section->parface->data_type, 2, section->parface->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } WRITE_ALL_INT_DATA(2, section->parface, newelems) free_parent_data(section); } return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Write element data for an element section * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \param[in] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and * MIXED according to Elements_t Structure Definition. * \return \ier * */ int cg_poly_elements_partial_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *elements, const cgsize_t *connect_offset) { if (cg_poly_elements_general_write(fn, B, Z, S, start, end, cgi_datatype(CG_SIZE_DATATYPE), elements, connect_offset)) { return CG_ERROR; } return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Write element data for an element section * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] m_type Data type of an array in memory. Admissible data types are \e Integer and * \e LongInteger. * \param[in] elements Element connectivity data. The element connectivity order is given in * Element Numbering Conventions. * \param[in] input_connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and * MIXED according to Elements_t Structure Definition. * \return \ier * */ int cg_poly_elements_general_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const CGNS_ENUMT(DataType_t) m_type, const void *elements, const void *input_connect_offset) { cgns_section *section; CGNS_ENUMT(ElementType_t) type; int i, elemsize=2; cgsize_t s_range_size; cgsize_t num, size, offset; cgsize_t n, j, newsize, ElementDataSize; cgsize_t *oldelems, *newelems; cgsize_t * alloc_offset=0; /* handle offset datatype conversion */ const cgsize_t *connect_offset; /* read only to a fake input mapping to alloc_offset or actual input */ cgns_array tmp_range; cgsize_t s_conn_size, m_conn_size; cgsize_t *section_offset; int ier; int do_it_in_memory = 1; CGNS_ENUMT(DataType_t) s_type; /* get file and check mode */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0 || section->connect == 0) return CG_ERROR; /* elementDataType provided is not correct */ if (m_type != CGNS_ENUMV(Integer) && m_type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid datatype for Elements array in section %s: %d", section->name, m_type); return CG_ERROR; } s_type = cgi_datatype(section->connect->data_type); num = end - start + 1; type = section->el_type; if (IS_FIXED_SIZE(type)) { cgi_error("element data type should not be of fixed size"); return CG_ERROR; } /* check input range */ if (num <= 0) { cgi_error("Invalid element range for section '%s' elements", section->name); return CG_ERROR; } if (cg->filetype == CG_FILE_ADF2) { if (m_type != cgi_datatype(CG_SIZE_DATATYPE)) return CG_ERROR; if (adf2_check_elems(type, num, elements)) return CG_ERROR; } /* NOT FIXED SIZE: NGON_n, NFACE_n, MIXED */ if (input_connect_offset == NULL){ cgi_error("element offsets not provided for partial write\n"); return CG_ERROR; } if (section->connect_offset == NULL){ cgi_error("missing offsets in section\n"); return CG_ERROR; } /* check data type coherency */ if (strcmp(section->connect->data_type, section->connect_offset->data_type)) { cgi_error("stored element offsets data type %s does not match elements value %s", section->connect_offset->data_type, section->connect->data_type); return CG_ERROR; } elemsize = 2; offset = start < section->range[0] ? section->range[0] - start : 0; /* current range size in file system */ s_range_size = section->range[1] - section->range[0] + 1; /* Handle type of input_connect_offset to get a cgsize_t offset array * The input connect offset is assumed to be of same type as elements */ if (m_type != cgi_datatype(CG_SIZE_DATATYPE)) { alloc_offset = (cgsize_t *) malloc((size_t)(num+1)*sizeof(cgsize_t)); if (alloc_offset == NULL){ return CG_ERROR; } cgi_convert_data(num+1, m_type, input_connect_offset, cgi_datatype(CG_SIZE_DATATYPE), alloc_offset); connect_offset = (const cgsize_t *)alloc_offset; } else { connect_offset = (const cgsize_t *)input_connect_offset; } ElementDataSize = connect_offset[end - start + 1] - connect_offset[0]; if (ElementDataSize < 0){ if (alloc_offset) free(alloc_offset); return CG_ERROR; } if (read_offset_data(section)) { if (alloc_offset) free(alloc_offset); return CG_ERROR; } section_offset = section->connect_offset->data; do_it_in_memory = 1; if (start >= section->range[0] && end <= section->range[1] && section->connect->data == 0) { /* determine connectivity size in memory to compare with file system */ m_conn_size = connect_offset[end - start + 1] - connect_offset[0]; if (section_offset) { s_conn_size = section_offset[end - section->range[0] + 1] - section_offset[start - section->range[0]]; } else { s_conn_size = -1; } /* cases when to directly use user data */ if (s_conn_size == m_conn_size){ /* connectivity is of same size */ cgsize_t s_start, s_end, s_stride; cgsize_t m_start, m_end, m_stride, m_dim; cgsize_t ii; s_start = section_offset[start - section->range[0]] + 1; s_end = section_offset[end - section->range[0] + 1]; s_stride = 1; m_start = 1; m_end = m_conn_size; m_dim = m_conn_size; m_stride = 1; WRITE_PART_1D_DATA(section->connect->id, ElementDataSize, m_type, s_type, elements, ier) if (ier) { if (alloc_offset) free(alloc_offset); return CG_ERROR; } /* update offset */ j = start-section->range[0]; for (ii=0; iiconnect_offset, section_offset); do_it_in_memory = 0; } else if ((section_offset[s_range_size]-section_offset[0]) + m_conn_size - s_conn_size <= section->connect->dim_vals[0]){ /* connectivity size can fit in the reserved file size */ cgsize_t start_trail_reading; cgsize_t s_start, s_end, s_stride; cgsize_t m_start, m_end, m_stride, m_dim; cgsize_t ii; cgsize_t m_trail_size = 0; cgsize_t *trail_elements = NULL; /* Reading trailing elements location */ start_trail_reading = end-section->range[0]+1; m_trail_size = section_offset[s_range_size] - section_offset[start_trail_reading]; if (m_trail_size > 0){ /* partial load trailing elements that will be relocated */ if (m_trail_size > CG_SIZE_MAX / sizeof(cgsize_t)) { cgi_error("Error in allocation size for trail_elements"); return CG_ERROR; } trail_elements = (cgsize_t *) malloc((size_t)m_trail_size * sizeof(cgsize_t)); if (trail_elements == NULL) { if (alloc_offset) free(alloc_offset); cgi_error("Error allocating trail_elements"); return CG_ERROR; } /* read them ... */ s_start = section_offset[start_trail_reading]+1; s_end = section_offset[s_range_size]; s_stride = 1; m_start = 1; m_end = m_trail_size; m_stride = 1; m_dim = m_trail_size; ier = CG_OK; if (0 == strcmp(CG_SIZE_DATATYPE, section->connect->data_type)) { if (cgio_read_data_type(cg->cgio, section->connect->id, &s_start, &s_end, &s_stride, CG_SIZE_DATATYPE, 1, &m_dim, &m_start, &m_end, &m_stride, trail_elements)) { cg_io_error("cgio_read_data_type"); ier = CG_ERROR; } } else if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { void *conv_data = NULL; conv_data = malloc(((size_t)m_trail_size)*size_of(section->connect->data_type)); if (conv_data == NULL) { cgi_error("Error allocating conv_data"); ier = CG_ERROR; } if ((ier == CG_OK) && cgio_read_data_type(cg->cgio, section->connect->id, &s_start, &s_end, &s_stride, section->connect->data_type, 1, &m_dim, &m_start, &m_end, &m_stride, conv_data)){ cg_io_error("cgio_read_data_type"); ier = CG_ERROR; } if ((ier == CG_OK) && cgi_convert_data(m_trail_size, cgi_datatype(section->connect->data_type), conv_data, cgi_datatype(CG_SIZE_DATATYPE), trail_elements)) { ier = CG_ERROR; } if (conv_data) free(conv_data); } else { if (cgio_read_data_type(cg->cgio, section->connect->id, &s_start, &s_end, &s_stride, CG_SIZE_DATATYPE, 1, &m_dim, &m_start, &m_end, &m_stride, trail_elements)) { ier = CG_ERROR; } } if (ier){ if (alloc_offset) free(alloc_offset); free(trail_elements); return CG_ERROR; } } /* now write new data */ s_start = section_offset[start - section->range[0]]+1; s_end = section_offset[start - section->range[0]]+m_conn_size; s_stride = 1; m_start = 1; m_end = m_conn_size; m_dim = m_conn_size; m_stride = 1; /* handle different data_type in files */ WRITE_PART_1D_DATA(section->connect->id, m_conn_size, m_type, s_type, elements, ier) if (ier){ if (alloc_offset) free(alloc_offset); if (trail_elements) free(trail_elements); return CG_ERROR; } /* append the trailing elements */ if (m_trail_size > 0){ s_start = section_offset[start - section->range[0]]+ m_conn_size + 1; s_end = section_offset[start - section->range[0]]+ m_conn_size + m_trail_size; s_stride = 1; m_start = 1; m_end = m_trail_size; m_dim = m_trail_size; m_stride = 1; /* writing, handle different data_type in files */ WRITE_1D_INT_DATA(section->connect, trail_elements, ier) free(trail_elements); if (ier) { if (alloc_offset) free(alloc_offset); return CG_ERROR; } } /* update offset */ j = start-section->range[0]; for (ii=0; iiconnect_offset, section_offset); do_it_in_memory = 0; } } if (do_it_in_memory) { cgsize_t *newoffsets; cgsize_t elemcount; cgsize_t ii; cgsize_t s_conn_size; if (section_offset) { s_conn_size = section_offset[s_range_size] - section_offset[0]; } else { s_conn_size = 0; } /* got to do it in memory */ if (read_element_data(section)){ if (alloc_offset) free(alloc_offset); return CG_ERROR; } oldelems = (cgsize_t *)section->connect->data; newsize = ElementDataSize; elemcount = end-start+1; if (end < section->range[0]) { newsize += s_conn_size; elemcount += (section->range[1]-section->range[0]+1); num = section->range[0] - end - 1; if (num > 0){ newsize += (elemsize * num); elemcount += num; } } else if (start > section->range[1]) { newsize += s_conn_size; elemcount += (section->range[1]-section->range[0]+1); num = start - section->range[1] - 1; if (num > 0){ newsize += (elemsize * num); elemcount += num; } } else { /* overlap */ if (start >= section->range[0]) { num = start - section->range[0]; size = section_offset[num] - section_offset[0]; if (size < 0) return CG_ERROR; newsize += size; elemcount += num; } if (end <= section->range[1]) { num = end - section->range[0] + 1; size = section_offset[section->range[1]-section->range[0]+1] - section_offset[num]; if (size < 0) return CG_ERROR; newsize += size; elemcount += (section->range[1] - end); } } /* create new element connectivity array and offsets*/ if (newsize > CG_SIZE_MAX / sizeof(cgsize_t)) { cgi_error("Error in allocation size for new connectivity data"); return CG_ERROR; } newelems = (cgsize_t *) malloc (((size_t)newsize) * sizeof(cgsize_t)); if (NULL == newelems) { if (alloc_offset) free(alloc_offset); cgi_error("Error allocating new connectivity data"); return CG_ERROR; } newoffsets = (cgsize_t *) malloc(((size_t)(elemcount+1)) * sizeof(cgsize_t)); if (NULL == newoffsets) { cgi_error("Error allocating new connectivity offset data"); if (alloc_offset) free(alloc_offset); free(newelems); return CG_ERROR; } newoffsets[0] = 0; n = 0; j = 0; if (start <= section->range[0]) { if (m_type == cgi_datatype(CG_SIZE_DATATYPE)){ memcpy(newelems, elements, ((size_t)ElementDataSize)*sizeof(cgsize_t)); } else { cgi_convert_data(ElementDataSize, m_type, elements, cgi_datatype(CG_SIZE_DATATYPE), newelems); } memcpy(newoffsets, connect_offset, ((size_t)(end-start+2))*sizeof(cgsize_t)); j += (end-start+1); n += ElementDataSize; if (end < section->range[0]) { num = section->range[0] - end - 1; cgsize_t val = (type == CGNS_ENUMV(MIXED) ? (cgsize_t)CGNS_ENUMV(NODE) : 0); while (num-- > 0) { newelems[n++] = val; newelems[n++] = 0; newoffsets[j+1] = newoffsets[j] + 2; j++; } memcpy(&newelems[n], oldelems, ((size_t)s_conn_size)*sizeof(cgsize_t)); n += s_conn_size; for (ii=0; ii<(section->range[1]-section->range[0]+1); ii++) { newoffsets[j+1] = (section_offset[ii+1] - section_offset[ii]) + newoffsets[j]; j++; } } else if (end < section->range[1]) { num = end - section->range[0] + 1; offset = section_offset[end - section->range[0] + 1]; if (offset < 0) { free(newelems); free(newoffsets); if (alloc_offset) free(alloc_offset); return CG_ERROR; } size = section_offset[section->range[1]-section->range[0]+1] - section_offset[num]; memcpy(&newelems[n], &oldelems[offset], ((size_t)size)*sizeof(cgsize_t)); n += size; for (ii=num; ii<(section->range[1]-section->range[0]+1); ii++) { newoffsets[j+1] = (section_offset[ii+1] - section_offset[ii]) + newoffsets[j]; j++; } } } else if (start > section->range[1]) { memcpy(newelems, oldelems, ((size_t)s_conn_size)*sizeof(cgsize_t)); memcpy(newoffsets, section_offset, ((size_t)(section->range[1]-section->range[0]+2))*sizeof(cgsize_t)); n += s_conn_size; j += section->range[1]-section->range[0]+1; num = start - section->range[1] - 1; cgsize_t val = (type == CGNS_ENUMV(MIXED) ? (cgsize_t)CGNS_ENUMV(NODE) : 0); while (num-- > 0) { newelems[n++] = val; newelems[n++] = 0; newoffsets[j+1] = newoffsets[j] + 2; j++; } if (m_type == cgi_datatype(CG_SIZE_DATATYPE)){ memcpy(&newelems[n], elements, ((size_t)ElementDataSize)*sizeof(cgsize_t)); } else { cgi_convert_data(ElementDataSize, m_type, elements, cgi_datatype(CG_SIZE_DATATYPE), &newelems[n]); } memcpy(&newelems[n], elements, ((size_t)ElementDataSize)*sizeof(cgsize_t)); n += ElementDataSize; for (ii=0; ii<(end-start+1); ii++) { newoffsets[j+1] = (connect_offset[ii+1] - connect_offset[ii]) + newoffsets[j]; j++; } } else { num = start - section->range[0]; size = section_offset[num]; memcpy(newelems, oldelems, ((size_t)size)*sizeof(cgsize_t)); memcpy(newoffsets, section_offset, (size_t)(num+1)*sizeof(cgsize_t)); n += size; j += num; if (m_type == cgi_datatype(CG_SIZE_DATATYPE)){ memcpy(&newelems[n], elements, ((size_t)ElementDataSize)*sizeof(cgsize_t)); } else { cgi_convert_data(ElementDataSize, m_type, elements, cgi_datatype(CG_SIZE_DATATYPE), &newelems[n]); } for (ii=0; ii<(end-start+1); ii++) { newoffsets[j+1] = (connect_offset[ii+1] - connect_offset[ii]) + newoffsets[j]; j++; } n += ElementDataSize; if (end < section->range[1]) { num = end - section->range[0] + 1; offset = section_offset[num]; if (offset < 0) { free(newelems); free(newoffsets); if (alloc_offset) free(alloc_offset); return CG_ERROR; } size = s_conn_size - offset; memcpy(&newelems[n], &oldelems[offset], ((size_t)size)*sizeof(cgsize_t)); n += size; for (ii=num; ii<(section->range[1]-section->range[0]+1); ii++) { newoffsets[j+1] = (section_offset[ii+1] - section_offset[ii]) + newoffsets[j]; j++; } } } if (alloc_offset) free(alloc_offset); if (n != newsize) { free(newelems); free(newoffsets); cgi_error("my counting is off !!!\n"); return CG_ERROR; } free(section->connect->data); free(section->connect_offset->data); section->connect->dim_vals[0] = newsize; section->connect->data = newelems; section->connect_offset->dim_vals[0] = elemcount+1; section->connect_offset->data = newoffsets; /* update ranges */ if (start < section->range[0]) section->range[0] = start; if (end > section->range[1]) section->range[1] = end; /* update ElementRange */ cgns_array *sec_range = &tmp_range; sec_range->data_dim = 1; sec_range->dim_vals[0] = 2; sec_range->data = section->range; if (cgio_get_node_id(cg->cgio, section->id, "ElementRange", &(sec_range->id))) { cg_io_error("cgio_get_node_id"); return CG_ERROR; } if (cgio_get_data_type(cg->cgio, sec_range->id, sec_range->data_type)){ cg_io_error("cgio_get_data_type"); return CG_ERROR; } WRITE_ALL_INT_DATA(1, sec_range, section->range); /* update Offsets */ if (cgio_set_dimensions(cg->cgio, section->connect_offset->id, section->connect_offset->data_type, 1, section->connect_offset->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } /* take care of data conversion */ WRITE_ALL_INT_DATA(1, section->connect_offset, newoffsets); /* update ElementConnectivity */ if (cgio_set_dimensions(cg->cgio, section->connect->id, section->connect->data_type, 1, section->connect->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } /* take care of data conversion */ WRITE_ALL_INT_DATA(1, section->connect, newelems); } /* update the parent element/face data array if it exists */ newsize = section->range[1] - section->range[0] + 1; if (section->parelem && 0 == strcmp(section->parelem->name, "ParentData")) { cgi_error("Deprecated ParentData node, impossible to do partial writing"); return CG_ERROR; } if (section->parelem && section->parface && newsize != section->parelem->dim_vals[0]) { int cnt = section->parelem->dim_vals[1]; if (read_parent_data(section)) return CG_ERROR; newelems = (cgsize_t *)malloc((size_t)(cnt * newsize) * sizeof(cgsize_t)); if (NULL == newelems) { cgi_error("Error allocating new ParentElements data"); return CG_ERROR; } offset = start - section->range[0]; for (n = 0; n < cnt*newsize; n++) newelems[n] = 0; oldelems = (cgsize_t *)section->parelem->data; for (num = 0, i = 0; i < cnt; i++) { j = i * newsize + offset; for (n = 0; n < s_range_size; n++) newelems[j++] = oldelems[num++]; } for (i = 0; i < cnt; i++) { j = i * newsize + offset; for (n = start; n <= end; n++) newelems[j++] = 0; } free(section->parelem->data); section->parelem->data = newelems; section->parelem->dim_vals[0] = newsize; if (cgio_set_dimensions(cg->cgio, section->parelem->id, section->parelem->data_type, 2, section->parelem->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } WRITE_ALL_INT_DATA(2, section->parelem, newelems) for (n = 0; n < 2*newsize; n++) newelems[n] = 0; oldelems = (cgsize_t *)section->parface->data; for (num = 0, i = 0; i < 2; i++) { j = i * newsize + offset; for (n = 0; n < s_range_size; n++) newelems[j++] = oldelems[num++]; } for (i = 0; i < 2; i++) { j = i * newsize + offset; for (n = start; n <= end; n++) newelems[j++] = 0; } free(section->parface->data); section->parface->data = newelems; section->parface->dim_vals[0] = newsize; section->parelem->data = NULL; if (cgio_set_dimensions(cg->cgio, section->parface->id, section->parface->data_type, 2, section->parface->dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } WRITE_ALL_INT_DATA(2, section->parface, newelems) free_parent_data(section); } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ElementConnectivity * * \brief Write parent info for an element section * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] parent_data For boundary or interface elements, this array contains information on the * cell(s) and cell face(s) sharing the element. If you do not need to read the * ParentData when reading the ElementData, you may set the value to NULL. * \return \ier * */ int cg_parent_data_write(int fn, int B, int Z, int S, const cgsize_t * parent_data) { cgns_section *section; cgsize_t num; /* get file and check mode */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; num = section->range[1]-section->range[0]+1; if (section->parelem) { if (cg->mode==CG_MODE_WRITE) { cgi_error("ParentElements is already defined under Elements_t '%s'", section->name); return CG_ERROR; } if (cgi_delete_node(section->id, section->parelem->id)) return CG_ERROR; cgi_free_array(section->parelem); memset(section->parelem, 0, sizeof(cgns_array)); } else { section->parelem = CGNS_NEW(cgns_array, 1); } if (section->connect) { strcpy(section->parelem->data_type, section->connect->data_type); } else { strcpy(section->parelem->data_type, CG_SIZE_DATATYPE); } section->parelem->data_dim =2; section->parelem->dim_vals[0]=num; if (cg->filetype == CG_FILE_ADF2) { strcpy(section->parelem->name, "ParentData"); section->parelem->dim_vals[1]=4; } else { strcpy(section->parelem->name, "ParentElements"); section->parelem->dim_vals[1]=2; } if (cgi_write_array(section->id, section->parelem)) return CG_ERROR; WRITE_ALL_INT_DATA(2, section->parelem, parent_data) if (cg->filetype == CG_FILE_ADF2) { if (section->parface) { if (cgi_delete_node(section->id, section->parface->id)) return CG_ERROR; cgi_free_array(section->parface); CGNS_FREE(section->parface); section->parface = NULL; } return CG_OK; } if (section->parface) { if (cg->mode==CG_MODE_WRITE) { cgi_error("ParentElementsPosition is already defined under Elements_t '%s'", section->name); return CG_ERROR; } if (cgi_delete_node(section->id, section->parface->id)) return CG_ERROR; cgi_free_array(section->parface); memset(section->parface, 0, sizeof(cgns_array)); } else { section->parface = CGNS_NEW(cgns_array, 1); } strcpy(section->parface->data_type, section->parelem->data_type); strcpy(section->parface->name, "ParentElementsPosition"); section->parface->data_dim =2; section->parface->dim_vals[0]=num; section->parface->dim_vals[1]=2; if (cgi_write_array(section->id, section->parface)) return CG_ERROR; WRITE_ALL_INT_DATA(2, section->parface, &parent_data[num<<1]) return CG_OK; } /** * \ingroup ElementConnectivity * * \brief Write a subset of parent info for an element section * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \CONN_S * \param[in] start Index of the first element in the section. * \param[in] end Index of the last element in the section. * \param[in] parent_data For boundary or interface elements, this array contains information on the * cell(s) and cell face(s) sharing the element. If you do not need to read the * ParentData when reading the ElementData, you may set the value to NULL. * \return \ier * */ int cg_parent_data_partial_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *parent_data) { cgns_section *section; cgsize_t size; /* get file and check mode */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; section = cgi_get_section(cg, B, Z, S); if (section == 0) return CG_ERROR; /* check input range */ if (start < section->range[0] || end > section->range[1] || start > end) { cgi_error("Invalid element range for section '%s' parent data", section->name); return CG_ERROR; } size = section->range[1] - section->range[0] + 1; /* create the parent data if it doesn't exist already */ if (section->parelem == 0) { section->parelem = CGNS_NEW(cgns_array, 1); if (section->connect) { strcpy(section->parelem->data_type, section->connect->data_type); } else { strcpy(section->parelem->data_type, CG_SIZE_DATATYPE); } section->parelem->data_dim =2; section->parelem->dim_vals[0]=size; if (cg->filetype == CG_FILE_ADF2) { strcpy(section->parelem->name, "ParentData"); section->parelem->dim_vals[1]=4; } else { strcpy(section->parelem->name, "ParentElements"); section->parelem->dim_vals[1]=2; } if (cgi_write_array(section->id, section->parelem)) return CG_ERROR; } else if (strcmp("I4", section->parelem->data_type) && strcmp("I8", section->parelem->data_type)) { cgi_error("ParentElements stored value %s is not valid", section->parelem->data_type); return CG_ERROR; } if (size != section->parelem->dim_vals[0]) { cgi_error("internal error - invalid ParentElements data size !!!"); return CG_ERROR; } if (strcmp(section->parelem->name, "ParentData")) { if (section->parface == 0) { section->parface = CGNS_NEW(cgns_array, 1); strcpy(section->parface->data_type, section->parelem->data_type); strcpy(section->parface->name, "ParentElementsPosition"); section->parface->data_dim =2; section->parface->dim_vals[0]=size; section->parface->dim_vals[1]=2; if (cgi_write_array(section->id, section->parface)) return CG_ERROR; } else if (strcmp("I4", section->parface->data_type) && strcmp("I8", section->parface->data_type)) { cgi_error("ParentElements stored value %s is not valid", section->parface->data_type); return CG_ERROR; } if (size != section->parface->dim_vals[0]) { cgi_error("internal error - invalid ParentElementsPosition data size !!!"); return CG_ERROR; } } /* The following test should always be true ... */ if (start >= section->range[0] && end <= section->range[1]) { cgsize_t s_start[2], s_end[2], s_stride[2]; cgsize_t m_start[2], m_end[2], m_stride[2], m_dim[2]; s_start[0] = start - section->range[0] + 1; s_end[0] = end - section->range[0] + 1; s_stride[0]= 1; s_start[1] = 1; s_end[1] = section->parelem->dim_vals[1]; s_stride[1]= 1; m_start[0] = 1; m_end[0] = end - start + 1; m_stride[0]= 1; m_start[1] = 1; m_end[1] = section->parelem->dim_vals[1]; m_stride[1]= 1; m_dim[0] = m_end[0]; m_dim[1] = 4; WRITE_2D_INT_DATA(section->parelem, parent_data) if (strcmp(section->parelem->name, "ParentData")) { m_start[1] = 1; m_end[1] = 2; WRITE_2D_INT_DATA(section->parface, &parent_data[(end-start+1)<<1]) } free_parent_data(section); } else { cgi_error("Unhandled case during parent data partial writing"); return CG_ERROR; } return CG_OK; } /*****************************************************************************\ * Read and Write FlowSolution_t Nodes \*****************************************************************************/ /** * \ingroup FlowSolution * * \brief Get the number of FlowSolution_t nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] nsols Number of flow solutions for zone Z. * \return \ier * */ int cg_nsols(int fn, int B, int Z, int *nsols) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; *nsols = zone->nsols; return CG_OK; } /** * \ingroup FlowSolution * * \brief Get information about a FlowSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[out] solname Name of the flow solution. * \param[out] location Grid location where the solution is recorded. The current permissible * locations are \e Vertex, \e CellCenter, \e IFaceCenter, \e JFaceCenter, and \e KFaceCenter. * \return \ier * */ int cg_sol_info(int fn, int B, int Z, int S, char *solname, CGNS_ENUMT(GridLocation_t) *location) { cgns_sol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_sol(cg, B, Z, S); if (sol==0) return CG_ERROR; strcpy(solname, sol->name); *location = sol->location; return CG_OK; } /** * \ingroup FlowSolution * * \brief Get ADF Solution ID number (address) of node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[out] sol_id ADF Solution ID number (address) of node. * \return \ier * */ int cg_sol_id(int fn, int B, int Z, int S, double *sol_id) { cgns_sol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_sol(cg, B, Z, S); if (sol==0) return CG_ERROR; *sol_id = sol->id; return CG_OK; } /** * \ingroup FlowSolution * * \brief Create and/or write to a FlowSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] solname Name of the flow solution. * \param[in] location Grid location where the solution is recorded. The current permissible * locations are \e Vertex, \e CellCenter, \e IFaceCenter, \e JFaceCenter, and \e KFaceCenter. * \param[out] S \SOL_S * \return \ier * */ int cg_sol_write(int fn, int B, int Z, const char * solname, CGNS_ENUMT(GridLocation_t) location, int *S) { cgns_zone *zone; cgns_sol *sol = NULL; int index, n, index_dim; /* verify input */ if (cgi_check_strlen(solname)) return CG_ERROR; if (location != CGNS_ENUMV(Vertex) && location != CGNS_ENUMV(CellCenter) && location != CGNS_ENUMV(IFaceCenter) && location != CGNS_ENUMV(JFaceCenter) && location != CGNS_ENUMV(KFaceCenter)) { cgi_error("Given grid location not supported for FlowSolution_t"); return CG_ERROR; } /* if (INVALID_ENUM(location,NofValidGridLocation)) { cgi_error("Invalid input: GridLocation=%d ?",location); return CG_ERROR; } */ /* get memory address for FlowSolution node */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; if (zone->type != CGNS_ENUMV(Structured) && (location == CGNS_ENUMV(IFaceCenter) || location == CGNS_ENUMV(JFaceCenter) || location == CGNS_ENUMV(KFaceCenter))) { cgi_error ("GridLocation [IJK]FaceCenter only valid for Structured grid"); return CG_ERROR; } /* Overwrite a FlowSolution_t Node: */ for (index=0; indexnsols; index++) { if (strcmp(solname, zone->sol[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",solname); return CG_ERROR; } /* overwrite an existing solution */ /* delete the existing solution from file */ if (cgi_delete_node(zone->id, zone->sol[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ sol = &(zone->sol[index]); /* free memory */ cgi_free_sol(sol); break; } } /* ... or add a FlowSolution_t Node: */ if (index==zone->nsols) { if (zone->nsols == 0) { zone->sol = CGNS_NEW(cgns_sol, zone->nsols+1); } else { zone->sol = CGNS_RENEW(cgns_sol, zone->nsols+1, zone->sol); } sol = &(zone->sol[zone->nsols]); zone->nsols++; } (*S) = index+1; /* save data in memory */ memset(sol, 0, sizeof(cgns_sol)); strcpy(sol->name,solname); sol->location = location; index_dim = zone->index_dim; sol->rind_planes = (int *)malloc(index_dim*2*sizeof(int)); if (sol->rind_planes == NULL) { cgi_error("Error allocating sol->rind_plane."); return CG_ERROR; } for (n=0; nrind_planes[2*n]=sol->rind_planes[2*n+1]=0; /* save data in file */ if (cgi_new_node(zone->id, sol->name, "FlowSolution_t", &sol->id, "MT", 0, 0, 0)) return CG_ERROR; if (sol->location != CGNS_ENUMV(Vertex)) { cgsize_t length = (cgsize_t)strlen(GridLocationName[sol->location]); double GL_id; if (cgi_new_node(sol->id, "GridLocation", "GridLocation_t", &GL_id, "C1", 1, &length, (void *)GridLocationName[sol->location])) return CG_ERROR; } return CG_OK; } /** * \ingroup FlowSolution * * \brief Get the dimensions of a FlowSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[out] data_dim Number of dimensions defining the solution data. If a point set has been * defined, this will be 1, otherwise this will be the current zone index * dimension. * \param[out] dim_vals The array of data_dim dimensions for the solution data. * \return \ier * */ int cg_sol_size(int fn, int B, int Z, int S, int *data_dim, cgsize_t *dim_vals) { cgns_sol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_sol(cg, B, Z, S); if (sol==0) return CG_ERROR; if (sol->ptset == NULL) { cgns_zone *zone = &cg->base[B-1].zone[Z-1]; *data_dim = zone->index_dim; if (cgi_datasize(zone->index_dim, zone->nijk, sol->location, sol->rind_planes, dim_vals)) return CG_ERROR; } else { *data_dim = 1; dim_vals[0] = sol->ptset->size_of_patch; } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup FlowSolution * * \brief Get info about a point set FlowSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[out] ptset_type Type of point set defining the interface in the current solution; either * \e PointRange or \e PointList. * \param[out] npnts Number of points defining the interface in the current solution. For a * ptset_type of \e PointRange, \p npnts is always two. For a ptset_type of * \e PointList, \p npnts is the number of points in the PointList. * \return \ier * */ int cg_sol_ptset_info(int fn, int B, int Z, int S, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts) { cgns_sol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_sol(cg, B, Z, S); if (sol==0) return CG_ERROR; if (sol->ptset == NULL) { *ptset_type = CGNS_ENUMV(PointSetTypeNull); *npnts = 0; } else { *ptset_type = sol->ptset->type; *npnts = sol->ptset->npts; } return CG_OK; } /** * \ingroup FlowSolution * * \brief Read a point set FlowSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[out] pnts Array of points defining the interface in the current solution. * \return \ier * */ int cg_sol_ptset_read(int fn, int B, int Z, int S, cgsize_t *pnts) { int dim = 0; cgns_sol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_sol(cg, B, Z, S); if (sol==0) return CG_ERROR; if (sol->ptset == 0 || sol->ptset->npts <= 0) { cgi_error("PointSet not defined for FlowSolution node %d\n", S); return CG_ERROR; } cg_index_dim(fn, B, Z, &dim); if (cgi_read_int_data(sol->ptset->id, sol->ptset->data_type, sol->ptset->npts * dim, pnts)) return CG_ERROR; return CG_OK; } /** * \ingroup FlowSolution * * \brief Create a point set FlowSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] solname Name of the flow solution. * \param[in] location Grid location where the solution is recorded. The permissible * locations are \e Vertex, \e CellCenter, \e IFaceCenter, \e JFaceCenter, and \e KFaceCenter. * \param[in] ptset_type Type of point set defining the interface in the current solution; either * \e PointRange or \e PointList. * \param[in] npnts Number of points defining the interface in the current solution. For a * ptset_type of \e PointRange, \p npnts is always two. For a ptset_type of * \e PointList, \p npnts is the number of points in the \e PointList. * \param[in] pnts Array of points defining the interface in the current solution. * \param[out] S \SOL_S * \return \ier * */ int cg_sol_ptset_write(int fn, int B, int Z, const char *solname, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts, int *S) { int i, index_dim = 0; cgsize_t cnt, dim_vals = 1; cgns_sol *sol; char_33 PointSetName; double id; /* verify input */ if (!((ptset_type == CGNS_ENUMV(PointList) && npnts > 0) || (ptset_type == CGNS_ENUMV(PointRange) && npnts == 2))) { cgi_error("Invalid input: npoint=%ld, point set type=%s", (long)npnts, PointSetTypeName[ptset_type]); return CG_ERROR; } if (cg_index_dim(fn, B, Z, &index_dim)) return CG_ERROR; if (cgi_check_location(cg->base[B-1].cell_dim, cg->base[B-1].zone[Z-1].type, location)) return CG_ERROR; if (cg_sol_write(fn, B, Z, solname, CGNS_ENUMV(Vertex), S)) return CG_ERROR; sol = cgi_get_sol(cg, B, Z, *S); if (sol == 0) return CG_ERROR; sol->location = location; sol->ptset = CGNS_NEW(cgns_ptset, 1); sol->ptset->type = ptset_type; strcpy(sol->ptset->data_type,CG_SIZE_DATATYPE); sol->ptset->npts = npnts; if (ptset_type == CGNS_ENUMV(PointList)) { sol->ptset->size_of_patch = npnts; } else { sol->ptset->size_of_patch = 1; for (i = 0; i < index_dim; i++) { cnt = pnts[i+index_dim] - pnts[i]; if (cnt < 0) cnt = -cnt; sol->ptset->size_of_patch *= (cnt + 1); } } strcpy(PointSetName, PointSetTypeName[ptset_type]); if (cgi_write_ptset(sol->id, PointSetName, sol->ptset, index_dim, (void *)pnts)) return CG_ERROR; if (location != CGNS_ENUMV(Vertex)) { dim_vals = (cgsize_t)strlen(GridLocationName[location]); if (cgi_new_node(sol->id, "GridLocation", "GridLocation_t", &id, "C1", 1, &dim_vals, (void *)GridLocationName[location])) return CG_ERROR; } return CG_OK; } /*****************************************************************************\ * Read and Write flow field DataArray_t Nodes \*****************************************************************************/ /** * \ingroup FlowSolutionData * * \brief Get the number of flow solution arrays * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[out] nfields Number of data arrays in flow solution S. * \return \ier * */ int cg_nfields(int fn, int B, int Z, int S, int *nfields) { cgns_sol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_sol(cg, B, Z, S); if (sol==0) return CG_ERROR; *nfields = sol->nfields; return CG_OK; } /** * \ingroup FlowSolutionData * * \brief Get info about a flow solution array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[in] F \PSOL_F * \param[out] datatype Data type of the solution array written to the file. Admissible data types * for a solution array are \e Integer, \e LongInteger, \e RealSingle, and \e RealDouble. * \param[out] fieldname Name of the solution array. It is strongly advised to use the SIDS * nomenclature conventions when naming the solution arrays to ensure file * compatibility. * \return \ier * */ int cg_field_info(int fn, int B, int Z, int S, int F, CGNS_ENUMT(DataType_t) *datatype, char *fieldname) { cgns_array *field; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; field = cgi_get_field(cg, B, Z, S, F); if (field==0) return CG_ERROR; strcpy(fieldname, field->name); *datatype = cgi_datatype(field->data_type); return CG_OK; } /** * \ingroup FlowSolutionData * * \brief Read flow solution * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[in] fieldname Name of the solution array. It is strongly advised to use the SIDS * nomenclature conventions when naming the solution arrays to ensure file * compatibility. * \param[in] mem_datatype Data type of an array in memory. Admissible data types for a solution array * are Integer, LongInteger, RealSingle, and RealDouble. * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). * \param[out] field_ptr Array of solution values. * \return \ier * */ int cg_field_read(int fn, int B, int Z, int S, const char *fieldname, CGNS_ENUMT(DataType_t) mem_datatype, const cgsize_t *s_rmin, const cgsize_t *s_rmax, void *field_ptr) { cgns_sol *sol; int n, m_numdim; /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_sol(cg, B, Z, S); if (sol == 0) return CG_ERROR; if (sol->ptset == NULL) /* sol implies zone exists */ m_numdim = cg->base[B-1].zone[Z-1].index_dim; else m_numdim = 1; /* verify that range requested does not exceed range stored */ if (s_rmin == NULL || s_rmax == NULL) { cgi_error("NULL range value."); return CG_ERROR; } cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; for (n = 0; nfilename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_sol(cg, B, Z, S); if (sol == 0) return CG_ERROR; /* find the field address in the database */ field = 0; for (f=0; fnfields; f++) { if (strcmp(sol->field[f].name, fieldname) == 0) { field = cgi_get_field(cg, B, Z, S, f+1); if (field == 0) return CG_ERROR; break; } } if (field == 0) { cgi_error("Flow solution array %s not found",fieldname); return CG_NODE_NOT_FOUND; } if (sol->ptset == NULL) s_numdim = cg->base[B-1].zone[Z-1].index_dim; else s_numdim = 1; return cgi_array_general_read(field, cgns_rindindex, sol->rind_planes, s_numdim, s_rmin, s_rmax, m_type, m_numdim, m_dimvals, m_rmin, m_rmax, field_ptr); } /** * \ingroup FlowSolutionData * * \brief Get the field solution ADF ID number (address) of node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[in] F \PSOL_F * \param[out] field_id Field solution ADF ID number (address) of node * \return \ier * */ int cg_field_id(int fn, int B, int Z, int S, int F, double *field_id) { cgns_array *field; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; field = cgi_get_field(cg, B, Z, S, F); if (field==0) return CG_ERROR; *field_id = field->id; return CG_OK; } /** * \ingroup FlowSolutionData * * \brief Write flow solution * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[in] fieldname Name of the solution array. It is strongly advised to use the SIDS * nomenclature conventions when naming the solution arrays to ensure file * compatibility. * \param[in] type Data type of the solution array written to the file. Admissible data types * for a solution array are Integer, LongInteger, RealSingle, and RealDouble. * \param[in] field_ptr Array of solution values. * \param[out] F \SOL_F * \return \ier * */ int cg_field_write(int fn, int B, int Z, int S, CGNS_ENUMT(DataType_t) type, const char *fieldname, const void *field_ptr, int *F) { cgns_zone *zone; cgns_sol *sol; int n, m_numdim; HDF5storage_type = CG_CONTIGUOUS; /* verify input */ if (cgi_check_strlen(fieldname)) return CG_ERROR; if (type != CGNS_ENUMV(RealSingle) && type != CGNS_ENUMV(RealDouble) && type != CGNS_ENUMV(ComplexSingle) && type != CGNS_ENUMV(ComplexDouble) && type != CGNS_ENUMV(Integer) && type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid datatype for solution array %s: %d",fieldname, type); return CG_ERROR; } /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone == 0) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_sol(cg, B, Z, S); if (sol == 0) return CG_ERROR; /* dimension is dependent on multidim or ptset */ cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; if (sol->ptset == NULL) { m_numdim = zone->index_dim; if (cgi_datasize(m_numdim, zone->nijk, sol->location, sol->rind_planes, m_dimvals)) return CG_ERROR; } else { m_numdim = 1; m_dimvals[0] = sol->ptset->size_of_patch; } cgsize_t s_rmin[CGIO_MAX_DIMENSIONS], s_rmax[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; for (n = 0; n < m_numdim; n++) { if (cgns_rindindex == CG_CONFIG_RIND_ZERO) { /* old obsolete behavior (versions < 3.4) */ s_rmin[n] = 1; } else { /* new behavior consistent with SIDS */ s_rmin[n] = 1 - sol->rind_planes[2*n]; } s_rmax[n] = s_rmin[n] + m_dimvals[n] - 1; m_rmin[n] = 1; m_rmax[n] = m_dimvals[n]; } return cg_field_general_write(fn, B, Z, S, fieldname, type, s_rmin, s_rmax, type, m_numdim, m_dimvals, m_rmin, m_rmax, field_ptr, F); } /** * \ingroup FlowSolutionData * * \brief Write subset of flow solution * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[in] fieldname Name of the solution array. It is strongly advised to use the SIDS * nomenclature conventions when naming the solution arrays to ensure file * compatibility. * \param[in] type Data type of the solution array written to the file. Admissible data types * for a solution array are Integer, LongInteger, RealSingle, and RealDouble. * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). * \param[in] field_ptr Array of solution values. * \param[out] F \SOL_F * \return \ier * */ int cg_field_partial_write(int fn, int B, int Z, int S, CGNS_ENUMT( DataType_t ) type, const char *fieldname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, const void *field_ptr, int *F) { cgns_zone *zone; cgns_sol *sol; int n, m_numdim; int status; /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone == 0) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_sol(cg, B, Z, S); if (sol == 0) return CG_ERROR; /* dimension is dependent on multidim or ptset */ if (sol->ptset == NULL) { m_numdim = zone->index_dim; } else { m_numdim = 1; } if (s_rmin == NULL || s_rmax == NULL) { cgi_error("NULL range value."); return CG_ERROR; } cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; for (n = 0; nfilename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone == 0) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_sol(cg, B, Z, S); if (sol == 0) return CG_ERROR; /* file dimension is dependent on multidim or ptset */ cgsize_t s_dimvals[CGIO_MAX_DIMENSIONS]; if (sol->ptset == NULL) { s_numdim = zone->index_dim; if (cgi_datasize(s_numdim, zone->nijk, sol->location, sol->rind_planes, s_dimvals)) return CG_ERROR; } else { s_numdim = 1; s_dimvals[0] = sol->ptset->size_of_patch; } status= cgi_array_general_write(sol->id, &(sol->nfields), &(sol->field), fieldname, cgns_rindindex, sol->rind_planes, s_type, s_numdim, s_dimvals, s_rmin, s_rmax, m_type, m_numdim, m_dimvals, m_rmin, m_rmax, field_ptr, F); HDF5storage_type = CG_COMPACT; return status; } /*************************************************************************\ * Read and write ZoneSubRegion_t Nodes * \*************************************************************************/ /** * \ingroup ZoneSubregions * * \brief Get the number of ZoneSubRegion_t nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] nsubregs Number of ZoneSubRegion_t nodes under Zone Z. * \return \ier * */ int cg_nsubregs(int fn, int B, int Z, int *nsubregs) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; (*nsubregs) = zone->nsubreg; return CG_OK; } static cgns_subreg *cg_subreg_read(int fn, int B, int Z, int S) { cg = cgi_get_file(fn); if (cg == 0) return NULL; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return NULL; return cgi_get_subreg(cg, B, Z, S); } /** * \ingroup ZoneSubregions * * \brief Get info about a ZoneSubRegion_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. * \param[out] regname Name of the ZoneSubRegion_t node. * \param[out] dimension Dimensionality of the subregion, 1 for lines, 2 for faces, 3 for volumes. * \param[out] location Grid location used in the definition of the point set. The currently * admissible locations are Vertex and CellCenter. * \param[out] ptset_type Type of point set defining the interface for the subregion data; either * PointRange or PointList. * \param[out] npnts Number of points defining the interface for the subregion data. For a * \p ptset_type of \e PointRange, \p npnts is always two. For a \p ptset_type of * \e PointList, \p npnts is the number of points in the \e PointList. * \param[out] bcname_len String length of bcname. * \param[out] gcname_len String length of gcname. * \return \ier * */ int cg_subreg_info(int fn, int B, int Z, int S, char *regname, int *dimension, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, int *bcname_len, int *gcname_len) { cgns_subreg *subreg = cg_subreg_read(fn, B, Z, S); if (subreg == NULL) return CG_ERROR; strcpy(regname,subreg->name); *dimension = subreg->reg_dim; *location = subreg->location; if (subreg->ptset) { *ptset_type = subreg->ptset->type; *npnts = subreg->ptset->npts; } else { *ptset_type = CGNS_ENUMV(PointSetTypeNull); *npnts = 0; } if (subreg->bcname) { *bcname_len = (int)strlen(subreg->bcname->text); } else { *bcname_len = 0; } if (subreg->gcname) { *gcname_len = (int)strlen(subreg->gcname->text); } else { *gcname_len = 0; } return CG_OK; } /** * \ingroup ZoneSubregions * * \brief Read point set data for a ZoneSubRegion_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. * \param[out] pnts Array of points defining the interface for the subregion data. * \return \ier * */ int cg_subreg_ptset_read(int fn, int B, int Z, int S, cgsize_t *pnts) { int dim = 0; cgns_subreg *subreg = cg_subreg_read(fn, B, Z, S); if (subreg == NULL) return CG_ERROR; if (subreg->ptset == 0 || subreg->ptset->npts <= 0) { cgi_error("PointSet not defined for ZoneSubRegion node %d\n", S); return CG_ERROR; } cg_index_dim(fn, B, Z, &dim); if (cgi_read_int_data(subreg->ptset->id, subreg->ptset->data_type, subreg->ptset->npts * dim, pnts)) return CG_ERROR; return CG_OK; } /** * \ingroup ZoneSubregions * * \brief Read the BC_t node name for a ZoneSubRegion_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. * \param[out] bcname The name of a BC_t node which defines the subregion. * \return \ier * */ int cg_subreg_bcname_read(int fn, int B, int Z, int S, char *bcname) { cgns_subreg *subreg = cg_subreg_read(fn, B, Z, S); if (subreg == NULL) return CG_ERROR; if (subreg->bcname == 0) { cgi_error("BCRegionName not defined for ZoneSubRegion node %d\n", S); return CG_ERROR; } strcpy(bcname, subreg->bcname->text); return CG_OK; } /** * \ingroup ZoneSubregions * * \brief Read the GridConnectivity_t node name for a ZoneSubRegion_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. * \param[out] gcname The name of a GridConnectivity_t or GridConnectivity1to1_t node which * defines the subregion. * \return \ier * */ int cg_subreg_gcname_read(int fn, int B, int Z, int S, char *gcname) { cgns_subreg *subreg = cg_subreg_read(fn, B, Z, S); if (subreg == NULL) return CG_ERROR; if (subreg->gcname == 0) { cgi_error("GridConnectivityRegionName not defined for ZoneSubRegion node %d\n", S); return CG_ERROR; } strcpy(gcname, subreg->gcname->text); return CG_OK; } static cgns_subreg *cg_subreg_write(int fn, int B, int Z, const char *name, int dimension, int *S) { cgns_zone *zone; cgns_subreg *subreg = NULL; int index, cell_dim; /* verify input */ if (cgi_check_strlen(name)) return NULL; if (cg_cell_dim(fn, B, &cell_dim)) return NULL; if (dimension < 1 || dimension > cell_dim) { cgi_error("invalid RegionCellDimension for ZoneSubRegion %s", name); return NULL; } /* get memory address */ cg = cgi_get_file(fn); if (cg == NULL) return NULL; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return NULL; zone = cgi_get_zone(cg, B, Z); if (zone == NULL) return NULL; /* Overwrite a ZoneSubRegion_t Node: */ for (index = 0; index < zone->nsubreg; index++) { if (0 == strcmp(name, zone->subreg[index].name)) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode == CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",name); return NULL; } /* overwrite an existing ZoneGridConnectivity_t node */ /* delete the existing ZoneGridConnectivity_t from file */ if (cgi_delete_node(zone->id, zone->subreg[index].id)) return NULL; /* save the old in-memory address to overwrite */ subreg = &(zone->subreg[index]); /* free memory */ cgi_free_subreg(subreg); break; } } /* ... or add a ZoneGridConnectivity_t Node: */ if (index == zone->nsubreg) { if (zone->nsubreg == 0) { zone->subreg = CGNS_NEW(cgns_subreg, 1); } else { zone->subreg = CGNS_RENEW(cgns_subreg, zone->nsubreg+1, zone->subreg); } subreg = &(zone->subreg[zone->nsubreg]); zone->nsubreg++; } (*S) = index+1; memset(subreg, 0, sizeof(cgns_subreg)); strcpy(subreg->name, name); subreg->reg_dim = dimension; return subreg; } /** * \ingroup ZoneSubregions * * \brief Create a point set ZoneSubRegion_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] regname Name of the ZoneSubRegion_t node. * \param[in] dimension Dimensionality of the subregion, 1 for lines, 2 for faces, 3 for volumes. * \param[in] location Grid location used in the definition of the point set. The currently * admissible locations are \e Vertex and \e CellCenter. * \param[in] ptset_type Type of point set defining the interface for the subregion data; either * PointRange or PointList. * \param[in] npnts Number of points defining the interface for the subregion data. For a * \p ptset_type of \e PointRange, \p npnts is always two. For a \p ptset_type of * \e PointList, \p npnts is the number of points in the \e PointList. * \param[in] pnts Array of points defining the interface for the subregion data. * \param[out] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. * \return \ier * */ int cg_subreg_ptset_write(int fn, int B, int Z, const char *regname, int dimension, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts, int *S) { int i, index_dim = 0; cgsize_t cnt, dim_vals = 1; cgns_zone *zone; cgns_subreg *subreg; char_33 PointSetName; double id; /* verify input */ if (!((ptset_type == CGNS_ENUMV(PointList) && npnts > 0) || (ptset_type == CGNS_ENUMV(PointRange) && npnts == 2))) { cgi_error("Invalid input: npoint=%ld, point set type=%s", (long)npnts, PointSetTypeName[ptset_type]); return CG_ERROR; } if (cg_index_dim(fn, B, Z, &index_dim)) return CG_ERROR; if (cgi_check_location(dimension+1, cg->base[B-1].zone[Z-1].type, location)) return CG_ERROR; subreg = cg_subreg_write(fn, B, Z, regname, dimension, S); if (subreg == NULL) return CG_ERROR; subreg->location = location; subreg->ptset = CGNS_NEW(cgns_ptset, 1); subreg->ptset->type = ptset_type; strcpy(subreg->ptset->data_type,CG_SIZE_DATATYPE); subreg->ptset->npts = npnts; if (ptset_type == CGNS_ENUMV(PointList)) { subreg->ptset->size_of_patch = npnts; } else { subreg->ptset->size_of_patch = 1; for (i = 0; i < index_dim; i++) { cnt = pnts[i+index_dim] - pnts[i]; if (cnt < 0) cnt = -cnt; subreg->ptset->size_of_patch *= (cnt + 1); } } /* save data in file */ zone = cgi_get_zone(cg, B, Z); if (zone == NULL) return CG_ERROR; if (cgi_new_node(zone->id, subreg->name, "ZoneSubRegion_t", &subreg->id, "I4", 1, &dim_vals, &subreg->reg_dim)) return CG_ERROR; strcpy(PointSetName, PointSetTypeName[subreg->ptset->type]); if (cgi_write_ptset(subreg->id, PointSetName, subreg->ptset, index_dim, (void *)pnts)) return CG_ERROR; if (location != CGNS_ENUMV(Vertex)) { dim_vals = (cgsize_t)strlen(GridLocationName[location]); if (cgi_new_node(subreg->id, "GridLocation", "GridLocation_t", &id, "C1", 1, &dim_vals, (void *)GridLocationName[location])) return CG_ERROR; } return CG_OK; } /** * \ingroup ZoneSubregions * * \brief Create a ZoneSubRegion_t node that references a BC_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] regname Name of the ZoneSubRegion_t node. * \param[in] dimension Dimensionality of the subregion, 1 for lines, 2 for faces, 3 for volumes. * \param[in] bcname The name of a BC_t node which defines the subregion. * \param[out] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. * \return \ier * */ int cg_subreg_bcname_write(int fn, int B, int Z, const char *regname, int dimension, const char *bcname, int *S) { cgsize_t dim_vals = 1; cgns_zone *zone; cgns_subreg *subreg; if (bcname == NULL || !*bcname) { cgi_error("BCRegionName not given"); return CG_ERROR; } subreg = cg_subreg_write(fn, B, Z, regname, dimension, S); if (subreg == NULL) return CG_ERROR; subreg->bcname = CGNS_NEW(cgns_descr, 1); strcpy(subreg->bcname->name, "BCRegionName"); subreg->bcname->text = (char *)malloc(strlen(bcname)+1); if (subreg->bcname->text == NULL) { cgi_error("malloc failed for BCRegionName name"); return CG_ERROR; } strcpy(subreg->bcname->text, bcname); /* save data in file */ zone = cgi_get_zone(cg, B, Z); if (zone == NULL) return CG_ERROR; if (cgi_new_node(zone->id, subreg->name, "ZoneSubRegion_t", &subreg->id, "I4", 1, &dim_vals, &subreg->reg_dim)) return CG_ERROR; if (cgi_write_descr(subreg->id, subreg->bcname)) return CG_ERROR; return CG_OK; } /** * \ingroup ZoneSubregions * * \brief Create a ZoneSubRegion_t node that references a GridConnectivity_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] regname Name of the ZoneSubRegion_t node. * \param[in] dimension Dimensionality of the subregion, 1 for lines, 2 for faces, 3 for volumes. * \param[in] gcname The name of a GridConnectivity_t or GridConnectivity1to1_t node which * defines the subregion. * \param[out] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. * \return \ier * */ int cg_subreg_gcname_write(int fn, int B, int Z, const char *regname, int dimension, const char *gcname, int *S) { cgsize_t dim_vals = 1; cgns_zone *zone; cgns_subreg *subreg; if (gcname == NULL || !*gcname) { cgi_error("GridConnectivityRegionName not given"); return CG_ERROR; } subreg = cg_subreg_write(fn, B, Z, regname, dimension, S); if (subreg == NULL) return CG_ERROR; subreg->gcname = CGNS_NEW(cgns_descr, 1); strcpy(subreg->gcname->name, "GridConnectivityRegionName"); int gcname_length = strlen(gcname)+1; subreg->gcname->text = (char *)malloc(gcname_length); if (subreg->gcname->text == NULL) { cgi_error("malloc failed for GridConnectivityRegionName name"); return CG_ERROR; } snprintf(subreg->gcname->text, gcname_length, "%s", gcname); /* save data in file */ zone = cgi_get_zone(cg, B, Z); if (cgi_new_node(zone->id, subreg->name, "ZoneSubRegion_t", &subreg->id, "I4", 1, &dim_vals, &subreg->reg_dim)) return CG_ERROR; if (cgi_write_descr(subreg->id, subreg->gcname)) return CG_ERROR; return CG_OK; } /*************************************************************************\ * Read and write ZoneGridConnectivity_t Nodes * \*************************************************************************/ /** * \ingroup ZoneGridConnectivity * * \brief Get the number of ZoneGridConnectivity_t nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] nzconns Number of ZoneGridConnectivity_t nodes under Zone Z. * \return \ier * */ int cg_nzconns(int fn, int B, int Z, int *nzconns) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for zone */ zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; (*nzconns) = zone->nzconn; return CG_OK; } /** * \ingroup ZoneGridConnectivity * * \brief Read ZoneGridConnectivity_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] ZC Zone grid connectivity index number, where 1 ≤ ZC ≤ nzconns. * \param[out] zcname Name of the ZoneGridConnectivity_t node. * \return \ier * */ int cg_zconn_read(int fn, int B, int Z, int ZC, char *zcname) { cgns_zconn *zconn; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for ZoneGridConnectivity_t node */ /* cgi_get_zconnZC() also sets active ZoneGridConnectivity_t node */ zconn = cgi_get_zconnZC(cg, B, Z, ZC); if (zconn==0) return CG_ERROR; /* Return name for the ZoneGridConnectivity_t node */ strcpy(zcname,zconn->name); return CG_OK; } /** * \ingroup ZoneGridConnectivity * * \brief Create ZoneGridConnectivity_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] zcname Name of the ZoneGridConnectivity_t node. * \param[out] ZC Zone grid connectivity index number, where 1 ≤ ZC ≤ nzconns. * \return \ier * */ int cg_zconn_write(int fn, int B, int Z, const char *zcname, int *ZC) { cgns_zone *zone; cgns_zconn *zconn = NULL; int index; /* verify input */ if (cgi_check_strlen(zcname)) return CG_ERROR; /* get memory address */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* Overwrite a ZoneGridConnectivity_t Node: */ for (index = 0; index < zone->nzconn; index++) { if (0 == strcmp(zcname, zone->zconn[index].name)) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode == CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",zcname); return CG_ERROR; } /* overwrite an existing ZoneGridConnectivity_t node */ /* delete the existing ZoneGridConnectivity_t from file */ if (cgi_delete_node(zone->id, zone->zconn[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ zconn = &(zone->zconn[index]); /* free memory */ cgi_free_zconn(zconn); break; } } /* ... or add a ZoneGridConnectivity_t Node: */ if (index == zone->nzconn) { if (zone->nzconn == 0) { zone->zconn = CGNS_NEW(cgns_zconn, 1); } else { zone->zconn = CGNS_RENEW(cgns_zconn, zone->nzconn+1, zone->zconn); } zconn = &(zone->zconn[zone->nzconn]); zone->nzconn++; } (*ZC) = index+1; zone->active_zconn = *ZC; memset(zconn, 0, sizeof(cgns_zconn)); strcpy(zconn->name,zcname); /* save data in file */ if (cgi_new_node(zone->id, zconn->name, "ZoneGridConnectivity_t", &zconn->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /** * \ingroup ZoneGridConnectivity * * \brief Get the current ZoneGridConnectivity_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] ZC Zone grid connectivity index number, where 1 ≤ ZC ≤ nzconns. * \return \ier * */ int cg_zconn_get(int fn, int B, int Z, int *ZC) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* Get memory address for zone */ zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; if (zone->nzconn <= 0) { *ZC = 0; cgi_error("no ZoneGridConnectivity_t node found."); return CG_NODE_NOT_FOUND; } if (zone->active_zconn <= 0 || zone->active_zconn > zone->nzconn) zone->active_zconn = 1; *ZC = zone->active_zconn; return CG_OK; } /** * \ingroup ZoneGridConnectivity * * \brief Set the current ZoneGridConnectivity_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] ZC Zone grid connectivity index number, where 1 ≤ ZC ≤ nzconns. * \return \ier * */ int cg_zconn_set(int fn, int B, int Z, int ZC) { cgns_zconn *zconn; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* Get memory address for ZoneGridConnectivity_t node */ /* cgi_get_zconnZC() also sets active ZoneGridConnectivity_t node */ zconn = cgi_get_zconnZC(cg, B, Z, ZC); if (zconn==0) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and Write OversetHoles_t Nodes \*****************************************************************************/ /** * \ingroup OversetHoles * * \brief Get the number of overset holes in a zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] nholes Number of overset holes in zone Z. * \return \ier * */ int cg_nholes(int fn, int B, int Z, int *nholes) { cgns_zconn *zconn; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zconn = cgi_get_zconn(cg, B, Z); if (zconn==0) *nholes = 0; /* if ZoneGridConnectivity_t is undefined */ else *nholes = zconn->nholes; return CG_OK; } /** * \ingroup OversetHoles * * \brief Get info about an overset hole * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Overset hole index number, where 1 ≤ J ≤ nholes. * \param[out] holename Name of the overset hole. * \param[out] location Grid location used in the definition of the point set. The currently * admissible locations are Vertex and CellCenter. * \param[out] ptset_type The extent of the overset hole may be defined using a range of points or * cells, or using a discrete list of all points or cells in the overset hole. * If a range of points or cells is used, ptset_type is set to PointRange. When * a discrete list of points or cells is used, ptset_type equals PointList. * \param[out] nptsets Number of point sets used to define the hole. If ptset_type is PointRange, * several point sets may be used. If ptset_type is PointList, only one point * set is allowed. * \param[out] npnts Number of points (or cells) in the point set. For a ptset_type of * PointRange, npnts is always two. For a ptset_type of PointList, npnts is the * number of points or cells in the PointList. * \return \ier * */ int cg_hole_info(int fn, int B, int Z, int J, char *holename, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, int *nptsets, cgsize_t *npnts) { cgns_hole *hole; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; hole = cgi_get_hole(cg, B, Z, J); if (hole==0) return CG_ERROR; strcpy(holename, hole->name); *location = hole->location; *ptset_type = hole->nptsets ? hole->ptset[0].type : CGNS_ENUMV(PointSetTypeNull); *nptsets = hole->nptsets; /* if multiple pointsets are defined, only PointRange is allowed */ if (hole->nptsets==1) *npnts = hole->ptset[0].npts; else *npnts = 2*hole->nptsets; return CG_OK; } /** * \ingroup OversetHoles * * \brief Read overset hole data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Overset hole index number, where 1 ≤ J ≤ nholes. * \param[out] pnts Array of points or cells in the point set. * \return \ier * */ int cg_hole_read(int fn, int B, int Z, int J, cgsize_t *pnts) { cgns_hole *hole; int set, index_dim; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; hole = cgi_get_hole(cg, B, Z, J); if (hole==0) return CG_ERROR; index_dim = cg->base[B-1].zone[Z-1].index_dim; /* read point-set directly from ADF file */ if (hole->nptsets > 1) { for (set = 0; set < hole->nptsets; set++) { if (hole->ptset[set].npts > 0) { if (cgi_read_int_data(hole->ptset[set].id, hole->ptset[set].data_type, 2*index_dim, &pnts[2*index_dim*set])) return CG_ERROR; } else { cgi_warning("Overset hole #%d set %d, of zone #%d, base #%d, contains no points", J, set, Z, B); } } } else if (hole->nptsets == 1) { if (hole->ptset[0].npts > 0) { if (cgi_read_int_data(hole->ptset[0].id, hole->ptset[0].data_type, hole->ptset[0].npts*index_dim, pnts)) return CG_ERROR; } else { cgi_warning("Overset hole #%d, of zone #%d, base #%d, contains no points", J, Z, B); } } else { cgi_warning("Overset hole #%d, of zone #%d, base #%d, contains no data", J, Z, B); } return CG_OK; } int cg_hole_id(int fn, int B, int Z, int J, double *hole_id) { cgns_hole *hole; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; hole = cgi_get_hole(cg, B, Z, J); if (hole==0) return CG_ERROR; *hole_id = hole->id; return CG_OK; } /** * \ingroup OversetHoles * * \brief Write overset hole data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] holename Name of the overset hole. * \param[in] location Grid location used in the definition of the point set. The currently * admissible locations are Vertex and CellCenter. * \param[in] ptset_type The extent of the overset hole may be defined using a range of points or * cells, or using a discrete list of all points or cells in the overset hole. * If a range of points or cells is used, ptset_type is set to PointRange. When * a discrete list of points or cells is used, ptset_type equals PointList. * \param[in] nptsets Number of point sets used to define the hole. If ptset_type is PointRange, * several point sets may be used. If ptset_type is PointList, only one point * set is allowed. * \param[in] npnts Number of points (or cells) in the point set. For a ptset_type of * PointRange, npnts is always two. For a ptset_type of PointList, npnts is the * number of points or cells in the PointList. * \param[in] pnts Array of points or cells in the point set. * \param[out] J Overset hole index number, where 1 ≤ J ≤ nholes. * \return \ier * */ int cg_hole_write(int fn, int B, int Z, const char * holename, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, int nptsets, cgsize_t npnts, const cgsize_t * pnts, int *J) { cgns_zone *zone; cgns_zconn *zconn; cgns_hole *hole = NULL; cgns_ptset *ptset; char_33 PointSetName; int index, set; int i, index_dim; /* verify input */ if (cgi_check_strlen(holename)) return CG_ERROR; if (location != CGNS_ENUMV(Vertex) && location != CGNS_ENUMV(CellCenter)) { cgi_error("cg_hole_write: GridLocation not Vertex or CellCenter"); return CG_ERROR; } if (ptset_type != CGNS_ENUMV(PointList) && ptset_type != CGNS_ENUMV(PointRange)) { cgi_error("Invalid input: ptset_type=%d ?",ptset_type); return CG_ERROR; } if (!(ptset_type == CGNS_ENUMV(PointRange) && npnts == 2*nptsets && nptsets > 0) && !(ptset_type == CGNS_ENUMV(PointList) && npnts >= 0 && nptsets == 1)) { cgi_error("Invalid input: nptsets=%d, npoint=%" PRIdCGSIZE ", point set type=%s", nptsets, npnts, PointSetTypeName[ptset_type]); return CG_ERROR; } /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for zone */ zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* Allocate ZoneGridConnectivity data struct. if not already created */ if (zone->nzconn == 0) { zone->nzconn = zone->active_zconn = 1; zone->zconn = CGNS_NEW(cgns_zconn, 1); strcpy(zone->zconn->name,"ZoneGridConnectivity"); } zconn = cgi_get_zconn(cg, B, Z); if (zconn == 0) return CG_ERROR; index_dim = zone->index_dim; /* Overwrite an OversetHoles_t Node: */ for (index=0; indexnholes; index++) { if (strcmp(holename, zconn->hole[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",holename); return CG_ERROR; } /* overwrite an existing Overset Hole */ /* delete the existing Overset hole from file */ if (cgi_delete_node(zconn->id, zconn->hole[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ hole = &(zconn->hole[index]); cgi_free_hole(hole); break; } } /* ... or add an OversetHoles_t Node: */ if (index==zconn->nholes) { if (zconn->nholes == 0) { zconn->hole = CGNS_NEW(cgns_hole, zconn->nholes+1); } else { zconn->hole = CGNS_RENEW(cgns_hole, zconn->nholes+1, zconn->hole); } hole = &(zconn->hole[zconn->nholes]); zconn->nholes++; } (*J) = index+1; /* write hole info to internal memory */ memset(hole, 0, sizeof(cgns_hole)); strcpy(hole->name,holename); hole->location = location; hole->nptsets = nptsets; hole->ptset = CGNS_NEW(cgns_ptset, nptsets); for (set=0; setptset[set]; ptset->type = ptset_type; strcpy(ptset->data_type,CG_SIZE_DATATYPE); if (ptset_type == CGNS_ENUMV(PointRange)) ptset->npts = 2; else ptset->npts = npnts; /* Record the number of nodes or elements in the point set */ if (ptset_type==CGNS_ENUMV( PointList )) ptset->size_of_patch=npnts; else if (ptset_type==CGNS_ENUMV( PointRange )) { ptset->size_of_patch = 1; for (i=0; isize_of_patch *= (pnts[i+index_dim]-pnts[i]+1); } } if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (zconn->id==0) { if (cgi_new_node(zone->id, zconn->name, "ZoneGridConnectivity_t", &zconn->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(zconn->id, hid); if (hid==0) { if (cgi_new_node(zone->id, zconn->name, "ZoneGridConnectivity_t", &zconn->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } if (cgi_new_node(zconn->id, hole->name, "OversetHoles_t", &hole->id, "MT", 0, 0, 0)) return CG_ERROR; if (hole->location != CGNS_ENUMV(Vertex)) { double GL_id; cgsize_t length = (cgsize_t)strlen(GridLocationName[hole->location]); if (cgi_new_node(hole->id, "GridLocation", "GridLocation_t", &GL_id, "C1", 1, &length, GridLocationName[hole->location])) return CG_ERROR; } for (set=0; setptset[set]; if (ptset->npts > 0) { /* Create Point Set node on disk */ if (ptset->type == CGNS_ENUMV(PointRange)) sprintf(PointSetName, "PointRange%d",set+1); else sprintf(PointSetName, "%s", PointSetTypeName[ptset->type]); if (cgi_write_ptset(hole->id, PointSetName, ptset, index_dim, (void *)&pnts[2*index_dim*set])) return CG_ERROR; } } return CG_OK; } /*****************************************************************************\ * Read and Write GridConnectivity_t Nodes \*****************************************************************************/ /** * \ingroup GeneralizedConnectivity * * \brief Get the number of generalized connectivity interfaces in a zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] nconns Number of interfaces for zone Z. * \return \ier * */ int cg_nconns(int fn, int B, int Z, int *nconns) { cgns_zconn *zconn; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zconn = cgi_get_zconn(cg, B, Z); if (zconn==0) *nconns = 0; /* if ZoneGridConnectivity_t is undefined */ else *nconns = zconn->nconns; return CG_OK; } /** * \ingroup GeneralizedConnectivity * * \brief Get info about a generalized connectivity interface * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Interface index number, where 1 ≤ J ≤ nconns. * \param[out] connectname Name of the interface. * \param[out] location Grid location used in the definition of the point set. The currently * admissible locations are Vertex and CellCenter. * \param[out] connect_type Type of interface being defined. The admissible types are Overset, Abutting, * and Abutting1to1. * \param[out] ptset_type Type of point set defining the interface in the current zone; either * PointRange or PointList. * \param[out] npnts Number of points defining the interface in the current zone. For a * ptset_type of PointRange, npnts is always two. For a ptset_type of * PointList, npnts is the number of points in the PointList. * \param[out] donorname Name of the zone interfacing with the current zone. * \param[out] donor_zonetype Type of the donor zone. The admissible types are Structured and * Unstructured. * \param[out] donor_ptset_type Type of point set defining the interface in the donor zone; either * PointListDonor or CellListDonor. * \param[out] donor_datatype Data type in which the donor points are stored in the file. As of Version * 3.0, this value is ignored when writing, and on reading, it will return * either Integer or LongInteger depending on whether the file was written * using 32 or 64-bit. The donor_datatype argument was left in these functions * only for backward compatibility. The donor data is always read as cgsize_t. * \param[out] ndata_donor Number of points or cells in the current zone. These are paired with points, * cells, or fractions thereof in the donor zone. * \return \ier * * \details In cg_conn_info, donor_datatype is useless starting with version 1.27, because it's always I4. * However, this arg. is left for backward compatibility of API and to be able to read old files * */ int cg_conn_info(int fn, int B, int Z, int J, char *connectname, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(GridConnectivityType_t) *connect_type, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, char *donorname, CGNS_ENUMT(ZoneType_t) *donor_zonetype, CGNS_ENUMT(PointSetType_t) *donor_ptset_type, CGNS_ENUMT(DataType_t) *donor_datatype, cgsize_t *ndata_donor) { int dZ, dB; cgns_conn *conn; char_33 basedonorname, zonedonorname; char *separator; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; conn = cgi_get_conn(cg, B, Z, J); if (conn==0) return CG_ERROR; strcpy(connectname, conn->name); *connect_type = conn->type; *location = conn->location; *ptset_type = conn->ptset.type; *npnts = conn->ptset.npts; /* information relative to donor */ strcpy(donorname, conn->donor); *donor_datatype = cgi_datatype(conn->dptset.data_type); *ndata_donor = conn->dptset.npts; *donor_ptset_type = conn->dptset.type; /* Split donorname into BaseName + zoneName */ separator = strchr(donorname, '/'); if (separator != NULL) { /* get ending zoneName */ strcpy(zonedonorname, separator + sizeof(char)); /* get base but do not use path syntax */ memcpy(basedonorname, donorname, (separator - donorname)*sizeof(char)); basedonorname[separator - donorname] = '\0'; /* Find donor base index */ for (dB=0;dBnbases; dB++) { if (strcmp(cg->base[dB].name,basedonorname)==0) { break; } } } else { /* zoneName is in current base */ strcpy(basedonorname, cg->base[B-1].name); strcpy(zonedonorname, donorname); dB = B-1; } /* Find ZoneType_t of DonorZone given its name */ *donor_zonetype = CGNS_ENUMV( ZoneTypeNull ); for (dZ=0; dZbase[dB].nzones; dZ++) { if (strcmp(cg->base[dB].zone[dZ].name,zonedonorname)==0) { *donor_zonetype = cg->base[dB].zone[dZ].type; break; } } if (*donor_zonetype == 0) { cgi_error("cg_conn_info:donor zone %s does not exist",donorname); return CG_ERROR; } return CG_OK; } /** * \ingroup GeneralizedConnectivity * * \brief Read generalized connectivity data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Interface index number, where 1 ≤ J ≤ nconns. * \param[out] pnts Array of points defining the interface in the current zone. * \param[out] donor_datatype Data type in which the donor points are stored in the file. As of Version * 3.0, this value is ignored when writing, and on reading, it will return * either Integer or LongInteger depending on whether the file was written * using 32 or 64-bit. The donor_datatype argument was left in these functions * only for backward compatibility. The donor data is always read as cgsize_t. * \param[out] donor_data Array of donor points or cells corresponding to ndata_donor. Note that it is * possible that the same donor point or cell may be used multiple times. * \return \ier * * \details In cg_conn_read, donor_datatype is useless starting with version 1.27, because it's always I4. * However, this arg. is left for backward compatibility of API and to be able to read old files */ int cg_conn_read(int fn, int B, int Z, int J, cgsize_t *pnts, CGNS_ENUMT(DataType_t) donor_datatype, cgsize_t *donor_data) { cgns_conn *conn; int n, cell_dim, index_dim; cgsize_t size; #if 0 /* verify input */ if (donor_data != NULL && donor_datatype != CGNS_ENUMV(Integer)) { cgi_error("Invalid datatype requested for donor data: %d", donor_datatype); return CG_ERROR; } #endif /* Find address */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; conn = cgi_get_conn(cg, B, Z, J); if (conn==0) return CG_ERROR; cell_dim = cg->base[B-1].cell_dim; index_dim = cg->base[B-1].zone[Z-1].type == CGNS_ENUMV(Structured) ? cell_dim : 1; size = index_dim*conn->ptset.npts; /* read point-set of current zone from ADF file */ if (conn->ptset.npts > 0) { if (cgi_read_int_data(conn->ptset.id, conn->ptset.data_type, size, pnts)) return CG_ERROR; } else { cgi_warning("Interface receiver patch #%d of zone #%d, base #%d, contains no points", J, Z, B); } if (donor_data == NULL) return CG_OK; /* read donor points from ADF file - data_type may be I4, R4 or R8 */ if (conn->dptset.npts > 0) { cgns_ptset dptset = conn->dptset; index_dim = 0; for (n=0; nbase[B-1].nzones; n++) { if (strcmp(cg->base[B-1].zone[n].name,conn->donor)==0) { index_dim = cg->base[B-1].zone[n].type == CGNS_ENUMV(Structured) ? cell_dim : 1; break; } } if (index_dim == 0) { cgi_error("cg_conn_read:donor zone %s does not exist",conn->donor); return CG_ERROR; } size = index_dim*dptset.npts; if (cgi_read_int_data(conn->dptset.id, conn->dptset.data_type, size, donor_data)) return CG_ERROR; } else { cgi_warning("Interface donor patch #%d of zone #%d, base #%d, contains no points", J, Z, B); } return CG_OK; } /** * \ingroup GeneralizedConnectivity * * \brief Read generalized connectivity data without donor information * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Interface index number, where 1 ≤ J ≤ nconns. * \param[out] pnts Array of points defining the interface in the current zone. * \return \ier * */ int cg_conn_read_short(int fn, int B, int Z, int J, cgsize_t *pnts) { return cg_conn_read(fn, B, Z, J, pnts, CGNS_ENUMV(DataTypeNull), NULL); } int cg_conn_id(int fn, int B, int Z, int J, double *conn_id) { cgns_conn *conn; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; conn = cgi_get_conn(cg, B, Z, J); if (conn==0) return CG_ERROR; *conn_id = conn->id; return CG_OK; } /** * \ingroup GeneralizedConnectivity * * \brief Write generalized connectivity data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] connectname Name of the interface. * \param[in] location Grid location used in the definition of the point set. The currently * admissible locations are Vertex and CellCenter. * \param[in] connect_type Type of interface being defined. The admissible types are Overset, Abutting, * and Abutting1to1. * \param[in] ptset_type Type of point set defining the interface in the current zone; either * PointRange or PointList. * \param[in] npnts Number of points defining the interface in the current zone. For a * ptset_type of PointRange, npnts is always two. For a ptset_type of * PointList, npnts is the number of points in the PointList. * \param[in] pnts Array of points defining the interface in the current zone. * \param[in] donorname Name of the zone interfacing with the current zone. * \param[in] donor_zonetype Type of the donor zone. The admissible types are Structured and * Unstructured. * \param[in] donor_ptset_type Type of point set defining the interface in the donor zone; either * PointListDonor or CellListDonor. * \param[in] donor_datatype Data type in which the donor points are stored in the file. As of Version * 3.0, this value is ignored when writing, and on reading it will return * either Integer or LongInteger depending on whether the file was written * using 32 or 64-bit. The donor_datatype argument was left in these functions * only for backward compatibility. The donor data is always read as cgsize_t. * \param[in] ndata_donor Number of points or cells in the current zone. These are paired with points, * cells, or fractions thereof in the donor zone. * \param[in] donor_data Array of donor points or cells corresponding to ndata_donor. Note that it is * possible that the same donor point or cell may be used multiple times. * \param[out] J Interface index number, where 1 ≤ J ≤ nconns. * \return \ier * */ int cg_conn_write(int fn, int B, int Z, const char * connectname, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(GridConnectivityType_t) connect_type, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts, const char * donorname, CGNS_ENUMT(ZoneType_t) donor_zonetype, CGNS_ENUMT(PointSetType_t) donor_ptset_type, CGNS_ENUMT(DataType_t) donor_datatype, cgsize_t ndata_donor, const cgsize_t * donor_data, int *J) { cgns_zone *zone; cgns_zconn *zconn; cgns_conn *conn = NULL; cgns_ptset *dptset; int i; cgsize_t size_of_zone, length; cgsize_t PointListSize; int cell_dim; int index, index_dim, index_dim_donor; double GL_id, C_id; /* verify input */ if (cgi_check_strlen(connectname)) return CG_ERROR; if (cgi_check_strlen(donorname)) return CG_ERROR; if (INVALID_ENUM(connect_type,NofValidGridConnectivityTypes)) { cgi_error("Invalid input: GridConnectivityType=%d ?",connect_type); return CG_ERROR; } if (location != CGNS_ENUMV(Vertex) && location != CGNS_ENUMV(CellCenter) && location != CGNS_ENUMV(FaceCenter) && location != CGNS_ENUMV(IFaceCenter) && location != CGNS_ENUMV(JFaceCenter) && location != CGNS_ENUMV(KFaceCenter)) { cgi_error("Invalid input: GridLocation=%d ?",location); return CG_ERROR; } if (connect_type == CGNS_ENUMV(Overset) && location != CGNS_ENUMV(Vertex) && location != CGNS_ENUMV(CellCenter)) { cgi_error("GridLocation must be Vertex or CellCenter for Overset"); return CG_ERROR; } if (ptset_type != CGNS_ENUMV(PointList) && ptset_type != CGNS_ENUMV(PointRange)) { cgi_error("Invalid input: ptset_type=%d ?",ptset_type); return CG_ERROR; } if (!(ptset_type==CGNS_ENUMV(PointRange) && npnts==2) && !(ptset_type==CGNS_ENUMV(PointList) && npnts>0)) { cgi_error("Invalid input: npoint=%ld, point set type=%s", npnts, PointSetTypeName[ptset_type]); return CG_ERROR; } if (ndata_donor) { if (NULL == donor_data) { cgi_error("Invalid input: number of donor points given but data is NULL"); return CG_ERROR; } if (donor_ptset_type!=CGNS_ENUMV(CellListDonor) && donor_ptset_type!=CGNS_ENUMV(PointListDonor)) { cgi_error("Invalid point set type for donor %s",donorname); return CG_ERROR; } #if 0 if (donor_datatype != CGNS_ENUMV(Integer)) { cgi_error("Invalid datatype for donor %s",donorname); return CG_ERROR; } if (donor_zonetype==CGNS_ENUMV( Unstructured ) && (donor_ptset_type!=CGNS_ENUMV( CellListDonor ) && donor_ptset_type!=PointListDonor)) { cgi_error("Invalid point set type for Unstructured donor %s",donorname); return CG_ERROR; } if (donor_zonetype==CGNS_ENUMV( Unstructured ) && donor_datatype != Integer) { cgi_error("Invalid datatype for Unstructured donor %s",donorname); return CG_ERROR; } if (donor_zonetype==CGNS_ENUMV( Structured ) && donor_ptset_type!=CGNS_ENUMV( PointListDonor )) { cgi_error("Invalid point set type for Structured donor %s",donorname); return CG_ERROR; } if (donor_datatype!=CGNS_ENUMV( RealSingle ) && donor_datatype!=CGNS_ENUMV( Integer ) && donor_datatype!=CGNS_ENUMV( RealDouble )) { cgi_error("Invalid data type for donor_data: %d",donor_datatype); return CG_ERROR; } #endif } else { donor_ptset_type = CGNS_ENUMV(PointSetTypeNull); } /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address of zone */ zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; if ((location == CGNS_ENUMV(IFaceCenter) || location == CGNS_ENUMV(JFaceCenter) || location == CGNS_ENUMV(KFaceCenter)) && zone->type != CGNS_ENUMV(Structured)) { cgi_error("GridLocation [IJK]FaceCenter only valid for Structured grids"); return CG_ERROR; } /* Allocate ZoneGridConnectivity data struct. if not already created */ if (zone->nzconn == 0) { zone->nzconn = zone->active_zconn = 1; zone->zconn = CGNS_NEW(cgns_zconn, 1); strcpy(zone->zconn->name,"ZoneGridConnectivity"); } zconn = cgi_get_zconn(cg, B, Z); if (zconn == 0) return CG_ERROR; /* IndexDimension & CellDimension */ index_dim = zone->index_dim; cell_dim=cg->base[B-1].cell_dim; /* verify input */ if (location == CGNS_ENUMV( Vertex )) { size_of_zone = 1; for (i=0; inijk[i]; if (npnts<0 || npnts>size_of_zone) { cgi_error("Inconsistent number of points in point set"); return CG_ERROR; } } else if (location == CGNS_ENUMV( CellCenter )) { size_of_zone = 1; for (i=0; inijk[i+index_dim]; if (npnts<0 || npnts>size_of_zone) { cgi_error("Inconsistent number of cells in cell set"); return CG_ERROR; } } #if 0 /* causes problems when grid is unstructured */ if (ptset_type==CGNS_ENUMV( PointRange )) { if (location == CGNS_ENUMV( Vertex )) { for (i=0; izone->nijk[i]) { cgi_error("Invalid input range: %d->%d",pnts[i], pnts[i+index_dim]); return CG_ERROR; } } } else if (location == CGNS_ENUMV( CellCenter )) { for (i=0; izone->nijk[i+index_dim]) { cgi_error("Invalid input range: %d->%d",pnts[i], pnts[i+index_dim]); return CG_ERROR; } } } } #endif /* Compute PointListSize */ if (ptset_type==CGNS_ENUMV(PointRange)) { PointListSize = 1; for (i=0; inconns; index++) { if (strcmp(connectname, zconn->conn[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",connectname); return CG_ERROR; } /* overwrite an existing GridConnectivity_t Node */ /* delete the existing GridConnectivity_t Node from file */ if (cgi_delete_node(zconn->id, zconn->conn[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ conn = &(zconn->conn[index]); cgi_free_conn(conn); break; } } /* ... or add a GridConnectivity_t Node: */ if (index==zconn->nconns) { if (zconn->nconns == 0) { zconn->conn = CGNS_NEW(cgns_conn, zconn->nconns+1); } else { zconn->conn = CGNS_RENEW(cgns_conn, zconn->nconns+1, zconn->conn); } conn = &(zconn->conn[zconn->nconns]); zconn->nconns++; } (*J) = index+1; /* write conn info to internal memory */ memset(conn, 0, sizeof(cgns_conn)); strcpy(conn->name,connectname); conn->type = connect_type; conn->location = location; conn->ptset.id = 0; conn->ptset.link = 0; conn->ptset.type = ptset_type; strcpy(conn->ptset.data_type,CG_SIZE_DATATYPE); conn->ptset.npts = npnts; conn->ptset.size_of_patch = PointListSize; /* ... donor: */ strcpy(conn->donor,donorname); conn->interpolants = 0; dptset = &conn->dptset; dptset->id = 0; dptset->link = 0; strcpy(dptset->name,PointSetTypeName[donor_ptset_type]); dptset->type = donor_ptset_type; strcpy(dptset->data_type, CG_SIZE_DATATYPE); dptset->npts = ndata_donor; dptset->size_of_patch = ndata_donor; if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { /* Create node ZoneGridConnectivity_t node, if not yet created */ if (zconn->id==0) { if (cgi_new_node(zone->id, zconn->name, "ZoneGridConnectivity_t", &zconn->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(zconn->id, hid); if (hid==0) { if (cgi_new_node(zone->id, zconn->name, "ZoneGridConnectivity_t", &zconn->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } /* Create node GridConnectivity_t node */ length = (cgsize_t)strlen(conn->donor); if (cgi_new_node(zconn->id, conn->name, "GridConnectivity_t", &conn->id, "C1", 1, &length, conn->donor)) return CG_ERROR; /* Create node GridConnectivityType_t */ length = (cgsize_t)strlen(GridConnectivityTypeName[conn->type]); if (cgi_new_node(conn->id,"GridConnectivityType","GridConnectivityType_t", &C_id, "C1", 1, &length, GridConnectivityTypeName[conn->type])) return CG_ERROR; /* write GridLocation */ if (conn->location != CGNS_ENUMV( Vertex )) { length = (cgsize_t)strlen(GridLocationName[conn->location]); if (cgi_new_node(conn->id, "GridLocation", "GridLocation_t", &GL_id, "C1", 1, &length, GridLocationName[conn->location])) return CG_ERROR; } /* Write Point Sets to disk */ if (npnts>0) { char_33 PointSetName; strcpy (PointSetName, PointSetTypeName[conn->ptset.type]); if (cgi_write_ptset(conn->id, PointSetName, &conn->ptset, index_dim, (void *)pnts)) return CG_ERROR; /* Write pointset of donor */ if (ndata_donor) { if (donor_zonetype==CGNS_ENUMV(Structured)) index_dim_donor = cell_dim; else index_dim_donor=1; strcpy (PointSetName, PointSetTypeName[donor_ptset_type]); if (cgi_write_ptset(conn->id, PointSetName, dptset, index_dim_donor, (void *)donor_data)) return CG_ERROR; } } return CG_OK; } /** * \ingroup GeneralizedConnectivity * * \brief Write generalized connectivity data without donor information * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] connectname Name of the interface. * \param[in] location Grid location used in the definition of the point set. The currently * admissible locations are Vertex and CellCenter. * \param[in] connect_type Type of interface being defined. The admissible types are Overset, Abutting, * and Abutting1to1. * \param[in] ptset_type Type of point set defining the interface in the current zone; either * PointRange or PointList. * \param[in] npnts Number of points defining the interface in the current zone. For a * ptset_type of PointRange, npnts is always two. For a ptset_type of * PointList, npnts is the number of points in the PointList. * \param[in] pnts Array of points defining the interface in the current zone. * \param[in] donorname Name of the zone interfacing with the current zone. * \param[out] J Interface index number, where 1 ≤ J ≤ nconns. * \return \ier * */ int cg_conn_write_short(int fn, int B, int Z, const char * connectname, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(GridConnectivityType_t) connect_type, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts, const char * donorname, int *J) { return cg_conn_write (fn, B, Z, connectname, location, connect_type, ptset_type, npnts, pnts, donorname, CGNS_ENUMV(ZoneTypeNull), CGNS_ENUMV(PointSetTypeNull), CGNS_ENUMV(DataTypeNull), 0, NULL, J); } /*****************************************************************************\ * Read and write GridConnectivity1to1_t Nodes \*****************************************************************************/ /** * \ingroup OneToOneConnectivity * * \brief Get number of 1-to-1 interfaces in a zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] n1to1 Number of one-to-one interfaces in zone Z, stored under * GridConnectivity1to1_t nodes. (I.e., this does not include one-to-one * interfaces that may be stored under GridConnectivity_t nodes, used for * generalized zone interfaces.) * \return \ier * */ int cg_n1to1(int fn, int B, int Z, int *n1to1) { cgns_zconn *zconn; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zconn = cgi_get_zconn(cg, B, Z); if (zconn==0) *n1to1 = 0; /* if ZoneGridConnectivity_t is undefined */ else *n1to1 = zconn->n1to1; return CG_OK; } /** * \ingroup OneToOneConnectivity * * \brief Get total number of 1-to-1 interfaces in a database * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] n1to1_global Total number of one-to-one interfaces in base B, stored under * GridConnectivity1to1_t nodes. (I.e., this does not include one-to-one * interfaces that may be stored under GridConnectivity_t nodes, used for * generalized zone interfaces.) Note that the function cg_n1to1 (described * below) may be used to get the number of one-to-one interfaces in a specific * zone. * \return \ier * */ int cg_n1to1_global(int fn, int B, int *n1to1_global) { cgns_base *base; cgns_zone *zone; cgns_zconn *zconn; int Z, J, D; cgint3_t transform; cgsize_t donor_range[6], range[6]; char_33 connectname, donorname; /* added for zones interfacing themselves (C-topology) */ int ndouble=0; char_33 *Dzonename = 0; cgsize6_t *Drange = 0, *Ddonor_range = 0; int index_dim; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; *n1to1_global = 0; for (Z=1; Z<=base->nzones; Z++) { zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; index_dim = zone->index_dim; zconn = cgi_get_zconn(cg, B, Z); if (zconn==0) continue; /* if ZoneGridConnectivity_t is undefined */ if (zconn->n1to1 ==0) continue; for (J=1; J<=zconn->n1to1; J++) { if (cg_1to1_read(fn, B, Z, J, connectname, donorname, range, donor_range, transform)) return CG_ERROR; if (cgi_zone_no(base, donorname, &D)) return CG_ERROR; /* count each interface only once */ if (Zname, range, donor_range, index_dim, &ndouble, &Dzonename, &Drange, &Ddonor_range)) { (*n1to1_global)++; } } } /* loop through interfaces of a zone */ } /* loop through zones */ if (Dzonename) free(Dzonename); if (Drange) free(Drange); if (Ddonor_range) free(Ddonor_range); return CG_OK; } /** * \ingroup OneToOneConnectivity * * \brief Read 1-to-1 connectivity data for a zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Interface index number, where 1 ≤ J ≤ n1to1. * \param[out] connectname Name of the interface. * \param[out] donorname Name of the zone interfacing with the current zone. * \param[out] range Range of points for the current zone. * \param[out] donor_range Range of points for the donor zone. * \param[out] transform Shorthand notation for the transformation matrix defining the relative * orientation of the two zones. * \return \ier * */ int cg_1to1_read(int fn, int B, int Z, int J, char *connectname, char *donorname, cgsize_t *range, cgsize_t *donor_range, int *transform) { cgns_1to1 *one21; int i, index_dim; /* in 2D, range[0], range[1] = imin, jmin range[2], range[3] = imax, jmax in 3D, range[0], range[1], range[2] = imin, jmin, kmin range[3], range[4], range[5] = imax, jmax, kmax */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; one21 = cgi_get_1to1(cg, B, Z, J); if (one21==0) return CG_ERROR; index_dim = cg->base[B-1].zone[Z-1].index_dim; /* read pointset from ADF file */ if (one21->ptset.npts > 0) { if (cgi_read_int_data(one21->ptset.id, one21->ptset.data_type, one21->ptset.npts * index_dim, range)) return CG_ERROR; } else { cgi_warning("1to1 interface %d (receiver side) for zone %d base % is undefined", J,Z,B); } /* read donor pointset from ADF file */ if (one21->dptset.npts > 0) { if (cgi_read_int_data(one21->dptset.id, one21->dptset.data_type, one21->dptset.npts * index_dim, donor_range)) return CG_ERROR; } else { cgi_warning("1to1 interface %d (donor side) for zone %d base % is undefined", J,Z,B); } /* read transform from internal database */ for (i=0; itransform[i]; strcpy(connectname, one21->name); strcpy(donorname, one21->donor); return CG_OK; } /** * \ingroup OneToOneConnectivity * * \brief Read data for all 1-to-1 interfaces in a database * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] connectname Name of the interface. * \param[out] zonename Name of the first zone, for all one-to-one interfaces in base B. * \param[out] donorname Name of the second zone, for all one-to-one interfaces in base B. * \param[out] range Range of points for the first zone, for all one-to-one interfaces in base B. * \param[out] donor_range Range of points for the current zone, for all one-to-one interfaces in base B. * \param[out] transform Shorthand notation for the transformation matrix defining the relative * orientation of the two zones. This transformation is given for all * one-to-one interfaces in base B. * \return \ier * */ int cg_1to1_read_global(int fn, int B, char **connectname, char **zonename, char **donorname, cgsize_t **range, cgsize_t **donor_range, int **transform) { cgns_base *base; cgns_zone *zone; cgns_zconn *zconn; int Z, J, D, n=0, k, index_dim; char connect[33], donor[33]; cgsize_t rang[6], drang[6]; int trans[3]; /* added for zones interfacing themselves (C-topology) */ int ndouble=0; char_33 *Dzonename = 0; cgsize6_t *Drange = 0, *Ddonor_range = 0; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; for (Z=1; Z<=base->nzones; Z++) { zone = cgi_get_zone(cg, B, Z); if (zone->type==CGNS_ENUMV( Unstructured )) { cgi_error("GridConnectivity1to1 is only applicable to structured zones."); return CG_ERROR; } index_dim = zone->index_dim; zconn = cgi_get_zconn(cg, B, Z); if (zconn==0) continue; /* if ZoneGridConnectivity_t is undefined */ if (zconn->n1to1 ==0) continue; for (J=1; J<=zconn->n1to1; J++) { if (cg_1to1_read(fn, B, Z, J, connect, donor, rang, drang, trans)) return CG_ERROR; if (cgi_zone_no(base, donor, &D)) return CG_ERROR; /* count each interface only once */ if (Zname, rang, drang, index_dim, &ndouble, &Dzonename, &Drange, &Ddonor_range))) { strcpy(connectname[n], connect); strcpy(zonename[n],zone->name); strcpy(donorname[n], donor); for (k=0; kfilename, cg->mode, CG_MODE_READ)) return CG_ERROR; one21 = cgi_get_1to1(cg, B, Z, J); if (one21==0) return CG_ERROR; *one21_id = one21->id; return CG_OK; } /** * \ingroup OneToOneConnectivity * * \brief Write 1-to-1 connectivity data for a zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] connectname Name of the interface. * \param[in] donorname Name of the zone interfacing with the current zone. * \param[in] range Range of points for the current zone. * \param[in] donor_range Range of points for the donor zone. * \param[in] transform Shorthand notation for the transformation matrix defining the relative * orientation of the two zones. * \param[out] J Interface index number, where 1 ≤ J ≤ n1to1. * \return \ier * */ int cg_1to1_write(int fn, int B, int Z, const char * connectname, const char * donorname, const cgsize_t * range, const cgsize_t * donor_range, const int * transform, int *J) { cgns_zone *zone; cgns_zconn *zconn; cgns_1to1 *one21 = NULL; int index, i, j; cgsize_t index_dim, length; double T_id; /* verify input */ if (cgi_check_strlen(connectname)) return CG_ERROR; #ifdef CG_BUILD_BASESCOPE if (cgi_check_strlen_x2(donorname)) return CG_ERROR; #else if (cgi_check_strlen(donorname)) return CG_ERROR; #endif /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address of zone */ zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* Allocate ZoneGridConnectivity data struct. if not already created */ if (zone->nzconn == 0) { zone->nzconn = zone->active_zconn = 1; zone->zconn = CGNS_NEW(cgns_zconn, 1); strcpy(zone->zconn->name,"ZoneGridConnectivity"); } zconn = cgi_get_zconn(cg, B, Z); if (zconn == 0) return CG_ERROR; /* verify input */ index_dim = zone->index_dim; for (i=0; izone->nijk[i]) { cgi_error("Invalid input range: %ld->%ld",range[i], range[i+index_dim]); return CG_ERROR; } if (abs(transform[i])>index_dim) { cgi_error("Invalid transformation index: %d. The indices must all be between 1 and %ld",i, index_dim); return CG_ERROR; } if (transform[i] != 0) { cgsize_t dr, ddr; j = abs(transform[i])-1; dr = range[i+index_dim] - range[i]; ddr = donor_range[j+index_dim] - donor_range[j]; if (dr != ddr && dr != -ddr) { cgi_error("Invalid input: range = %ld->%ld and donor_range = %ld->%ld", range[i], range[i+index_dim], donor_range[j], donor_range[j+index_dim]); return CG_ERROR; } } } /* Overwrite a GridConnectivity1to1_t Node: */ for (index=0; indexn1to1; index++) { if (strcmp(connectname, zconn->one21[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",connectname); return CG_ERROR; } /* overwrite an existing GridConnectivity1to1_t Node */ /* delete the existing GridConnectivity1to1_t Node from file */ if (cgi_delete_node(zconn->id, zconn->one21[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ one21 = &(zconn->one21[index]); /* free memory */ cgi_free_1to1(one21); break; } } /* ... or add a GridConnectivity1to1_t Node: */ if (index==zconn->n1to1) { if (zconn->n1to1 == 0) { zconn->one21 = CGNS_NEW(cgns_1to1, zconn->n1to1+1); } else { zconn->one21 = CGNS_RENEW(cgns_1to1, zconn->n1to1+1, zconn->one21); } one21 = &(zconn->one21[zconn->n1to1]); zconn->n1to1++; } (*J) = index+1; memset(one21, 0, sizeof(cgns_1to1)); /* allocate memory */ if ((one21->transform = (int *)malloc((size_t)(index_dim*sizeof(int))))==NULL) { cgi_error("Error allocating memory in cg_1to1_write"); return CG_ERROR; } /* write 1to1 info to internal memory */ strcpy(one21->name,connectname); one21->ptset.type = CGNS_ENUMV(PointRange); strcpy(one21->ptset.data_type,CG_SIZE_DATATYPE); one21->ptset.npts = 2; /* ... donor: */ strcpy(one21->donor,donorname); one21->dptset.type = CGNS_ENUMV(PointRangeDonor); strcpy(one21->dptset.data_type,CG_SIZE_DATATYPE); one21->dptset.npts = 2; /* ... transform: */ memcpy((void *)one21->transform, (void *)transform, (size_t)(index_dim*sizeof(int))); /* Create node ZoneGridConnectivity_t node, if not yet created */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (zconn->id==0) { if (cgi_new_node(zone->id, zconn->name, "ZoneGridConnectivity_t", &zconn->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(zconn->id, hid); if (hid==0) { if (cgi_new_node(zone->id, zconn->name, "ZoneGridConnectivity_t", &zconn->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } /* Create the node */ length = (cgsize_t)strlen(one21->donor); if (cgi_new_node(zconn->id, one21->name, "GridConnectivity1to1_t", &one21->id, "C1", 1, &length, one21->donor)) return CG_ERROR; /* Create transform node */ if (cgi_new_node(one21->id, "Transform", "\"int[IndexDimension]\"", &T_id, "I4", 1, &index_dim, (void *)one21->transform)) return CG_ERROR; /* Create RECEIVER Point Set node on disk */ if (cgi_write_ptset(one21->id, "PointRange", &one21->ptset, (int)index_dim, (void *)range)) return CG_ERROR; /* Create DONOR Point Set node on disk */ if (cgi_write_ptset(one21->id, "PointRangeDonor", &one21->dptset, (int)index_dim, (void *)donor_range)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and write BC_t Nodes \*****************************************************************************/ /** * \ingroup BoundaryConditionType * * \brief Get the number of boundary conditions in the zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] nbocos Number of boundary conditions in zone Z. * \return \ier * */ int cg_nbocos(int fn, int B, int Z, int *nbocos) { cgns_zboco *zboco; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zboco = cgi_get_zboco(cg, B, Z); if (zboco==0) *nbocos = 0; /* if ZoneBC_t is undefined */ else *nbocos = zboco->nbocos; return CG_OK; } /** * \ingroup BoundaryConditionType * * \brief Get boundary condition info * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[out] boconame Name of the boundary condition. * \param[out] bocotype Type of boundary condition defined. See the eligible types for BCType_t in * the Typedefs section. Note that if \p bocotype is FamilySpecified the boundary * condition type is being specified for the family to which the boundary * belongs. The boundary condition type for the family may be read and written * using cg_fambc_read() and cg_fambc_write(). * \param[out] ptset_type The extent of the boundary condition may be defined using a range of points * or elements using \e PointRange, or using a discrete list of all points or * elements at which the boundary condition is applied using \e PointList. When * the boundary condition is to be applied anywhere other than points, then * GridLocation_t under the BC_t node must be used to indicate this. The value * of GridLocation_t may be read or written by cg_boco_gridlocation_read() and * cg_boco_gridlocation_write(). As in previous versions of the library, this may * also be done by first using cg_goto() to access the BC_t node, then using * cg_gridlocation_read() or cg_gridlocation_write(). * \param[out] npnts Number of points or elements defining the boundary condition region. For a * ptset_type of PointRange, \p npnts is always two. For a ptset_type of * PointList, npnts is the number of points or elements in the list. * \param[out] NormalIndex Index vector indicating the computational coordinate direction of the * boundary condition patch normal. * \param[out] NormalListSize If the normals are defined in NormalList, NormalListSize is the number of * points in the patch times phys_dim, the number of coordinates required to * define a vector in the field. If the normals are not defined in NormalList, * NormalListSize is 0. * \param[out] NormalDataType Data type used in defining the normals. Admissible data types for * the normals are \e RealSingle and \e RealDouble. * \param[out] ndataset Number of boundary condition datasets for the current boundary condition. * \return \ier * */ int cg_boco_info(int fn, int B, int Z, int BC, char *boconame, CGNS_ENUMT(BCType_t) *bocotype, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, int *NormalIndex, cgsize_t *NormalListSize, CGNS_ENUMT(DataType_t) *NormalDataType, int *ndataset) { cgns_boco *boco; int n, index_dim; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_ERROR; strcpy(boconame,boco->name); *bocotype = boco->type; if (boco->ptset) { *ptset_type = boco->ptset->type; *npnts = boco->ptset->npts; } else { *ptset_type = CGNS_ENUMV(PointSetTypeNull); *npnts = 0; } index_dim = cg->base[B-1].zone[Z-1].index_dim; if (NormalIndex) { if (boco->Nindex) { for (n=0; nNindex[n]; } else { for (n=0; nnormal && boco->ptset) { *NormalListSize = boco->ptset->size_of_patch*cg->base[B-1].phys_dim; *NormalDataType = cgi_datatype(boco->normal->data_type); } else { *NormalListSize = 0; *NormalDataType = CGNS_ENUMV(DataTypeNull); } *ndataset = boco->ndataset; return CG_OK; } /** * \ingroup BoundaryConditionType * * \brief Read boundary condition data and normals * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[out] pnts Array of point or element indices defining the boundary condition region. * There should be npnts values, each of dimension IndexDimension (i.e., 1 for * unstructured grids, and 2 or 3 for structured grids with 2-D or 3-D * elements, respectively). * \param[out] NormalList List of vectors normal to the boundary condition patch pointing into the * interior of the zone. * \return \ier * */ int cg_boco_read(int fn, int B, int Z, int BC, cgsize_t *pnts, void *NormalList) { cgns_boco *boco; int dim = 0; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_ERROR; /* Read point-set directly from ADF-file */ if (boco->ptset && boco->ptset->npts > 0) { cg_index_dim(fn, B, Z, &dim); if (cgi_read_int_data(boco->ptset->id, boco->ptset->data_type, boco->ptset->npts * dim, pnts)) return CG_ERROR; } else { cgi_warning("B.C. patch %d of zone %d base %d is undefined", BC, Z, B); } /* if it exists, read NormalList */ dim = cg->base[B-1].phys_dim; if (NormalList && boco->normal && boco->ptset && boco->ptset->npts>0) { memcpy(NormalList, boco->normal->data, ((size_t)(boco->ptset->size_of_patch*dim))*size_of(boco->normal->data_type)); } return CG_OK; } int cg_boco_id(int fn, int B, int Z, int BC, double *boco_id) { cgns_boco *boco; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_ERROR; *boco_id = boco->id; return CG_OK; } /** * \ingroup BoundaryConditionType * * \brief Read boundary condition location * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[out] location Grid location used in the definition of the point set. The currently * admissible locations are Vertex (the default if not given), and CellCenter. * Interpretation of CellCenter, and additional allowable values of grid * location depends on the base cell dimension. For CellDim=1, CellCenter * refers to line elements. For CellDim=2, CellCenter refers to area elements, * and the additional value EdgeCenter is allowed. For CellDim=3, CellCenter * refers to volume elements, and in addition to EdgeCenter, the values of * FaceCenter, IFaceCenter, JFaceCenter, and KFaceCenter may be used. * \return \ier * */ int cg_boco_gridlocation_read(int fn, int B, int Z, int BC, CGNS_ENUMT(GridLocation_t) *location) { cgns_boco *boco; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_ERROR; *location = boco->location; return CG_OK; } /** * \ingroup BoundaryConditionType * * \brief Write boundary condition type and data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] boconame Name of the boundary condition. * \param[in] bocotype Type of boundary condition defined. See the eligible types for BCType_t in * the Typedefs section. Note that if bocotype is FamilySpecified the boundary * condition type is being specified for the family to which the boundary * belongs. The boundary condition type for the family may be read and written * using cg_fambc_read() and cg_fambc_write(). * \param[in] ptset_type The extent of the boundary condition may be defined using a range of points * or elements using PointRange, or using a discrete list of all points or * elements at which the boundary condition is applied using PointList. When * the boundary condition is to be applied anywhere other than points, then * GridLocation_t under the BC_t node must be used to indicate this. The value * of GridLocation_t may be read or written by cg_boco_gridlocation_read() and * cg_boco_gridlocation_write(). As in previous versions of the library, this may * also be done by first using cg_goto() to access the BC_t node, then using * cg_gridlocation_read() or cg_gridlocation_write(). * \param[in] npnts Number of points or elements defining the boundary condition region. For a * ptset_type of PointRange, \p npnts is always two. For a ptset_type of * PointList, npnts is the number of points or elements in the list. * \param[in] pnts Array of point or element indices defining the boundary condition region. * There should be \p npnts values, each of dimension IndexDimension (i.e., 1 for * unstructured grids, and 2 or 3 for structured grids with 2-D or 3-D * elements, respectively). * \param[out] BC \BC * \return \ier * */ int cg_boco_write(int fn, int B, int Z, const char * boconame, CGNS_ENUMT(BCType_t) bocotype, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts, int *BC) { cgns_zone *zone; cgns_zboco *zboco; cgns_boco *boco = NULL; int index, i, index_dim; CGNS_ENUMT(PointSetType_t) ptype; CGNS_ENUMT(GridLocation_t) location; cgsize_t length; /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address of zone */ zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* verify input */ if (cgi_check_strlen(boconame)) return CG_ERROR; ptype = ptset_type; location = CGNS_ENUMV(Vertex); if (ptset_type == CGNS_ENUMV(ElementList) || ptset_type == CGNS_ENUMV(ElementRange)) { if (cg->filetype != CG_FILE_ADF2) { if (ptset_type == CGNS_ENUMV(ElementList)) ptype = CGNS_ENUMV(PointList); else ptype = CGNS_ENUMV(PointRange); if (cg->base[B-1].cell_dim == 1) location = CGNS_ENUMV(Vertex); else if (cg->base[B-1].cell_dim == 2) location = CGNS_ENUMV(EdgeCenter); else location = CGNS_ENUMV(FaceCenter); } } else { if (ptset_type != CGNS_ENUMV(PointList) && ptset_type != CGNS_ENUMV(PointRange)) { cgi_error("Invalid point set type: %d...?",ptset_type); return CG_ERROR; } } if (((ptype == CGNS_ENUMV(PointList) || ptype == CGNS_ENUMV(ElementList)) && npnts <= 0) || ((ptype == CGNS_ENUMV(PointRange) || ptype == CGNS_ENUMV(ElementRange)) && npnts != 2)) { cgi_error("Invalid input: npoint=%ld, point set type=%s", npnts, PointSetTypeName[ptype]); return CG_ERROR; } if (INVALID_ENUM(bocotype,NofValidBCTypes)) { cgi_error("Invalid BCType: %d",bocotype); return CG_ERROR; } if (cgi_check_location(cg->base[B-1].cell_dim, cg->base[B-1].zone[Z-1].type, location)) return CG_ERROR; #ifdef CG_FIX_BC_CELL_CENTER if (location == CGNS_ENUMV(CellCenter)) { cgi_error("GridLocation CellCenter not valid - use Edge/FaceCenter"); return CG_ERROR; } #endif /* Allocate ZoneBC data struct. if not already created */ if (zone->zboco == 0) { zone->zboco = CGNS_NEW(cgns_zboco, 1); zboco = zone->zboco; strcpy(zboco->name,"ZoneBC"); } else zboco = zone->zboco; /* Overwrite a BC_t Node: */ for (index=0; indexnbocos; index++) { if (strcmp(boconame, zboco->boco[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",boconame); return CG_ERROR; } /* overwrite an existing BC_t Node */ /* delete the existing BC_t Node from file */ if (cgi_delete_node(zboco->id, zboco->boco[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ boco = &(zboco->boco[index]); cgi_free_boco(boco); break; } } /* ... or add a BC_t Node: */ if (index==zboco->nbocos) { if (zboco->nbocos == 0) { zboco->boco = CGNS_NEW(cgns_boco, zboco->nbocos+1); } else { zboco->boco = CGNS_RENEW(cgns_boco, zboco->nbocos+1, zboco->boco); } boco = &(zboco->boco[zboco->nbocos]); zboco->nbocos++; } (*BC) = index+1; /* write boco info to internal memory */ memset(boco, 0, sizeof(cgns_boco)); strcpy(boco->name, boconame); boco->type = bocotype; boco->location = location; boco->ptset = CGNS_NEW(cgns_ptset,1); boco->ptset->type = ptype; strcpy(boco->ptset->name, PointSetTypeName[boco->ptset->type]); strcpy(boco->ptset->data_type,CG_SIZE_DATATYPE); boco->ptset->npts = npnts; /* Record the number of nodes or elements in the point set */ index_dim = zone->index_dim; if (boco->ptset->type == CGNS_ENUMV(PointList)) boco->ptset->size_of_patch=npnts; else { boco->ptset->size_of_patch = 1; for (i=0; iptset->size_of_patch = boco->ptset->size_of_patch * (pnts[i+index_dim]-pnts[i]+1); } /* Create ZoneBC_t node if it doesn't yet exist */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (zboco->id==0) { if (cgi_new_node(zone->id, "ZoneBC", "ZoneBC_t", &zboco->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(zboco->id, hid); if (hid==0) { if (cgi_new_node(zone->id, "ZoneBC", "ZoneBC_t", &zboco->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } /* Create the BC_t Node */ length = (cgsize_t)strlen(BCTypeName[boco->type]); if (cgi_new_node(zboco->id, boco->name, "BC_t", &boco->id, "C1", 1, &length, BCTypeName[boco->type])) return CG_ERROR; /* Save Point-Set on Disk */ if (npnts > 0) { if (cgi_write_ptset(boco->id, boco->ptset->name, boco->ptset, index_dim, (void *)pnts)) return CG_ERROR; } if (boco->location != CGNS_ENUMV(Vertex)) { double dummy_id; length = (cgsize_t)strlen(GridLocationName[boco->location]); if (cgi_new_node(boco->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &length, GridLocationName[boco->location])) return CG_ERROR; } return CG_OK; } /** * \ingroup BoundaryConditionType * * \brief Write boundary condition location * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[in] location Grid location used in the definition of the point set. The currently * admissible locations are Vertex (the default if not given), and CellCenter. * Interpretation of CellCenter, and additional allowable values of grid * location depends on the base cell dimension. For CellDim=1, CellCenter * refers to line elements. For CellDim=2, CellCenter refers to area elements, * and the additional value EdgeCenter is allowed. For CellDim=3, CellCenter * refers to volume elements, and in addition to EdgeCenter, the values of * FaceCenter, IFaceCenter, JFaceCenter, and KFaceCenter may be used. * \return \ier * */ int cg_boco_gridlocation_write(int fn, int B, int Z, int BC, CGNS_ENUMT(GridLocation_t) location) { cgns_boco *boco; cgsize_t dim_vals; double dummy_id; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_ERROR; if (cgi_check_location(cg->base[B-1].cell_dim, cg->base[B-1].zone[Z-1].type, location)) return CG_ERROR; #ifdef CG_FIX_BC_CELL_CENTER if (location == CGNS_ENUMV(CellCenter)) { cgi_error("GridLocation CellCenter not valid - use Edge/FaceCenter"); return CG_ERROR; } #endif boco->location = location; dim_vals = (cgsize_t)strlen(GridLocationName[location]); if (cgi_new_node(boco->id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[location])) return CG_ERROR; return CG_OK; } /** * \ingroup BoundaryConditionType * * \brief Write boundary condition normals * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[in] NormalIndex Index vector indicating the computational coordinate direction of the * boundary condition patch normal. * \param[in] NormalListFlag Flag indicating if the normals are defined in NormalList and are to be * written out; 1 if they are defined, 0 if they're not. * \param[in] NormalDataType Data type used in defining the normals. Admissible data types for * the normals are RealSingle and RealDouble. * \param[in] NormalList List of vectors normal to the boundary condition patch pointing into the * interior of the zone. * \return \ier * */ int cg_boco_normal_write(int fn, int B, int Z, int BC, const int * NormalIndex, int NormalListFlag, CGNS_ENUMT(DataType_t) NormalDataType, const void * NormalList) { cgns_boco *boco; int n, phys_dim; cgsize_t npnts, index_dim; /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_ERROR; npnts = boco->ptset->size_of_patch; phys_dim=cg->base[B-1].phys_dim; if (NormalListFlag && npnts) { cgns_array *normal; if (boco->normal) { if (cg->mode==CG_MODE_WRITE) { cgi_error("InwardNormalList is already defined under BC_t '%s'", boco->name); return CG_ERROR; } if (cgi_delete_node(boco->id, boco->normal->id)) return CG_ERROR; cgi_free_array(boco->normal); memset(boco->normal, 0, sizeof(cgns_array)); } else { boco->normal = CGNS_NEW(cgns_array, 1); } normal = boco->normal; strcpy(normal->data_type, cgi_adf_datatype(NormalDataType)); normal->data = (void *)malloc(((size_t)(npnts*phys_dim))*size_of(normal->data_type)); if (normal->data == NULL) { cgi_error("Error allocating normal->data"); return CG_ERROR; } memcpy(normal->data, NormalList, ((size_t)(npnts*phys_dim))*size_of(normal->data_type)); strcpy(normal->name, "InwardNormalList"); normal->data_dim =2; normal->dim_vals[0]=phys_dim; normal->dim_vals[1]=npnts; if (cgi_new_node(boco->id, "InwardNormalList", "IndexArray_t", &normal->id, normal->data_type, 2, normal->dim_vals, (void *)normal->data)) return CG_ERROR; } if (boco->Nindex) { if (cg->mode==CG_MODE_WRITE) { cgi_error("InwardNormalIndex is already defined under BC_t '%s'", boco->name); return CG_ERROR; } else { if (cgi_delete_node(boco->id, boco->index_id)) return CG_ERROR; free(boco->Nindex); boco->Nindex = 0; } } if (NormalIndex && cg->base[B-1].zone[Z-1].type == CGNS_ENUMV( Structured )) { index_dim=cg->base[B-1].zone[Z-1].index_dim; boco->Nindex = CGNS_NEW(int, index_dim); for (n=0; nNindex[n]=NormalIndex[n]; if (cgi_new_node(boco->id, "InwardNormalIndex", "\"int[IndexDimension]\"", &boco->index_id, "I4", 1, &index_dim, (void *)NormalIndex)) return CG_ERROR; } return CG_OK; } /*****************************************************************************\ * Read and write BCDataSet_t Nodes \*****************************************************************************/ /** * \ingroup BoundaryConditionDatasets * * \brief Read boundary condition dataset info * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[in] DSet \DSet * \param[out] DatasetName Name of dataset. * \param[out] BCType Simple boundary condition type for the dataset. The supported types are * listed in the table of Simple Boundary Condition Types in the SIDS manual, * but note that FamilySpecified does not apply here. * \param[out] DirichletFlag Flag indicating if the dataset contains Dirichlet data. * \param[out] NeumannFlag Flag indicating if the dataset contains Neumann data. * \return \ier * */ int cg_dataset_read(int fn, int B, int Z, int BC, int DSet, char *DatasetName, CGNS_ENUMT(BCType_t) *BCType, int *DirichletFlag, int *NeumannFlag) { cgns_dataset *dataset; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; dataset = cgi_get_dataset(cg, B, Z, BC, DSet); if (dataset==0) return CG_ERROR; strcpy(DatasetName, dataset->name); *BCType = dataset->type; if (dataset->dirichlet) *DirichletFlag=1; else *DirichletFlag=0; if (dataset->neumann) *NeumannFlag=1; else *NeumannFlag=0; return CG_OK; } /** * \ingroup BoundaryConditionDatasets * * \brief Write boundary condition dataset info * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[in] DatasetName Name of dataset. * \param[in] BCType Simple boundary condition type for the dataset. The supported types are * listed in the table of Simple Boundary Condition Types in the SIDS manual, * but note that FamilySpecified does not apply here. * \param[out] Dset \DSet * \return \ier * */ int cg_dataset_write(int fn, int B, int Z, int BC, const char * DatasetName, CGNS_ENUMT( BCType_t ) BCType, int *Dset) { cgns_boco *boco; cgns_dataset *dataset = NULL; int index; cgsize_t length; /* verify input */ if (INVALID_ENUM(BCType,NofValidBCTypes)) { cgi_error("Invalid BCType: %d",BCType); return CG_ERROR; } if (cgi_check_strlen(DatasetName)) return CG_ERROR; /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_ERROR; /* Overwrite a BCDataSet_t node : */ for (index=0; indexndataset; index++) { if (strcmp(DatasetName, boco->dataset[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",DatasetName); return CG_ERROR; } /* overwrite an existing solution */ /* delete the existing dataset from file */ if (cgi_delete_node(boco->id, boco->dataset[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ dataset = &(boco->dataset[index]); /* free memory */ cgi_free_dataset(dataset); break; } } /* ... or add a BCDataSet_t Node: */ if (index==boco->ndataset) { if (boco->ndataset == 0) boco->dataset = CGNS_NEW(cgns_dataset, boco->ndataset+1); else boco->dataset= CGNS_RENEW(cgns_dataset, boco->ndataset+1, boco->dataset); dataset= &boco->dataset[boco->ndataset]; boco->ndataset++; } (*Dset) = index+1; /* save data in memory */ memset(dataset, 0, sizeof(cgns_dataset)); dataset->type = BCType; strcpy(dataset->name, DatasetName); dataset->location = CGNS_ENUMV(Vertex); /* save data in file */ length = (cgsize_t)strlen(BCTypeName[dataset->type]); if (cgi_new_node(boco->id, dataset->name, "BCDataSet_t", &dataset->id, "C1", 1, &length, (void *)BCTypeName[dataset->type])) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * write BCdata_t Nodes \*****************************************************************************/ /** * \ingroup BCData * * \brief Write boundary condition data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[in] Dset \DSet * \param[in] BCDataType Type of boundary condition in the dataset. Admissible boundary condition * types are \e Dirichlet and \e Neumann. * \return \ier * * \details To write the boundary condition data itself, after creating the BCData_t node using * the function cg_bcdata_write(), use cg_goto() to access the node, then cg_array_write() to * write the data. Note that when using cg_goto() to access a BCData_t node, the node index * should be specified as either Dirichlet or Neumann, depending on the type of boundary * condition. See the description of cg_goto() for details. * */ int cg_bcdata_write(int fn, int B, int Z, int BC, int Dset, CGNS_ENUMT(BCDataType_t) BCDataType) { cgns_dataset *dataset; cgns_bcdata *bcdata; /* verify input */ if (INVALID_ENUM(BCDataType,NofValidBCDataTypes)) { cgi_error("BCDataType %d not valid",BCDataType); return CG_ERROR; } /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; dataset = cgi_get_dataset(cg, B, Z, BC, Dset); if (dataset==0) return CG_ERROR; if (BCDataType==CGNS_ENUMV( Dirichlet )) { if (dataset->dirichlet) { if (cg->mode == CG_MODE_WRITE) { cgi_error("Dirichlet data already defined under BCDataSet_t '%s'", dataset->name); return CG_ERROR; } if (cgi_delete_node(dataset->id, dataset->dirichlet->id)) return CG_ERROR; cgi_free_bcdata(dataset->dirichlet); memset(dataset->dirichlet, 0, sizeof(cgns_bcdata)); } else { dataset->dirichlet = CGNS_NEW(cgns_bcdata,1); } strcpy(dataset->dirichlet->name, "DirichletData"); bcdata = dataset->dirichlet; } else { if (dataset->neumann) { if (cg->mode == CG_MODE_WRITE) { cgi_error("Neumann data already defined under BCDataSet_t '%s'", dataset->name); return CG_ERROR; } if (cgi_delete_node(dataset->id, dataset->neumann->id)) return CG_ERROR; cgi_free_bcdata(dataset->neumann); memset(dataset->neumann, 0, sizeof(cgns_bcdata)); } else { dataset->neumann = CGNS_NEW(cgns_bcdata,1); } strcpy(dataset->neumann->name, "NeumannData"); bcdata = dataset->neumann; } if (cgi_new_node(dataset->id, bcdata->name, "BCData_t", &bcdata->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and write RigidGridMotion_t Nodes \*****************************************************************************/ /** * \ingroup RigidGridMotion * * \brief Get the number of RigidGridMotion_t nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] n_rigid_motions Number of RigidGridMotion_t nodes under zone Z. * \return \ier * */ int cg_n_rigid_motions(int fn, int B, int Z, int *n_rigid_motions) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; *n_rigid_motions = zone->nrmotions; return CG_OK; } /** * \ingroup RigidGridMotion * * \brief Read RigidGridMotion_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] R Rigid rotation index number, where 1 ≤ R ≤ n_rigid_motions. * \param[out] name Name of the RigidGridMotion_t node. * \param[out] type Type of rigid grid motion. The admissible types are CG_Null, CG_UserDefined, * ConstantRate, and VariableRate. * \return \ier * */ int cg_rigid_motion_read(int fn, int B, int Z, int R, char *name, CGNS_ENUMT(RigidGridMotionType_t) *type) { cgns_rmotion *rmotion; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; rmotion = cgi_get_rmotion(cg, B, Z, R); if (rmotion==0) return CG_ERROR; strcpy(name, rmotion->name); *type = rmotion->type; return CG_OK; } /** * \ingroup RigidGridMotion * * \brief Create RigidGridMotion_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] rmotionname Name of the RigidGridMotion_t node. * \param[in] type Type of rigid grid motion. The admissible types are \e CG_Null, \e CG_UserDefined, * \e ConstantRate, and \e VariableRate. * \param[out] R Rigid rotation index number, where 1 ≤ R ≤ n_rigid_motions. * \return \ier * */ int cg_rigid_motion_write(int fn, int B, int Z, const char * rmotionname, CGNS_ENUMT(RigidGridMotionType_t) type, int *R) { cgns_zone *zone; cgns_rmotion *rmotion = NULL; int index; cgsize_t length; /* verify input */ if (cgi_check_strlen(rmotionname)) return CG_ERROR; if (INVALID_ENUM(type,NofValidRigidGridMotionTypes)) { cgi_error("Invalid input: RigidGridMotionType=%d ?",type); return CG_ERROR; } /* get memory address for RigidGridMotion_t node */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* Overwrite a RigidGridMotion_t Node: */ for (index=0; indexnrmotions; index++) { if (strcmp(rmotionname, zone->rmotion[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",rmotionname); return CG_ERROR; } /* overwrite an existing rmotion */ /* delete the existing rmotion from file */ if (cgi_delete_node(zone->id, zone->rmotion[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ rmotion = &(zone->rmotion[index]); /* free memory */ cgi_free_rmotion(rmotion); break; } } /* ... or add a new RigidGridMotion_t Node: */ if (index==zone->nrmotions) { if (zone->nrmotions == 0) { zone->rmotion = CGNS_NEW(cgns_rmotion, 1); } else { zone->rmotion = CGNS_RENEW(cgns_rmotion, zone->nrmotions+1, zone->rmotion); } rmotion = &(zone->rmotion[zone->nrmotions]); zone->nrmotions++; } (*R) = index+1; /* save data for cgns_rmotion *rmotion */ memset(rmotion, 0, sizeof(cgns_rmotion)); strcpy(rmotion->name,rmotionname); rmotion->type = type; /* Create node RigidGridMotion_t */ length = (cgsize_t)strlen(RigidGridMotionTypeName[rmotion->type]); if (cgi_new_node(zone->id, rmotion->name, "RigidGridMotion_t", &rmotion->id, "C1", 1, &length, (void *)RigidGridMotionTypeName[rmotion->type])) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and write ArbitraryGridMotion_t Nodes \*****************************************************************************/ /** * \ingroup ArbitraryGridMotion * * \brief Get the number of ArbitraryGridMotion_t nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] n_arbitrary_motions Number of ArbitraryGridMotion_t nodes under zone Z. * \return \ier * */ int cg_n_arbitrary_motions(int fn, int B, int Z, int *n_arbitrary_motions) { cgns_zone *zone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; *n_arbitrary_motions = zone->namotions; return CG_OK; } /** * \ingroup ArbitraryGridMotion * * \brief Read ArbitraryGridMotion_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] A \A_grid * \param[out] name Name of the ArbitraryGridMotion_t node. * \param[out] type Type of arbitrary grid motion. The admissible types are CG_Null, * CG_UserDefined, NonDeformingGrid, and DeformingGrid. * \return \ier * */ int cg_arbitrary_motion_read(int fn, int B, int Z, int A, char *name, CGNS_ENUMT(ArbitraryGridMotionType_t) *type) { cgns_amotion *amotion; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; amotion = cgi_get_amotion(cg, B, Z, A); if (amotion==0) return CG_ERROR; strcpy(name, amotion->name); *type = amotion->type; return CG_OK; } /** * \ingroup ArbitraryGridMotion * * \brief Write ArbitraryGridMotion_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] amotionname Name of the ArbitraryGridMotion_t node. * \param[in] type Type of arbitrary grid motion. The admissible types are \e CG_Null, * \e CG_UserDefined, \e NonDeformingGrid, and \e DeformingGrid. * \param[out] A \A_grid * \return \ier * */ int cg_arbitrary_motion_write(int fn, int B, int Z, const char * amotionname, CGNS_ENUMT(ArbitraryGridMotionType_t) type, int *A) { cgns_zone *zone; cgns_amotion *amotion = NULL; int index; cgsize_t length; /* verify input */ if (cgi_check_strlen(amotionname)) return CG_ERROR; if (INVALID_ENUM(type,NofValidArbitraryGridMotionTypes)) { cgi_error("Invalid input: ArbitraryGridMotionType=%d ?",type); return CG_ERROR; } /* get memory address for ArbitraryGridMotion_t node */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* Overwrite a ArbitraryGridMotion_t Node: */ for (index=0; indexnamotions; index++) { if (strcmp(amotionname, zone->amotion[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",amotionname); return CG_ERROR; } /* overwrite an existing amotion */ /* delete the existing amotion from file */ if (cgi_delete_node(zone->id, zone->amotion[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ amotion = &(zone->amotion[index]); /* free memory */ cgi_free_amotion(amotion); break; } } /* ... or add a new ArbitraryGridMotion_t Node: */ if (index==zone->namotions) { if (zone->namotions == 0) { zone->amotion = CGNS_NEW(cgns_amotion, 1); } else { zone->amotion = CGNS_RENEW(cgns_amotion, zone->namotions+1, zone->amotion); } amotion = &(zone->amotion[zone->namotions]); zone->namotions++; } (*A) = index+1; /* save data for cgns_amotion *amotion */ memset(amotion, 0, sizeof(cgns_amotion)); strcpy(amotion->name,amotionname); amotion->type = type; amotion->location = CGNS_ENUMV(Vertex); /* Create node ArbitraryGridMotion_t */ length = (cgsize_t)strlen(ArbitraryGridMotionTypeName[amotion->type]); if (cgi_new_node(zone->id, amotion->name, "ArbitraryGridMotion_t", &amotion->id, "C1", 1, &length, (void *)ArbitraryGridMotionTypeName[amotion->type])) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and write SimulationType_t Node \*****************************************************************************/ /** * \ingroup SimulationType * * \brief Read simulation type * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] SimulationType Type of simulation. Valid types are \e CG_Null, \e CG_UserDefined, \e TimeAccurate, * and \e NonTimeAccurate. * \return \ier * */ int cg_simulation_type_read(int fn, int B, CGNS_ENUMT(SimulationType_t) *SimulationType) { cgns_base *base; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; *SimulationType = base->type; return CG_OK; } /** * \ingroup SimulationType * * \brief Write simulation type * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] SimulationType Type of simulation. Valid types are \e CG_Null, \e CG_UserDefined, \e TimeAccurate, * and \e NonTimeAccurate. * \return \ier * */ int cg_simulation_type_write(int fn, int B, CGNS_ENUMT(SimulationType_t) SimulationType) { cgns_base *base; cgsize_t length; /* check input */ if (INVALID_ENUM(SimulationType,NofValidSimulationTypes)) { cgi_error("Invalid input: SimulationType=%d ?", SimulationType); return CG_ERROR; } /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for CGNSBase_t node */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* write or overwrite SimulationType_t to Base */ if (base->type) { if (cg->mode==CG_MODE_WRITE) { cgi_error("Simulation type already defined under CGNSBase_t '%s'", base->name); return CG_ERROR; } if (cgi_delete_node(base->id, base->type_id)) return CG_ERROR; } base->type = SimulationType; base->type_id = 0; /* save data in file */ length = (cgsize_t)strlen(SimulationTypeName[SimulationType]); if (cgi_new_node(base->id, "SimulationType", "SimulationType_t", &base->type_id, "C1", 1, &length, (void *)SimulationTypeName[SimulationType])) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * read and write BaseIterativeData_t Node \*****************************************************************************/ /** * \ingroup BaseIterativeData * * \brief Read BaseIterativeData_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] bitername Name of the BaseIterativeData_t node. * \param[out] nsteps Number of time steps or iterations. * \return \ier * */ int cg_biter_read(int fn, int B, char *bitername, int *nsteps) { cgns_biter *biter; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; biter = cgi_get_biter(cg, B); if (biter==0) return CG_NODE_NOT_FOUND; *nsteps = biter->nsteps; strcpy(bitername,biter->name); return CG_OK; } /** * \ingroup BaseIterativeData * * \brief Write BaseIterativeData_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] bitername Name of the BaseIterativeData_t node. * \param[in] nsteps Number of time steps or iterations. * \return \ier * */ int cg_biter_write(int fn, int B, const char * bitername, int nsteps) { cgns_base *base; cgns_biter *biter; cgsize_t length=1; /* verify input */ if (nsteps<=0) { cgi_error("Invalid input: The number of steps must be a positive integer!"); return CG_ERROR; } /* get memory address for BaseIterativeData_t node */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* If BaseIterativeData_t already exist: */ if (base->biter) { if (cg->mode==CG_MODE_WRITE) { cgi_error("Error: BaseIterativeData_t already defined"); return CG_ERROR; } /* overwrite an existing rmotion */ /* delete the existing biter from file */ if (cgi_delete_node(base->id, base->biter->id)) return CG_ERROR; /* save the old in-memory address to overwrite */ biter = base->biter; /* free memory */ cgi_free_biter(biter); /* ... or add a new BaseIterativeData_t Node: */ } else { base->biter = CGNS_NEW(cgns_biter, 1); biter = base->biter; } /* save data for cgns_biter *biter */ memset(biter, 0, sizeof(cgns_biter)); strcpy(biter->name,bitername); biter->nsteps = nsteps; /* Create node BaseIterativeData_t */ if (cgi_new_node(base->id, biter->name, "BaseIterativeData_t", &biter->id, "I4", 1, &length, (void *)&nsteps)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * read and write ZoneIterativeData_t Node \*****************************************************************************/ /** * \ingroup ZoneIterativeData * * \brief Read ZontIterativeData_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[out] zitername Name of the ZoneIterativeData_t node. * \return \ier * */ int cg_ziter_read(int fn, int B, int Z, char *zitername) { cgns_ziter *ziter; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; ziter = cgi_get_ziter(cg, B, Z); if (ziter==0) return CG_NODE_NOT_FOUND; strcpy(zitername, ziter->name); return CG_OK; } /** * \ingroup ZoneIterativeData * * \brief Write ZontIterativeData_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] zitername Name of the ZoneIterativeData_t node. * \return \ier * */ int cg_ziter_write(int fn, int B, int Z, const char * zitername) { cgns_zone *zone; cgns_ziter *ziter; /* verify input */ if (cgi_check_strlen(zitername)) return CG_ERROR; /* get memory address for ZoneIterativeData_t node */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; /* Overwrite the ZoneIterativeData_t Node: */ if (zone->ziter) { if (cg->mode==CG_MODE_WRITE) { cgi_error("Error: ZoneIterativeData_t already defined"); return CG_ERROR; } /* overwrite an existing ZoneIterativeData_t Node */ /* delete the existing ziter from file */ if (cgi_delete_node(zone->id, zone->ziter->id)) return CG_ERROR; /* save the old in-memory address to overwrite */ ziter = zone->ziter; /* free memory */ cgi_free_ziter(ziter); } else { zone->ziter = CGNS_NEW(cgns_ziter, 1); ziter = zone->ziter; } /* save data for cgns_ziter *ziter */ memset(ziter, 0, sizeof(cgns_ziter)); strcpy(ziter->name,zitername); /* Create node ZoneIterativeData_t */ if (cgi_new_node(zone->id, ziter->name, "ZoneIterativeData_t", &ziter->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * read and write ParticleIterativeData_t Node \*****************************************************************************/ /** * \ingroup ParticleIterativeData * * \brief Read ParticleIterativeData_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[out] pitername Name of the ParticleIterativeData_t node. * \return \ier * */ int cg_piter_read(int fn, int B, int P, char *pitername) { cgns_ziter *piter; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; piter = cgi_get_piter(cg, B, P); if (piter==0) return CG_NODE_NOT_FOUND; strcpy(pitername, piter->name); return CG_OK; } /** * \ingroup ParticleIterativeData * * \brief Write ParticleIterativeData_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] pitername Name of the ParticleIterativeData_t node. * \return \ier * */ int cg_piter_write(int fn, int B, int P, const char * pitername) { cgns_pzone *pzone; cgns_ziter *piter; /* verify input */ if (cgi_check_strlen(pitername)) return CG_ERROR; /* get memory address for ParticleIterativeData_t node */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_ERROR; /* Overwrite the ParticleIterativeData_t Node: */ if (pzone->piter) { if (cg->mode==CG_MODE_WRITE) { cgi_error("Error: ParticleIterativeData_t already defined"); return CG_ERROR; } /* overwrite an existing ParticleIterativeData_t Node */ /* delete the existing piter from file */ if (cgi_delete_node(pzone->id, pzone->piter->id)) return CG_ERROR; /* save the old in-memory address to overwrite */ piter = pzone->piter; /* free memory */ cgi_free_ziter(piter); } else { pzone->piter = CGNS_NEW(cgns_ziter, 1); piter = pzone->piter; } /* save data for cgns_ziter *piter */ memset(piter, 0, sizeof(cgns_ziter)); strcpy(piter->name,pitername); /* Create node ParticleIterativeData_t */ if (cgi_new_node(pzone->id, piter->name, "ParticleIterativeData_t", &piter->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * read and write Gravity_t Node \*****************************************************************************/ /** * \ingroup Gravity * * \brief Read Gravity_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] gravity_vector Components of the gravity vector. The number of components must equal * PhysicalDimension. (In Fortran, this is an array of Real*4 values.) * \return \ier * */ int cg_gravity_read(int fn, int B, float *gravity_vector) { cgns_base *base; cgns_gravity *gravity; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for base */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* get memory address for gravity */ gravity = cgi_get_gravity(cg, B); if (gravity==0) return CG_NODE_NOT_FOUND; memcpy(gravity_vector, gravity->vector->data, base->phys_dim*sizeof(float)); return CG_OK; } /** * \ingroup Gravity * * \brief Write Gravity_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] gravity_vector Components of the gravity vector. The number of components must equal * PhysicalDimension. (In Fortran, this is an array of Real*4 values.) * \return \ier * */ int cg_gravity_write(int fn, int B, float const *gravity_vector) { cgns_base *base; cgns_gravity *gravity; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for base */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; if (base->gravity) { if (cg->mode==CG_MODE_WRITE) { cgi_error("Gravity is already defined under CGNSBase_t '%s'", base->name); return CG_ERROR; } if (cgi_delete_node(base->id, base->gravity->id)) return CG_ERROR; cgi_free_gravity(base->gravity); memset(base->gravity, 0, sizeof(cgns_gravity)); } else { base->gravity = CGNS_NEW(cgns_gravity, 1); } gravity = base->gravity; gravity->vector = CGNS_NEW(cgns_array, 1); /* initialize other fields of gravity */ strcpy(gravity->name, "Gravity"); /* Create DataArray_t GravityVector under gravity */ strcpy(gravity->vector->data_type, "R4"); gravity->vector->data = (void *)malloc(base->phys_dim*sizeof(float)); if (gravity->vector->data == NULL) { cgi_error("Error allocating gravity->vector->data"); return CG_ERROR; } memcpy(gravity->vector->data, gravity_vector, base->phys_dim*sizeof(float)); strcpy(gravity->vector->name, "GravityVector"); gravity->vector->data_dim=1; gravity->vector->dim_vals[0]=base->phys_dim; /* Write to disk */ if (cgi_write_gravity(base->id, gravity)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * read and write Axisymmetry_t Node \*****************************************************************************/ /** * \ingroup Axisymmetry * * \brief Read Axisymmetry_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] ref_point Origin used for defining the axis of rotation. (In Fortran, this is an array * of Real*4 values.) * \param[out] axis Direction cosines of the axis of rotation, through the reference point. (In * Fortran, this is an array of Real*4 values.) * \return \ier * * \details This node can only be used for a bi-dimensional model, i.e., PhysicalDimension must equal two. * */ int cg_axisym_read(int fn, int B, float *ref_point, float *axis) { int n; cgns_base *base; cgns_axisym *axisym; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for base (for base->phys_dim) */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* get memory address for axisym */ axisym = cgi_get_axisym(cg, B); if (axisym==0) return CG_NODE_NOT_FOUND; for (n=0; nnarrays; n++) { if (strcmp(axisym->array[n].name,"AxisymmetryReferencePoint")==0) memcpy(ref_point, axisym->array[n].data, base->phys_dim*sizeof(float)); else if (strcmp(axisym->array[n].name,"AxisymmetryAxisVector")==0) memcpy(axis, axisym->array[n].data, base->phys_dim*sizeof(float)); } return CG_OK; } /** * \ingroup Axisymmetry * * \brief Create axisymmetry data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] ref_point Origin used for defining the axis of rotation. (In Fortran, this is an array * of Real*4 values.) * \param[in] axis Direction cosines of the axis of rotation, through the reference point. (In * Fortran, this is an array of Real*4 values.) * \return \ier * * \details Axisymmetry_t node can only be used for a bi-dimensional model, i.e., PhysicalDimension must equal two. * */ int cg_axisym_write(int fn, int B, float const *ref_point, float const *axis) { int n; cgns_base *base; cgns_axisym *axisym; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for base */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* Verify that this is a bidimensional base */ if (base->phys_dim != 2) { cgi_error("Error: Axisymmetry_t can only be specified for bidimensional bases"); return CG_ERROR; } if (base->axisym) { if (cg->mode==CG_MODE_WRITE) { cgi_error("Axisymmetry is already defined under CGNSBase_t '%s'", base->name); return CG_ERROR; } if (cgi_delete_node(base->id, base->axisym->id)) return CG_ERROR; cgi_free_axisym(base->axisym); memset(base->axisym, 0, sizeof(cgns_axisym)); } else { base->axisym = CGNS_NEW(cgns_axisym, 1); } axisym = base->axisym; strcpy(axisym->name, "Axisymmetry"); axisym->array = CGNS_NEW(cgns_array, 2); axisym->narrays=2; /* Create DataArray_t AxisymmetryReferencePoint & AxisymmetryAxisVector under axisym */ for (n=0; nnarrays; n++) { strcpy(axisym->array[n].data_type, "R4"); axisym->array[n].data = (void *)malloc(base->phys_dim*sizeof(float)); if (axisym->array[n].data == NULL) { cgi_error("Error allocating axisym->array[n].data"); return CG_ERROR; } axisym->array[n].data_dim=1; axisym->array[n].dim_vals[0]=base->phys_dim; } memcpy(axisym->array[0].data, ref_point, base->phys_dim*sizeof(float)); memcpy(axisym->array[1].data, axis, base->phys_dim*sizeof(float)); strcpy(axisym->array[0].name, "AxisymmetryReferencePoint"); strcpy(axisym->array[1].name, "AxisymmetryAxisVector"); /* Write to disk */ if (cgi_write_axisym(base->id, axisym)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * read and write BCProperty_t Node \*****************************************************************************/ /** * \ingroup SpecialBoundaryConditionProperty * * \brief Read wall function data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[out] WallFunctionType The wall function type. Valid types are CG_Null, CG_UserDefined, and * Generic. * \return \ier * * \details The "read" functions will return with \p ier = 2 = CG_NODE_NOT_FOUND if the requested boundary * condition property, or the BCProperty_t node itself, doesn't exist. * */ int cg_bc_wallfunction_read(int fn, int B, int Z, int BC, CGNS_ENUMT(WallFunctionType_t) *WallFunctionType) { cgns_bprop *bprop; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for bprop */ bprop = cgi_get_bprop(cg, B, Z, BC); if (bprop==0) return CG_NODE_NOT_FOUND; if (bprop->bcwall==0) { cgi_error("BCProperty_t/WallFunction_t node doesn't exist under BC_t %d",BC); return CG_NODE_NOT_FOUND; } *WallFunctionType = bprop->bcwall->type; return CG_OK; } /** * \ingroup SpecialBoundaryConditionProperty * * \brief Write wall function data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[in] WallFunctionType The wall function type. Valid types are \e CG_Null, \e CG_UserDefined, and * \e Generic. * \return \ier * * \details The "write" functions will create the BCProperty_t node if it doesn't already exist, then * add the appropriate boundary condition property. Multiple boundary condition properties * may be recorded under the same BCProperty_t node. * */ int cg_bc_wallfunction_write(int fn, int B, int Z, int BC, CGNS_ENUMT(WallFunctionType_t) WallFunctionType) { cgns_bprop *bprop; cgns_bcwall *bcwall; cgns_boco *boco; cgsize_t length; double dummy_id; /* verify input */ if (INVALID_ENUM(WallFunctionType,NofValidWallFunctionTypes)) { cgi_error("Invalid WallFunctionType: %d",WallFunctionType); return CG_ERROR; } /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address of BC_t node */ boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_ERROR; /* Allocate BCProperty_t data struct. if not already created */ if (boco->bprop == 0) { boco->bprop = CGNS_NEW(cgns_bprop, 1); bprop = boco->bprop; strcpy(bprop->name,"BCProperty"); } else bprop = boco->bprop; /* Overwrite a WallFunction_t Node: */ if (bprop->bcwall) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("WallFunction_t already defined under BCProperty_t."); return CG_ERROR; } /* overwrite an existing WallFunction_t Node */ /* delete the existing WallFunction_t Node from file */ if (cgi_delete_node(bprop->id, bprop->bcwall->id)) return CG_ERROR; cgi_free_bcwall(bprop->bcwall); memset(bprop->bcwall, 0, sizeof(cgns_bcwall)); } else { bprop->bcwall = CGNS_NEW(cgns_bcwall, 1); } bcwall = bprop->bcwall; /* write bcwall info to internal memory */ bcwall->type = WallFunctionType; strcpy(bcwall->name,"WallFunction"); /* Create BCProperty_t node if it doesn't yet exist */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (bprop->id==0) { if (cgi_new_node(boco->id, "BCProperty", "BCProperty_t", &bprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(bprop->id, hid); if (hid==0) { if (cgi_new_node(boco->id, "BCProperty", "BCProperty_t", &bprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } /* Create the WallFunction_t Node */ if (cgi_new_node(bprop->id, "WallFunction", "WallFunction_t", &bcwall->id, "MT", 0, 0, 0)) return CG_ERROR; /* WallFunction_t/WallFunctionType_t */ length = (cgsize_t)strlen(WallFunctionTypeName[bcwall->type]); if (cgi_new_node(bcwall->id, "WallFunctionType", "WallFunctionType_t", &dummy_id, "C1", 1, &length, (void *)WallFunctionTypeName[bcwall->type])) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup SpecialBoundaryConditionProperty * * \brief Read area-related data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[out] AreaType The type of area. Valid types are CG_Null, CG_UserDefined, BleedArea, and * CaptureArea. * \param[out] SurfaceArea The size of the area. (In Fortran, this is a Real*4 value.) * \param[out] RegionName The name of the region, 32 characters max. * \return \ier * * \details The "read" functions will return with \p ier = 2 = CG_NODE_NOT_FOUND if the requested boundary * condition property, or the BCProperty_t node itself, doesn't exist. * */ int cg_bc_area_read(int fn, int B, int Z, int BC, CGNS_ENUMT(AreaType_t) *AreaType, float *SurfaceArea, char *RegionName) { int n; cgns_bprop *bprop; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for bprop */ bprop = cgi_get_bprop(cg, B, Z, BC); if (bprop==0) return CG_NODE_NOT_FOUND; if (bprop->bcarea==0) { cgi_error("BCProperty_t/Area_t node doesn't exist under BC_t %d",BC); return CG_NODE_NOT_FOUND; } *AreaType = bprop->bcarea->type; for (n=0; nbcarea->narrays; n++) { if (strcmp("SurfaceArea",bprop->bcarea->array[n].name)==0) memcpy(SurfaceArea, bprop->bcarea->array[n].data, sizeof(float)); else if (strcmp("RegionName",bprop->bcarea->array[n].name)==0) { memcpy(RegionName, bprop->bcarea->array[n].data, 32*sizeof(char)); RegionName[32]='\0'; } } return CG_OK; } /** * \ingroup SpecialBoundaryConditionProperty * * \brief Write area related data * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] BC \BC * \param[in] AreaType The type of area. Valid types are CG_Null, CG_UserDefined, BleedArea, and * CaptureArea. * \param[in] SurfaceArea The size of the area. (In Fortran, this is a Real*4 value.) * \param[in] RegionName The region's name, 32 characters max. * \return \ier * * \details The "write" functions will create the BCProperty_t node if it doesn't already exist, then * add the appropriate boundary condition property. Multiple boundary condition properties * may be recorded under the same BCProperty_t node. * */ int cg_bc_area_write(int fn, int B, int Z, int BC, CGNS_ENUMT( AreaType_t ) AreaType, float SurfaceArea, const char *RegionName) { cgns_boco *boco; cgns_bprop *bprop; cgns_bcarea *bcarea; int n; cgsize_t len; char *RegionName32; double dummy_id; /* verify input */ if (INVALID_ENUM(AreaType,NofValidAreaTypes)) { cgi_error("Invalid AreaType: %d",AreaType); return CG_ERROR; } /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address of BC_t node */ boco = cgi_get_boco(cg, B, Z, BC); if (boco==0) return CG_ERROR; /* Allocate BCProperty_t data struct. if not already created */ if (boco->bprop == 0) { boco->bprop = CGNS_NEW(cgns_bprop, 1); bprop = boco->bprop; strcpy(bprop->name,"BCProperty"); } else bprop = boco->bprop; /* Overwrite a Area_t Node: */ if (bprop->bcarea) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Area_t already defined under BCProperty_t."); return CG_ERROR; } /* overwrite an existing Area_t Node */ /* delete the existing Area_t Node from file */ if (cgi_delete_node(bprop->id, bprop->bcarea->id)) return CG_ERROR; cgi_free_bcarea(bprop->bcarea); memset(bprop->bcarea, 0, sizeof(cgns_bcarea)); } else { bprop->bcarea = CGNS_NEW(cgns_bcarea, 1); } bcarea = bprop->bcarea; /* write bcarea info to internal memory */ bcarea->type = AreaType; strcpy(bcarea->name,"Area"); bcarea->narrays = 2; /* Create DataArray_t SurfaceArea & RegionName under Area_t */ bcarea->array = CGNS_NEW(cgns_array, 2); strcpy(bcarea->array[0].data_type, "R4"); bcarea->array[0].data = (void *)malloc(sizeof(float)); if (bcarea->array[0].data == NULL) { cgi_error("Error allocating bcarea->array[0].data"); return CG_ERROR; } memcpy(bcarea->array[0].data, &SurfaceArea, sizeof(float)); /* *((float *)bcarea->array[0].data) = SurfaceArea; */ strcpy(bcarea->array[0].name, "SurfaceArea"); bcarea->array[0].data_dim=1; bcarea->array[0].dim_vals[0]=1; strcpy(bcarea->array[1].data_type, "C1"); bcarea->array[1].data = (void *)malloc(32*sizeof(char)); if (bcarea->array[1].data == NULL) { cgi_error("Error allocating bcarea->array[1].data"); return CG_ERROR; } /* check length of RegionName and fill in with blanks */ RegionName32 = (char *)bcarea->array[1].data; len = (int)strlen(RegionName); for (n=0; n<(int)len; n++) RegionName32[n]=RegionName[n]; for (n=(int)len; n<32; n++) RegionName32[n]=' '; strcpy(bcarea->array[1].name, "RegionName"); bcarea->array[1].data_dim=1; bcarea->array[1].dim_vals[0]=32; /* Create BCProperty_t node if it doesn't yet exist */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (bprop->id==0) { if (cgi_new_node(boco->id, "BCProperty", "BCProperty_t", &bprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(bprop->id, hid); if (hid==0) { if (cgi_new_node(boco->id, "BCProperty", "BCProperty_t", &bprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } /* Create the Area_t Node */ if (cgi_new_node(bprop->id, "Area", "Area_t", &bcarea->id, "MT", 0, 0, 0)) return CG_ERROR; /* Area_t/AreaType_t */ len = (cgsize_t)strlen(AreaTypeName[bcarea->type]); if (cgi_new_node(bcarea->id, "AreaType", "AreaType_t", &dummy_id, "C1", 1, &len, (void *)AreaTypeName[bcarea->type])) return CG_ERROR; /* Area_t/DataArray_t: SurfaceArea & RegionName */ for (n=0; nnarrays; n++) if (cgi_write_array(bcarea->id, &bcarea->array[n])) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * read and write GridConnectivityProperty_t Node \*****************************************************************************/ /** * \ingroup SpecialGridConnectivityProperty * * \brief Read data for periodic interface * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" * functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. * \param[out] RotationCenter An array of size phys_dim defining the coordinates of the origin for * defining the rotation angle between the periodic interfaces. (phys_dim is * the number of coordinates required to define a vector in the field.) (In * Fortran, this is an array of Real*4 values.) * \param[out] RotationAngle An array of size phys_dim defining the rotation angle from the current * interface to the connecting interface. If rotating about more than one axis, * the rotation is performed first about the x-axis, then the y-axis, then the * z-axis. (In Fortran, this is an array of Real*4 values.) * \param[out] Translation An array of size phys_dim defining the translation from the current * interface to the connecting interface. (In Fortran, this is an array of * Real*4 values.) * \return \ier * * \details The "read" functions will return with \p ier = 2 = CG_NODE_NOT_FOUND if the requested connectivity * property, or the GridConnectivityProperty_t node itself, doesn't exist. * */ int cg_conn_periodic_read(int fn, int B, int Z, int J, float *RotationCenter, float *RotationAngle, float *Translation) { int n; cgns_base *base; cgns_cprop *cprop; cgns_cperio *cperio; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for base (for base->phys_dim) */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* get memory address for cprop */ cprop = cgi_get_cprop(cg, B, Z, J); if (cprop==0) return CG_NODE_NOT_FOUND; if (cprop->cperio == 0) { cgi_error("GridConnectivityProperty_t/Periodic_t node doesn't exist under GridConnectivity_t %d",J); return CG_NODE_NOT_FOUND; } cperio = cprop->cperio; /* Copy data to be returned */ for (n=0; nnarrays; n++) { if (strcmp(cperio->array[n].name,"RotationCenter")==0) memcpy(RotationCenter, cperio->array[n].data, base->phys_dim*sizeof(float)); else if (strcmp(cperio->array[n].name,"RotationAngle")==0) memcpy(RotationAngle, cperio->array[n].data, base->phys_dim*sizeof(float)); else if (strcmp(cperio->array[n].name,"Translation")==0) memcpy(Translation, cperio->array[n].data, base->phys_dim*sizeof(float)); } return CG_OK; } /** * \ingroup SpecialGridConnectivityProperty * * \brief Write data for periodic interface * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" * functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. * \param[in] RotationCenter An array of size phys_dim defining the coordinates of the origin for * defining the rotation angle between the periodic interfaces. (phys_dim is * the number of coordinates required to define a vector in the field.) (In * Fortran, this is an array of Real*4 values.) * \param[in] RotationAngle An array of size phys_dim defining the rotation angle from the current * interface to the connecting interface. If rotating about more than one axis, * the rotation is performed first about the x-axis, then the y-axis, then the * z-axis. (In Fortran, this is an array of Real*4 values.) * \param[in] Translation An array of size phys_dim defining the translation from the current * interface to the connecting interface. (In Fortran, this is an array of * Real*4 values.) * \return \ier * * \details The "write" functions will create the GridConnectivityProperty_t node if it doesn't already * exist, then add the appropriate connectivity property. Multiple grid connectivity properties * may be recorded under the same GridConnectivityProperty_t node. * */ int cg_conn_periodic_write(int fn, int B, int Z, int J, float const *RotationCenter, float const *RotationAngle, float const *Translation) { cgns_base *base; cgns_conn *conn; cgns_cprop *cprop; cgns_cperio *cperio; int n; /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for base */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* get memory address of GridConnectivity_t node */ conn = cgi_get_conn(cg, B, Z, J); if (conn==0) return CG_ERROR; /* Allocate GridConnectivityProperty_t data struct. if not already created */ if (conn->cprop == 0) { conn->cprop = CGNS_NEW(cgns_cprop, 1); cprop = conn->cprop; strcpy(cprop->name,"GridConnectivityProperty"); } else cprop = conn->cprop; /* Overwrite a Periodic_t Node: */ if (cprop->cperio) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Periodic_t already defined under GridConnectivityProperty_t."); return CG_ERROR; } /* overwrite an existing Periodic_t Node */ /* delete the existing Periodic_t Node from file */ if (cgi_delete_node(cprop->id, cprop->cperio->id)) return CG_ERROR; cgi_free_cperio(cprop->cperio); memset(cprop->cperio, 0, sizeof(cgns_cperio)); } else { cprop->cperio = CGNS_NEW(cgns_cperio, 1); } cperio = cprop->cperio; /* write cperio info to internal memory */ strcpy(cperio->name,"Periodic"); cperio->narrays = 3; /* Create DataArray_t RotationCenter, RotationAngle, & Translation under Periodic_t */ cperio->array = CGNS_NEW(cgns_array, 3); for (n=0; nnarrays; n++) { strcpy(cperio->array[n].data_type, "R4"); cperio->array[n].data = (void *)malloc(base->phys_dim*sizeof(float)); if (cperio->array[n].data == NULL) { cgi_error("Error allocating cperio->array[n].data"); return CG_ERROR; } cperio->array[n].data_dim=1; cperio->array[n].dim_vals[0]=base->phys_dim; } memcpy(cperio->array[0].data,RotationCenter,base->phys_dim*sizeof(float)); memcpy(cperio->array[1].data,RotationAngle,base->phys_dim*sizeof(float)); memcpy(cperio->array[2].data,Translation,base->phys_dim*sizeof(float)); strcpy(cperio->array[0].name,"RotationCenter"); strcpy(cperio->array[1].name,"RotationAngle"); strcpy(cperio->array[2].name,"Translation"); /* Create GridConnectivityProperty_t node if it doesn't yet exist */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (cprop->id==0) { if (cgi_new_node(conn->id, "GridConnectivityProperty", "GridConnectivityProperty_t", &cprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(cprop->id, hid); if (hid==0) { if (cgi_new_node(conn->id, "GridConnectivityProperty", "GridConnectivityProperty_t", &cprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } /* Create the Periodic_t Node */ if (cgi_new_node(cprop->id, "Periodic", "Periodic_t", &cperio->id, "MT", 0, 0, 0)) return CG_ERROR; /* Periodic_t/DataArray_t: RotationCenter, RotationAngle, Translation */ for (n=0; nnarrays; n++) if (cgi_write_array(cperio->id, &cperio->array[n])) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup SpecialGridConnectivityProperty * * \brief Read data for averaging interface * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" * functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. * \param[out] AverageInterfaceType The type of averaging to be done. Valid types are CG_Null, CG_UserDefined, * AverageAll, AverageCircumferential, AverageRadial, AverageI, AverageJ, and * AverageK. * \return \ier * * \details The "read" functions will return with \p ier = 2 = CG_NODE_NOT_FOUND if the requested * connectivity property, or the GridConnectivityProperty_t node itself, doesn't exist. * */ int cg_conn_average_read(int fn, int B, int Z, int J, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType) { cgns_cprop *cprop; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for cprop */ cprop = cgi_get_cprop(cg, B, Z, J); if (cprop==0) return CG_NODE_NOT_FOUND; if (cprop->caverage == 0) { cgi_error("GridConnectivityProperty_t/AverageInterface_t node doesn't exist under GridConnectivity_t %d",J); return CG_NODE_NOT_FOUND; } *AverageInterfaceType = cprop->caverage->type; return CG_OK; } /** * \ingroup SpecialGridConnectivityProperty * * \brief Write data for averaging interface * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" * functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. * \param[in] AverageInterfaceType The type of averaging to be done. Valid types are CG_Null, CG_UserDefined, * AverageAll, AverageCircumferential, AverageRadial, AverageI, AverageJ, and * AverageK. * \return \ier * * \details The "write" functions will create the GridConnectivityProperty_t node if it doesn't already * exist, then add the appropriate connectivity property. Multiple grid connectivity properties * may be recorded under the same GridConnectivityProperty_t node. * */ int cg_conn_average_write(int fn, int B, int Z, int J, CGNS_ENUMT(AverageInterfaceType_t) AverageInterfaceType) { cgns_cprop *cprop; cgns_caverage *caverage; cgns_conn *conn; cgsize_t length; double dummy_id; /* verify input */ if (INVALID_ENUM(AverageInterfaceType,NofValidAverageInterfaceTypes)) { cgi_error("Invalid AverageInterfaceType: %d",AverageInterfaceType); return CG_ERROR; } /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address of GridConnectivity_t node */ conn = cgi_get_conn(cg, B, Z, J); if (conn==0) return CG_ERROR; /* Allocate GridConnectivityProperty_t data struct. if not already created */ if (conn->cprop == 0) { conn->cprop = CGNS_NEW(cgns_cprop, 1); cprop = conn->cprop; strcpy(cprop->name,"GridConnectivityProperty"); } else cprop = conn->cprop; /* Overwrite an AverageInterface_t Node: */ if (cprop->caverage) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("AverageInterface_t already defined under GridConnectivityProperty_t"); return CG_ERROR; } /* overwrite an existing AverageInterface_t Node */ /* delete the existing AverageInterface_t Node from file */ if (cgi_delete_node(cprop->id, cprop->caverage->id)) return CG_ERROR; cgi_free_caverage(cprop->caverage); memset(cprop->caverage, 0, sizeof(cgns_caverage)); } else { cprop->caverage = CGNS_NEW(cgns_caverage, 1); } caverage = cprop->caverage; /* write caverage info to internal memory */ caverage->type = AverageInterfaceType; strcpy(caverage->name,"AverageInterface"); /* Create GridConnectivityProperty_t node if it doesn't yet exist */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (cprop->id==0) { if (cgi_new_node(conn->id, "GridConnectivityProperty", "GridConnectivityProperty_t", &cprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(cprop->id, hid); if (hid==0) { if (cgi_new_node(conn->id, "GridConnectivityProperty", "GridConnectivityProperty_t", &cprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } /* Create the AverageInterface_t Node */ if (cgi_new_node(cprop->id, "AverageInterface", "AverageInterface_t", &caverage->id, "MT", 0, 0, 0)) return CG_ERROR; /* AverageInterface_t/AverageInterfaceType_t */ length = (cgsize_t)strlen(AverageInterfaceTypeName[caverage->type]); if (cgi_new_node(caverage->id, "AverageInterfaceType", "AverageInterfaceType_t", &dummy_id, "C1", 1, &length, (void *)AverageInterfaceTypeName[caverage->type])) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup SpecialGridConnectivityProperty * * \brief Read data for periodic interface * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" * functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. * \param[out] RotationCenter An array of size phys_dim defining the coordinates of the origin for * defining the rotation angle between the periodic interfaces. (phys_dim is * the number of coordinates required to define a vector in the field.) (In * Fortran, this is an array of Real*4 values.) * \param[out] RotationAngle An array of size phys_dim defining the rotation angle from the current * interface to the connecting interface. If rotating about more than one axis, * the rotation is performed first about the x-axis, then the y-axis, then the * z-axis. (In Fortran, this is an array of Real*4 values.) * \param[out] Translation An array of size phys_dim defining the translation from the current * interface to the connecting interface. (In Fortran, this is an array of * Real*4 values.) * \return \ier * * \details The "read" functions will return with \p ier = 2 = CG_NODE_NOT_FOUND if the requested * connectivity property, or the GridConnectivityProperty_t node itself, doesn't exist. * */ int cg_1to1_periodic_read(int fn, int B, int Z, int J, float *RotationCenter, float *RotationAngle, float *Translation) { int n; cgns_base *base; cgns_cprop *cprop; cgns_cperio *cperio; cgns_1to1 *one21; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for base (for base->phys_dim) */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* get memory address for cprop from one21->cprop */ one21 = cgi_get_1to1(cg, B, Z, J); if (one21==0) return CG_ERROR; cprop = one21->cprop; if (cprop == 0 || cprop->cperio == 0) { cgi_error("GridConnectivityProperty_t/Periodic_t node doesn't exist under GridConnectivity1to1_t %d",J); return CG_NODE_NOT_FOUND; } cperio = cprop->cperio; /* Copy data to be returned */ for (n=0; nnarrays; n++) { if (strcmp(cperio->array[n].name,"RotationCenter")==0) memcpy(RotationCenter, cperio->array[n].data, base->phys_dim*sizeof(float)); else if (strcmp(cperio->array[n].name,"RotationAngle")==0) memcpy(RotationAngle, cperio->array[n].data, base->phys_dim*sizeof(float)); else if (strcmp(cperio->array[n].name,"Translation")==0) memcpy(Translation, cperio->array[n].data, base->phys_dim*sizeof(float)); } return CG_OK; } /** * \ingroup SpecialGridConnectivityProperty * * \brief Write data for periodic interface * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" * functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. * \param[in] RotationCenter An array of size phys_dim defining the coordinates of the origin for * defining the rotation angle between the periodic interfaces. (phys_dim is * the number of coordinates required to define a vector in the field.) (In * Fortran, this is an array of Real*4 values.) * \param[in] RotationAngle An array of size phys_dim defining the rotation angle from the current * interface to the connecting interface. If rotating about more than one axis, * the rotation is performed first about the x-axis, then the y-axis, then the * z-axis. (In Fortran, this is an array of Real*4 values.) * \param[in] Translation An array of size phys_dim defining the translation from the current * interface to the connecting interface. (In Fortran, this is an array of * Real*4 values.) * \return \ier * * \details The "write" functions will create the GridConnectivityProperty_t node if it doesn't already * exist, then add the appropriate connectivity property. Multiple grid connectivity properties * may be recorded under the same GridConnectivityProperty_t node. * */ int cg_1to1_periodic_write(int fn, int B, int Z, int J, float const *RotationCenter, float const *RotationAngle, float const *Translation) { cgns_base *base; cgns_1to1 *one21; cgns_cprop *cprop; cgns_cperio *cperio; int n; /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for base */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* get memory address of GridConnectivity1to1_t node */ one21 = cgi_get_1to1(cg, B, Z, J); if (one21 == 0) return CG_ERROR; /* Allocate GridConnectivityProperty_t data struct. if not already created */ if (one21->cprop == 0) { one21->cprop = CGNS_NEW(cgns_cprop, 1); cprop = one21->cprop; strcpy(cprop->name,"GridConnectivityProperty"); } else cprop = one21->cprop; /* Overwrite a Periodic_t Node: */ if (cprop->cperio) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Periodic_t already defined under GridConnectivityProperty_t."); return CG_ERROR; } /* overwrite an existing Periodic_t Node */ else if (cg->mode==CG_MODE_MODIFY) { /* delete the existing Periodic_t Node from file */ if (cgi_delete_node(cprop->id, cprop->cperio->id)) return CG_ERROR; cgi_free_cperio(cprop->cperio); memset(cprop->cperio, 0, sizeof(cgns_cperio)); } } else cprop->cperio = CGNS_NEW(cgns_cperio, 1); cperio = cprop->cperio; /* write cperio info to internal memory */ strcpy(cperio->name,"Periodic"); cperio->narrays = 3; /* Create DataArray_t RotationCenter, RotationAngle, & Translation under Periodic_t */ cperio->array = CGNS_NEW(cgns_array, 3); for (n=0; nnarrays; n++) { strcpy(cperio->array[n].data_type, "R4"); cperio->array[n].data = (void *)malloc(base->phys_dim*sizeof(float)); if (cperio->array[n].data == NULL) { cgi_error("Error allocating cperio->array[n].data"); return CG_ERROR; } cperio->array[n].data_dim=1; cperio->array[n].dim_vals[0]=base->phys_dim; } memcpy(cperio->array[0].data,RotationCenter,base->phys_dim*sizeof(float)); memcpy(cperio->array[1].data,RotationAngle,base->phys_dim*sizeof(float)); memcpy(cperio->array[2].data,Translation,base->phys_dim*sizeof(float)); strcpy(cperio->array[0].name,"RotationCenter"); strcpy(cperio->array[1].name,"RotationAngle"); strcpy(cperio->array[2].name,"Translation"); /* Create GridConnectivityProperty_t node if it doesn't yet exist */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (cprop->id==0) { if (cgi_new_node(one21->id, "GridConnectivityProperty", "GridConnectivityProperty_t", &cprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(cprop->id, hid); if (hid==0) { if (cgi_new_node(one21->id, "GridConnectivityProperty", "GridConnectivityProperty_t", &cprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } /* Create the Periodic_t Node */ if (cgi_new_node(cprop->id, "Periodic", "Periodic_t", &cperio->id, "MT", 0, 0, 0)) return CG_ERROR; /* Periodic_t/DataArray_t: RotationCenter, RotationAngle, Translation */ for (n=0; nnarrays; n++) if (cgi_write_array(cperio->id, &cperio->array[n])) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup SpecialGridConnectivityProperty * * \brief Read data for averaging interface * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" * functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. * \param[out] AverageInterfaceType The type of averaging to be done. Valid types are CG_Null, CG_UserDefined, * AverageAll, AverageCircumferential, AverageRadial, AverageI, AverageJ, and * AverageK. * \return \ier * * \details The "read" functions will return with \p ier = 2 = CG_NODE_NOT_FOUND if the requested * connectivity property, or the GridConnectivityProperty_t node itself, doesn't exist. * */ int cg_1to1_average_read(int fn, int B, int Z, int J, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType) { cgns_cprop *cprop; cgns_1to1 *one21; /* get memory address for file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for cprop from one21->cprop */ one21 = cgi_get_1to1(cg, B, Z, J); if (one21==0) return CG_ERROR; cprop = one21->cprop; if (cprop == 0 || cprop->caverage == 0) { cgi_error("GridConnectivityProperty_t/AverageInterface_t node doesn't exist under GridConnectivity1to1_t %d",J); return CG_NODE_NOT_FOUND; } *AverageInterfaceType = cprop->caverage->type; return CG_OK; } /** * \ingroup SpecialGridConnectivityProperty * * \brief Write data for averaging interface * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" * functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. * \param[in] AverageInterfaceType The type of averaging to be done. Valid types are CG_Null, CG_UserDefined, * AverageAll, AverageCircumferential, AverageRadial, AverageI, AverageJ, and * AverageK. * \return \ier * * \details The "write" functions will create the GridConnectivityProperty_t node if it doesn't * already exist, then add the appropriate connectivity property. Multiple grid connectivity * properties may be recorded under the same GridConnectivityProperty_t node. * */ int cg_1to1_average_write(int fn, int B, int Z, int J, CGNS_ENUMT(AverageInterfaceType_t) AverageInterfaceType) { cgns_cprop *cprop; cgns_caverage *caverage; cgns_1to1 *one21; cgsize_t length; double dummy_id; /* verify input */ if (INVALID_ENUM(AverageInterfaceType,NofValidAverageInterfaceTypes)) { cgi_error("Invalid AverageInterfaceType: %d",AverageInterfaceType); return CG_ERROR; } /* get memory address of file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address of GridConnectivity_t node */ one21 = cgi_get_1to1(cg, B, Z, J); if (one21 == 0) return CG_ERROR; /* Allocate GridConnectivityProperty_t data struct. if not already created */ if (one21->cprop == 0) { one21->cprop = CGNS_NEW(cgns_cprop, 1); cprop = one21->cprop; strcpy(cprop->name,"GridConnectivityProperty"); } else cprop = one21->cprop; /* Overwrite an AverageInterface_t Node: */ if (cprop->caverage) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("AverageInterface_t already defined under GridConnectivityProperty_t"); return CG_ERROR; } /* overwrite an existing AverageInterface_t Node */ else if (cg->mode==CG_MODE_MODIFY) { /* delete the existing AverageInterface_t Node from file */ if (cgi_delete_node(cprop->id, cprop->caverage->id)) return CG_ERROR; cgi_free_caverage(cprop->caverage); memset(cprop->caverage, 0, sizeof(cgns_caverage)); } } else cprop->caverage = CGNS_NEW(cgns_caverage, 1); caverage = cprop->caverage; /* write caverage info to internal memory */ caverage->type = AverageInterfaceType; /* initialize other fields */ strcpy(caverage->name,"AverageInterface"); /* Create GridConnectivityProperty_t node if it doesn't yet exist */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (cprop->id==0) { if (cgi_new_node(one21->id, "GridConnectivityProperty", "GridConnectivityProperty_t", &cprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(cprop->id, hid); if (hid==0) { if (cgi_new_node(one21->id, "GridConnectivityProperty", "GridConnectivityProperty_t", &cprop->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } /* Create the AverageInterface_t Node */ if (cgi_new_node(cprop->id, "AverageInterface", "AverageInterface_t", &caverage->id, "MT", 0, 0, 0)) return CG_ERROR; /* AverageInterface_t/AverageInterfaceType_t */ length = (cgsize_t)strlen(AverageInterfaceTypeName[caverage->type]); if (cgi_new_node(caverage->id, "AverageInterfaceType", "AverageInterfaceType_t", &dummy_id, "C1", 1, &length, (void *)AverageInterfaceTypeName[caverage->type])) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Particle Functions \*****************************************************************************/ /** * \ingroup ParticleZoneInformation * * \brief Get the number of a particle zone in the base * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[out] nparticlezones Number of particle zones present in base B. * \return \ier * */ int cg_nparticle_zones(int fn, int B, int *nparticlezones) { cgns_base *base; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; *nparticlezones = base->npzones; return CG_OK; } /** * \ingroup ParticleZoneInformation * * \brief Get the CGIO identifier of the CGNS Particle zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[out] particle_id CGIO node identifier for the particle zone * \return \ier * */ int cg_particle_id(int fn, int B, int P, double *particle_id) { cgns_pzone *pzone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_ERROR; *particle_id = pzone->id; return CG_OK; } /** * \ingroup ParticleZoneInformation * * \brief Read particle zone information * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[out] particlename Name of the particle zone * \param[out] size Number of particles in this ParticleZone (i.e. ParticleSize) * \return \ier */ int cg_particle_read(int fn, int B, int P, char *particlename, cgsize_t *size) { cgns_pzone *pzone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_ERROR; strcpy(particlename, pzone->name); (*size) = pzone->nparticles; return CG_OK; } /** * \ingroup ParticleZoneInformation * * \brief Create and/or write to a CGNS particle zone * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] particlename Name of the particle zone. * \param[in] size Number of particles in this particle zone. * \param[out] P \P_ParticleZone * \return \ier */ int cg_particle_write(int fn, int B, const char *particlename, const cgsize_t size, int *P) { cgns_base *base; cgns_pzone *pzone = NULL; int index; cgsize_t dim_vals[1]; /* verify input */ if (cgi_check_strlen(particlename)) return CG_ERROR; /* get memory address file */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for base */ base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; /* Verify the particle count - We allow 0-sized ParticleZone_t nodes, but they cannot have solution/coordinate arrays */ if (size < 0) { cgi_error("Invalid particle size %d", size); return CG_ERROR; } /* Overwrite a ParticleZone_t Node: */ if (base->pzonemap == 0) { base->pzonemap = cgi_new_presized_hashmap(base->npzones); if (base->pzonemap == NULL) { cgi_error("Could not allocate particlemap"); return CG_ERROR; } for (index = 0; index < base->npzones; index++) { if (cgi_map_set_item(base->pzonemap, base->pzone[index].name, index) != 0) { cgi_error("Can not set particle %s into hashmap", base->pzone[index].name); return CG_ERROR; } } } index = (int) cgi_map_get_item(base->pzonemap, particlename); /* */ if (index != -1) { pzone = &(base->pzone[index]); /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode == CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s", pzone->name); return CG_ERROR; } /* overwrite an existing particle zone*/ /* delete the existing particle zone from file */ if (cgi_delete_node(base->id, pzone->id)) return CG_ERROR; cgi_free_particle(pzone); } else { if (base->npzones == 0) { base->pzone = CGNS_NEW(cgns_pzone, base->npzones + 1); } else { base->pzone = CGNS_RENEW(cgns_pzone, base->npzones + 1, base->pzone); } pzone = &(base->pzone[base->npzones]); index = base->npzones; if (cgi_map_set_item(base->pzonemap, particlename, index) != 0) { cgi_error("Error while adding particlename %s to particlemap hashtable", particlename); return CG_ERROR; } base->npzones++; } (*P) = index + 1; /* save data to particle */ memset(pzone, 0, sizeof(cgns_pzone)); strcpy(pzone->name, particlename); pzone->nparticles = size; /* save data in file */ dim_vals[0]=1; if (cgi_new_node(base->id, pzone->name, "ParticleZone_t", &pzone->id, CG_SIZE_DATATYPE, 1, dim_vals, &pzone->nparticles)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and Write ParticleCoordinates_t Nodes * \*****************************************************************************/ /** * \ingroup ParticleCoordinates * * \brief Get number of \e ParticleCoordinates_t nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[out] ncoord_nodes Number of \e ParticleCoordinates_t nodes for ParticleZone \p P. * \return \ier * */ int cg_particle_ncoord_nodes(int fn, int B, int P, int *ncoord_nodes) { cgns_pzone *pzone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for particle zone*/ pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_ERROR; (*ncoord_nodes) = pzone->npcoor; return CG_OK; } /** * \ingroup ParticleCoordinates * * \brief Get Name of a \e ParticleCoordinates_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] C \C_Coordinate * \param[out] pcoord_name Name of the \e ParticleCoordinates_t node. Note that * the name "ParticleCoordinates" is reserved for the * original particle location and must be the first * \e ParticleCoordinates_t node to be defined. * \return \ier * */ int cg_particle_coord_node_read(int fn, int B, int P, int C, char *pcoord_name) { cgns_pcoor *pcoor; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for ParticleCoordinates_t node */ pcoor = cgi_get_particle_pcoor(cg, B, P, C); if (pcoor==0) return CG_ERROR; /* Return ADF name for the ParticleCoordinates_t node */ strcpy(pcoord_name,pcoor->name); return CG_OK; } /** * \ingroup ParticleCoordinates * * \brief Create a `ParticleCoordinates_t` nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] pcoord_name Name of the \e ParticleCoordinates_t node. * Note that the name "ParticleCoordinates" is reserved * for the original particle location and must be the first * \e ParticleCoordinates_t node to be defined. * \param[out] C \C_Coordinate * \return \ier * */ int cg_particle_coord_node_write(int fn, int B, int P, const char * pcoord_name, int *C) { cgns_pzone *pzone; cgns_pcoor *pcoor = NULL; int index; /* verify input */ if (cgi_check_strlen(pcoord_name)) return CG_ERROR; /* get memory address */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_ERROR; /* Overwrite a ParticleCoordinates_t Node: */ for (index=0; indexnpcoor; index++) { if (strcmp(pcoord_name, pzone->pcoor[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",pcoord_name); return CG_ERROR; } /* overwrite an existing ParticleCoordinates_t node */ /* delete the existing ParticleCoordinates_t from file */ if (cgi_delete_node(pzone->id, pzone->pcoor[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ pcoor = &(pzone->pcoor[index]); /* free memory */ cgi_free_pcoor(pcoor); break; } } /* ... or add a ParticleCoordinates_t Node: */ if (index==pzone->npcoor) { if (pzone->npcoor == 0) { pzone->pcoor = CGNS_NEW(cgns_pcoor, 1); } else { pzone->pcoor = CGNS_RENEW(cgns_pcoor, pzone->npcoor+1, pzone->pcoor); } pcoor = &(pzone->pcoor[pzone->npcoor]); pzone->npcoor++; } (*C) = index+1; /* save data in memory */ memset(pcoor, 0, sizeof(cgns_pcoor)); strcpy(pcoor->name,pcoord_name); /* save data in file */ if (cgi_new_node(pzone->id, pcoor->name, "ParticleCoordinates_t", &pcoor->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and Write ParticleCoordinates_t bounding box \*****************************************************************************/ /** * \ingroup ParticleCoordinates * * \brief Get bounding box associated with a \e ParticleCoordinates_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] C \C_Coordinate * \param[in] datatype Data type of the bounding box array written to the file * or read. Admissible data types for a coordinate bounding * box are \e RealSingle and \e RealDouble. * \param[out] boundingbox Data Array with bounding box values. * \return \ier * * \details When reading a bounding box, if the information is missing from the * file, the \p boundingbox array will remain untouched, and the CG_NODE_NOT_FOUND * status is returned. The CGNS MLL relies on the user to compute the bounding * box and ensure that the bounding box being stored is coherent with the * coordinates under \e GridCoordinates_t node. * */ int cg_particle_bounding_box_read(int fn, int B, int P, int C, CGNS_ENUMT(DataType_t) datatype, void* boundingbox) { cgns_pcoor *pcoor; cgns_base *base; char_33 name; char_33 data_type; int ndim; void * vdata; cgsize_t dim_vals[12]; cgsize_t num; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for ParticleCoordinates_t node */ pcoor = cgi_get_particle_pcoor(cg, B, P, C); if (pcoor==0) return CG_ERROR; /* Read Bounding box from ParticleCoordinates node data */ if (cgi_read_node(pcoor->id, name, data_type, &ndim, dim_vals, &vdata, READ_DATA)){ cgi_error("Error reading node ParticleCoordinates_t"); return CG_ERROR; } /* check bounding box is not an empty array*/ if (strcmp(data_type,"MT")==0) { cgi_error("No bounding box found for reading"); return CG_NODE_NOT_FOUND; } if (strcmp(data_type,"R4") && strcmp(data_type,"R8")) { cgi_error("Datatype %s not supported for coordinates bounding box", data_type); return CG_ERROR; } if (ndim != 2) { cgi_error("Particle coordinates bounding box is %d dimensional. It should be 2.", ndim); return CG_ERROR; } base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; num = 2*base->phys_dim; if (dim_vals[0]*dim_vals[1] != num){ cgi_error("Particle coordinates bounding box is not coherent with physical dimension."); return CG_ERROR; } /* verify input */ if (datatype != CGNS_ENUMV(RealSingle) && datatype != CGNS_ENUMV(RealDouble)) { cgi_error("Invalid data type for bounding box array: %d", datatype); return CG_ERROR; } /* transfer small bounding box data to user with correct data type */ cgi_convert_data(num, cgi_datatype(data_type), vdata, datatype, boundingbox); CGNS_FREE(vdata); return CG_OK; } /** * \ingroup ParticleCoordinates * * \brief Write bounding box associated with a `ParticleCoordinates_t` node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] C \C_Coordinate * \param[in] datatype Data type of the bounding box array written to the file * or read. Admissible data types for a coordinate bounding * box are \e RealSingle and \e RealDouble. * \param[in] boundingbox Data Array with bounding box values. * \return \ier * * \details The CGNS MLL relies on the user to compute the bounding box and ensure * that the bounding box being stored is coherent with the coordinates under * \e ParticleCoordinates_t node. */ int cg_particle_bounding_box_write(int fn, int B, int P, int C, CGNS_ENUMT(DataType_t) datatype, void* boundingbox) { cgns_base *base; cgns_pcoor *pcoor; cgsize_t dim_vals[2]; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* Get memory address for ParticleCoordinates_t node */ pcoor = cgi_get_particle_pcoor(cg, B, P, C); if (pcoor==0) return CG_ERROR; if ((cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) && pcoor->id == 0) { cgi_error("Impossible to write coordinates bounding box to unwritten node"); return CG_ERROR; } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(pcoor->id, hid); if (hid == 0) { cgi_error("Impossible to write coordinates bounding box to unwritten node HDF5"); return CG_ERROR; } } #endif base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; dim_vals[0] = base->phys_dim; dim_vals[1] = 2; /* Check input */ if (boundingbox == NULL) return CG_OK; if (datatype != CGNS_ENUMV(RealSingle) && datatype != CGNS_ENUMV(RealDouble)) { cgi_error("Invalid data type for bounding box array: %d", datatype); return CG_ERROR; } /* Write Bounding box into existing ParticleCoordinates_t node */ if (cgio_set_dimensions(cg->cgio, pcoor->id, cgi_adf_datatype(datatype), 2, dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } if (cgio_write_all_data(cg->cgio, pcoor->id, boundingbox)){ cg_io_error("cgio_write_all_data"); return CG_ERROR; } return CG_OK; } /** * \ingroup ParticleCoordinates * * \brief Get the number of coordinate arrays * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[out] ncoords Number of coordinate arrays for particle zone \p P. * \return \ier * */ int cg_particle_ncoords(int fn, int B, int P, int *ncoords) { cgns_pcoor *pcoor; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for node "ParticleCoordinates" */ pcoor = cgi_get_particle_pcoorPC(cg, B, P); if (pcoor==0) *ncoords = 0; /* if ParticleCoordinates_t is undefined */ else *ncoords = pcoor->ncoords; return CG_OK; } /** * \ingroup ParticleCoordinates * * \brief Get info about a coordinate array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] C \C_Coordinate * \param[out] datatype Data type of the coordinate array written to the file. * Admissible data types for a coordinate array are RealSingle and RealDouble. * \param[out] coordname Name of the coordinate array. It is strongly advised to use the * SIDS nomenclature conventions when naming the coordinate arrays * to ensure file compatibility. * \return \ier * */ int cg_particle_coord_info(int fn, int B, int P, int C, CGNS_ENUMT(DataType_t) *datatype, char *coordname) { cgns_pcoor *pcoor; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for node "ParticleCoordinates" */ pcoor = cgi_get_particle_pcoorPC(cg, B, P); if (pcoor==0) return CG_ERROR; if (C>pcoor->ncoords || C<=0) { cgi_error("Particle coord number %d invalid",C); return CG_ERROR; } *datatype = cgi_datatype(pcoor->coord[C-1].data_type); strcpy(coordname, pcoor->coord[C-1].name); return CG_OK; } /** * \ingroup ParticleCoordinates * * \brief Read particle coordinate array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] coordname Name of the coordinate array. It is strongly advised to use the * SIDS nomenclature conventions when naming the coordinate arrays * to ensure file compatibility. * \param[in] mem_datatype Data type of an array in memory. Admissible data types for a * coordinate array are RealSingle and RealDouble. * \param[in] s_rmin Lower range index in file. * \param[in] s_rmax Upper range index in file. * \param[out] coord_array Array of coordinate values. * \return \ier * */ int cg_particle_coord_read(int fn, int B, int P, const char *coordname, CGNS_ENUMT(DataType_t) mem_datatype, const cgsize_t *s_rmin, const cgsize_t *s_rmax, void *coord_array) { cgns_pzone *pzone; /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone == 0) return CG_ERROR; /* verify that range requested is not NULL */ if (s_rmin == NULL || s_rmax == NULL) { cgi_error("NULL range value."); return CG_ERROR; } cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; m_rmin[0] = 1; m_rmax[0] = s_rmax[0] - s_rmin[0] + 1; m_dimvals[0] = m_rmax[0]; return cg_particle_coord_general_read(fn, B, P, coordname, s_rmin, s_rmax, mem_datatype, m_dimvals, m_rmin, m_rmax, coord_array); } /** * \ingroup ParticleCoordinates * * \brief Read subset of coordinates to a shaped array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] coordname Name of the coordinate array. It is strongly advised to use * the SIDS nomenclature conventions when naming the coordinate * arrays to ensure file compatibility. * \param[in] m_type Data type of an array in memory. Admissible data types for a * coordinate array are RealSingle and RealDouble. * \param[in] s_rmin Lower range index in file. * \param[in] s_rmax Upper range index in file. * \param[in] m_dimvals Dimensions of array in memory. * \param[in] m_rmin Lower range index in memory. * \param[in] m_rmax Upper range index in memory. * \param[out] coord_ptr Array of coordinate values. * \return \ier * */ int cg_particle_coord_general_read(int fn, int B, int P, const char *coordname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *coord_ptr) { /* s_ prefix is file space, m_ prefix is memory space */ cgns_pcoor *pcoor; cgns_array *coord; int c, s_numdim, m_numdim; /* verify input */ if (m_type != CGNS_ENUMV(RealSingle) && m_type != CGNS_ENUMV(RealDouble)) { cgi_error("Invalid data type for coord. array: %d", m_type); return CG_ERROR; } /* find address */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for node "ParticleCoordinates" */ pcoor = cgi_get_particle_pcoorPC(cg, B, P); if (pcoor == 0) return CG_ERROR; /* find the coord address in the database */ coord = 0; for (c=0; cncoords; c++) { if (strcmp(pcoor->coord[c].name, coordname) == 0) { coord = &pcoor->coord[c]; break; } } if (coord==0) { cgi_error("Particle coordinate %s not found.",coordname); return CG_NODE_NOT_FOUND; } /* ParticleZone_t is analogous to Unstructured Zone_t*/ s_numdim = 1; m_numdim = 1; return cgi_array_general_read(coord, cgns_rindindex, NULL, s_numdim, s_rmin, s_rmax, m_type, m_numdim, m_dimvals, m_rmin, m_rmax, coord_ptr); } /** * \ingroup ZoneGridCoordinates * * \brief Get particle coordinate ids * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] C \C_Coordinate * \param[out] coord_id Particle coordinate id. * \return \ier * */ int cg_particle_coord_id(int fn, int B, int P, int C, double *coord_id) { cgns_pcoor *pcoor; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* Get memory address for node "ParticleCoordinates" */ pcoor = cgi_get_particle_pcoorPC(cg, B, P); if (pcoor==0) return CG_ERROR; if (C>pcoor->ncoords || C<=0) { cgi_error("Particle coord number %d invalid",C); return CG_ERROR; } *coord_id = pcoor->coord[C-1].id; return CG_OK; } /** * \ingroup ParticleCoordinates * * \brief Write particle coordinates * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] datatype Data type of the coordinate array written to the file. * Admissible data types for a coordinate array are * RealSingle and RealDouble. * \param[in] coordname Name of the coordinate array. It is strongly advised to * use the SIDS nomenclature conventions when naming the * coordinate arrays to ensure file compatibility. * \param[in] coord_ptr Array of coordinate values. * \param[out] C \C_Coordinate * \return \ier * */ int cg_particle_coord_write(int fn, int B, int P, CGNS_ENUMT(DataType_t) datatype, const char *coordname, const void *coord_ptr, int *C) { cgns_pzone *pzone; cgns_pcoor *pcoor; int status; HDF5storage_type = CG_CONTIGUOUS; /* verify input */ if (cgi_check_strlen(coordname)) return CG_ERROR; if (datatype!=CGNS_ENUMV( RealSingle ) && datatype!=CGNS_ENUMV( RealDouble )) { cgi_error("Invalid datatype for particle coord. array: %d", datatype); return CG_ERROR; } /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone == 0) return CG_ERROR; /* Get memory address for node "ParticleCoordinates" */ pcoor = cgi_get_particle_pcoorPC(cg, B, P); if (pcoor == 0) return CG_ERROR; cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t s_rmin[CGIO_MAX_DIMENSIONS], s_rmax[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; m_dimvals[0] = pzone->nparticles; s_rmin[0] = 1; s_rmax[0] = s_rmin[0] + m_dimvals[0] - 1; m_rmin[0] = 1; m_rmax[0] = m_dimvals[0]; status = cg_particle_coord_general_write(fn, B, P, coordname, datatype, s_rmin, s_rmax, datatype, m_dimvals, m_rmin, m_rmax, coord_ptr, C); HDF5storage_type = CG_COMPACT; return status; } /** * \ingroup ParticleCoordinates * * \brief Write subset of particle coordinates * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] datatype Data type of the coordinate array written to the file. * Admissible data types for a coordinate array are * RealSingle and RealDouble. * \param[in] coordname Name of the coordinate array. It is strongly advised * to use the SIDS nomenclature conventions when naming * the coordinate arrays to ensure file compatibility. * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). * \param[in] coord_ptr Array of coordinate values. * \param[out] C \C_Coordinate * \return \ier * */ int cg_particle_coord_partial_write(int fn, int B, int P, CGNS_ENUMT(DataType_t) datatype, const char *coordname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, const void *coord_ptr, int *C) { cgns_pzone *pzone; int status; /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone == 0) return CG_ERROR; if (s_rmin == NULL || s_rmax == NULL) { cgi_error("NULL range value."); return CG_ERROR; } cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; m_rmin[0] = 1; m_rmax[0] = s_rmax[0] - s_rmin[0] + 1; m_dimvals[0] = m_rmax[0]; status = cg_particle_coord_general_write(fn, B, P, coordname, datatype, s_rmin, s_rmax, datatype, m_dimvals, m_rmin, m_rmax, coord_ptr, C); return status; } /** * \ingroup ParticleCoordinates * * \brief Write shaped array to a subset of particle coordinates * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] coordname Name of the coordinate array. It is strongly advised to * use the SIDS nomenclature conventions when naming the * coordinate arrays to ensure file compatibility. * \param[in] s_type Data type of the coordinate array written to the file. * Admissible data types for a coordinate array are * \e RealSingle and \e RealDouble. * \param[in] m_type Data type of an array in memory. Admissible data types for * a coordinate array are \e RealSingle and \e RealDouble. * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). * \param[in] m_dimvals Dimensions of array in memory. * \param[in] m_rmin Lower range index in memory (eg., imin, jmin, kmin). * \param[in] m_rmax Upper range index in memory (eg., imax, jmax, kmax). * \param[in] coord_ptr Array of coordinate values. * \param[out] C \C_Coordinate * \return \ier * */ int cg_particle_coord_general_write(int fn, int B, int P, const char *coordname, CGNS_ENUMT(DataType_t) s_type, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, const void *coord_ptr, int *C) { /* s_ prefix is file space, m_ prefix is memory space */ cgns_pzone *pzone; cgns_pcoor *pcoor; int n, s_numdim, m_numdim; int status; HDF5storage_type = CG_CONTIGUOUS; /* verify input */ if (cgi_check_strlen(coordname)) return CG_ERROR; if (s_type!=CGNS_ENUMV(RealSingle) && s_type!=CGNS_ENUMV(RealDouble)) { cgi_error("Invalid file data type for coord. array: %d", s_type); return CG_ERROR; } if (m_type != CGNS_ENUMV(RealSingle) && m_type != CGNS_ENUMV(RealDouble) && m_type != CGNS_ENUMV(Integer) && m_type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid input data type for coord. array: %d", m_type); return CG_ERROR; } /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone == 0) return CG_ERROR; /* Get memory address for node "ParticleCoordinates" */ pcoor = cgi_get_particle_pcoorPC(cg, B, P); if (pcoor == 0) return CG_ERROR; cgsize_t s_dimvals[CGIO_MAX_DIMENSIONS]; s_numdim = 1; m_numdim = 1; s_dimvals[0] = pzone->nparticles; /* Create ParticleCoordinates_t node if not already created */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (pcoor->id == 0) { if (cgi_new_node(pzone->id, "ParticleCoordinates", "ParticleCoordinates_t", &pcoor->id, "MT", 0, 0, 0)) return CG_ERROR; } } #if CG_BUILD_HDF5 else if (cg->filetype == CGIO_FILE_HDF5) { hid_t hid; to_HDF_ID(pcoor->id, hid); if (hid == 0) { if (cgi_new_node(pzone->id, "ParticleCoordinates", "ParticleCoordinates_t", &pcoor->id, "MT", 0, 0, 0)) return CG_ERROR; } } #endif else { return CG_ERROR; } status = cgi_array_general_write(pcoor->id, &(pcoor->ncoords), &(pcoor->coord), coordname, cgns_rindindex, NULL, s_type, s_numdim, s_dimvals, s_rmin, s_rmax, m_type, m_numdim, m_dimvals, m_rmin, m_rmax, coord_ptr, C); HDF5storage_type = CG_COMPACT; return status; } /*****************************************************************************\ * Read and Write ParticleSolution_t Nodes \*****************************************************************************/ /** * \ingroup ParticleSolution * * \brief Get the number of ParticleSolution_t nodes * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[out] nsols Number of solutions for particle \p P. * \return \ier * */ int cg_particle_nsols(int fn, int B, int P, int *nsols) { cgns_pzone *pzone; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_ERROR; *nsols = pzone->nsols; return CG_OK; } /** * \ingroup ParticleSolution * * \brief Get information about a ParticleSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[out] solname Name of the particle solution. * \return \ier * */ int cg_particle_sol_info(int fn, int B, int P, int S, char *solname) { cgns_psol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_particle_sol(cg, B, P, S); if (sol==0) return CG_ERROR; strcpy(solname, sol->name); return CG_OK; } /** * \ingroup ParticleSolution * * \brief Get the CGIO node identifier for a ParticleSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[out] sol_id CGIO node identifier of the particle solution node * \return \ier * */ int cg_particle_sol_id(int fn, int B, int P, int S, double *sol_id) { cgns_psol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_particle_sol(cg, B, P, S); if (sol==0) return CG_ERROR; *sol_id = sol->id; return CG_OK; } /** * \ingroup ParticleSolution * * \brief Create and/or write to a ParticleSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] solname Name of the particle solution. * \param[out] S \SOL_S * \return \ier * */ int cg_particle_sol_write(int fn, int B, int P, const char * solname, int *S) { cgns_pzone *pzone; cgns_psol *sol = NULL; int index; /* verify input */ if (cgi_check_strlen(solname)) return CG_ERROR; /* get memory address for ParticleSolution node */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone==0) return CG_ERROR; /* Overwrite a ParticleSolution_t Node: */ for (index=0; indexnsols; index++) { if (strcmp(solname, pzone->sol[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { cgi_error("Duplicate child name found: %s",solname); return CG_ERROR; } /* overwrite an existing solution */ /* delete the existing solution from file */ if (cgi_delete_node(pzone->id, pzone->sol[index].id)) return CG_ERROR; /* save the old in-memory address to overwrite */ sol = &(pzone->sol[index]); /* free memory */ cgi_free_psol(sol); break; } } /* ... or add a ParticleSolution_t Node: */ if (index==pzone->nsols) { if (pzone->nsols == 0) { pzone->sol = CGNS_NEW(cgns_psol, pzone->nsols+1); } else { pzone->sol = CGNS_RENEW(cgns_psol, pzone->nsols+1, pzone->sol); } sol = &(pzone->sol[pzone->nsols]); pzone->nsols++; } (*S) = index+1; /* save data in memory */ memset(sol, 0, sizeof(cgns_psol)); strcpy(sol->name,solname); /* save data in file */ if (cgi_new_node(pzone->id, sol->name, "ParticleSolution_t", &sol->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /** * \ingroup ParticleSolution * * \brief Get the dimensions of a ParticleSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[out] size Number of particles for which solutions are defined. * \return \ier * */ int cg_particle_sol_size(int fn, int B, int P, int S, cgsize_t *size) { cgns_psol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_particle_sol(cg, B, P, S); if (sol==0) return CG_ERROR; if (sol->ptset == NULL) { cgns_pzone *pzone = cgi_get_particle(cg, B, P); *size = pzone->nparticles; } else { *size = sol->ptset->size_of_patch; } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ParticleSolution * * \brief Get info about a point set ParticleSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[out] ptset_type Type of point set defining the interface in the * current solution; either \e PointRange or \e PointList. * \param[out] npnts Number of points defining the interface in the * current solution. For a ptset_type of PointRange, * npnts is always two. For a ptset_type of PointList, * npnts is the number of points in the PointList. * \return \ier * */ int cg_particle_sol_ptset_info(int fn, int B, int P, int S, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts) { cgns_psol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_particle_sol(cg, B, P, S); if (sol==0) return CG_ERROR; if (sol->ptset == NULL) { *ptset_type = CGNS_ENUMV(PointSetTypeNull); *npnts = 0; } else { *ptset_type = sol->ptset->type; *npnts = sol->ptset->npts; } return CG_OK; } /** * \ingroup ParticleSolution * * \brief Read a point set ParticleSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[out] pnts Array of points defining the interface in the current solution. * \return \ier * */ int cg_particle_sol_ptset_read(int fn, int B, int P, int S, cgsize_t *pnts) { cgns_psol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_particle_sol(cg, B, P, S); if (sol==0) return CG_ERROR; if (sol->ptset == 0 || sol->ptset->npts <= 0) { cgi_error("PointSet not defined for ParticleSolution node %d\n", S); return CG_ERROR; } if (cgi_read_int_data(sol->ptset->id, sol->ptset->data_type, sol->ptset->npts, pnts)) return CG_ERROR; return CG_OK; } /** * \ingroup ParticleSolution * * \brief Create a point set ParticleSolution_t node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] solname Name of the particle solution. * \param[in] ptset_type Type of point set defining the interface in the current * solution; either PointRange or PointList. * \param[in] npnts Number of points defining the interface in the current solution. * For a \p ptset_type of \e PointRange, \p npnts is always two. For a * \p ptset_type of \e PointList, \p npnts is the number of points in the \e PointList. * \param[in] pnts Array of points defining the interface in the current solution. * \param[out] S \SOL_S * \return \ier * */ int cg_particle_sol_ptset_write(int fn, int B, int P, const char *solname, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts, int *S) { cgsize_t cnt; cgns_psol *sol; char_33 PointSetName; double id; /* verify input */ if (!((ptset_type == CGNS_ENUMV(PointList) && npnts > 0) || (ptset_type == CGNS_ENUMV(PointRange) && npnts == 2))) { cgi_error("Invalid input: npoint=%ld, point set type=%s", (long)npnts, PointSetTypeName[ptset_type]); return CG_ERROR; } if (cg_particle_sol_write(fn, B, P, solname, S)) return CG_ERROR; sol = cgi_get_particle_sol(cg, B, P, *S); if (sol == 0) return CG_ERROR; sol->ptset = CGNS_NEW(cgns_ptset, 1); sol->ptset->type = ptset_type; strcpy(sol->ptset->data_type,CG_SIZE_DATATYPE); sol->ptset->npts = npnts; if (ptset_type == CGNS_ENUMV(PointList)) { sol->ptset->size_of_patch = npnts; } else { cnt = pnts[1] - pnts[0]; if (cnt < 0) cnt = -cnt; sol->ptset->size_of_patch = (cnt + 1); } strcpy(PointSetName, PointSetTypeName[ptset_type]); if (cgi_write_ptset(sol->id, PointSetName, sol->ptset, 1, (void *)pnts)) return CG_ERROR; return CG_OK; } /*****************************************************************************\ * Read and Write particle field DataArray_t Nodes \*****************************************************************************/ /** * \ingroup ParticleSolutionData * * \brief Get the number of particle solution arrays * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[out] nfields Number of data arrays in particle solution S. * \return \ier * */ int cg_particle_nfields(int fn, int B, int P, int S, int *nfields) { cgns_psol *sol; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; sol = cgi_get_particle_sol(cg, B, P, S); if (sol==0) return CG_ERROR; *nfields = sol->nfields; return CG_OK; } /** * \ingroup ParticleSolutionData * * \brief Get info about a particle solution array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[in] F \PSOL_F * \param[out] datatype Data type of the solution array written to the file. * Admissible data types for a solution array are \e Integer, * \e LongInteger, \e RealSingle, and \e RealDouble. * \param[out] fieldname Name of the solution array. It is strongly advised to use * the SIDS nomenclature conventions when naming the solution * arrays to ensure file compatibility. * \return \ier * */ int cg_particle_field_info(int fn, int B, int P, int S, int F, CGNS_ENUMT(DataType_t) *datatype, char *fieldname) { cgns_array *field; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; field = cgi_get_particle_field(cg, B, P, S, F); if (field==0) return CG_ERROR; strcpy(fieldname, field->name); *datatype = cgi_datatype(field->data_type); return CG_OK; } /** * \ingroup ParticleSolutionData * * \brief Read particle solution * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[in] fieldname Name of the solution array. It is strongly advised to use the * SIDS nomenclature conventions when naming the solution arrays * to ensure file compatibility. * \param[in] mem_datatype Data type of an array in memory. Admissible data types for * a solution array are Integer, LongInteger, RealSingle, * and RealDouble. * \param[in] s_rmin Lower range index in file * \param[in] s_rmax Upper range index in file * \param[out] field_ptr Array of solution values. * \return \ier * */ int cg_particle_field_read(int fn, int B, int P, int S, const char *fieldname, CGNS_ENUMT(DataType_t) mem_datatype, const cgsize_t *s_rmin, const cgsize_t *s_rmax, void *field_ptr) { cgns_psol *sol; int n, m_numdim; /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_particle_sol(cg, B, P, S); if (sol == 0) return CG_ERROR; /* verify that range requested does not exceed range stored */ if (s_rmin == NULL || s_rmax == NULL) { cgi_error("NULL range value."); return CG_ERROR; } cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; m_rmin[0] = 1; m_rmax[0] = s_rmax[0] - s_rmin[0] + 1; m_dimvals[0] = m_rmax[0]; return cg_particle_field_general_read(fn, B, P, S, fieldname, s_rmin, s_rmax, mem_datatype, m_dimvals, m_rmin, m_rmax, field_ptr); } /** * \ingroup ParticleSolutionData * * \brief Read subset of particle solution to a shaped array * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[in] fieldname Name of the solution array. It is strongly advised to use the * SIDS nomenclature conventions when naming the solution arrays * to ensure file compatibility. * \param[in] s_rmin Lower range index in file. * \param[in] s_rmax Upper range index in file. * \param[in] m_type Data type of an array in memory. Admissible data types for a solution * array are Integer, LongInteger, RealSingle, and RealDouble. * \param[in] m_dimvals Dimensions of array in memory. * \param[in] m_rmin Lower range index in memory. * \param[in] m_rmax Upper range index in memory. * \param[out] field_ptr Array of solution values. * \return \ier * */ int cg_particle_field_general_read(int fn, int B, int P, int S, const char *fieldname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *field_ptr) { /* s_ prefix is file space, m_ prefix is memory space */ cgns_psol *sol; cgns_array *field; int f, s_numdim, m_numdim = 1; /* verify input */ if (INVALID_ENUM(m_type, NofValidDataTypes)) { cgi_error("Invalid data type requested for flow solution: %d", m_type); return CG_ERROR; } /* find address */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_particle_sol(cg, B, P, S); if (sol == 0) return CG_ERROR; /* find the field address in the database */ field = 0; for (f=0; fnfields; f++) { if (strcmp(sol->field[f].name, fieldname) == 0) { field = cgi_get_particle_field(cg, B, P, S, f+1); if (field == 0) return CG_ERROR; break; } } if (field == 0) { cgi_error("Flow solution array %s not found",fieldname); return CG_NODE_NOT_FOUND; } s_numdim = 1; return cgi_array_general_read(field, cgns_rindindex, NULL, s_numdim, s_rmin, s_rmax, m_type, m_numdim, m_dimvals, m_rmin, m_rmax, field_ptr); } /** * \ingroup FlowSolutionData * * \brief Get the particle field solution ADF ID number (address) of node * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] Z \Z_Zone * \param[in] S \SOL_S * \param[in] F \PSOL_F * \param[out] field_id Field particle solution ADF ID number (address) of node * \return \ier * */ int cg_particle_field_id(int fn, int B, int P, int S, int F, double *field_id) { cgns_array *field; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; field = cgi_get_particle_field(cg, B, P, S, F); if (field==0) return CG_ERROR; *field_id = field->id; return CG_OK; } /** * \ingroup ParticleSolutionData * * \brief Write Particle solution * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[in] fieldname Name of the solution array. It is strongly advised to use * the SIDS nomenclature conventions when naming the solution * arrays to ensure file compatibility. * \param[in] type Data type of the solution array written to the file. Admissible * data types for a solution array are Integer, LongInteger, * RealSingle, and RealDouble. * \param[in] field_ptr Array of solution values. * \param[out] F \SOL_F * \return \ier * */ int cg_particle_field_write(int fn, int B, int P, int S, CGNS_ENUMT(DataType_t) type, const char *fieldname, const void *field_ptr, int *F) { cgns_pzone *pzone; cgns_psol *sol; int n, m_numdim; HDF5storage_type = CG_CONTIGUOUS; /* verify input */ if (cgi_check_strlen(fieldname)) return CG_ERROR; if (type != CGNS_ENUMV(RealSingle) && type != CGNS_ENUMV(RealDouble) && type != CGNS_ENUMV(ComplexSingle) && type != CGNS_ENUMV(ComplexDouble) && type != CGNS_ENUMV(Integer) && type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid datatype for solution array %s: %d",fieldname, type); return CG_ERROR; } /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone == 0) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_particle_sol(cg, B, P, S); if (sol == 0) return CG_ERROR; /* dimension is dependent on multidim or ptset */ cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; if (sol->ptset == NULL) { m_dimvals[0] = pzone->nparticles; } else { m_dimvals[0] = sol->ptset->size_of_patch; } cgsize_t s_rmin[CGIO_MAX_DIMENSIONS], s_rmax[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; s_rmin[0] = 1 ; s_rmax[0] = s_rmin[0] + m_dimvals[0] - 1; m_rmin[0] = 1; m_rmax[0] = m_dimvals[0]; return cg_particle_field_general_write(fn, B, P, S, fieldname, type, s_rmin, s_rmax, type, m_dimvals, m_rmin, m_rmax, field_ptr, F); } /** * \ingroup ParticleSolutionData * * \brief Write subset of particle solution * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[in] fieldname Name of the solution array. It is strongly advised to use the * SIDS nomenclature conventions when naming the solution arrays * to ensure file compatibility. * \param[in] type Data type of the solution array written to the file. Admissible data * types for a solution array are Integer, LongInteger, RealSingle, * and RealDouble. * \param[in] s_rmin Lower range index in file * \param[in] s_rmax Upper range index in file * \param[in] field_ptr Array of solution values. * \param[out] F \SOL_F * \return \ier * */ int cg_particle_field_partial_write(int fn, int B, int P, int S, CGNS_ENUMT( DataType_t ) type, const char *fieldname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, const void *field_ptr, int *F) { cgns_pzone *pzone; cgns_psol *sol; int n, m_numdim; int status; /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone == 0) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_particle_sol(cg, B, P, S); if (sol == 0) return CG_ERROR; if (s_rmin == NULL || s_rmax == NULL) { cgi_error("NULL range value."); return CG_ERROR; } cgsize_t m_dimvals[CGIO_MAX_DIMENSIONS]; cgsize_t m_rmin[CGIO_MAX_DIMENSIONS], m_rmax[CGIO_MAX_DIMENSIONS]; m_rmin[0] = 1; m_rmax[0] = s_rmax[0] - s_rmin[0] + 1; m_dimvals[0] = m_rmax[0]; status = cg_particle_field_general_write(fn, B, P, S, fieldname, type, s_rmin, s_rmax, type, m_dimvals, m_rmin, m_rmax, field_ptr, F); HDF5storage_type = CG_COMPACT; return status; } /** * \ingroup ParticleSolutionData * * \brief Write shaped array to a subset of the flow solution * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] P \P_ParticleZone * \param[in] S \SOL_S * \param[in] fieldname Name of the solution array. It is strongly advised to use the * SIDS nomenclature conventions when naming the solution arrays * to ensure file compatibility. * \param[in] s_type Data type of the solution array written to the file. Admissible * data types for a solution array are Integer, LongInteger, * RealSingle, and RealDouble. * \param[in] s_rmin Lower range index in file * \param[in] s_rmax Upper range index in file * * \param[in] m_type Data type of an array in memory. Admissible data types for a solution * array are Integer, LongInteger, RealSingle, and RealDouble. * \param[in] m_dimvals Dimensions of array in memory. * \param[in] m_rmin Lower range index in memory * \param[in] m_rmax Upper range index in memory * \param[in] field_ptr Array of solution values. * \param[out] F \SOL_F * \return \ier * */ int cg_particle_field_general_write(int fn, int B, int P, int S, const char *fieldname, CGNS_ENUMT(DataType_t) s_type, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, const void *field_ptr, int *F) { /* s_ prefix is file space, m_ prefix is memory space */ cgns_pzone *pzone; cgns_psol *sol; int s_numdim; int status; HDF5storage_type = CG_CONTIGUOUS; /* verify input */ if (cgi_check_strlen(fieldname)) return CG_ERROR; if (s_type != CGNS_ENUMV(RealSingle) && s_type != CGNS_ENUMV(RealDouble) && s_type != CGNS_ENUMV(ComplexSingle) && s_type != CGNS_ENUMV(ComplexDouble) && s_type != CGNS_ENUMV(Integer) && s_type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid file data type for solution array %s: %d", fieldname, s_type); return CG_ERROR; } if (m_type != CGNS_ENUMV(RealSingle) && m_type != CGNS_ENUMV(RealDouble) && m_type != CGNS_ENUMV(ComplexSingle) && m_type != CGNS_ENUMV(ComplexDouble) && m_type != CGNS_ENUMV(Integer) && m_type != CGNS_ENUMV(LongInteger)) { cgi_error("Invalid input data type for solution array %s: %d", fieldname, m_type); return CG_ERROR; } /* get memory addresses */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; pzone = cgi_get_particle(cg, B, P); if (pzone == 0) return CG_ERROR; /* get memory address for solution */ sol = cgi_get_particle_sol(cg, B, P, S); if (sol == 0) return CG_ERROR; /* file dimension is dependent on multidim or ptset */ cgsize_t s_dimvals[CGIO_MAX_DIMENSIONS]; s_numdim = 1; int m_numdim = 1; if (sol->ptset == NULL) { s_dimvals[0] = pzone->nparticles; } else { s_numdim = 1; s_dimvals[0] = sol->ptset->size_of_patch; } status= cgi_array_general_write(sol->id, &(sol->nfields), &(sol->field), fieldname, cgns_rindindex, NULL, s_type, s_numdim, s_dimvals, s_rmin, s_rmax, m_type, m_numdim, m_dimvals, m_rmin, m_rmax, field_ptr, F); HDF5storage_type = CG_COMPACT; return status; } /*****************************************************************************\ * Go - To Function \*****************************************************************************/ int vcg_goto(int fn, int B, va_list ap) { int n; int index[CG_MAX_GOTO_DEPTH]; char *label[CG_MAX_GOTO_DEPTH]; /* initialize */ posit = 0; /* set global variable cg */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* read variable argument list */ for (n = 0; n < CG_MAX_GOTO_DEPTH; n++) { label[n] = va_arg(ap,char *); if (label[n] == NULL || label[n][0] == 0) break; if (strcmp("end",label[n])==0 || strcmp("END",label[n])==0) break; index[n] = va_arg(ap, int); } return cgi_set_posit(fn, B, n, index, label); } /** * \ingroup AccessingANode * * \brief Access a node via label/name, index pairs * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] ... Variable argument list used to specify the path to a node. It comprises * an unlimited list of paired arguments identifying each node in the path. Nodes * may be identified by their label or name. Thus, a paired argument may be of * the form * \code{C} "CGNS_NodeLabel", NodeIndex \endcode * where \e CGNS_NodeLabel is the node label and \e NodeIndex is the node index, or * \code{C} "CGNS_NodeName", 0 \endcode * where \e CGNS_NodeName is the node name. The \e 0 in the second form is required to indicate * that a node name is being specified rather than a node label. In addition, a * pair-argument may be specified as * \code{C} "..", 0 \endcode * indicating the parent of the current node. The different pair-argument forms may be * intermixed in the same function call.\n * There is one exception to this rule. When accessing a \e BCData_t node, the index must be set * to either \e Dirichlet or \e Neumann since only these two types are allowed. (Note that * \e Dirichlet and \e Neumann are defined in the include files cgnslib.h, cgnslib_f.h and the CGNS module). * Since \e "Dirichlet" and \e "Neuman" are also the names for these nodes, you may also use * the \e "Dirichlet", \e 0 or \e "Neuman", \e 0 to access the node. See \ref CGNS_Navigation_Ill * "CGNS Navigation Illustration" for example usage. * \return \ier * * \details The character string "end" (or 'end' for the Fortran function) must be the last argument. It * is used to indicate the end of the argument list. You may also use the empty string, * "" ('' for Fortran), or the NULL string in C, to terminate the list. * */ int cg_goto(int fn, int B, ...) { va_list ap; int status; va_start(ap, B); status = vcg_goto(fn, B, ap); va_end(ap); return status; } /*----------------------------------------------------------------------- * F2008 C-FORTRAN INTERFACE ROUTINE * * cg_goto function which is compatible with F2008 and TS 29113 * "Further Interoperability of Fortran with C WG5/N1942" and * allows optional function parameters to be passed to a C function * which has a variable number of arguments. This function is * directly callable from FORTRAN. * */ int cg_goto_f08(int fn, int B, ...) { int n; va_list ap; int index[CG_MAX_GOTO_DEPTH]; char *label[CG_MAX_GOTO_DEPTH]; /* initialize */ posit = 0; /* set global variable cg */ cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; va_start(ap, B); /* read variable argument list */ for (n = 0; n < CG_MAX_GOTO_DEPTH; n++) { label[n] = va_arg(ap,char *); if (label[n] == NULL || label[n][0] == 0) break; if (strcmp("end",label[n])==0 || strcmp("END",label[n])==0) break; index[n] = (int)*va_arg(ap, int *); } va_end(ap); return cgi_set_posit(fn, B, n, index, label); } /*-----------------------------------------------------------------------*/ int vcg_gorel(int fn, va_list ap) { int n = 0; int index[CG_MAX_GOTO_DEPTH]; char *label[CG_MAX_GOTO_DEPTH]; if (posit == 0) { cgi_error ("position not set with cg_goto"); return CG_ERROR; } if (fn != posit_file) { cgi_error("current position is in the wrong file"); return CG_ERROR; } for (n = 0; n < CG_MAX_GOTO_DEPTH; n++) { label[n] = va_arg(ap, char *); if (label[n] == NULL || label[n][0] == 0) break; if (strcmp("end",label[n])==0 || strcmp("END",label[n])==0) break; index[n] = va_arg(ap, int); } return cgi_update_posit(n, index, label); } /** * \ingroup AccessingANode * * \brief Access a node via relative path * * \param[in] fn \FILE_fn * \param[in] ... Variable argument list used to specify the path to a node. It comprises * an unlimited list of paired arguments identifying each node in the path. Nodes * may be identified by their label or name. Thus, a paired argument may be of * the form * \code{C} "CGNS_NodeLabel", NodeIndex \endcode * where \e CGNS_NodeLabel is the node label and NodeIndex is the node index, or * \code{C} "CGNS_NodeName", 0 \endcode * where \e CGNS_NodeName is the node name. The \e 0 in the second form is required, * to indicate that a node name is being specified rather than a node label. In * addition, a paired argument may be specified as * \code{C} "..", 0 \endcode * indicating the parent of the current node. The different pair-argument forms * may be intermixed in the same function call.\n * There is one exception to this rule. When accessing a \e BCData_t node, the index * must be set to either \e Dirichlet or \e Neumann since only these two types are allowed. * (Note that \e Dirichlet and \e Neumann are defined in the include files cgnslib.h and * cgnslib_f.h, and the CGNS module). Since \e "Dirichlet" and \e "Neuman" are also the names for these nodes, * you may also use the \e "Dirichlet", \e 0 or \e "Neuman", \e 0 to access the node. See * \ref CGNS_Navigation_Ill "CGNS Navigation Illustration" for example usage. * \return \ier * * \details The character string "end" (or 'end' for the Fortran function) must be the last argument. * It is used to indicate the end of the argument list. You may also use the empty string, * "" ('' for Fortran), or the NULL string in C, to terminate the list. */ int cg_gorel(int fn, ...) { va_list ap; int status; va_start (ap, fn); status = vcg_gorel(fn, ap); va_end(ap); return status; } /*----------------------------------------------------------------------- * F2008 C-FORTRAN INTERFACE ROUTINE * * cg_gorel function which is compatible with F2008 and TS 29113 * "Further Interoperability of Fortran with C WG5/N1942" and * allows optional function parameters to be passed to a C function * which has a variable number of arguments. This function is * directly callable from FORTRAN. * */ int cg_gorel_f08(int fn, ...) { int n = 0; int index[CG_MAX_GOTO_DEPTH]; char *label[CG_MAX_GOTO_DEPTH]; va_list ap; if (posit == 0) { cgi_error ("position not set with cg_goto"); return CG_ERROR; } if (fn != posit_file) { cgi_error("current position is in the wrong file"); return CG_ERROR; } va_start (ap, fn); for (n = 0; n < CG_MAX_GOTO_DEPTH; n++) { label[n] = va_arg(ap, char *); if (label[n] == NULL || label[n][0] == 0) break; if (strcmp("end",label[n])==0 || strcmp("END",label[n])==0) break; index[n] = (int)*va_arg(ap, int *); } va_end(ap); return cgi_update_posit(n, index, label); } /*-----------------------------------------------------------------------*/ /** * \ingroup AccessingANode * * \brief Access a node via pathname * * \param[in] fn \FILE_fn * \param[in] path The pathname for the node to go to. If a position has been already set, this * may be a relative path; otherwise, it is an absolute path name, starting with * \e "/Basename", where \e Basename is the base under which you wish to move. * \return \ier * */ int cg_gopath(int fn, const char *path) { int n, len; const char *p = path, *s; int index[CG_MAX_GOTO_DEPTH]; char label[CG_MAX_GOTO_DEPTH][CGIO_MAX_NAME_LENGTH+1]; char *lab[CG_MAX_GOTO_DEPTH]; if (p == 0 || !*p) { cgi_error("path not given"); return CG_ERROR; } /* absolute path */ if (*p == '/') { int ierr, B = 0; posit = 0; while (*++p && *p == '/') ; if (!*p) { cgi_error("base name not given"); return CG_ERROR; } s = strchr(p, '/'); if (s == 0) len = (int)strlen(p); else len = (int)(s - p); if (len > 32) { cgi_error("base name in path is too long"); return CG_ERROR; } strncpy(label[0], p, len); label[0][len] = 0; cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; for (n = 0; n < cg->nbases; n++) { if (0 == strcmp(label[0], cg->base[n].name)) { B = n + 1; break; } } if (B == 0) { cgi_error("base '%s' not found", label[0]); return CG_ERROR; } ierr = cgi_set_posit(fn, B, 0, index, lab); if (ierr != CG_OK) return ierr; if (s == 0) return CG_OK; p = s; } /* relative path */ else { if (posit == 0) { cgi_error("position not set with cg_goto"); return CG_ERROR; } if (fn != posit_file) { cgi_error("current position is in the wrong file"); return CG_ERROR; } } n = 0; while (p && *p) { while (*p && *p == '/') p++; if (!*p) break; s = strchr(p, '/'); if (s == 0) len = (int)strlen(p); else len = (int)(s - p); if (len > 32) { posit = 0; cgi_error("node name in path is too long"); return CG_ERROR; } if (n == CG_MAX_GOTO_DEPTH) { posit = 0; cgi_error("path is too deep"); return CG_ERROR; } strncpy(label[n], p, len); label[n][len] = 0; lab[n] = label[n]; index[n++] = 0; p = s; } return cgi_update_posit(n, index, lab); } /*-----------------------------------------------------------------------*/ /** * \ingroup AccessingANode * * \brief Access a node via arrays of labels and indices * * \param[in] fn \FILE_fn * \param[in] B \B_Base * \param[in] depth Depth of the path list. The maximum depth is defined in cgnslib.h by * CG_MAX_GOTO_DEPTH, and is currently equal to 20. * \param[in] label Array of node labels for the path. This argument may be passed as NULL to * cg_where(), otherwise it must be dimensioned by the calling program. The * maximum size required is label[MAX_GO_TO_DEPTH][33]. You may call cg_where() * with both label and index set to NULL to get the current depth, * then dimension to that value. * \param[in] index Array of node indices for the path. This argument may be passed as NULL to * cg_where(), otherwise it must be dimensioned by the calling program. The * maximum size required is \c index[MAX_GO_TO_DEPTH]. You may call cg_where() * with both label and index set to NULL to get the current depth, * then dimension to that value. * \return \ier * */ int cg_golist(int fn, int B, int depth, char **label, int *index) { if (depth >= CG_MAX_GOTO_DEPTH) { cgi_error("path is too deep"); return CG_ERROR; } return cgi_set_posit(fn, B, depth, index, label); } /*-----------------------------------------------------------------------*/ /** * \ingroup AccessingANode * * \brief Get path to current node * * \param[out] fn \FILE_fn * \param[out] B \B_Base * \param[out] depth Depth of the path list. The maximum depth is defined in cgnslib.h by * CG_MAX_GOTO_DEPTH, and is currently equal to 20. * \param[out] label Array of node labels for the path. This argument may be passed as NULL to * cg_where(), otherwise it must be dimensioned by the calling program. The * maximum size required is label[MAX_GO_TO_DEPTH][33]. You may call cg_where() * with both label and index set to NULL to get the current depth, * then dimension to that value. * \param[out] num Array of node indices for the path. This argument may be passed as NULL to * cg_where(), otherwise it must be dimensioned by the calling program. The * maximum size required is index[MAX_GO_TO_DEPTH]. You may call cg_where() * with both label and index set to NULL to get the current depth, * then dimension to that value. * \return \ier * */ int cg_where(int *fn, int *B, int *depth, char **label, int *num) { int n; if (posit == 0) { cgi_error ("position not set with cg_goto"); return CG_ERROR; } *fn = posit_file; *B = posit_base; /* first entry is base */ *depth = posit_depth > 1 ? posit_depth - 1 : 0; if (NULL != label) { for (n = 1; n < posit_depth; n++) strcpy(label[n-1], posit_stack[n].label); } if (NULL != num) { for (n = 1; n < posit_depth; n++) num[n-1] = posit_stack[n].index; } return CG_OK; } /*****************************************************************************\ * Read and write Multiple path nodes \*****************************************************************************/ /** * \ingroup FamilyName * * \brief Read family name * * \param[out] family_name \family_name * \return \ier * */ int cg_famname_read(char *family_name) { char *famname; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; famname = cgi_famname_address(CG_MODE_READ, &ier); if (famname==0) return ier; strcpy(family_name,famname); if (!strlen(famname)) return CG_NODE_NOT_FOUND; return CG_OK; } /** * \ingroup FamilyName * * \brief Write family name * * \param[in] family_name \family_name * \return \ier * */ int cg_famname_write(const char * family_name) { char *famname; int ier=0; cgsize_t dim_vals; double posit_id, dummy_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* Family Tree */ /*if (cgi_check_strlen(family_name)) return CG_ERROR;*/ famname = cgi_famname_address(CG_MODE_WRITE, &ier); if (famname==0) return ier; strcpy(famname, family_name); /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; dim_vals = (cgsize_t)strlen(family_name); if (cgi_new_node(posit_id, "FamilyName", "FamilyName_t", &dummy_id, "C1", 1, &dim_vals, (void *)family_name)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup FamilyName * * \brief Get the number of family names * * \param[out] nfams Number of additional family names. * \return \ier * */ int cg_nmultifam(int *nfams) { CHECK_FILE_OPEN /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*nfams) = 0; return CG_ERROR; } if (0 == strcmp(posit->label,"Zone_t")) { cgns_zone *zone= (cgns_zone *)posit->posit; (*nfams) = zone->nfamname; } else if (0 == strcmp(posit->label,"BC_t")) { cgns_boco *boco = (cgns_boco *)posit->posit; (*nfams) = boco->nfamname; } else if (strcmp(posit->label,"ZoneSubRegion_t")==0) { cgns_subreg *subreg = (cgns_subreg *)posit->posit; (*nfams) = subreg->nfamname; } else if (strcmp(posit->label,"UserDefinedData_t")==0) { cgns_user_data *user_data = (cgns_user_data *)posit->posit; (*nfams) = user_data->nfamname; } else { cgi_error("AdditionalFamilyName_t node not supported under '%s' type node",posit->label); (*nfams) = 0; return CG_INCORRECT_PATH; } return CG_OK; } /** * \ingroup FamilyName * * \brief Read multiple family names * * \param[in] N Family name index number, where 1 ≤ N ≤ nNames. * \param[out] name Node name. * \param[out] family Family name * \return \ier * */ int cg_multifam_read(int N, char *name, char *family) { cgns_famname *famname; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; famname = cgi_multfam_address(CG_MODE_READ, N, "", &ier); if (famname==0) return ier; strcpy(name, famname->name); strcpy(family, famname->family); return CG_OK; } /** * \ingroup FamilyName * * \brief Write multiple family names * * \param[in] name Node name. * \param[in] family Family name * \return \ier * * \details The additional family names written with cg_multifam_write are stored in * AdditionalFamilyName_t nodes. */ int cg_multifam_write(const char *name, const char *family) { cgns_famname *famname; int ier=0; cgsize_t dim_vals; double posit_id, dummy_id; CHECK_FILE_OPEN if (cgi_check_strlen(name) || cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* ** FAMILY TREE ** */ /* #ifdef CG_BUILD_BASESCOPE if (cgi_check_strlen_x2(family)) return CG_ERROR; #else if (cgi_check_strlen(family)) return CG_ERROR; #endif */ famname = cgi_multfam_address(CG_MODE_WRITE, 0, name, &ier); if (famname == 0) return ier; strcpy(famname->name, name); strcpy(famname->family, family); if (cgi_posit_id(&posit_id)) return CG_ERROR; dim_vals = (cgsize_t)strlen(family); if (cgi_new_node(posit_id, name, "AdditionalFamilyName_t", &dummy_id, "C1", 1, &dim_vals, (void *)family)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ConvergenceHistory * * \brief Read ConvergenceHistory_t node * * \param[out] iterations Number of iterations for which convergence information is recorded. * \param[out] NormDefinitions Description of the convergence information recorded in the data arrays. * \return \ier * * \details The function cg_convergence_read() reads a ConvergenceHistory_t node. If NormDefinitions * is not defined in the CGNS database, this function returns a null string. If * NormDefinitions exists, and then the library will allocate the space to store the description * string and return the description string to the application. It is the responsibility * of the application to free this space when it is no longer needed by a call * to cg_free(NormDefinitions). * */ int cg_convergence_read(int *iterations, char **NormDefinitions) { cgns_converg *converg; cgns_descr *descr; int ier=0; CHECK_FILE_OPEN /* verify input (cg set in cg_goto) */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; converg = cgi_converg_address(CG_MODE_READ, &ier); if (converg==0) return ier; (*iterations) = converg->iterations; if (converg->NormDefinitions==0) { NormDefinitions[0] = CGNS_NEW(char, 1); NormDefinitions[0][0]='\0'; } else { descr = converg->NormDefinitions; NormDefinitions[0] = CGNS_NEW(char, strlen(descr->text)+1); strcpy(NormDefinitions[0], descr->text); } return CG_OK; } /** * \ingroup ConvergenceHistory * * \brief Write ConvergenceHistory_t node * * \param[in] iterations Number of iterations for which convergence information is recorded. * \param[in] NormDefinitions Description of the convergence information recorded in the data arrays. * \return \ier * * \details The function cg_convergence_write creates a ConvergenceHistory_t node. It must be * the first one called when recording convergence history data. The NormDefinitions * may be left undefined (i.e., a blank string). After the creation of this node, the descriptors, * data arrays, data class, and dimensional units characterizing the ConvergenceHistory_t data * structure may be added. * */ int cg_convergence_write(int iterations, const char * NormDefinitions) { cgns_converg *converg; int ier=0; cgsize_t dim_vals; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; converg = cgi_converg_address(CG_MODE_WRITE, &ier); if (converg==0) return ier; /* initialize new ConvergenceHistory_t node */ converg->iterations=0; converg->id = 0; converg->link=0; converg->ndescr=0; converg->NormDefinitions = 0; converg->narrays=0; converg->data_class=CGNS_ENUMV( DataClassNull ); converg->units=0; converg->nuser_data=0; /* save data in memory */ converg->iterations = iterations; if (NormDefinitions && strlen(NormDefinitions)) { converg->NormDefinitions=CGNS_NEW(cgns_descr, 1); converg->NormDefinitions->id=0; converg->NormDefinitions->link=0; converg->NormDefinitions->text = CGNS_NEW(char, strlen(NormDefinitions)+1); strcpy(converg->NormDefinitions->text, NormDefinitions); strcpy(converg->NormDefinitions->name, "NormDefinitions"); } /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; dim_vals=1; if (cgi_new_node(posit_id, converg->name, "ConvergenceHistory_t", &converg->id, "I4", 1, &dim_vals, (void *)&converg->iterations)) return CG_ERROR; /* write NormDefinitions */ if (converg->NormDefinitions && cgi_write_descr(converg->id, converg->NormDefinitions)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ReferenceState * * \brief Read text description of reference state. * * \param[in] StateDescription Text description of reference state. * \return \ier * * \details The function cg_state_read reads the StateDescription of the local ReferenceState_t node. * If StateDescription is undefined in the CGNS database, this function returns a null string. * If StateDescription exists, the library will allocate the space to store the description string, * and return the description string to the application. It is the responsibility of the application * to free this space when it is no longer needed by a call to cg_free(StateDescription). * */ int cg_state_read(char **StateDescription) { cgns_state *state; cgns_descr *descr; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; state = cgi_state_address(CG_MODE_READ, &ier); if (state==0) return ier; if (state->StateDescription == 0) { StateDescription[0]=CGNS_NEW(char, 1); StateDescription[0][0]='\0'; } else { descr = state->StateDescription; StateDescription[0]=CGNS_NEW(char, strlen(descr->text)+1); strcpy(StateDescription[0], descr->text); } return CG_OK; } /** * \ingroup ReferenceState * * \brief Create ReferenceState_t node * * \param[in] StateDescription Text description of reference state. * \return \ier * * \details The function cg_state_write creates the ReferenceState_t node and must be called even if * StateDescription is undefined (i.e., a blank string). The descriptors, data arrays, * data class, and dimensional units characterizing the ReferenceState_t data structure * may be added to this data structure after its creation. * */ int cg_state_write(const char * StateDescription) { cgns_state *state; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; state = cgi_state_address(CG_MODE_WRITE, &ier); if (state==0) return ier; /* initialize state */ strcpy(state->name,"ReferenceState"); state->id = 0; state->link=0; state->ndescr=0; state->narrays=0; state->data_class=CGNS_ENUMV( DataClassNull ); state->units=0; state->StateDescription=0; state->nuser_data=0; /* Save data in memory */ if (StateDescription && strlen(StateDescription)) { state->StateDescription=CGNS_NEW(cgns_descr, 1); state->StateDescription->id = 0; state->StateDescription->link = 0; state->StateDescription->text = CGNS_NEW(char, strlen(StateDescription)+1); strcpy(state->StateDescription->text, StateDescription); strcpy(state->StateDescription->name, "ReferenceStateDescription"); } /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; /* ReferenceState_t */ if (cgi_new_node(posit_id, state->name, "ReferenceState_t", &state->id, "MT", 0, 0, 0)) return CG_ERROR; /* ReferenceStateDescription */ if (state->StateDescription && cgi_write_descr(state->id, state->StateDescription)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup FlowEquationSet * * \brief Read Flow equation set info * * \param[out] EquationDimension Dimensionality of the governing equations; it is the number of spatial * variables describing the flow. * \param[out] GoverningEquationsFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of the governing equations; 0 if it doesn't, 1 if it does. * \param[out] GasModelFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of a gas model; 0 if it doesn't, 1 if it does. * \param[out] ViscosityModelFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of a viscosity model; 0 if it doesn't, 1 if it does. * \param[out] ThermalConductivityModelFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of a thermal conductivity model; 0 if it doesn't, 1 if it does. * \param[out] TurbulenceClosureFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of the turbulence closure; 0 if it doesn't, 1 if it does. * \param[out] TurbulenceModelFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of a turbulence model; 0 if it doesn't, 1 if it does. * \return \ier * */ int cg_equationset_read(int *EquationDimension, int *GoverningEquationsFlag, int *GasModelFlag, int *ViscosityModelFlag, int *ThermalConductivityModelFlag, int *TurbulenceClosureFlag, int *TurbulenceModelFlag) { cgns_equations *eq; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; eq = cgi_equations_address(CG_MODE_READ, &ier); if (eq==0) return ier; (*EquationDimension) = eq->equation_dim; if (eq->governing) (*GoverningEquationsFlag)=1; else (*GoverningEquationsFlag)=0; if (eq->gas) (*GasModelFlag)=1; else (*GasModelFlag)=0; if (eq->visc) (*ViscosityModelFlag)=1; else (*ViscosityModelFlag)=0; if (eq->conduct) (*ThermalConductivityModelFlag)=1; else (*ThermalConductivityModelFlag)=0; if (eq->closure) (*TurbulenceClosureFlag)=1; else (*TurbulenceClosureFlag)=0; if (eq->turbulence) (*TurbulenceModelFlag)=1; else (*TurbulenceModelFlag)=0; /* Version 2.1 chemistry extensions get their own read routine ** for backward compatibility. */ return CG_OK; } /** * \ingroup FlowEquationSet * * \brief Read chemistry equation set info * * \param[out] ThermalRelaxationFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of a thermal relaxation model; 0 if it doesn't, 1 if it does. * \param[out] ChemicalKineticsFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of a chemical kinetics model; 0 if it doesn't, 1 if it does. * \return \ier * */ int cg_equationset_chemistry_read(int *ThermalRelaxationFlag, int *ChemicalKineticsFlag) { cgns_equations *eq; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; eq = cgi_equations_address(CG_MODE_READ, &ier); if (eq==0) return ier; if (eq->relaxation) (*ThermalRelaxationFlag)=1; else (*ThermalRelaxationFlag)=0; if (eq->chemkin) (*ChemicalKineticsFlag)=1; else (*ChemicalKineticsFlag)=0; return CG_OK; } /** * \ingroup FlowEquationSet * * \brief Read electromagnetic equation set info * * \param[out] ElecFldModelFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of an electric field model for electromagnetic flows; 0 if it * doesn't, 1 if it does. * \param[out] MagnFldModelFlag Flag indicates whether this FlowEquationSet_t node includes the * definition of a magnetic field model for electromagnetic flows; 0 if it * doesn't, 1 if it does. * \param[out] ConductivityModelFlag Flag indicating whether or not this FlowEquationSet_t node includes the * definition of a conductivity model for electromagnetic flows; 0 if it * doesn't, 1 if it does. * \return \ier * */ int cg_equationset_elecmagn_read(int *ElecFldModelFlag, int *MagnFldModelFlag, int *ConductivityModelFlag) { cgns_equations *eq; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; eq = cgi_equations_address(CG_MODE_READ, &ier); if (eq==0) return ier; if (eq->elecfield) (*ElecFldModelFlag)=1; else (*ElecFldModelFlag)=0; if (eq->magnfield) (*MagnFldModelFlag)=1; else (*MagnFldModelFlag)=0; if (eq->emconduct) (*ConductivityModelFlag)=1; else (*ConductivityModelFlag)=0; return CG_OK; } /** * \ingroup FlowEquationSet * * \brief Write dimensionality of flow equations * * \param[in] EquationDimension Dimensionality of the governing equations; it is the number of spatial * variables describing the flow. * \return \ier * */ int cg_equationset_write(int EquationDimension) { cgns_equations *equations; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; equations=cgi_equations_address(CG_MODE_WRITE, &ier); if (equations==0) return ier; /* Save data */ equations->equation_dim=EquationDimension; /* initialize other fields */ strcpy(equations->name, "FlowEquationSet"); equations->id=0; equations->link=0; equations->ndescr=0; equations->governing=0; equations->gas=0; equations->visc=0; equations->conduct=0; equations->closure=0; equations->turbulence=0; equations->relaxation=0; equations->chemkin=0; equations->data_class=CGNS_ENUMV( DataClassNull ); equations->units=0; equations->nuser_data=0; equations->elecfield = 0; equations->magnfield = 0; equations->emconduct = 0; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_equations(posit_id, equations)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ParticleEquationSet * * \brief Read particle equation set info * * \param[out] EquationDimension Dimensionality of the governing equations; it is the number of spatial variables describing the flow. * \param[out] ParticleGoverningEquationsFlag Flag indicates whether this ParticleEquationSet_t node includes the definition of the particle governing equations; 0 if it doesn't, 1 if it does. * \param[out] CollisionModelFlag Flag indicates whether or not this ParticleEquationSet_t node includes the definition of a collision model; 0 if it doesn't, 1 if it does. * \param[out] BreakupModelFlag Flag indicates whether this ParticleEquationSet_t node includes the definition of a breakup model; 0 if it doesn't, 1 if it does. * \param[out] ForceModelFlag Flag indicates whether or not this ParticleEquationSet_t node includes the definition of a force model; 0 if it doesn't, 1 if it does. * \param[out] WallInteractionModelFlag Flag indicates whether or not this ParticleEquationSet_t node includes the definition of a wall interaction model; 0 if it doesn't, 1 if it does. * \param[out] PhaseChangeModelFlag Flag indicates whether or not this ParticleEquationSet_t node includes the definition of a phase change model; 0 if it doesn't, 1 if it does. * \return \ier * */ int cg_particle_equationset_read(int *EquationDimension, int *ParticleGoverningEquationsFlag, int *CollisionModelFlag, int *BreakupModelFlag, int *ForceModelFlag, int *WallInteractionModelFlag, int *PhaseChangeModelFlag) { cgns_pequations *eq; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; eq = cgi_particle_equations_address(CG_MODE_READ, &ier); if (eq==0) return ier; (*EquationDimension) = eq->equation_dim; if (eq->governing) (*ParticleGoverningEquationsFlag)=1; else (*ParticleGoverningEquationsFlag)=0; if (eq->collision) (*CollisionModelFlag)=1; else (*CollisionModelFlag)=0; if (eq->breakup) (*BreakupModelFlag)=1; else (*BreakupModelFlag)=0; if (eq->force) (*ForceModelFlag)=1; else (*ForceModelFlag)=0; if (eq->wallinteract) (*WallInteractionModelFlag)=1; else (*WallInteractionModelFlag)=0; if (eq->phasechange) (*PhaseChangeModelFlag)=1; else (*PhaseChangeModelFlag)=0; return CG_OK; } /** * \ingroup ParticleEquationSet * * \brief Write dimensionality of particle equations * * \param[in] EquationDimension Dimensionality of the governing equations; it is the number of spatial variables describing the particle flow. * \return \ier * */ int cg_particle_equationset_write(int EquationDimension) { cgns_pequations *equations; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; equations=cgi_particle_equations_address(CG_MODE_WRITE, &ier); if (equations==0) return ier; /* Save data */ equations->equation_dim=EquationDimension; /* initialize other fields */ strcpy(equations->name, "ParticleEquationSet"); equations->id=0; equations->link=0; equations->ndescr=0; equations->governing=0; equations->collision=0; equations->breakup=0; equations->force=0; equations->wallinteract=0; equations->phasechange=0; equations->data_class=CGNS_ENUMV( DataClassNull ); equations->units=0; equations->nuser_data=0; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_particle_equations(posit_id, equations)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup GoverningEquations * * \brief Read type of governing equation * * \param[out] EquationsType Type of governing equations. The admissible types are \e CG_Null, * \e CG_UserDefined, \e FullPotential, \e Euler, \e NSLaminar, \e NSTurbulent, * \e NSLaminarIncompressible, and \e NSTurbulentIncompressible. * \return \ier * */ int cg_governing_read(CGNS_ENUMT(GoverningEquationsType_t) *EquationsType) { cgns_governing *governing; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; governing = cgi_governing_address(CG_MODE_READ, &ier); if (governing==0) return ier; (*EquationsType) = governing->type; return CG_OK; } /** * \ingroup GoverningEquations * * \brief Write the type of governing equation * * \param[in] Equationstype Type of governing equations. The admissible types are \e CG_Null, * \e CG_UserDefined, \e FullPotential, \e Euler, \e NSLaminar, \e NSTurbulent, * \e NSLaminarIncompressible, and \e NSTurbulentIncompressible. * \return \ier * */ int cg_governing_write(CGNS_ENUMT(GoverningEquationsType_t) Equationstype) { cgns_governing *governing; int ier=0, index_dim; cgsize_t dim_vals; double posit_id; CHECK_FILE_OPEN /* verify input */ if (INVALID_ENUM(Equationstype,NofValidGoverningEquationsTypes)) { cgi_error("Invalid Governing Equations Type: %d",Equationstype); return CG_ERROR; } if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; governing = cgi_governing_address(CG_MODE_WRITE, &ier); if (governing==0) return ier; /* Save data */ governing->type=Equationstype; /* initialize other fields */ strcpy(governing->name, "GoverningEquations"); governing->id=0; governing->link=0; governing->ndescr=0; governing->diffusion_model=0; governing->nuser_data=0; if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; /* If defined under CGNSBase_t node */ } else if (posit_base) { index_dim = cg->base[posit_base-1].cell_dim; } else { cgi_error("Can't find IndexDimension in cg_governing_write."); return CG_NO_INDEX_DIM; } if (index_dim==1) governing->dim_vals=1; else if (index_dim==2) governing->dim_vals=3; else if (index_dim==3) governing->dim_vals=6; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; dim_vals = (cgsize_t)strlen(GoverningEquationsTypeName[governing->type]); if (cgi_new_node(posit_id, "GoverningEquations", "GoverningEquations_t", &governing->id, "C1", 1, &dim_vals, GoverningEquationsTypeName[governing->type])) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup GoverningEquations * * \brief Read flags for diffusion terms * * \param[out] diffusion_model Flags defining which diffusion terms are included in the governing * equations. This is only applicable to the Navier-Stokes equations with * structured grids. See the discussion in the SIDS manual for details. * \return \ier * */ int cg_diffusion_read(int *diffusion_model) { int n, ndata, ier=0; int *diffusion, index_dim; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; diffusion = cgi_diffusion_address(CG_MODE_READ, &ier); if (diffusion==0) return ier; if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; /* If defined under CGNSBase_t node */ } else if (posit_base) { index_dim = cg->base[posit_base-1].cell_dim; } else { cgi_error("Can't find IndexDimension in cg_diffusion_read."); return CG_NO_INDEX_DIM; } if (index_dim==1) ndata=1; else if (index_dim==2) ndata=3; else if (index_dim==3) ndata=6; else { cgi_error("invalid value for IndexDimension"); return CG_ERROR; } for (n=0; nfilename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; diffusion = cgi_diffusion_address(CG_MODE_WRITE, &ier); if (diffusion==0) return ier; /* Save data */ if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; /* If defined under CGNSBase_t node */ } else if (posit_base) { index_dim = cg->base[posit_base-1].cell_dim; } else { cgi_error("Can't find IndexDimension in cg_diffusion_write."); return CG_NO_INDEX_DIM; } if (index_dim==1) ndata=1; else if (index_dim==2) ndata=3; else if (index_dim==3) ndata=6; else { cgi_error("invalid value for IndexDimension"); return CG_ERROR; } for (n=0; n * GasModel_t CG_Null, CG_UserDefined, Ideal, VanderWaals, CaloricallyPerfect, * ThermallyPerfect, ConstantDensity, RedlichKwong * ViscosityModel_t CG_Null, CG_UserDefined, Constant, * PowerLaw, SutherlandLaw * ThermalConductivityModel_t CG_Null, CG_UserDefined, PowerLaw, * SutherlandLaw, ConstantPrandtl * TurbulenceModel_t CG_Null, CG_UserDefined, Algebraic_BaldwinLomax, * Algebraic_CebeciSmith, HalfEquation_JohnsonKing, * OneEquation_BaldwinBarth, OneEquation_SpalartAllmaras, * TwoEquation_JonesLaunder, TwoEquation_MenterSST, * TwoEquation_Wilcox * TurbulenceClosure_t CG_Null, CG_UserDefined, EddyViscosity, * ReynoldsStress, ReynoldsStressAlgebraic * ThermalRelaxationModel_t CG_Null, CG_UserDefined, Frozen, * ThermalEquilib, ThermalNonequilib * ChemicalKineticsModel_t CG_Null, CG_UserDefined, Frozen, ChemicalEquilibCurveFit, * ChemicalEquilibMinimization, ChemicalNonequilib * EMElectricFieldModel_t CG_Null, CG_UserDefined, Constant, Frozen, * Interpolated, Voltage * EMMagneticFieldModel_t CG_Null, CG_UserDefined, Constant, Frozen, Interpolated * EMConductivityModel_t CG_Null, CG_UserDefined, Constant, Frozen, * Equilibrium_LinRessler, Chemistry_LinRessler * * \return \ier */ int cg_model_read(const char *ModelLabel, CGNS_ENUMT(ModelType_t) *ModelType) { cgns_model *model; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; model = cgi_model_address(CG_MODE_READ, ModelLabel, &ier); if (model==0) return ier; (*ModelType) = model->type; return CG_OK; } /** * \ingroup AuxiliaryModel * * \brief Write auxiliary model types * * \param[in] ModelLabel The CGNS label for the model being defined. The models supported by CGNS * are: * - GasModel_t * - ViscosityModel_t * - ThermalConductivityModel_t * - TurbulenceClosure_t * - TurbulenceModel_t * - ThermalRelaxationModel_t * - ChemicalKineticsModel_t * - EMElectricFieldModel_t * - EMMagneticFieldModel_t * - EMConductivityModel_t * \param[in] ModelType One of the model types (listed below) allowed for the ModelLabel selected. * * \details * The types allowed for the various models are: * *
GasModel_t CG_Null, CG_UserDefined, Ideal, VanderWaals, CaloricallyPerfect, * ThermallyPerfect, ConstantDensity, RedlichKwong *
ViscosityModel_t CG_Null, CG_UserDefined, Constant, * PowerLaw, SutherlandLaw *
ThermalConductivityModel_t CG_Null, CG_UserDefined, PowerLaw, * SutherlandLaw, ConstantPrandtl *
TurbulenceModel_t CG_Null, CG_UserDefined, Algebraic_BaldwinLomax, * Algebraic_CebeciSmith, HalfEquation_JohnsonKing, * OneEquation_BaldwinBarth, OneEquation_SpalartAllmaras, * TwoEquation_JonesLaunder, TwoEquation_MenterSST, * TwoEquation_Wilcox *
TurbulenceClosure_t CG_Null, CG_UserDefined, EddyViscosity, * ReynoldsStress, ReynoldsStressAlgebraic *
ThermalRelaxationModel_t CG_Null, CG_UserDefined, Frozen, * ThermalEquilib, ThermalNonequilib *
ChemicalKineticsModel_t CG_Null, CG_UserDefined, Frozen, ChemicalEquilibCurveFit, * ChemicalEquilibMinimization, ChemicalNonequilib *
EMElectricFieldModel_t CG_Null, CG_UserDefined, Constant, Frozen, * Interpolated, Voltage *
EMMagneticFieldModel_t CG_Null, CG_UserDefined, Constant, Frozen, Interpolated *
EMConductivityModel_t CG_Null, CG_UserDefined, Constant, Frozen, * Equilibrium_LinRessler, Chemistry_LinRessler *
* \return \ier */ int cg_model_write(const char * ModelLabel, CGNS_ENUMT(ModelType_t) ModelType) { cgns_model *model; char ModelName[33]; int ier=0, index_dim; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; if (INVALID_ENUM(ModelType,NofValidModelTypes)) { cgi_error("Invalid %s Type: %d",ModelLabel,ModelType); return CG_ERROR; } /* Validate enums for each model type. */ if (strcmp(ModelLabel, "GasModel_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Ideal ) && ModelType!=CGNS_ENUMV( VanderWaals ) && ModelType!=CGNS_ENUMV( CaloricallyPerfect ) && ModelType!=CGNS_ENUMV( ThermallyPerfect ) && ModelType!=CGNS_ENUMV( ConstantDensity ) && ModelType!=CGNS_ENUMV( RedlichKwong )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "ViscosityModel_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Constant ) && ModelType!=CGNS_ENUMV( PowerLaw ) && ModelType!=CGNS_ENUMV( SutherlandLaw )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "ThermalConductivityModel_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( PowerLaw ) && ModelType!=CGNS_ENUMV( SutherlandLaw ) && ModelType!=CGNS_ENUMV( ConstantPrandtl )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "TurbulenceModel_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Algebraic_BaldwinLomax )&& ModelType!=CGNS_ENUMV( Algebraic_CebeciSmith )&& ModelType!=CGNS_ENUMV( HalfEquation_JohnsonKing )&& ModelType!=CGNS_ENUMV( OneEquation_BaldwinBarth )&& ModelType!=CGNS_ENUMV( OneEquation_SpalartAllmaras )&& ModelType!=CGNS_ENUMV( TwoEquation_JonesLaunder )&& ModelType!=CGNS_ENUMV( TwoEquation_MenterSST )&& ModelType!=CGNS_ENUMV( TwoEquation_Wilcox )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "TurbulenceClosure_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( EddyViscosity ) && ModelType!=CGNS_ENUMV( ReynoldsStress ) && ModelType!=CGNS_ENUMV( ReynoldsStressAlgebraic )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "ThermalRelaxationModel_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Frozen ) && ModelType!=CGNS_ENUMV( ThermalEquilib ) && ModelType!=CGNS_ENUMV( ThermalNonequilib )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "ChemicalKineticsModel_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Frozen ) && ModelType!=CGNS_ENUMV( ChemicalEquilibCurveFit ) && ModelType!=CGNS_ENUMV( ChemicalEquilibMinimization ) && ModelType!=CGNS_ENUMV( ChemicalNonequilib )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "EMElectricFieldModel_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Frozen ) && ModelType!=CGNS_ENUMV( Voltage ) && ModelType!=CGNS_ENUMV( Interpolated ) && ModelType!=CGNS_ENUMV( Constant )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "EMMagneticFieldModel_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Frozen ) && ModelType!=CGNS_ENUMV( Interpolated ) && ModelType!=CGNS_ENUMV( Constant )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "EMConductivityModel_t")==0) { if (ModelType!=CGNS_ENUMV( ModelTypeNull ) && ModelType!=CGNS_ENUMV( ModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Frozen ) && ModelType!=CGNS_ENUMV( Constant ) && ModelType!=CGNS_ENUMV( Equilibrium_LinRessler ) && ModelType!=CGNS_ENUMV( Chemistry_LinRessler )) { cgi_error("Model Type '%s' is not supported for %s", ModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } if (strcmp(ModelLabel, "ChemicalKineticsModel_t") && strcmp(ModelLabel, "ThermalRelaxationModel_t") && strcmp(ModelLabel, "TurbulenceClosure_t") && strcmp(ModelLabel, "TurbulenceModel_t") && strcmp(ModelLabel, "ThermalConductivityModel_t") && strcmp(ModelLabel, "ViscosityModel_t") && strcmp(ModelLabel, "EMElectricFieldModel_t") && strcmp(ModelLabel, "EMMagneticFieldModel_t") && strcmp(ModelLabel, "EMConductivityModel_t") && strcmp(ModelLabel, "GasModel_t")) { cgi_error("Invalid Model Label: %s",ModelLabel); return CG_ERROR; } /* get address */ model = cgi_model_address(CG_MODE_WRITE, ModelLabel, &ier); if (model==0) return ier; /* Save data */ model->type = ModelType; strcpy(ModelName,ModelLabel); ModelName[strlen(ModelLabel)-2]='\0'; strcpy(model->name, ModelName); /* initialize other fields */ model->id=0; model->link=0; model->ndescr=0; model->narrays=0; model->data_class=CGNS_ENUMV( DataClassNull ); model->units=0; model->diffusion_model=0; model->dim_vals=0; model->nuser_data=0; if (strcmp(ModelLabel, "TurbulenceModel_t")==0) { if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; /* For TurbulenceModel_t defined under CGNSBase_t */ } else if (posit_base) { index_dim = cg->base[posit_base-1].cell_dim; } else { cgi_error("Can't find IndexDimension in cg_model_write."); return CG_NO_INDEX_DIM; } if (index_dim==1) model->dim_vals=1; else if (index_dim==2) model->dim_vals=3; else if (index_dim==3) model->dim_vals=6; else { cgi_error("invalid value for IndexDimension"); return CG_ERROR; } } /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_model(posit_id, model)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ParticleGoverningEquations * * \brief Read type of particle governing equation * * \param[out] ParticleEquationsType Type of particle governing equations. The * admissible types are \e CG_Null, \e CG_UserDefined, \e DEM, \e DSMC and \e SPH. * \return \ier * */ int cg_particle_governing_read(CGNS_ENUMT(ParticleGoverningEquationsType_t) *ParticleEquationsType) { cgns_pgoverning *governing; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; governing = cgi_particle_governing_address(CG_MODE_READ, &ier); if (governing==0) return ier; (*ParticleEquationsType) = governing->type; return CG_OK; } /** * \ingroup ParticleGoverningEquations * * \brief Write the type of particle governing equation * * \param[in] ParticleEquationstype Type of particle governing equations. The * admissible types are \e CG_Null, \e CG_UserDefined, \e DEM, \e DSMC and \e SPH. * \return \ier * */ int cg_particle_governing_write(CGNS_ENUMT(ParticleGoverningEquationsType_t) ParticleEquationstype) { cgns_pgoverning *governing; int ier=0, index_dim; cgsize_t dim_vals; double posit_id; CHECK_FILE_OPEN /* verify input */ if (INVALID_ENUM(ParticleEquationstype,NofValidParticleGoverningEquationsTypes)) { cgi_error("Invalid Particle Governing Equations Type: %d",ParticleEquationstype); return CG_ERROR; } if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; governing = cgi_particle_governing_address(CG_MODE_WRITE, &ier); if (governing==0) return ier; /* Save data */ governing->type=ParticleEquationstype; /* initialize other fields */ strcpy(governing->name, "ParticleGoverningEquations"); governing->id=0; governing->link=0; governing->ndescr=0; governing->nuser_data=0; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; dim_vals = (cgsize_t)strlen(ParticleGoverningEquationsTypeName[governing->type]); if (cgi_new_node(posit_id, "ParticleGoverningEquations", "ParticleGoverningEquations_t", &governing->id, "C1", 1, &dim_vals, ParticleGoverningEquationsTypeName[governing->type])) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup ParticleModel * * \brief Read particle model types * * \param[out] ModelLabel The CGNS label for the particle model being defined. The particle models supported by CGNS are: * - ParticleCollisionModel_t * - ParticleBreakupModel_t * - ParticleForceModel_t * - ParticleWallInteractionModel_t * - ParticlePhaseChangeModel_t * * \param[out] ModelType One of the particle model types (listed below) allowed for the ModelLabel selected. * * The types allowed for the various models are: * ParticleCollisionModel_t CG_Null, CG_UserDefined, Linear, NonLinear, HardSphere, SoftSphere, * LinearSpringDashpot, Pair, HertzMindlin, HertzKuwabaraKono, ORourke, Stochastic, NonStochastic, NTC * ParticleBreakupModel_t CG_Null, CG_UserDefined, KelvinHelmholtz, KelvinHelmholtzACT, RayleighTaylor, * KelvinHelmholtzRayleighTaylor, ReitzKHRT, TAB, ETAB, LISA, SHF, PilchErdman, ReitzDiwakar * ParticleForceModel_t CG_Null, CG_UserDefined, Sphere, NonShpere, Tracer, BeetstraVanDerHoefKuipers, Ergun, * CliftGrace, Gidaspow, HaiderLevenspiel, PlessisMasliyah, SyamlalOBrien, SaffmanMei, * TennetiGargSubramaniam, Tomiyama, Stokes, StokesCunningham, WenYu * ParticleWallInteractionModel_t CG_Null, CG_UserDefined, Linear, NonLinear, HardSphere, SoftSphere, * LinearSpringDashpot, BaiGosman, HertzMindlin, HertzKuwabaraKono, Khunke, ORourke, NTC * ParticlePhaseChangeModel_t CG_Null, CG_UserDefined, Boil, Chiang, Frossling, FuchsKnudsen * \return \ier */ int cg_particle_model_read(const char *ModelLabel, CGNS_ENUMT(ParticleModelType_t) *ModelType) { cgns_pmodel *model; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; model = cgi_particle_model_address(CG_MODE_READ, ModelLabel, &ier); if (model==0) return ier; (*ModelType) = model->type; return CG_OK; } /** * \ingroup ParticleModel * * \brief Write particle model types * * \param[in] ModelLabel The CGNS label for the particle model being defined. The particle models supported by CGNS are: * - ParticleCollisionModel_t * - ParticleBreakupModel_t * - ParticleForceModel_t * - ParticleWallInteractionModel_t * - ParticlePhaseChangeModel_t * * \param[in] ModelType One of the particle model types (listed below) allowed for the ModelLabel selected. * * The types allowed for the various models are: * ParticleCollisionModel_t CG_Null, CG_UserDefined, Linear, NonLinear, HardSphere, SoftSphere, LinearSpringDashpot, * Pair, HertzMindlin, HertzKuwabaraKono, ORourke, Stochastic, NonStochastic, NTC * ParticleBreakupModel_t CG_Null, CG_UserDefined, KelvinHelmholtz, KelvinHelmholtzACT, RayleighTaylor, * KelvinHelmholtzRayleighTaylor, ReitzKHRT, TAB, ETAB, LISA, SHF, PilchErdman, ReitzDiwakar * ParticleForceModel_t CG_Null, CG_UserDefined, Sphere, NonShpere, Tracer, BeetstraVanDerHoefKuipers, Ergun, * CliftGrace, Gidaspow, HaiderLevenspiel, PlessisMasliyah, SyamlalOBrien, SaffmanMei, * TennetiGargSubramaniam, Tomiyama, Stokes, StokesCunningham, WenYu * ParticleWallInteractionModel_t CG_Null, CG_UserDefined, Linear, NonLinear, HardSphere, SoftSphere, * LinearSpringDashpot, BaiGosman, HertzMindlin, HertzKuwabaraKono, Khunke, ORourke, NTC * ParticlePhaseChangeModel_t CG_Null, CG_UserDefined, Boil, Chiang, Frossling, FuchsKnudsen * \return \ier */ int cg_particle_model_write(const char * ModelLabel, CGNS_ENUMT(ParticleModelType_t) ModelType) { cgns_pmodel *model; char ModelName[33]; int ier=0, index_dim; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; if (INVALID_ENUM(ModelType,NofValidParticleModelTypes)) { cgi_error("Invalid %s Type: %d",ModelLabel,ModelType); return CG_ERROR; } /* Validate enums for each model type. */ if (strcmp(ModelLabel, "ParticleCollisionModel_t")==0) { if (ModelType!=CGNS_ENUMV( ParticleModelTypeNull ) && ModelType!=CGNS_ENUMV( ParticleModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Linear ) && ModelType!=CGNS_ENUMV( NonLinear ) && ModelType!=CGNS_ENUMV( SoftSphere ) && ModelType!=CGNS_ENUMV( HardSphere ) && ModelType!=CGNS_ENUMV( LinearSpringDashpot ) && ModelType!=CGNS_ENUMV( Pair ) && ModelType!=CGNS_ENUMV( HertzMindlin ) && ModelType!=CGNS_ENUMV( HertzKuwabaraKono ) && ModelType!=CGNS_ENUMV( ORourke ) && ModelType!=CGNS_ENUMV( Stochastic ) && ModelType!=CGNS_ENUMV( NonStochastic ) && ModelType!=CGNS_ENUMV( NTC )) { cgi_error("Particle Model Type '%s' is not supported for %s", ParticleModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "ParticleBreakupModel_t")==0) { if (ModelType!=CGNS_ENUMV( ParticleModelTypeNull ) && ModelType!=CGNS_ENUMV( ParticleModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( KelvinHelmholtz ) && ModelType!=CGNS_ENUMV( KelvinHelmholtzACT ) && ModelType!=CGNS_ENUMV( RayleighTaylor ) && ModelType!=CGNS_ENUMV( KelvinHelmholtzRayleighTaylor ) && ModelType!=CGNS_ENUMV( ReitzKHRT ) && ModelType!=CGNS_ENUMV( TAB ) && ModelType!= CGNS_ENUMV( ETAB ) && ModelType!=CGNS_ENUMV( LISA ) && ModelType!=CGNS_ENUMV( SHF ) && ModelType!= CGNS_ENUMV( PilchErdman ) && ModelType!=CGNS_ENUMV( ReitzDiwakar )) { cgi_error("Particle Model Type '%s' is not supported for %s", ParticleModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "ParticleForceModel_t")==0) { if (ModelType!=CGNS_ENUMV( ParticleModelTypeNull ) && ModelType!=CGNS_ENUMV( ParticleModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Sphere ) && ModelType!=CGNS_ENUMV( NonSphere ) && ModelType!=CGNS_ENUMV( Tracer ) && ModelType!=CGNS_ENUMV( BeetstraVanDerHoefKuipers ) && ModelType!=CGNS_ENUMV( Ergun ) && ModelType!=CGNS_ENUMV( CliftGrace ) && ModelType!= CGNS_ENUMV( Gidaspow ) && ModelType!=CGNS_ENUMV( HaiderLevenspiel ) && ModelType!=CGNS_ENUMV( PlessisMasliyah ) && ModelType!=CGNS_ENUMV( SyamlalOBrien ) && ModelType!=CGNS_ENUMV( SaffmanMei ) && ModelType!=CGNS_ENUMV( TennetiGargSubramaniam ) && ModelType!=CGNS_ENUMV( Tomiyama ) && ModelType!=CGNS_ENUMV( Stokes ) && ModelType!=CGNS_ENUMV( StokesCunningham ) && ModelType!=CGNS_ENUMV( WenYu )) { cgi_error("Particle Model Type '%s' is not supported for %s", ParticleModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "ParticleWallInteractionModel_t")==0) { if (ModelType!=CGNS_ENUMV( ParticleModelTypeNull ) && ModelType!=CGNS_ENUMV( ParticleModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Linear ) && ModelType!=CGNS_ENUMV( NonLinear ) && ModelType!=CGNS_ENUMV( SoftSphere ) && ModelType!=CGNS_ENUMV( HardSphere ) && ModelType!=CGNS_ENUMV( LinearSpringDashpot ) && ModelType!=CGNS_ENUMV( Pair ) && ModelType!=CGNS_ENUMV( HertzMindlin ) && ModelType!=CGNS_ENUMV( HertzKuwabaraKono ) && ModelType!=CGNS_ENUMV( ORourke ) && ModelType!=CGNS_ENUMV( Khunke ) && ModelType!=CGNS_ENUMV( BaiGosman ) && ModelType!=CGNS_ENUMV( NTC )) { cgi_error("Particle Model Type '%s' is not supported for %s", ParticleModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } else if (strcmp(ModelLabel, "ParticlePhaseChangeModel_t")==0) { if (ModelType!=CGNS_ENUMV( ParticleModelTypeNull ) && ModelType!=CGNS_ENUMV( ParticleModelTypeUserDefined ) && ModelType!=CGNS_ENUMV( Boil ) && ModelType!=CGNS_ENUMV( Chiang ) && ModelType!=CGNS_ENUMV( Frossling ) && ModelType!=CGNS_ENUMV( FuchsKnudsen )) { cgi_error("Particle Model Type '%s' is not supported for %s", ParticleModelTypeName[ModelType],ModelLabel); return CG_ERROR; } } if (strcmp(ModelLabel, "ParticleCollisionModel_t") && strcmp(ModelLabel, "ParticleBreakupModel_t") && strcmp(ModelLabel, "ParticleForceModel_t") && strcmp(ModelLabel, "ParticleWallInteractionModel_t") && strcmp(ModelLabel, "ParticlePhaseChangeModel_t")) { cgi_error("Invalid Particle Model Label: %s",ModelLabel); return CG_ERROR; } /* get address */ model = cgi_particle_model_address(CG_MODE_WRITE, ModelLabel, &ier); if (model==0) return ier; /* Save data */ model->type = ModelType; strcpy(ModelName,ModelLabel); ModelName[strlen(ModelLabel)-2]='\0'; strcpy(model->name, ModelName); /* initialize other fields */ model->id=0; model->link=0; model->ndescr=0; model->narrays=0; model->data_class=CGNS_ENUMV( DataClassNull ); model->units=0; model->dim_vals=0; model->nuser_data=0; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_particle_model(posit_id, model)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup DataArrays * * \brief Get the number of data arrays under the current node * * \param[out] narrays Number of DataArray_t nodes under the current node. * * \return \ier */ int cg_narrays(int *narrays) { /* Possible parents: * GridCoordinates_t, FlowSolution_t, DiscreteData_t, BC_t, * BCData_t, GasModel_t, ViscosityModel_t, ThermalConductivityModel_t, TurbulenceClosure_t, * TurbulenceModel_t, ThermalRelaxationModel_t, ChemicalKineticsModel_t, * EMElectricFieldModel_t, EMMagneticFieldModel_t, EMConductivityModel_t, * ConvergenceHistory_t, IntegralData_t, ReferenceState_t, * RigidGridMotion_t, ArbitraryGridMotion_t, BaseIterativeData_t, ZoneIterativeData_t * GridConnectivity_t, UserDefinedData_t, Gravity_t, Axisymmetry_t, RotatingCoordinates_t, * Area_t, Periodic_t, ZoneSubRegion_t, ParticleCoordinates_t, ParticleSolution_t, * ParticleIterativeData_t, ParticleCollisionModel_t, ParticleBreakupModel_t, ParticleWallInteractionModel_t, * ParticleForceModel_t, ParticlePhaseChangeModel_t */ CHECK_FILE_OPEN /* verify input */ /* if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR;*/ /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*narrays) = 0; return CG_ERROR; } if (strcmp(posit->label,"GridCoordinates_t")==0) { cgns_zcoor *zcoor= (cgns_zcoor *)posit->posit; (*narrays) = zcoor->ncoords; } else if (strcmp(posit->label,"ParticleCoordinates_t")==0) { cgns_pcoor *pcoor= (cgns_pcoor *)posit->posit; (*narrays) = pcoor->ncoords; } else if (strcmp(posit->label,"FlowSolution_t")==0) { cgns_sol *sol = (cgns_sol *)posit->posit; (*narrays) = sol->nfields; } else if (strcmp(posit->label,"ParticleSolution_t")==0) { cgns_psol *sol = (cgns_psol *)posit->posit; (*narrays) = sol->nfields; } else if (strcmp(posit->label,"DiscreteData_t")==0) { cgns_discrete *discrete = (cgns_discrete *)posit->posit; (*narrays) = discrete->narrays; } else if (strcmp(posit->label,"GridConnectivity_t")==0) { cgns_conn *conn = (cgns_conn *)posit->posit; (*narrays) = conn->narrays; } else if (strcmp(posit->label,"BC_t")==0) { /*cgns_boco *boco = (cgns_boco *)posit->posit;*/ (*narrays) = 1; /* Always supports exactly 1. */ } else if (strcmp(posit->label,"BCData_t")==0) { cgns_bcdata *bcdata = (cgns_bcdata *)posit->posit; (*narrays) = bcdata->narrays; } else if (strcmp(posit->label,"GasModel_t")==0 || strcmp(posit->label,"ViscosityModel_t")==0 || strcmp(posit->label,"ThermalConductivityModel_t")==0 || strcmp(posit->label,"TurbulenceModel_t")==0 || strcmp(posit->label,"TurbulenceClosure_t")==0 || strcmp(posit->label,"ThermalRelaxationModel_t")==0 || strcmp(posit->label,"ChemicalKineticsModel_t")==0 || strcmp(posit->label,"EMElectricFieldModel_t")==0 || strcmp(posit->label,"EMMagneticFieldModel_t")==0 || strcmp(posit->label,"EMConductivityModel_t")==0) { cgns_model *model = (cgns_model *)posit->posit; (*narrays) = model->narrays; } else if (strcmp(posit->label,"ConvergenceHistory_t")==0) { cgns_converg *converg = (cgns_converg *)posit->posit; (*narrays) = converg->narrays; } else if (strcmp(posit->label,"IntegralData_t")==0) { cgns_integral *integral = (cgns_integral *)posit->posit; (*narrays) = integral->narrays; } else if (strcmp(posit->label,"ReferenceState_t")==0) { cgns_state *state = (cgns_state *)posit->posit; (*narrays) = state->narrays; } else if (strcmp(posit->label,"RigidGridMotion_t")==0) { cgns_rmotion *rmotion = (cgns_rmotion *)posit->posit; (*narrays) = rmotion->narrays; } else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) { cgns_amotion *amotion = (cgns_amotion *)posit->posit; (*narrays) = amotion->narrays; } else if (strcmp(posit->label,"BaseIterativeData_t")==0) { cgns_biter *biter = (cgns_biter *)posit->posit; (*narrays) = biter->narrays; } else if (strcmp(posit->label,"ZoneIterativeData_t")==0 || strcmp(posit->label,"ParticleIterativeData_t")==0) { cgns_ziter *ziter = (cgns_ziter *)posit->posit; (*narrays) = ziter->narrays; } else if (strcmp(posit->label,"UserDefinedData_t")==0) { cgns_user_data *user_data = (cgns_user_data *)posit->posit; (*narrays) = user_data->narrays; } else if (strcmp(posit->label,"Gravity_t")==0) { cgns_gravity *gravity = (cgns_gravity *)posit->posit; (*narrays) = gravity->narrays; } else if (strcmp(posit->label,"Axisymmetry_t")==0) { cgns_axisym *axisym = (cgns_axisym *)posit->posit; (*narrays) = axisym->narrays; } else if (strcmp(posit->label,"RotatingCoordinates_t")==0) { cgns_rotating *rotating = (cgns_rotating *)posit->posit; (*narrays) = rotating->narrays; } else if (strcmp(posit->label,"Area_t")==0) { cgns_bcarea *bcarea = (cgns_bcarea *)posit->posit; (*narrays) = bcarea->narrays; } else if (strcmp(posit->label,"Periodic_t")==0) { cgns_cperio *cperio = (cgns_cperio *)posit->posit; (*narrays) = cperio->narrays; } else if (strcmp(posit->label,"ZoneSubRegion_t")==0) { cgns_subreg *subreg = (cgns_subreg *)posit->posit; (*narrays) = subreg->narrays; } else if (strcmp(posit->label,"ParticleCollisionModel_t")==0 || strcmp(posit->label,"ParticleBreakupModel_t")==0 || strcmp(posit->label,"ParticleWallInteractionModel_t")==0 || strcmp(posit->label,"ParticleForceModel_t")==0 || strcmp(posit->label,"ParticlePhaseChangeModel_t")==0) { cgns_pmodel *model = (cgns_pmodel *)posit->posit; (*narrays) = model->narrays; }else { cgi_error("User defined DataArray_t node not supported under '%s' type node",posit->label); (*narrays) = 0; return CG_INCORRECT_PATH; } return CG_OK; } /** * \ingroup DataArrays * * \brief Get data array info * * \param[in] A \A * \param[out] ArrayName Name of the DataArray_t node. * \param[out] DataType Type of data held in the DataArray_t node. The admissible types are \e Integer, * \e LongInteger, \e RealSingle, \e RealDouble, and \e Character. * \param[out] DataDimension Number of dimensions of array in file (max 12). See Node Management Routines * in CGIO User's Guide. * \param[out] DimensionVector Dimensions of array in file. * * \return \ier */ int cg_array_info(int A, char *ArrayName, CGNS_ENUMT(DataType_t) *DataType, int *DataDimension, cgsize_t *DimensionVector) { cgns_array *array; int n, ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; int have_dup = 0; array = cgi_array_address(CG_MODE_READ, 0, A, "dummy", &have_dup, &ier); if (array==0) return ier; strcpy(ArrayName, array->name); (*DataType) = cgi_datatype(array->data_type); (*DataDimension) = array->data_dim; for (n=0; ndata_dim; n++) DimensionVector[n] = array->dim_vals[n]; return CG_OK; } /** * \ingroup DataArrays * * \brief Read data array * * \param[in] A \A * \param[out] Data The data array in memory. * * \return \ier */ int cg_array_read(int A, void *Data) { cgns_array *array; int n, ier=0; cgsize_t num = 1; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; int have_dup = 0; array = cgi_array_address(CG_MODE_READ, 0, A, "dummy", &have_dup, &ier); if (array==0) return ier; for (n=0; ndata_dim; n++) num *= array->dim_vals[n]; if (array->data) memcpy(Data, array->data, ((size_t)num)*size_of(array->data_type)); else { if (cgio_read_all_data_type(cg->cgio, array->id, array->data_type, Data)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } return CG_OK; } /** * \ingroup DataArrays * * \brief Read data array as a certain type * * \param[in] A \A * \param[in] type Type of data held in the DataArray_t node. The admissible types are \e Integer, * \e LongInteger, \e RealSingle, \e RealDouble, and \e Character. * \param[out] Data The data array in memory. * * \return \ier */ int cg_array_read_as(int A, CGNS_ENUMT(DataType_t) type, void *Data) { cgns_array *array; int n, ier=0; cgsize_t num = 1; void *array_data; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; int have_dup = 0; array = cgi_array_address(CG_MODE_READ, 0, A, "dummy", &have_dup, &ier); if (array==0) return ier; for (n=0; ndata_dim; n++) num *= array->dim_vals[n]; /* Special for Character arrays */ if ((type == CGNS_ENUMV(Character) && cgi_datatype(array->data_type) != CGNS_ENUMV(Character)) || (type != CGNS_ENUMV(Character) && cgi_datatype(array->data_type) == CGNS_ENUMV(Character))) { cgi_error("Error exit: Character array can only be read as character"); return CG_ERROR; } if (type==CGNS_ENUMV(Character)) { if (array->data) memcpy(Data, array->data, ((size_t)num)*size_of(array->data_type)); else { if (cgio_read_all_data_type(cg->cgio, array->id, array->data_type, Data)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } return CG_OK; } /* All numerical data types: */ if (array->data) array_data = array->data; else { array_data = malloc(((size_t)num)*size_of(array->data_type)); if (array_data == NULL) { cgi_error("Error allocating array_data"); return CG_ERROR; } if (cgio_read_all_data_type(cg->cgio, array->id, array->data_type, array_data)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } } ier = cgi_convert_data(num, cgi_datatype(array->data_type), array_data, type, Data); if (array_data != array->data) free(array_data); return ier ? CG_ERROR : CG_OK; } /** * \ingroup DataArrays * * \brief Read subset of data array to a shaped memory * * \param[in] A \A * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). * \param[in] m_type The type of data held in memory. The admissible types are \e Integer, * \e LongInteger, \e RealSingle, \e RealDouble, and \e Character. * \param[in] m_numdim Number of dimensions of array in memory (max 12). * \param[in] m_dimvals Dimensions of array in memory. * \param[in] m_rmin Lower range index in memory (eg., imin, jmin, kmin). * \param[in] m_rmax Upper range index in memory (eg., imax, jmax, kmax). * \param[out] data The data array in memory. * * \return \ier * * \details The functions cg_array_general_read allow for type conversion when reading from the file. * When using cg_array_general_read, the lower core elements in the file have index 1 for * defining range_min and range_max; whereas for the array in memory, defined by mem_rank * and mem_dimensions, the lower array elements in memory have index 1 for defining * mem_range_min and mem_range_max. The actual lower and upper bounds of the array in * memory can be anything. For example, to fully read a two-dimensional 6 × 6 data array * with 1 rind plane on each side in the file to an 8 × 8 array in memory (mem_rank = 2 * and mem_dimensions = (8,8)), set range_min and range_max to (0,0) and (7,7), and set * mem_range_min and mem_range_max to (1,1) and (8,8). */ int cg_array_general_read(int A, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, int m_numdim, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *data) { /* s_ prefix is file space, m_ prefix is memory space */ cgns_array *array; int s_numdim, ier = CG_OK; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* find address */ int have_dup = 0; array = cgi_array_address(CG_MODE_READ, 0, A, "dummy", &have_dup, &ier); if (array == 0) return ier; s_numdim = array->data_dim; /* special for Character arrays */ if ((m_type != CGNS_ENUMV(Character) && cgi_datatype(array->data_type) == CGNS_ENUMV(Character))) { cgi_error("Error exit: Character array can only be read as character"); return CG_ERROR; } /* do we have rind planes? */ int *rind_planes = cgi_rind_address(CG_MODE_READ, &ier); if (ier != CG_OK) rind_planes = NULL; return cgi_array_general_read(array, cgns_rindindex, rind_planes, s_numdim, s_rmin, s_rmax, m_type, m_numdim, m_dimvals, m_rmin, m_rmax, data); } /** * \ingroup DataArrays * * \brief Write data array * * \param[in] ArrayName Name of the DataArray_t node. * \param[in] DataType Type of data held in the DataArray_t node. The admissible types are \e Integer, * \e LongInteger, \e RealSingle, \e RealDouble, and \e Character. * \param[in] DataDimension Number of dimensions of array in file (max 12). See Node Management Routines * in CGIO User's Guide. * \param[in] DimensionVector Dimensions of array in file. * \param[in] Data The data array in memory. * * \return \ier */ int cg_array_write(const char * ArrayName, CGNS_ENUMT(DataType_t) DataType, int DataDimension, const cgsize_t * DimensionVector, const void * Data) { cgns_array *array; int n, ier=0; double posit_id; HDF5storage_type = CG_CONTIGUOUS; CHECK_FILE_OPEN /* verify input */ if (cgi_check_strlen(ArrayName)) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; if (DataType != CGNS_ENUMV(RealSingle) && DataType != CGNS_ENUMV(RealDouble) && DataType != CGNS_ENUMV(Integer) && DataType != CGNS_ENUMV(LongInteger) && DataType != CGNS_ENUMV(Character) && DataType != CGNS_ENUMV(ComplexSingle) && DataType != CGNS_ENUMV(ComplexDouble)) { cgi_error("Invalid datatype for data array: %d", DataType); return CG_ERROR; } if (DataDimension>12) { cgi_error("Data arrays are limited to 12 dimensions"); return CG_ERROR; } for (n=0; nname, ArrayName); strcpy(array->data_type, cgi_adf_datatype(DataType)); array->data_dim = DataDimension; for (n=0; ndim_vals[n]=DimensionVector[n]; /* initialize other fields */ array->link=0; array->ndescr=0; array->data_class=CGNS_ENUMV(DataClassNull); array->units=0; array->exponents=0; array->convert=0; array->data=0; /* write to disk */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_new_node(posit_id, array->name, "DataArray_t", &array->id, array->data_type, array->data_dim, array->dim_vals, Data)) return CG_ERROR; HDF5storage_type = CG_COMPACT; return CG_OK; } /** * \ingroup DataArrays * * \brief Write shaped array to a subset of data array * * \param[in] arrayname Name of the DataArray_t node. * \param[in] s_type Type of data held in the DataArray_t node. The admissible types are Integer, * LongInteger, RealSingle, RealDouble, and Character. * \param[in] s_numdim Number of dimensions of array in file (max 12). See Node Management Routines * in CGIO User's Guide. * \param[in] s_dimvals Dimensions of array in file. * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). * \param[in] m_type The type of data held in memory. The admissible types are Integer, * LongInteger, RealSingle, RealDouble, and Character. * \param[in] m_numdim Number of dimensions of array in memory (max 12). * \param[in] m_dimvals Dimensions of array in memory. * \param[in] m_rmin Lower range index in memory (eg., imin, jmin, kmin). * \param[in] m_rmax Upper range index in memory (eg., imax, jmax, kmax). * \param[in] data The data array in memory. * * \return \ier * * \details The function cg_array_general_write may be used to write from a subset of the array in memory to a * subset of the array in the file. When using the partial write, the new values will overwrite any * existing data from \p range_min to \p range_max. All other values will not be affected. * The functions cg_array_general_write allow for type conversion when reading to the file. * When using cg_array_general_write, the lower core elements in the file have index 1 for * defining range_min and range_max; whereas for the array in memory, defined by mem_rank * and mem_dimensions, the lower array elements in memory have index 1 for defining mem_range_min * and mem_range_max. The actual lower and upper bounds of the array in memory can be anything. * For example, to fully read a two-dimensional 6 × 6 data array with 1 rind plane on each side in the * file to an 8 × 8 array in memory (mem_rank = 2 and mem_dimensions = (8,8)), set range_min and range_max * to (0,0) and (7,7), and set mem_range_min and mem_range_max to (1,1) and (8,8). */ int cg_array_general_write(const char *arrayname, CGNS_ENUMT(DataType_t) s_type, int s_numdim, const cgsize_t *s_dimvals, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, int m_numdim, const cgsize_t* m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, const void *data) { /* s_ prefix is file space, m_ prefix is memory space */ int n, ier = CG_OK; CHECK_FILE_OPEN /* verify input */ if (cgi_check_strlen(arrayname)) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; if (s_type != CGNS_ENUMV(RealSingle) && s_type != CGNS_ENUMV(RealDouble) && s_type != CGNS_ENUMV(Integer) && s_type != CGNS_ENUMV(LongInteger) && s_type != CGNS_ENUMV(ComplexSingle) && s_type != CGNS_ENUMV(ComplexDouble) && s_type != CGNS_ENUMV(Character)) { cgi_error("Invalid file data type for data array: %d", s_type); return CG_ERROR; } if (m_type != CGNS_ENUMV(RealSingle) && m_type != CGNS_ENUMV(RealDouble) && m_type != CGNS_ENUMV(Integer) && m_type != CGNS_ENUMV(LongInteger) && m_type != CGNS_ENUMV(ComplexSingle) && m_type != CGNS_ENUMV(ComplexDouble) && m_type != CGNS_ENUMV(Character)) { cgi_error("Invalid input data type for data array: %d", m_type); return CG_ERROR; } /*** verification for dataset in file */ /* verify the rank and dimensions of the file-space array */ if (s_numdim <= 0 || s_numdim > CGIO_MAX_DIMENSIONS) { cgi_error("Data arrays are limited to %d dimensions in file", CGIO_MAX_DIMENSIONS); return CG_ERROR; } if (s_dimvals == NULL) { cgi_error("NULL dimension value"); return CG_ERROR; } for (n=0; nfilename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*nintegrals) = 0; return CG_ERROR; } if (strcmp(posit->label,"CGNSBase_t")==0) { cgns_base *base= (cgns_base *)posit->posit; (*nintegrals) = base->nintegrals; } else if (strcmp(posit->label,"Zone_t")==0) { cgns_zone *zone = (cgns_zone *)posit->posit; (*nintegrals) = zone->nintegrals; } else { cgi_error("IntegralData_t node not supported under '%s' type node",posit->label); (*nintegrals) = 0; return CG_INCORRECT_PATH; } return CG_OK; } /** * \ingroup IntegralData * * \brief Get the name of an IntegralData_t node * * \param[in] IntegralDataIndex Integral data index number, where 1 ≤ IntegralDataIndex ≤ nintegrals. * \param[out] IntegralDataName Name of the IntegralData_t data structure. * * \return \ier */ int cg_integral_read(int IntegralDataIndex, char *IntegralDataName) { int ier=0; cgns_integral *integral; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; integral = cgi_integral_address(CG_MODE_READ, IntegralDataIndex, "dummy", &ier); if (integral==0) return ier; strcpy(IntegralDataName, integral->name); return CG_OK; } /** * \ingroup IntegralData * * \brief Create IntegralData_t node * * \param[in] IntegralDataName Name of the IntegralData_t data structure. * * \return \ier */ int cg_integral_write(const char * IntegralDataName) { cgns_integral *integral; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_strlen(IntegralDataName)) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; integral = cgi_integral_address(CG_MODE_WRITE, 0, IntegralDataName, &ier); if (integral==0) return ier; strcpy(integral->name, IntegralDataName); /* initialize other fields */ integral->id=0; integral->link=0; integral->ndescr=0; integral->narrays=0; integral->data_class=CGNS_ENUMV( DataClassNull ); integral->units=0; integral->nuser_data=0; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_new_node(posit_id, integral->name, "IntegralData_t", &integral->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup RindLayers * * \brief Read the number of rind layers * * \param[out] RindData Number of rind layers for each computational direction (structured grid) or * number of rind points or elements (unstructured grid). For structured grids, * the low/high sides have unit stride in the array (e.g., [NRindLowI, * NRindHighI, NRindLowJ, NRindHighJ, NRindLowK, NRindHighK]). * * \return \ier */ int cg_rind_read(int *RindData) { int n, ier=0; int *rind, index_dim; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; rind = cgi_rind_address(CG_MODE_READ, &ier); if (rind==0) return ier; if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can't find IndexDimension in cg_rind_read."); return CG_NO_INDEX_DIM; } for (n=0; n<2*index_dim; n++) RindData[n] = rind[n]; return CG_OK; } /** * \ingroup RindLayers * * \brief Write the number of rind layers * * \param[in] RindData Number of rind layers for each computational direction (structured grid) or * number of rind points or elements (unstructured grid). For structured grids, * the low/high sides have unit stride in the array (e.g., [NRindLowI, * NRindHighI, NRindLowJ, NRindHighJ, NRindLowK, NRindHighK]). * * \return \ier * * \details When writing rind data for elements, cg_section_write() must be called first, followed * by cg_goto() to access the Elements_t node, and then cg_rind_write(). */ int cg_rind_write(const int * RindData) { int n, ier=0; int *rind, index_dim, narrays; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; rind = cgi_rind_address(CG_MODE_WRITE, &ier); if (rind==0) return ier; if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can't find IndexDimension in cg_rind_write."); return CG_NO_INDEX_DIM; } for (n=0; n<2*index_dim; n++) rind[n]=RindData[n]; /* save data in file & if different from default (6*0) */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_rind(posit_id, rind, index_dim)) return CG_ERROR; /* Writing rind planes invalidates dimensions of existing arrays. The rind planes are still written but an error is returned */ ier = cg_narrays(&narrays); if (ier == CG_OK && narrays > 0) { cgi_error("Writing rind planes invalidates dimensions of existing " "array(s)."); return CG_ERROR; } return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup DescriptiveText * * \brief Get the number of descriptors in the file * * \param[out] ndescriptors Number of Descriptor_t nodes under the current node. * \return \ier * */ int cg_ndescriptors(int *ndescriptors) { /* Possible parents of Descriptor_t node: * CGNSBase_t, Zone_t, GridCoordinates_t, Elements_t, FlowSolution_t, * DiscreteData_t, ZoneGridConnectivity_t, GridConnectivity1to1_t, * GridConnectivity_t, OversetHoles_t, ZoneBC_t, BC_t, BCDataSet_t, * BCData_t, FlowEquationSet_t, GoverningEquations_t, GasModel_t, * ViscosityModel_t, ThermalConductivityModel_t, TurbulenceClosure_t, * TurbulenceModel_t, ThermalRelaxationModel_t, ChemicalKineticsModel_t, * EMElectricFieldModel_t, EMMagneticFieldModel_t, EMConductivityModel_t, * ConvergenceHistory_t, IntegralData_t, ReferenceState_t, * DataArray_t, Family_t, GeometryReference_t, RigidGridMotion_t, * ArbitraryGridMotion_t, BaseIterativeData_t, ZoneIterativeData_t, * UserDefinedData_t, Gravity_t, Axisymmetry_t, RotatingCoordinates_t, * BCProperty_t, WallFunction_t, Area_t, ZoneSubRegion_t, * GridConnectivityProperty_t, Periodic_t, AverageInterface_t * FamilyBCDataSet_t, ParticleZone_t, ParticleCoordinates_t, ParticleSolution_t, * ParticleIterativeData_t, ParticleEquationSet_t, ParticleGoverningEquations_t, * ParticleCollisionModel_t, ParticleBreakupModel_t, ParticleForceModel_t, * ParticleWallInteractionModel_t, ParticlePhaseChangeModel_t, ParticleGoverningEquations_t */ CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*ndescriptors)=0; return CG_ERROR; } if (strcmp(posit->label,"CGNSBase_t")==0) NDESCRIPTOR(cgns_base) else if (strcmp(posit->label,"Zone_t")==0) NDESCRIPTOR(cgns_zone) else if (strcmp(posit->label,"GridCoordinates_t")==0) NDESCRIPTOR(cgns_zcoor) else if (strcmp(posit->label,"ParticleCoordinates_t")==0) NDESCRIPTOR(cgns_pcoor) else if (strcmp(posit->label,"Elements_t")==0) NDESCRIPTOR(cgns_section) else if (strcmp(posit->label,"FlowSolution_t")==0) NDESCRIPTOR(cgns_sol) else if (strcmp(posit->label,"ParticleSolution_t")==0) NDESCRIPTOR(cgns_psol) else if (strcmp(posit->label,"DiscreteData_t")==0) NDESCRIPTOR(cgns_discrete) else if (strcmp(posit->label,"ZoneGridConnectivity_t")==0) NDESCRIPTOR(cgns_zconn) else if (strcmp(posit->label,"GridConnectivity1to1_t")==0) NDESCRIPTOR(cgns_1to1) else if (strcmp(posit->label,"GridConnectivity_t")==0) NDESCRIPTOR(cgns_conn) else if (strcmp(posit->label,"OversetHoles_t")==0) NDESCRIPTOR(cgns_hole) else if (strcmp(posit->label,"ZoneBC_t")==0) NDESCRIPTOR(cgns_zboco) else if (strcmp(posit->label,"BC_t")==0) NDESCRIPTOR(cgns_boco) else if (strcmp(posit->label,"BCDataSet_t")==0 || strcmp(posit->label,"FamilyBCDataSet_t")==0) NDESCRIPTOR(cgns_dataset) else if (strcmp(posit->label,"BCData_t")==0) NDESCRIPTOR(cgns_bcdata) else if (strcmp(posit->label,"FlowEquationSet_t")==0) NDESCRIPTOR(cgns_equations) else if (strcmp(posit->label,"GoverningEquations_t")==0) NDESCRIPTOR(cgns_governing) else if (strcmp(posit->label,"GasModel_t")==0 || strcmp(posit->label,"ViscosityModel_t")==0 || strcmp(posit->label,"ThermalConductivityModel_t")==0 || strcmp(posit->label,"TurbulenceModel_t")==0 || strcmp(posit->label,"TurbulenceClosure_t")==0 || strcmp(posit->label,"ThermalRelaxationModel_t")==0 || strcmp(posit->label,"ChemicalKineticsModel_t")==0 || strcmp(posit->label,"EMElectricFieldModel_t")==0 || strcmp(posit->label,"EMMagneticFieldModel_t")==0 || strcmp(posit->label,"EMConductivityModel_t")==0) NDESCRIPTOR(cgns_model) else if (strcmp(posit->label,"ConvergenceHistory_t")==0) NDESCRIPTOR(cgns_converg) else if (strcmp(posit->label,"IntegralData_t")==0) NDESCRIPTOR(cgns_integral) else if (strcmp(posit->label,"ReferenceState_t")==0) NDESCRIPTOR(cgns_state) else if (strcmp(posit->label,"DataArray_t")==0) NDESCRIPTOR(cgns_array) else if (strcmp(posit->label,"Family_t")==0) NDESCRIPTOR(cgns_family) else if (strcmp(posit->label,"GeometryReference_t")==0) NDESCRIPTOR(cgns_geo) else if (strcmp(posit->label,"RigidGridMotion_t")==0) NDESCRIPTOR(cgns_rmotion) else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) NDESCRIPTOR(cgns_amotion) else if (strcmp(posit->label,"BaseIterativeData_t")==0) NDESCRIPTOR(cgns_biter) else if (strcmp(posit->label,"ZoneIterativeData_t")==0 || strcmp(posit->label,"ParticleIterativeData_t")==0) NDESCRIPTOR(cgns_ziter) else if (strcmp(posit->label,"UserDefinedData_t")==0) NDESCRIPTOR(cgns_user_data) else if (strcmp(posit->label,"Gravity_t")==0) NDESCRIPTOR(cgns_gravity) else if (strcmp(posit->label,"Axisymmetry_t")==0) NDESCRIPTOR(cgns_axisym) else if (strcmp(posit->label,"RotatingCoordinates_t")==0) NDESCRIPTOR(cgns_rotating) else if (strcmp(posit->label,"BCProperty_t")==0) NDESCRIPTOR(cgns_bprop) else if (strcmp(posit->label,"WallFunction_t")==0) NDESCRIPTOR(cgns_bcwall) else if (strcmp(posit->label,"Area_t")==0) NDESCRIPTOR(cgns_bcarea) else if (strcmp(posit->label,"GridConnectivityProperty_t")==0) NDESCRIPTOR(cgns_cprop) else if (strcmp(posit->label,"Periodic_t")==0) NDESCRIPTOR(cgns_cperio) else if (strcmp(posit->label,"AverageInterface_t")==0) NDESCRIPTOR(cgns_caverage) else if (strcmp(posit->label,"ZoneSubRegion_t")==0) NDESCRIPTOR(cgns_subreg) else if (strcmp(posit->label,"ParticleZone_t")==0) NDESCRIPTOR(cgns_pzone) else if (strcmp(posit->label,"ParticleEquationSet_t")==0) NDESCRIPTOR(cgns_pequations) else if (strcmp(posit->label,"ParticleGoverningEquations_t")==0) NDESCRIPTOR(cgns_pgoverning) else if (strcmp(posit->label,"ParticleCollisionModel_t")==0 || strcmp(posit->label,"ParticleBreakupModel_t")==0 || strcmp(posit->label,"ParticleForceModel_t")==0 || strcmp(posit->label,"ParticleWallInteractionModel_t")==0 || strcmp(posit->label,"ParticlePhaseChangeModel_t")==0) NDESCRIPTOR(cgns_pmodel) else { cgi_error("Descriptor_t node not supported under '%s' type node",posit->label); (*ndescriptors)=0; return CG_INCORRECT_PATH; } return CG_OK; } /** * \ingroup DescriptiveText * * \brief Read descriptive text * * \param[in] descr_no Descriptor index number, where 1 ≤ descr_no ≤ ndescriptors. * \param[out] descr_name Name of the Descriptor_t node. * \param[out] descr_text Description held in the Descriptor_t node. * \return \ier * * \details Note that with cg_descriptor_read(), the memory for the descriptor character string, * text, will be allocated by the Mid-Level Library. The application code is responsible * for releasing this memory when it is no longer needed by calling cg_free(text). * */ int cg_descriptor_read(int descr_no, char *descr_name, char **descr_text) { cgns_descr *descr; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; /* common part */ descr = cgi_descr_address(CG_MODE_READ, descr_no, "dummy", &ier); if (descr==0) return ier; /* return Descriptor text and name */ descr_text[0]=CGNS_NEW(char, strlen(descr->text)+1); strcpy(descr_text[0], descr->text); strcpy(descr_name, descr->name); return CG_OK; } /** * \ingroup DescriptiveText * * \brief Write descriptive text * * \param[in] descr_name Name of the Descriptor_t node. * \param[in] descr_text Description held in the Descriptor_t node. * \return \ier */ int cg_descriptor_write(const char * descr_name, const char * descr_text) { cgns_descr *descr; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_strlen(descr_name)) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; descr = cgi_descr_address(CG_MODE_WRITE, 0, descr_name, &ier); if (descr==0) return ier; /* Save Descriptor_t data */ strcpy(descr->name, descr_name); if ((descr->text = (char *)malloc((strlen(descr_text)+1)*sizeof(char)))==NULL) { cgi_error("Error allocating memory for Descriptor..."); return CG_ERROR; } strcpy(descr->text, descr_text); /* initialize other fields */ descr->id=0; descr->link=0; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_descr(posit_id, descr)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup DimensionalUnits * * \brief Get the number of dimensional units * * \param[out] nunits Number of units used in the file (i.e., either 5 or 8). * \return \ier */ int cg_nunits(int *nunits) { cgns_units *units; int ier=0; CHECK_FILE_OPEN *nunits = 0; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; units = cgi_units_address(CG_MODE_READ, &ier); if (units==0) return ier; *nunits = units->nunits; return CG_OK; } /** * \ingroup DimensionalUnits * * \brief Read first five dimensional units * * \param[out] mass Mass units. Admissible values are CG_Null, CG_UserDefined, Kilogram, Gram, * Slug, and PoundMass. * \param[out] length Length units. Admissible values are CG_Null, CG_UserDefined, Meter, * Centimeter, Millimeter, Foot, and Inch. * \param[out] time Time units. Admissible values are CG_Null, CG_UserDefined, and Second. * \param[out] temperature Temperature units. Admissible values are CG_Null, CG_UserDefined, Kelvin, * Celsius, Rankine, and Fahrenheit. * \param[out] angle Angle units. Admissible values are CG_Null, CG_UserDefined, Degree, and * Radian. * * \return \ier */ int cg_units_read(CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, CGNS_ENUMT(TemperatureUnits_t) *temperature, CGNS_ENUMT(AngleUnits_t) *angle) { cgns_units *units; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; units = cgi_units_address(CG_MODE_READ, &ier); if (units==0) return ier; (*mass) = units->mass; (*length) = units->length; (*time) = units->time; (*temperature) = units->temperature; (*angle) = units->angle; return CG_OK; } /** * \ingroup DimensionalUnits * * \brief Write first five dimensional units * * \param[in] mass Mass units. Admissible values are CG_Null, CG_UserDefined, Kilogram, Gram, * Slug, and PoundMass. * \param[in] length Length units. Admissible values are CG_Null, CG_UserDefined, Meter, * Centimeter, Millimeter, Foot, and Inch. * \param[in] time Time units. Admissible values are CG_Null, CG_UserDefined, and Second. * \param[in] temperature Temperature units. Admissible values are CG_Null, CG_UserDefined, Kelvin, * Celsius, Rankine, and Fahrenheit. * \param[in] angle Angle units. Admissible values are CG_Null, CG_UserDefined, Degree, and * Radian. * * \return \ier */ int cg_units_write(CGNS_ENUMT(MassUnits_t) mass, CGNS_ENUMT(LengthUnits_t) length, CGNS_ENUMT(TimeUnits_t) time, CGNS_ENUMT(TemperatureUnits_t) temperature, CGNS_ENUMT(AngleUnits_t) angle) { int ier=0; cgns_units *units; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; if (INVALID_ENUM(mass,NofValidMassUnits)) { cgi_error("Invalid input: mass unit %d not supported",mass); return CG_ERROR; } if (INVALID_ENUM(length,NofValidLengthUnits)) { cgi_error("Invalid input: length unit %d not supported", length); return CG_ERROR; } if (INVALID_ENUM(time,NofValidTimeUnits)) { cgi_error("Invalid input: time unit %d not supported", time); return CG_ERROR; } if (INVALID_ENUM(temperature,NofValidTemperatureUnits)) { cgi_error("Invalid input: temperature unit %d not supported", temperature); return CG_ERROR; } if (INVALID_ENUM(angle,NofValidAngleUnits)) { cgi_error("Invalid input: angle unit %d not supported", angle); return CG_ERROR; } /* get address */ units = cgi_units_address(CG_MODE_WRITE, &ier); if (units==0) return ier; /* save data in memory */ units->mass = mass; units->length = length; units->time = time; units->temperature = temperature; units->angle = angle; /* initialize other fields */ strcpy(units->name, "DimensionalUnits"); units->id = 0; units->link=0; units->nunits = 5; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_units(posit_id, units)) return CG_ERROR; return CG_OK; } /** * \ingroup DimensionalUnits * * \brief Read all eight dimensional units * * \param[out] mass Mass units. Admissible values are CG_Null, CG_UserDefined, Kilogram, Gram, * Slug, and PoundMass. * \param[out] length Length units. Admissible values are CG_Null, CG_UserDefined, Meter, * Centimeter, Millimeter, Foot, and Inch. * \param[out] time Time units. Admissible values are CG_Null, CG_UserDefined, and Second. * \param[out] temperature Temperature units. Admissible values are CG_Null, CG_UserDefined, Kelvin, * Celsius, Rankine, and Fahrenheit. * \param[out] angle Angle units. Admissible values are CG_Null, CG_UserDefined, Degree, and * Radian. * \param[out] current Electric current units. Admissible values are CG_Null, CG_UserDefined, * Ampere, Abampere, Statampere, Edison, and auCurrent. * \param[out] amount Substance amount units. Admissible values are CG_Null, CG_UserDefined, Mole, * Entities, StandardCubicFoot, and StandardCubicMeter. * \param[out] intensity Luminous intensity units. Admissible values are CG_Null, CG_UserDefined, * Candela, Candle, Carcel, Hefner, and Violle. * \return \ier */ int cg_unitsfull_read(CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, CGNS_ENUMT(TemperatureUnits_t) *temperature, CGNS_ENUMT(AngleUnits_t) *angle, CGNS_ENUMT(ElectricCurrentUnits_t) *current, CGNS_ENUMT(SubstanceAmountUnits_t) *amount, CGNS_ENUMT(LuminousIntensityUnits_t) *intensity) { cgns_units *units; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; units = cgi_units_address(CG_MODE_READ, &ier); if (units==0) return ier; (*mass) = units->mass; (*length) = units->length; (*time) = units->time; (*temperature) = units->temperature; (*angle) = units->angle; (*current) = units->current; (*amount) = units->amount; (*intensity) = units->intensity; return CG_OK; } /** * \ingroup DimensionalUnits * * \brief Write all eight dimensional units * * \param[in] mass Mass units. Admissible values are CG_Null, CG_UserDefined, Kilogram, Gram, * Slug, and PoundMass. * \param[in] length Length units. Admissible values are CG_Null, CG_UserDefined, Meter, * Centimeter, Millimeter, Foot, and Inch. * \param[in] time Time units. Admissible values are CG_Null, CG_UserDefined, and Second. * \param[in] temperature Temperature units. Admissible values are CG_Null, CG_UserDefined, Kelvin, * Celsius, Rankine, and Fahrenheit. * \param[in] angle Angle units. Admissible values are CG_Null, CG_UserDefined, Degree, and * Radian. * \param[in] current Electric current units. Admissible values are CG_Null, CG_UserDefined, * Ampere, Abampere, Statampere, Edison, and auCurrent. * \param[in] amount Substance amount units. Admissible values are CG_Null, CG_UserDefined, Mole, * Entities, StandardCubicFoot, and StandardCubicMeter. * \param[in] intensity Luminous intensity units. Admissible values are CG_Null, CG_UserDefined, * Candela, Candle, Carcel, Hefner, and Violle. * * \return \ier */ int cg_unitsfull_write(CGNS_ENUMT(MassUnits_t) mass, CGNS_ENUMT(LengthUnits_t) length, CGNS_ENUMT(TimeUnits_t) time, CGNS_ENUMT(TemperatureUnits_t) temperature, CGNS_ENUMT(AngleUnits_t) angle, CGNS_ENUMT(ElectricCurrentUnits_t) current, CGNS_ENUMT(SubstanceAmountUnits_t) amount, CGNS_ENUMT(LuminousIntensityUnits_t) intensity) { int ier=0; cgns_units *units; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; if (INVALID_ENUM(mass,NofValidMassUnits)) { cgi_error("Invalid input: mass unit %d not supported",mass); return CG_ERROR; } if (INVALID_ENUM(length,NofValidLengthUnits)) { cgi_error("Invalid input: length unit %d not supported", length); return CG_ERROR; } if (INVALID_ENUM(time,NofValidTimeUnits)) { cgi_error("Invalid input: time unit %d not supported", time); return CG_ERROR; } if (INVALID_ENUM(temperature,NofValidTemperatureUnits)) { cgi_error("Invalid input: temperature unit %d not supported", temperature); return CG_ERROR; } if (INVALID_ENUM(angle,NofValidAngleUnits)) { cgi_error("Invalid input: angle unit %d not supported", angle); return CG_ERROR; } if (INVALID_ENUM(current,NofValidElectricCurrentUnits)) { cgi_error("Invalid input: electric current unit %d not supported", current); return CG_ERROR; } if (INVALID_ENUM(amount,NofValidSubstanceAmountUnits)) { cgi_error("Invalid input: substance amount unit %d not supported", amount); return CG_ERROR; } if (INVALID_ENUM(intensity,NofValidLuminousIntensityUnits)) { cgi_error("Invalid input: luminous intensity unit %d not supported", intensity); return CG_ERROR; } /* get address */ units = cgi_units_address(CG_MODE_WRITE, &ier); if (units==0) return ier; /* save data in memory */ units->mass = mass; units->length = length; units->time = time; units->temperature = temperature; units->angle = angle; units->current = current; units->amount = amount; units->intensity = intensity; /* initialize other fields */ strcpy(units->name, "DimensionalUnits"); units->id = 0; units->link=0; units->nunits = 8; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_units(posit_id, units)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup DimensionalExponents * * \brief Get exponent data type * \param[out] DataType Data type in which the exponents are recorded. Admissible data types for the * exponents are RealSingle and RealDouble. * \return \ier */ int cg_exponents_info(CGNS_ENUMT(DataType_t) *DataType) { cgns_exponent *exponent; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; exponent = cgi_exponent_address(CG_MODE_READ, &ier); if (exponent==0) return ier; (*DataType) = cgi_datatype(exponent->data_type); return CG_OK; } /** * \ingroup DimensionalExponents * * \brief Get the number of dimensional exponents * \param[out] numexp Number of exponents used in the file (i.e., either 5 or 8). * \return \ier */ int cg_nexponents(int *numexp) { cgns_exponent *exponent; int ier=0; CHECK_FILE_OPEN *numexp = 0; /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; exponent = cgi_exponent_address(CG_MODE_READ, &ier); if (exponent==0) return ier; *numexp = exponent->nexps; return CG_OK; } /** * \ingroup DimensionalExponents * * \brief Read first five dimensional exponents * \param[out] exponents Exponents for the dimensional units for mass, length, time, temperature, * angle, electric current, substance amount, and luminous intensity, in that * order. * \return \ier * * \details When reading exponent data, either cg_exponents_read() or cg_expfull_read() may be used, * regardless of the number of exponents used in the file. If cg_exponents_read() is used, * but all eight exponents are used in the file, only the first five exponents are returned. * If cg_expfull_read() is used, but only five exponents are used in the file, the returned * values of the exponents for electric current, substance amount, and luminous intensity * will be zero. */ int cg_exponents_read(void *exponents) { cgns_exponent *exponent; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; exponent = cgi_exponent_address(CG_MODE_READ, &ier); if (exponent==0) return ier; if (cgi_datatype(exponent->data_type)==CGNS_ENUMV( RealSingle )) { (*((float *)exponents+0)) = (*((float *) exponent->data+0)); (*((float *)exponents+1)) = (*((float *) exponent->data+1)); (*((float *)exponents+2)) = (*((float *) exponent->data+2)); (*((float *)exponents+3)) = (*((float *) exponent->data+3)); (*((float *)exponents+4)) = (*((float *) exponent->data+4)); } else if (cgi_datatype(exponent->data_type)==CGNS_ENUMV( RealDouble )) { (*((double *)exponents+0)) = (*((double *) exponent->data+0)); (*((double *)exponents+1)) = (*((double *) exponent->data+1)); (*((double *)exponents+2)) = (*((double *) exponent->data+2)); (*((double *)exponents+3)) = (*((double *) exponent->data+3)); (*((double *)exponents+4)) = (*((double *) exponent->data+4)); } return CG_OK; } /** * \ingroup DimensionalExponents * * \brief Write first five dimensional exponents * \param[in] DataType Data type in which the exponents are recorded. Admissible data types for the * exponents are RealSingle and RealDouble. * \param[in] exponents Exponents for the dimensional units for mass, length, time, temperature, * angle, electric current, substance amount, and luminous intensity, in that * order. * \return \ier */ int cg_exponents_write(CGNS_ENUMT(DataType_t) DataType, const void * exponents) { cgns_exponent *exponent; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; exponent = cgi_exponent_address(CG_MODE_WRITE, &ier); if (exponent==0) return ier; /* Save Data */ strcpy(exponent->data_type, cgi_adf_datatype(DataType)); exponent->data = (void *)malloc(5*size_of(exponent->data_type)); if (exponent->data == NULL) { cgi_error("Error allocating exponent->data"); return CG_ERROR; } if (DataType==CGNS_ENUMV( RealSingle )) { (*((float *)exponent->data+0)) = (*((float *) exponents+0)); (*((float *)exponent->data+1)) = (*((float *) exponents+1)); (*((float *)exponent->data+2)) = (*((float *) exponents+2)); (*((float *)exponent->data+3)) = (*((float *) exponents+3)); (*((float *)exponent->data+4)) = (*((float *) exponents+4)); } else if (DataType==CGNS_ENUMV( RealDouble )) { (*((double *)exponent->data+0)) = (*((double *) exponents+0)); (*((double *)exponent->data+1)) = (*((double *) exponents+1)); (*((double *)exponent->data+2)) = (*((double *) exponents+2)); (*((double *)exponent->data+3)) = (*((double *) exponents+3)); (*((double *)exponent->data+4)) = (*((double *) exponents+4)); } /* initialize other fields */ strcpy(exponent->name, "DimensionalExponents"); exponent->id = 0; exponent->link = 0; exponent->nexps = 5; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_exponents(posit_id, exponent)) return CG_ERROR; return CG_OK; } /** * \ingroup DimensionalExponents * * \brief Read all eight dimensional exponents * \param[out] exponents Exponents for the dimensional units for mass, length, time, temperature, * angle, electric current, substance amount, and luminous intensity, in that * order. * \return \ier * * \details When reading exponent data, either cg_exponents_read() or cg_expfull_read() may be used, * regardless of the number of exponents used in the file. If cg_exponents_read() is used, * but all eight exponents are used in the file, only the first five exponents are returned. * If cg_expfull_read() is used, but only five exponents are used in the file, the returned * values of the exponents for electric current, substance amount, and luminous intensity * will be zero. */ int cg_expfull_read(void *exponents) { cgns_exponent *exponent; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; exponent = cgi_exponent_address(CG_MODE_READ, &ier); if (exponent==0) return ier; /* don't fail - just return 0's for last 3 if(exponent->nexps != 8) { cgi_error("Full set of exponents not written, use cg_exponents_read."); return CG_ERROR; }*/ if (cgi_datatype(exponent->data_type)==CGNS_ENUMV( RealSingle )) { (*((float *)exponents+0)) = (*((float *) exponent->data+0)); (*((float *)exponents+1)) = (*((float *) exponent->data+1)); (*((float *)exponents+2)) = (*((float *) exponent->data+2)); (*((float *)exponents+3)) = (*((float *) exponent->data+3)); (*((float *)exponents+4)) = (*((float *) exponent->data+4)); if (exponent->nexps == 8) { (*((float *)exponents+5)) = (*((float *) exponent->data+5)); (*((float *)exponents+6)) = (*((float *) exponent->data+6)); (*((float *)exponents+7)) = (*((float *) exponent->data+7)); } else { (*((float *)exponents+5)) = (float)0.0; (*((float *)exponents+6)) = (float)0.0;; (*((float *)exponents+7)) = (float)0.0;; } } else if (cgi_datatype(exponent->data_type)==CGNS_ENUMV( RealDouble )) { (*((double *)exponents+0)) = (*((double *) exponent->data+0)); (*((double *)exponents+1)) = (*((double *) exponent->data+1)); (*((double *)exponents+2)) = (*((double *) exponent->data+2)); (*((double *)exponents+3)) = (*((double *) exponent->data+3)); (*((double *)exponents+4)) = (*((double *) exponent->data+4)); if (exponent->nexps == 8) { (*((double *)exponents+5)) = (*((double *) exponent->data+5)); (*((double *)exponents+6)) = (*((double *) exponent->data+6)); (*((double *)exponents+7)) = (*((double *) exponent->data+7)); } else { (*((double *)exponents+5)) = (double)0.0; (*((double *)exponents+6)) = (double)0.0;; (*((double *)exponents+7)) = (double)0.0;; } } return CG_OK; } /** * \ingroup DimensionalExponents * * \brief Write all eight dimensional exponents * \param[in] DataType Data type in which the exponents are recorded. Admissible data types for the * exponents are RealSingle and RealDouble. * \param[in] exponents Exponents for the dimensional units for mass, length, time, temperature, * angle, electric current, substance amount, and luminous intensity, in that * order. * \return \ier */ int cg_expfull_write(CGNS_ENUMT(DataType_t) DataType, const void * exponents) { cgns_exponent *exponent; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; exponent = cgi_exponent_address(CG_MODE_WRITE, &ier); if (exponent==0) return ier; /* Save Data */ strcpy(exponent->data_type, cgi_adf_datatype(DataType)); exponent->data = (void *)malloc(8*size_of(exponent->data_type)); if (exponent->data == NULL) { cgi_error("Error allocating exponent->data"); return CG_ERROR; } if (DataType==CGNS_ENUMV( RealSingle )) { (*((float *)exponent->data+0)) = (*((float *) exponents+0)); (*((float *)exponent->data+1)) = (*((float *) exponents+1)); (*((float *)exponent->data+2)) = (*((float *) exponents+2)); (*((float *)exponent->data+3)) = (*((float *) exponents+3)); (*((float *)exponent->data+4)) = (*((float *) exponents+4)); (*((float *)exponent->data+5)) = (*((float *) exponents+5)); (*((float *)exponent->data+6)) = (*((float *) exponents+6)); (*((float *)exponent->data+7)) = (*((float *) exponents+7)); } else if (DataType==CGNS_ENUMV( RealDouble )) { (*((double *)exponent->data+0)) = (*((double *) exponents+0)); (*((double *)exponent->data+1)) = (*((double *) exponents+1)); (*((double *)exponent->data+2)) = (*((double *) exponents+2)); (*((double *)exponent->data+3)) = (*((double *) exponents+3)); (*((double *)exponent->data+4)) = (*((double *) exponents+4)); (*((double *)exponent->data+5)) = (*((double *) exponents+5)); (*((double *)exponent->data+6)) = (*((double *) exponents+6)); (*((double *)exponent->data+7)) = (*((double *) exponents+7)); } /* initialize other fields */ strcpy(exponent->name, "DimensionalExponents"); exponent->id = 0; exponent->link = 0; exponent->nexps = 8; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_exponents(posit_id, exponent)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup DataConversionFactors * * \brief Get conversion factors data type * \param[out] DataType Data type in which the conversion factors are recorded. * Admissible data types for the exponents are RealSingle * and RealDouble. * \return \ier */ int cg_conversion_info(CGNS_ENUMT(DataType_t) *DataType) { cgns_conversion *conversion; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; conversion = cgi_conversion_address(CG_MODE_READ, &ier); if (conversion==0) return ier; (*DataType) = cgi_datatype(conversion->data_type); return CG_OK; } /** * \ingroup DataConversionFactors * * \brief Read conversion factors * \param[out] ConversionFactors Two-element array containing the scaling and offset factors. * \return \ier * * \details The DataConversion_t data structure contains factors to convert the nondimensional * data to "raw" dimensional data. The scaling and offset factors are contained in the * two-element array ConversionFactors. In pseudo-Fortran, the conversion process is as follows: * * \code{C} * ConversionScale = ConversionFactors(1) * ConversionOffset = ConversionFactors(2) * Data(raw) = Data(nondimensional)*ConversionScale + ConversionOffset * \endcode * */ int cg_conversion_read(void *ConversionFactors) { cgns_conversion *conversion; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; conversion = cgi_conversion_address(CG_MODE_READ, &ier); if (conversion==0) return ier; if (cgi_datatype(conversion->data_type)==CGNS_ENUMV( RealSingle )) { *((float *)ConversionFactors+0) = *((float *) conversion->data+0); *((float *)ConversionFactors+1) = *((float *) conversion->data+1); } else if (cgi_datatype(conversion->data_type)==CGNS_ENUMV( RealDouble )) { *((double *)ConversionFactors+0) = *((double *) conversion->data+0); *((double *)ConversionFactors+1) = *((double *) conversion->data+1); } return CG_OK; } /** * \ingroup DataConversionFactors * * \brief Write conversion factors * \param[in] DataType Data type in which the conversion factors are recorded. Admissible data * types for the exponents are `RealSingle` and `RealDouble`. * \param[in] ConversionFactors Two-element array containing the scaling and offset factors. * \return \ier */ int cg_conversion_write(CGNS_ENUMT(DataType_t) DataType, const void * ConversionFactors) { cgns_conversion *conversion; int ier=0; cgsize_t dim_vals=2; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; conversion = cgi_conversion_address(CG_MODE_WRITE, &ier); if (conversion==0) return ier; /* Save data */ strcpy(conversion->data_type, cgi_adf_datatype(DataType)); conversion->data = (void *)malloc(2*size_of(conversion->data_type)); if (conversion->data == NULL) { cgi_error("Error allocating conversion->data"); return CG_ERROR; } if (DataType==CGNS_ENUMV( RealSingle )) { *((float *) conversion->data+0) = *((float *)ConversionFactors+0); *((float *) conversion->data+1) = *((float *)ConversionFactors+1); } else if (DataType==CGNS_ENUMV( RealDouble )) { *((double *) conversion->data+0) = *((double *)ConversionFactors+0); *((double *) conversion->data+1) = *((double *)ConversionFactors+1); } /* initialize other fields */ strcpy(conversion->name, "DataConversion"); conversion->id=0; conversion->link=0; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_new_node(posit_id, "DataConversion", "DataConversion_t", &conversion->id, conversion->data_type, 1, &dim_vals, conversion->data)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup DataClass * * \brief Read data class * \param[out] dataclass Data class for the nodes at this level. See below for the data classes * currently supported in CGNS. * \return \ier * * \details The data classes currently supported in CGNS are: * * *
Dimensional Regular dimensional data. *
NormalizedByDimensional Nondimensional data that is normalized by dimensional reference quantities. *
NormalizedByUnknownDimensional All fields and reference data are nondimensional. *
NondimensionalParameter Nondimensional parameters such as Mach number and lift coefficient. *
DimensionlessConstant Constant such as π. *
* * These classes are declared within typedef DataClass_t in cgnslib.h, and as parameters in cgnslib_f.h. */ int cg_dataclass_read(CGNS_ENUMT(DataClass_t) *dataclass) { CGNS_ENUMT(DataClass_t) *DataClass; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; DataClass = cgi_dataclass_address(CG_MODE_READ, &ier); if (DataClass==0) return ier; if (*DataClass==CGNS_ENUMV( DataClassNull )) return CG_NODE_NOT_FOUND; (*dataclass) = (*DataClass); return CG_OK; } /** * \ingroup DataClass * * \brief Write data class * \param[in] dataclass Data class for the nodes at this level. See below for the data classes * currently supported in CGNS. * \return \ier * * \details The data classes currently supported in CGNS are: * * *
Dimensional Regular dimensional data. *
NormalizedByDimensional Nondimensional data that is normalized by dimensional reference quantities. *
NormalizedByUnknownDimensional All fields and reference data are nondimensional. *
NondimensionalParameter Nondimensional parameters such as Mach number and lift coefficient. *
DimensionlessConstant Constant such as π. *
* * These classes are declared within typedef \e DataClass_t in cgnslib.h, and as parameters in cgnslib_f.h. */ int cg_dataclass_write(CGNS_ENUMT(DataClass_t) dataclass) { CGNS_ENUMT(DataClass_t) *DataClass; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; DataClass = cgi_dataclass_address(CG_MODE_WRITE, &ier); if (DataClass==0) return ier; (*DataClass) = dataclass; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_dataclass(posit_id, dataclass)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup GridLocation * * \brief Read grid location * \param[out] GridLocation Location in the grid. The admissible locations * are `CG_Null`, `CG_UserDefined`, `Vertex`, * `CellCenter`, `FaceCenter`, `IFaceCenter`, * `JFaceCenter`, `KFaceCenter`, and `EdgeCenter`. * \return \ier * */ int cg_gridlocation_read(CGNS_ENUMT(GridLocation_t) *GridLocation) { CGNS_ENUMT(GridLocation_t) *location; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; location = cgi_location_address(CG_MODE_READ, &ier); if (location==0) return ier; #ifdef CG_FIX_BC_CELL_CENTER /* convert old BC_t CellCenter values */ if (*location == CGNS_ENUMV(CellCenter) && 0 == strcmp(posit->label, "BC_t")) { int dim = cg->base[posit_base-1].cell_dim; if (dim == 1) *GridLocation = CGNS_ENUMV(Vertex); else if (dim == 2) *GridLocation = CGNS_ENUMV(EdgeCenter); else *GridLocation = CGNS_ENUMV(FaceCenter); return CG_OK; } #endif (*GridLocation) = (*location); return CG_OK; } /** * \ingroup GridLocation * * \brief Write grid location * \param[in] GridLocation Location in the grid. The admissible locations * are `CG_Null`, `CG_UserDefined`, `Vertex`, * `CellCenter`, `FaceCenter`, `IFaceCenter`, * `JFaceCenter`, `KFaceCenter`, and `EdgeCenter`. * \return \ier * */ int cg_gridlocation_write(CGNS_ENUMT(GridLocation_t) GridLocation) { CGNS_ENUMT(GridLocation_t) *location; int ier=0; cgsize_t dim_vals; double posit_id, dummy_id; int cell_dim = 0; CGNS_ENUMT(ZoneType_t) type = CGNS_ENUMV(ZoneTypeNull); CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; location = cgi_location_address(CG_MODE_WRITE, &ier); if (location==0) return ier; if (posit_base) { cell_dim = cg->base[posit_base-1].cell_dim; if (posit_zone) type = cg->base[posit_base-1].zone[posit_zone-1].type; } if ((GridLocation == CGNS_ENUMV(IFaceCenter) || GridLocation == CGNS_ENUMV(JFaceCenter) || GridLocation == CGNS_ENUMV(KFaceCenter)) && type != CGNS_ENUMV(Structured)) { cgi_error("GridLocation [IJK]FaceCenter only valid for Structured Grid"); return CG_ERROR; } ier = 0; if (strcmp(posit->label,"FlowSolution_t")==0 || strcmp(posit->label,"DiscreteData_t")== 0) { if (cgi_check_location(cell_dim, type, GridLocation)) return CG_ERROR; } else if (strcmp(posit->label,"ArbitraryGridMotion_t")== 0 || strcmp(posit->label,"GridConnectivity_t")==0) { if (GridLocation != CGNS_ENUMV(Vertex) && GridLocation != CGNS_ENUMV(CellCenter) && GridLocation != CGNS_ENUMV(FaceCenter) && GridLocation != CGNS_ENUMV(IFaceCenter) && GridLocation != CGNS_ENUMV(JFaceCenter) && GridLocation != CGNS_ENUMV(KFaceCenter)) ier = 1; } else if (strcmp(posit->label,"OversetHoles_t")==0) { if (GridLocation != CGNS_ENUMV(Vertex) && GridLocation != CGNS_ENUMV(CellCenter)) ier = 1; } else if (strcmp(posit->label,"BC_t")==0) { if (cgi_check_location(cell_dim, type, GridLocation)) return CG_ERROR; #ifdef CG_FIX_BC_CELL_CENTER if (GridLocation == CGNS_ENUMV(CellCenter)) { if (cell_dim == 1) GridLocation = CGNS_ENUMV(Vertex); else if (cell_dim == 2) GridLocation = CGNS_ENUMV(EdgeCenter); else GridLocation = CGNS_ENUMV(FaceCenter); cgi_warning("GridLocation CellCenter for BC_t is deprecated" " - changed to %s", GridLocationName[GridLocation]); } #endif } else { if (INVALID_ENUM(GridLocation,NofValidGridLocation)) ier = 1; } if (ier) { cgi_error("GridLocation %d not valid for %s", GridLocation, posit->label); return CG_ERROR; } (*location) = GridLocation; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; dim_vals = (cgsize_t)strlen(GridLocationName[GridLocation]); if (cgi_new_node(posit_id, "GridLocation", "GridLocation_t", &dummy_id, "C1", 1, &dim_vals, (void *)GridLocationName[GridLocation])) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup OrdinalValue * * \brief Read ordinal value * \param[out] Ordinal Any integer value. * \return \ier * */ int cg_ordinal_read(int *Ordinal) { int *ordinal; int ier=0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; ordinal = cgi_ordinal_address(CG_MODE_READ, &ier); if (ordinal==0) return ier; (*Ordinal) = (*ordinal); return CG_OK; } /** * \ingroup OrdinalValue * * \brief Write ordinal value * \param[in] Ordinal Any integer value. * \return \ier * */ int cg_ordinal_write(int Ordinal) { int *ordinal; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; ordinal = cgi_ordinal_address(CG_MODE_WRITE, &ier); if (ordinal==0) return ier; (*ordinal) = Ordinal; /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_ordinal(posit_id, Ordinal)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup Links * * \brief Test if a node is a link * \param[out] path_length Length of the path name of the linked node. The * value 0 is returned if the node is not a link * \return \ier * */ int cg_is_link(int *path_length) { double posit_id; *path_length = 0; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgio_is_link(cg->cgio, posit_id, path_length)) { cg_io_error("cgio_is_link"); return CG_ERROR; } return CG_OK; } /** * \ingroup Links * * \brief Get path information for a link at the current location * * \param[out] filename Name of the linked file, or an empty string if the * link is within the same file. * \param[out] link_path Path name of the node the link points to. * * \return \ier * * \details Use cg_goto() to position to a location in the file prior * to calling these routines. Memory is allocated by the library * for the return values of the C function cg_link_read(). * This memory should be freed by the user when no longer needed * by calling \p cg_free(filename) and \p cg_free(link_path). * */ int cg_link_read(char **filename, char **link_path) { int name_len, file_len; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgio_link_size(cg->cgio, posit_id, &file_len, &name_len)) { cg_io_error("cgio_link_size"); return CG_ERROR; } *filename = CGNS_NEW(char, file_len + 1); *link_path = CGNS_NEW(char, name_len + 1); if (cgio_get_link(cg->cgio, posit_id, *filename, *link_path)) { CGNS_FREE(*filename); CGNS_FREE(*link_path); *filename = *link_path = 0; cg_io_error("cgio_get_link"); return CG_ERROR; } return CG_OK; } /** * \ingroup Links * * \brief Create a link at the current location * * \param[in] nodename Name of the link node to create, e.g., GridCoordinates. * \param[in] filename Name of the linked file, or an empty string if the link is within the same * file. * \param[in] name_in_file Path name of the node the link points to. This can be a simple or a * compound name, e.g., Base/Zone 1/GridCoordinates. * * \return \ier * * \details Use cg_goto() to position to a location in the file prior to calling these routines. * When using cg_link_write(), the node being linked to does not have to exist when the link * is created. However, when the link is used, an error will occur if the linked-to node does not exist. * * Only nodes that support child nodes will support links. * * It is assumed that the CGNS version for the file containing the link, as determined by the * CGNSLibraryVersion_t node, is also applicable to \p filename, the file containing the linked node. * */ int cg_link_write(const char * nodename, const char * filename, const char * name_in_file) { double posit_id, link_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; if (cgi_posit_id(&posit_id)) return CG_ERROR; /* check for valid posit */ if (strcmp(posit->label,"DataArray_t") && strcmp(posit->label,"UserDefinedData_t") && strcmp(posit->label,"IntegralData_t") && strcmp(posit->label,"DiscreteData_t") && strcmp(posit->label,"ConvergenceHistory_t") && strcmp(posit->label,"ReferenceState_t") && strcmp(posit->label,"GasModel_t") && strcmp(posit->label,"ViscosityModel_t") && strcmp(posit->label,"ThermalConductivityModel_t") && strcmp(posit->label,"TurbulenceModel_t") && strcmp(posit->label,"TurbulenceClosure_t") && strcmp(posit->label,"ThermalRelaxationModel_t") && strcmp(posit->label,"ChemicalKineticsModel_t") && strcmp(posit->label,"EMElectricFieldModel_t") && strcmp(posit->label,"EMMagneticFieldModel_t") && strcmp(posit->label,"EMConductivityModel_t") && strcmp(posit->label,"GoverningEquations_t") && strcmp(posit->label,"BCData_t") && strcmp(posit->label,"BCDataSet_t") && strcmp(posit->label,"FamilyBCDataSet_t") && strcmp(posit->label,"Elements_t") && strcmp(posit->label,"BC_t") && strcmp(posit->label,"ZoneBC_t") && strcmp(posit->label,"OversetHoles_t") && strcmp(posit->label,"GridConnectivity_t") && strcmp(posit->label,"GridConnectivity1to1_t") && strcmp(posit->label,"ZoneGridConnectivity_t") && strcmp(posit->label,"FlowSolution_t") && strcmp(posit->label,"GridCoordinates_t") && strcmp(posit->label,"RigidGridMotion_t") && strcmp(posit->label,"ArbitraryGridMotion_t") && strcmp(posit->label,"ZoneIterativeData_t") && strcmp(posit->label,"BaseIterativeData_t") && strcmp(posit->label,"Zone_t") && strcmp(posit->label,"ZoneSubRegion_t") && strcmp(posit->label,"GeometryReference_t ") && strcmp(posit->label,"Family_t") && strcmp(posit->label,"CGNSBase_t") && strcmp(posit->label,"Gravity_t") && strcmp(posit->label,"Axisymmetry_t") && strcmp(posit->label,"RotatingCoordinates_t") && strcmp(posit->label,"BCProperty_t") && strcmp(posit->label,"WallFunction_t") && strcmp(posit->label,"Area_t") && strcmp(posit->label,"GridConnectivityProperty_t") && strcmp(posit->label,"Periodic_t") && strcmp(posit->label,"AverageInterface_t") && strcmp(posit->label,"ParticleZone_t") && strcmp(posit->label,"ParticleCoordinates_t") && strcmp(posit->label,"ParticleSolution_t") && strcmp(posit->label,"ParticleIterativeData_t") && strcmp(posit->label,"ParticleEquationSet_t") && strcmp(posit->label,"ParticleGoverningEquations_t") && strcmp(posit->label,"ParticleCollisionModel_t") && strcmp(posit->label,"ParticleBreakupModel_t") && strcmp(posit->label,"ParticleForceModel_t") && strcmp(posit->label,"ParticleWallInteractionModel_t") && strcmp(posit->label,"ParticlePhaseChangeModel_t")) { cgi_error("Links not supported under '%s' type node",posit->label); return CG_INCORRECT_PATH; } #if DEBUG_LINKS printf("Modify link %s -> \"%s>%s\"\n", nodename, filename, name_in_file); #endif /* Create the ADF link. */ /* If a node already exists by that name, this will fail. */ /* Need to fix this to allow modifying an existing node */ /* but that's going to take a bit of work to keep the */ /* in-core information current */ if (cgio_create_link(cg->cgio, posit_id, nodename, filename, name_in_file, &link_id)) { cg_io_error("cgio_create_link"); return CG_ERROR; } (cg->added)++; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup UserDefinedData * * * \brief Get the number of UserDefinedData_t nodes * * \param[out] nuser_data Number of UserDefinedData_t nodes under current node. * * \return \ier * * \details After accessing a particular UserDefinedData_t node using cg_goto(), * the Point Set functions may be used to read or write point set information for the node. * The function cg_gridlocation_write() may also be used to specify the location of the data * with respect to the grid (e.g., Vertex or FaceCenter). * * Multiple levels of UserDefinedData_t nodes may be written and retrieved by positioning * via cg_goto(). E.g., * \code{C} * ier = cg_goto(fn, B, "Zone_t", Z, "UserDefinedData_t", ud1, * "UserDefinedData_t", ud2, "UserDefinedData_t", ud3, "end"); * \endcode * */ int cg_nuser_data(int *nuser_data) { /* Possible parents of UserDefinedData_t node: * IntegralData_t, DiscreteData_t, ConvergenceHistory_t, ReferenceState_t, * xxxModel_t, GoverningEquations_t, FlowEquationSet_t, BCData_t, BCDataSet_t, * Elements_t, BC_t, ZoneBC_t, OversetHoles_t, GridConnectivity_t, * GridConnectivity1to1_t, ZoneGridConnectivity_t, FlowSolution_t, * GridCoordinates_t, RigidGridMotion_t, ArbitraryGridMotion_t, * ZoneIterativeData_t, BaseIterativeData_t, Zone_t, GeometryReference_t, * Family_t, CGNSBase_t, Gravity_t, Axisymmetry_t, RotatingCoordinates_t, * BCProperty_t, WallFunction_t, Area_t, UserDefinedData_t, * GridConnectivityProperty_t, Periodic_t, AverageInterface_t * FamilyBCDataSet_t, ParticleZone_t, ParticleCoordinates_t, ParticleSolution_t, * ParticleIterativeData_t, ParticleEquationSet_t, ParticleGoverningEquations_t, * ParticleCollisionModel_t, ParticleBreakupModel_t, ParticleForceModel_t, * ParticleWallInteractionModel_t, ParticlePhaseChangeModel_t, ParticleGoverningEquations_t */ /* This is valid and used during write as well as read mode. */ CHECK_FILE_OPEN /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*nuser_data) = 0; return CG_ERROR; } if (strcmp(posit->label,"IntegralData_t")==0) (*nuser_data) = ((cgns_integral *)posit->posit)->nuser_data; else if (strcmp(posit->label,"DiscreteData_t")==0) (*nuser_data) = ((cgns_discrete *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ConvergenceHistory_t")==0) (*nuser_data) = ((cgns_converg *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ReferenceState_t")==0) (*nuser_data) = ((cgns_state *)posit->posit)->nuser_data; else if ( (strcmp(posit->label,"GasModel_t")==0 || strcmp(posit->label,"ViscosityModel_t")==0 || strcmp(posit->label,"ThermalConductivityModel_t")==0 || strcmp(posit->label,"TurbulenceModel_t")==0 || strcmp(posit->label,"TurbulenceClosure_t")==0 || strcmp(posit->label,"ThermalRelaxationModel_t")==0 || strcmp(posit->label,"ChemicalKineticsModel_t")==0 || strcmp(posit->label,"EMElectricFieldModel_t")==0 || strcmp(posit->label,"EMMagneticFieldModel_t")==0 || strcmp(posit->label,"EMConductivityModel_t")==0) ) (*nuser_data) = ((cgns_model *)posit->posit)->nuser_data; else if (strcmp(posit->label,"GoverningEquations_t")==0) (*nuser_data) = ((cgns_governing *)posit->posit)->nuser_data; else if (strcmp(posit->label,"FlowEquationSet_t")==0) (*nuser_data) = ((cgns_equations *)posit->posit)->nuser_data; else if (strcmp(posit->label,"BCData_t")==0) (*nuser_data) = ((cgns_bcdata *)posit->posit)->nuser_data; else if (strcmp(posit->label,"BCDataSet_t")==0 || strcmp(posit->label,"FamilyBCDataSet_t")==0) (*nuser_data) = ((cgns_dataset *)posit->posit)->nuser_data; else if (strcmp(posit->label,"Elements_t")==0) (*nuser_data) = ((cgns_section *)posit->posit)->nuser_data; else if (strcmp(posit->label,"BC_t")==0) (*nuser_data) = ((cgns_boco *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ZoneBC_t")==0) (*nuser_data) = ((cgns_zboco *)posit->posit)->nuser_data; else if (strcmp(posit->label,"OversetHoles_t")==0) (*nuser_data) = ((cgns_hole *)posit->posit)->nuser_data; else if (strcmp(posit->label,"GridConnectivity_t")==0) (*nuser_data) = ((cgns_conn *)posit->posit)->nuser_data; else if (strcmp(posit->label,"GridConnectivity1to1_t")==0) (*nuser_data) = ((cgns_1to1 *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ZoneGridConnectivity_t")==0) (*nuser_data) = ((cgns_zconn *)posit->posit)->nuser_data; else if (strcmp(posit->label,"FlowSolution_t")==0) (*nuser_data) = ((cgns_sol *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ParticleSolution_t")==0) (*nuser_data) = ((cgns_psol *)posit->posit)->nuser_data; else if (strcmp(posit->label,"GridCoordinates_t")==0) (*nuser_data) = ((cgns_zcoor *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ParticleCoordinates_t")==0) (*nuser_data) = ((cgns_pcoor *)posit->posit)->nuser_data; else if (strcmp(posit->label,"RigidGridMotion_t")==0) (*nuser_data) = ((cgns_rmotion *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) (*nuser_data) = ((cgns_amotion *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ZoneIterativeData_t")==0 || strcmp(posit->label,"ParticleIterativeData_t")==0) (*nuser_data) = ((cgns_ziter *)posit->posit)->nuser_data; else if (strcmp(posit->label,"BaseIterativeData_t")==0) (*nuser_data) = ((cgns_biter *)posit->posit)->nuser_data; else if (strcmp(posit->label,"Zone_t")==0) (*nuser_data) = ((cgns_zone *)posit->posit)->nuser_data; else if (strcmp(posit->label,"GeometryReference_t")==0) (*nuser_data) = ((cgns_geo *)posit->posit)->nuser_data; else if (strcmp(posit->label,"Family_t")==0) (*nuser_data) = ((cgns_family *)posit->posit)->nuser_data; else if (strcmp(posit->label,"CGNSBase_t")==0) (*nuser_data) = ((cgns_base *)posit->posit)->nuser_data; else if (strcmp(posit->label,"Gravity_t")==0) (*nuser_data) = ((cgns_gravity *)posit->posit)->nuser_data; else if (strcmp(posit->label,"Axisymmetry_t")==0) (*nuser_data) = ((cgns_axisym *)posit->posit)->nuser_data; else if (strcmp(posit->label,"RotatingCoordinates_t")==0) (*nuser_data) = ((cgns_rotating *)posit->posit)->nuser_data; else if (strcmp(posit->label,"BCProperty_t")==0) (*nuser_data) = ((cgns_bprop *)posit->posit)->nuser_data; else if (strcmp(posit->label,"WallFunction_t")==0) (*nuser_data) = ((cgns_bcwall *)posit->posit)->nuser_data; else if (strcmp(posit->label,"Area_t")==0) (*nuser_data) = ((cgns_bcarea *)posit->posit)->nuser_data; else if (strcmp(posit->label,"UserDefinedData_t")==0) (*nuser_data) = ((cgns_user_data *)posit->posit)->nuser_data; else if (strcmp(posit->label,"GridConnectivityProperty_t")==0) (*nuser_data) = ((cgns_cprop *)posit->posit)->nuser_data; else if (strcmp(posit->label,"Periodic_t")==0) (*nuser_data) = ((cgns_cperio *)posit->posit)->nuser_data; else if (strcmp(posit->label,"AverageInterface_t")==0) (*nuser_data) = ((cgns_caverage *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ZoneSubRegion_t")==0) (*nuser_data) = ((cgns_subreg *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ParticleZone_t")==0) (*nuser_data) = ((cgns_pzone *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ParticleEquationSet_t")==0) (*nuser_data) = ((cgns_pequations *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ParticleGoverningEquations_t")==0) (*nuser_data) = ((cgns_pgoverning *)posit->posit)->nuser_data; else if (strcmp(posit->label,"ParticleCollisionModel_t")==0 || strcmp(posit->label,"ParticleBreakupModel_t")==0 || strcmp(posit->label,"ParticleForceModel_t")==0 || strcmp(posit->label,"ParticleWallInteractionModel_t")==0 || strcmp(posit->label,"ParticlePhaseChangeModel_t")==0) (*nuser_data) = ((cgns_pmodel *)posit->posit)->nuser_data; else { cgi_error("UserDefinedData_t node not supported under '%s' type node",posit->label); (*nuser_data) = 0; return CG_INCORRECT_PATH; } return CG_OK; } /** * \ingroup UserDefinedData * * * \brief Get name of an UserDefinedData_t node * * \param[in] Index User-defined data index number, where 1 ≤ Index ≤ nuser_data. * \param[out] UserDataName Name of the UserDefinedData_t node. * * \return \ier * */ int cg_user_data_read(int Index, char *UserDataName) { int ier=0; cgns_user_data *user_data; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; user_data = cgi_user_data_address(CG_MODE_READ, Index, "dummy", &ier); if (user_data==0) return ier; strcpy(UserDataName, user_data->name); return CG_OK; } /** * \ingroup UserDefinedData * * * \brief Create UserDefinedData_t node * * \param[in] UserDataName Name of the UserDefinedData_t node. * * \return \ier * */ int cg_user_data_write(const char * UserDataName) { cgns_user_data *user_data; int ier=0; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_strlen(UserDataName)) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; user_data = cgi_user_data_address(CG_MODE_WRITE, 0, UserDataName, &ier); if (user_data==0) return ier; memset(user_data, 0, sizeof(cgns_user_data)); strcpy(user_data->name, UserDataName); /* initialize other fields */ user_data->data_class=CGNS_ENUMV( DataClassNull ); user_data->location = CGNS_ENUMV( Vertex ); /* save data in file */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_new_node(posit_id, user_data->name, "UserDefinedData_t", &user_data->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup RotatingCoordinates * * * \brief Read rotating coordinates data * * \param[out] rot_rate Components of the angular velocity of the grid about the center of rotation. * (In Fortran, this is an array of Real*4 values.) * \param[out] rot_center Coordinates of the center of rotation. (In Fortran, this is an array of * Real*4 values.) * * \return \ier * */ int cg_rotating_read(float *rot_rate, float *rot_center) { cgns_rotating *rotating; cgns_base *base; int ier=0, n; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; rotating = cgi_rotating_address(CG_MODE_READ, &ier); if (rotating==0) return ier; if (posit_base) { base = &cg->base[posit_base-1]; } else { cgi_error("Can't find the base"); return CG_ERROR; } for (n=0; nnarrays; n++) { if (strcmp(rotating->array[n].name,"RotationCenter")==0) memcpy(rot_center, rotating->array[n].data, base->phys_dim*sizeof(float)); else if (strcmp(rotating->array[n].name,"RotationRateVector")==0) memcpy(rot_rate, rotating->array[n].data, base->phys_dim*sizeof(float)); } return CG_OK; } /** * \ingroup RotatingCoordinates * * * \brief Create rotating coordinates data * * \param[in] rot_rate Components of the angular velocity of the grid about the center of rotation. * (In Fortran, this is an array of Real*4 values.) * \param[in] rot_center Coordinates of the center of rotation. (In Fortran, this is an array of * Real*4 values.) * * \return \ier * */ int cg_rotating_write(float const *rot_rate, float const *rot_center) { cgns_rotating *rotating; cgns_base *base; int ier=0, n; double posit_id; CHECK_FILE_OPEN /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; rotating=cgi_rotating_address(CG_MODE_WRITE, &ier); if (rotating==0) return ier; if (posit_base) { base = &cg->base[posit_base-1]; } else { cgi_error("Can't find the base"); return CG_ERROR; } rotating->array = CGNS_NEW(cgns_array, 2); rotating->narrays=2; /* Create DataArray_t RotationCenter & RotationRateVector under rotating */ for (n=0; nnarrays; n++) { strcpy(rotating->array[n].data_type, "R4"); rotating->array[n].data = (void *)malloc(base->phys_dim*sizeof(float)); if (rotating->array[n].data == NULL) { cgi_error("Error allocating rotating->array[n].data"); return CG_ERROR; } rotating->array[n].data_dim=1; rotating->array[n].dim_vals[0]=base->phys_dim; } memcpy(rotating->array[0].data, rot_center, base->phys_dim*sizeof(float)); memcpy(rotating->array[1].data, rot_rate, base->phys_dim*sizeof(float)); strcpy(rotating->array[0].name, "RotationCenter"); strcpy(rotating->array[1].name, "RotationRateVector"); /* initialize other fields of rotating->array[n] */ for (n=0; nnarrays; n++) { rotating->array[n].id=0; rotating->array[n].link=0; rotating->array[n].ndescr=0; rotating->array[n].data_class=CGNS_ENUMV( DataClassNull ); rotating->array[n].units=0; rotating->array[n].exponents=0; rotating->array[n].convert=0; } /* initialize other fields of rotating */ strcpy(rotating->name, "RotatingCoordinates"); rotating->id=0; rotating->link=0; rotating->ndescr=0; rotating->data_class=CGNS_ENUMV( DataClassNull ); rotating->units=0; rotating->nuser_data=0; /* Write to disk */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_rotating(posit_id, rotating)) return CG_ERROR; return CG_OK; } /*----------------------------------------------------------------------*/ /** * \ingroup PointSets * * * \brief Get point set information * * \param[out] ptset_type The point set type; either PointRange for a range of points or cells, or * PointList for a list of discrete points or cells. * \param[out] npnts The number of points or cells in the point set. For a point set type of * PointRange, npnts is always two. For a point set type of PointList, npnts is * the number of points or cells in the list. * * \return \ier * */ int cg_ptset_info(CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts) { cgns_ptset *ptset; int ier=0; CHECK_FILE_OPEN if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; ptset = cgi_ptset_address(CG_MODE_READ, &ier); if (ptset == 0) return ier; *ptset_type = ptset->type; *npnts = ptset->npts; return CG_OK; } /** * \ingroup PointSets * * * \brief Read point set data * * \param[out] pnts The array of point or cell indices defining the point set. There should be * npnts values, each of dimension IndexDimension (i.e., 1 for unstructured * grids, and 2 or 3 for structured grids with 2-D or 3-D elements, * respectively). * * \return \ier * */ int cg_ptset_read(cgsize_t *pnts) { cgns_ptset *ptset; cgsize_t size; int ier=0; CHECK_FILE_OPEN if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; ptset = cgi_ptset_address(CG_MODE_READ, &ier); if (ptset == 0) return ier; if (ptset->npts <= 0) return CG_OK; size = ptset->size_of_patch; if (posit_base && posit_zone) { size *= cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can not properly resolve IndexDimension unless under a Zone_t node."); return CG_NO_INDEX_DIM; } if (cgi_read_int_data(ptset->id, ptset->data_type, size, pnts)) return CG_ERROR; return CG_OK; } /** * \ingroup PointSets * * * \brief Write point set data * * \param[in] ptset_type The point set type; either PointRange for a range of points or cells, or * PointList for a list of discrete points or cells. * \param[in] npnts The number of points or cells in the point set. For a point set type of * PointRange, npnts is always two. For a point set type of PointList, npnts is * the number of points or cells in the list. * \param[in] pnts The array of point or cell indices defining the point set. There should be * npnts values, each of dimension IndexDimension (i.e., 1 for unstructured * grids, and 2 or 3 for structured grids with 2-D or 3-D elements, * respectively). * * \return \ier * */ int cg_ptset_write(CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts) { cgns_ptset *ptset = 0; int i, index_dim; int ier=0; CHECK_FILE_OPEN /* verify input */ if(npnts == 0 || pnts == NULL) { cgi_error("Invalid input: npoint=%ld, point set type=%s", npnts, PointSetTypeName[ptset_type]); return CG_ERROR; } if (ptset_type == CGNS_ENUMV(PointList)) { if (npnts <= 0) { cgi_error("Invalid input: npoint=%ld, point set type=%s", npnts, PointSetTypeName[ptset_type]); return CG_ERROR; } } else if (ptset_type == CGNS_ENUMV(PointRange)) { if (npnts != 2) { cgi_error("Invalid input: npoint=%ld, point set type=%s", npnts, PointSetTypeName[ptset_type]); return CG_ERROR; } } else { cgi_error("Invalid point set type: %d...?",ptset_type); return CG_ERROR; } if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can not properly resolve IndexDimension unless under a Zone_t node."); return CG_NO_INDEX_DIM; } /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; ptset = cgi_ptset_address(CG_MODE_WRITE, &ier); if (ptset==0) return ier; /* set these with the provided argument data */ ptset->type = ptset_type; ptset->npts = npnts; if (ptset_type == CGNS_ENUMV(PointList)) { ptset->size_of_patch = npnts; } else { ptset->size_of_patch = 1; for (i=0; i < index_dim; i++) ptset->size_of_patch = ptset->size_of_patch * (pnts[i+index_dim] - pnts[i]+1); } /* initialize the following to default values */ ptset->id = 0; ptset->link = 0; strcpy(ptset->name, PointSetTypeName[ptset->type]); strcpy(ptset->data_type,CG_SIZE_DATATYPE); /* Save Point-Set on Disk */ if (ptset->npts > 0) { double posit_id; /* write to disk */ if (cgi_posit_id(&posit_id)) return CG_ERROR; if (cgi_write_ptset(posit_id, ptset->name, ptset, index_dim, (void *)pnts)) return CG_ERROR; } return CG_OK; } /*****************************************************************************\ * Read and write FamilyBCDataSet_t nodes \*****************************************************************************/ /** * \ingroup BoundaryConditionDatasets * * * \brief Get the number of family boundary condition datasets * * \param[out] n_dataset Number of BCDataSet nodes under the current FamilyBC_t node. * \return \ier * * \details The above functions apply to BCDataSet_t nodes that are used to * define boundary conditions for a CFD family and thus are children of a * FamilyBC_t node. The FamilyBC_t node must first be accessed using cg_goto(). */ int cg_bcdataset_info(int *n_dataset) { CHECK_FILE_OPEN /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); (*n_dataset) = 0; return CG_ERROR; } if(strcmp(posit->label,"FamilyBC_t") ==0) { cgns_fambc *fambc = (cgns_fambc *)posit->posit; *n_dataset = fambc->ndataset; } else { *n_dataset = 0; cgi_error("FamilyBC_t node not supported under '%s' type node", posit->label); return CG_INCORRECT_PATH; } return CG_OK; } /** * \ingroup BoundaryConditionDatasets * * * \brief Read family boundary condition dataset info * * \param[in] index Dataset index number, where 1 ≤ index ≤ ndataset. * \param[out] name Name of dataset. * \param[out] BCType Simple boundary condition type for the dataset. The supported types are * listed in the table of Simple Boundary Condition Types in the SIDS manual, * but note that FamilySpecified does not apply here. * \param[out] DirichletFlag Flag indicating if the dataset contains Dirichlet data. * \param[out] NeumannFlag Flag indicating if the dataset contains Neumann data. * \return \ier * * \details The above functions apply to BCDataSet_t nodes that define boundary * conditions for a CFD family and thus are children of a FamilyBC_t node. The FamilyBC_t * node must first be accessed using cg_goto(). */ int cg_bcdataset_read(int index, char *name, CGNS_ENUMT(BCType_t) *BCType, int *DirichletFlag, int *NeumannFlag) { cgns_dataset *dataset; int ier = 0; CHECK_FILE_OPEN if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; dataset = cgi_bcdataset_address(CG_MODE_READ, index, NULL, &ier); if (dataset==0) return CG_ERROR; strcpy(name, dataset->name); *BCType = dataset->type; if (dataset->dirichlet) *DirichletFlag=1; else *DirichletFlag=0; if (dataset->neumann) *NeumannFlag=1; else *NeumannFlag=0; return CG_OK; } /** * \ingroup BoundaryConditionDatasets * * * \brief Write family boundary condition dataset info * * \param[in] name Name of dataset. * \param[in] BCType Simple boundary condition type for the dataset. The supported types are * listed in the table of Simple Boundary Condition Types in the SIDS manual, * but note that FamilySpecified does not apply here. * \param[in] BCDataType Type of boundary condition in the dataset (i.e., for a BCData_t child node). * Admissible types are Dirichlet and Neumann. * \return \ier * * \details The above functions apply to BCDataSet_t nodes that define * boundary conditions for a CFD family, and thus are children of a FamilyBC_t node. * The FamilyBC_t node must first be accessed using cg_goto(). The first time cg_bcdataset_write() * is called with a particular DatasetName, BCType, and BCDataType, a new BCDataSet_t node is * created, with a child BCData_t node. Subsequent calls with the same DatasetName and BCType * may be made to add additional BCData_t nodes, of type BCDataType, to the existing BCDataSet_t node. */ int cg_bcdataset_write(const char *name, CGNS_ENUMT(BCType_t) BCType, CGNS_ENUMT(BCDataType_t) BCDataType) { cgns_fambc *fambc; cgns_dataset *dataset = NULL; cgns_bcdata *bcdata = NULL; cgsize_t length; int index, ierr=0; double posit_id; CHECK_FILE_OPEN if (posit == 0) { cgi_error("No current position set by cg_goto\n"); return CG_ERROR; } if (strcmp(posit->label, "FamilyBC_t")) { cgi_error("FamilyBCDataSet_t node not supported under '%s' type node", posit->label); return CG_INCORRECT_PATH; } /* verify input */ if (INVALID_ENUM(BCType,NofValidBCTypes)) { cgi_error("Invalid BCType: %d",BCType); return CG_ERROR; } if (INVALID_ENUM(BCDataType,NofValidBCDataTypes)) { cgi_error("BCDataType %d not valid",BCDataType); return CG_ERROR; } if (cgi_check_strlen(name)) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; fambc = (cgns_fambc *)posit->posit; for (index = 0; index < fambc->ndataset; index++) { if (0 == strcmp(name, fambc->dataset[index].name)) { dataset = &fambc->dataset[index]; break; } } if (dataset != NULL) { /* Overwrite a BCDataSet_t node : */ if (dataset->dirichlet && BCDataType == CGNS_ENUMV(Dirichlet)) { if (cg->mode == CG_MODE_WRITE) { cgi_error("Dirichlet data already defined under FamilyBCDataSet_t '%s'", dataset->name); return CG_ERROR; } if (cgi_delete_node(dataset->id, dataset->dirichlet->id)) return CG_ERROR; cgi_free_bcdata(dataset->dirichlet); dataset->dirichlet = NULL; } else if (dataset->neumann && BCDataType == CGNS_ENUMV(Neumann)) { if (cg->mode == CG_MODE_WRITE) { cgi_error("Neumann data already defined under FamilyBCDataSet_t '%s'", dataset->name); return CG_ERROR; } if (cgi_delete_node(dataset->id, dataset->neumann->id)) return CG_ERROR; cgi_free_bcdata(dataset->neumann); dataset->neumann = NULL; } } else { /* get memory address for FamilyBCDataSet_t node */ dataset = cgi_bcdataset_address(CG_MODE_WRITE, 0, name, &ierr); if (dataset == 0) return ierr; /* save data in memory */ memset(dataset, 0, sizeof(cgns_dataset)); dataset->type = BCType; strcpy(dataset->name, name); /* write to disk */ if (cgi_posit_id(&posit_id)) return CG_ERROR; /* save data in file */ length = (cgsize_t)strlen(BCTypeName[dataset->type]); if (cg->filetype == CG_FILE_ADF2) { if (cgi_new_node(posit_id, dataset->name, "BCDataSet_t", &dataset->id, "C1", 1, &length, (void *)BCTypeName[dataset->type])) return CG_ERROR; } else { if (cgi_new_node(posit_id, dataset->name, "FamilyBCDataSet_t", &dataset->id, "C1", 1, &length, (void *)BCTypeName[dataset->type])) return CG_ERROR; } } if (BCDataType == CGNS_ENUMV(Dirichlet)) { if ( !dataset->dirichlet) dataset->dirichlet = CGNS_NEW(cgns_bcdata,1); strcpy(dataset->dirichlet->name, "DirichletData"); bcdata = dataset->dirichlet; } else if(BCDataType == CGNS_ENUMV(Neumann)){ if ( !dataset->neumann) dataset->neumann = CGNS_NEW(cgns_bcdata,1); strcpy(dataset->neumann->name, "NeumannData"); bcdata = dataset->neumann; } else { cgi_error("BCDataType is not Dirichlet or Neumann"); return CG_ERROR; } if (cgi_new_node(dataset->id, bcdata->name, "BCData_t", &bcdata->id, "MT", 0, 0, 0)) return CG_ERROR; return CG_OK; } /****************************************************************************/ /** * \ingroup ElementConnectivity * * * \brief Get the number of nodes for an element type. * * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs * section. * \param[out] npe Number of nodes for an element of type type. * \return \ier * */ int cg_npe(CGNS_ENUMT( ElementType_t ) type, int *npe) { /* the index in this list IS the cgnslib.h ElementType_t index */ static int el_size[NofValidElementTypes] = { 0, /* ElementTypeNull */ 0, /* ElementTypeUserDefined */ #ifdef CGNS_SCOPE_ENUMS CG_NPE_NODE, /* NODE */ CG_NPE_BAR_2, /* BAR_2 */ CG_NPE_BAR_3, /* BAR_3 */ CG_NPE_TRI_3, /* TRI_3 */ CG_NPE_TRI_6, /* TRI_6 */ CG_NPE_QUAD_4, /* QUAD_4 */ CG_NPE_QUAD_8, /* QUAD_8 */ CG_NPE_QUAD_9, /* QUAD_9 */ CG_NPE_TETRA_4, /* TETRA_4 */ CG_NPE_TETRA_10, /* TETRA_10 */ CG_NPE_PYRA_5, /* PYRA_5 */ CG_NPE_PYRA_14, /* PYRA_14 */ CG_NPE_PENTA_6, /* PENTA_6 */ CG_NPE_PENTA_15, /* PENTA_15 */ CG_NPE_PENTA_18, /* PENTA_18 */ CG_NPE_HEXA_8, /* HEXA_8 */ CG_NPE_HEXA_20, /* HEXA_20 */ CG_NPE_HEXA_27, /* HEXA_27 */ CG_NPE_MIXED, /* MIXED */ CG_NPE_PYRA_13, /* PYRA_13 */ CG_NPE_NGON_n, /* NGON_n */ CG_NPE_NFACE_n, /* NFACE_n */ CG_NPE_BAR_4, CG_NPE_TRI_9, CG_NPE_TRI_10, CG_NPE_QUAD_12, CG_NPE_QUAD_16, CG_NPE_TETRA_16, CG_NPE_TETRA_20, CG_NPE_PYRA_21, CG_NPE_PYRA_29, CG_NPE_PYRA_30, CG_NPE_PENTA_24, CG_NPE_PENTA_38, CG_NPE_PENTA_40, CG_NPE_HEXA_32, CG_NPE_HEXA_56, CG_NPE_HEXA_64, CG_NPE_BAR_5, CG_NPE_TRI_12, CG_NPE_TRI_15, CG_NPE_QUAD_P4_16, CG_NPE_QUAD_25, CG_NPE_TETRA_22, CG_NPE_TETRA_34, CG_NPE_TETRA_35, CG_NPE_PYRA_P4_29, CG_NPE_PYRA_50, CG_NPE_PYRA_55, CG_NPE_PENTA_33, CG_NPE_PENTA_66, CG_NPE_PENTA_75, CG_NPE_HEXA_44, CG_NPE_HEXA_98, CG_NPE_HEXA_125 #else NPE_NODE, /* NODE */ NPE_BAR_2, /* BAR_2 */ NPE_BAR_3, /* BAR_3 */ NPE_TRI_3, /* TRI_3 */ NPE_TRI_6, /* TRI_6 */ NPE_QUAD_4, /* QUAD_4 */ NPE_QUAD_8, /* QUAD_8 */ NPE_QUAD_9, /* QUAD_9 */ NPE_TETRA_4, /* TETRA_4 */ NPE_TETRA_10, /* TETRA_10 */ NPE_PYRA_5, /* PYRA_5 */ NPE_PYRA_14, /* PYRA_14 */ NPE_PENTA_6, /* PENTA_6 */ NPE_PENTA_15, /* PENTA_15 */ NPE_PENTA_18, /* PENTA_18 */ NPE_HEXA_8, /* HEXA_8 */ NPE_HEXA_20, /* HEXA_20 */ NPE_HEXA_27, /* HEXA_27 */ NPE_MIXED, /* MIXED */ NPE_PYRA_13, /* PYRA_13 */ NPE_NGON_n, /* NGON_n */ NPE_NFACE_n, /* NFACE_n */ NPE_BAR_4, NPE_TRI_9, NPE_TRI_10, NPE_QUAD_12, NPE_QUAD_16, NPE_TETRA_16, NPE_TETRA_20, NPE_PYRA_21, NPE_PYRA_29, NPE_PYRA_30, NPE_PENTA_24, NPE_PENTA_38, NPE_PENTA_40, NPE_HEXA_32, NPE_HEXA_56, NPE_HEXA_64, NPE_BAR_5, NPE_TRI_12, NPE_TRI_15, NPE_QUAD_P4_16, NPE_QUAD_25, NPE_TETRA_22, NPE_TETRA_34, NPE_TETRA_35, NPE_PYRA_P4_29, NPE_PYRA_50, NPE_PYRA_55, NPE_PENTA_33, NPE_PENTA_66, NPE_PENTA_75, NPE_HEXA_44, NPE_HEXA_98, NPE_HEXA_125 #endif }; if (INVALID_ENUM(type,NofValidElementTypes)) { *npe = -1; cgi_error("Invalid element type"); return CG_ERROR; } (*npe) = el_size[type]; return CG_OK; } /*****************************************************************************\ * General Delete Function \*****************************************************************************/ /** * \ingroup DeletingANode * * \brief Delete a node * * \param[in] node_name Name of the child to be deleted. * \return \ier * * \details The function cg_delete_node() is used is conjunction with cg_goto(). Once * positioned at a parent node with cg_goto(), a child of this node can be * deleted with cg_delete_node(). This function requires a single argument, * \e NodeName, which is the name of the child to be deleted. * * Since the highest level that can be pointed to with cg_goto() is a base node * for a CGNS database (CGNSBase_t), the highest-level nodes that can be deleted * are the children of a CGNSBase_t node. In other words, nodes located directly * under the ADF (or HDF) root node (CGNSBase_t and CGNSLibraryVersion_t) can not * be deleted with cg_delete(). * * A few other nodes are not allowed to be deleted from the database because these * are required nodes as defined by the SIDS, and deleting them would make the file * non-CGNS compliant. These are: * * - Under Zone_t: ZoneType * - Under GridConnectivity1to1_t: PointRange, PointRangeDonor, Transform * - Under OversetHoles_t: PointList and any IndexRange_t * - Under GridConnectivity_t: PointRange, PointList, CellListDonor, PointListDonor * - Under BC_t: PointList, PointRange * - Under GeometryReference_t: GeometryFile, GeometryFormat * - Under Elements_t: ElementRange, ElementConnectivity * - Under Gravity_t: GravityVector * - Under Axisymmetry_t: AxisymmetryReferencePoint, AxisymmetryAxisVector * - Under RotatingCoordinates_t: RotationCenter, RotationRateVector * - Under Periodic_t: RotationCenter, RotationAngle, Translation * - Under AverageInterface_t: AverageInterfaceType * - Under WallFunction_t: WallFunctionType * - Under Area_t: AreaType, SurfaceArea, RegionName * * When a child node is deleted, both the database and the file on disk are updated to remove * the node. One must be careful not to delete a node from within a loop of that node type. * For example, if the number of zones below a CGNSBase_t node is nzones, a zone should never * be deleted from within a zone loop! By deleting a zone, the total number of zones (nzones) * changes, as well as the zone indexing. Suppose for example that nzones is 5, and that the * third zone is deleted. After calling cg_delete_node(), nzones is changed to 4, and the zones * originally indexed 4 and 5 are now indexed 3 and 4. * */ int cg_delete_node(const char *node_name) { int n, m, index_dim; double posit_id, node_id; char_33 node_label; CHECK_FILE_OPEN /* verify input */ if (cg->mode != CG_MODE_MODIFY) { cgi_error("File %s must be opened in mode modify to delete a node", cg->filename); return CG_ERROR; } /* ADF ID of parent = posit_id */ if (cgi_posit_id(&posit_id)) return CG_ERROR; /* ADF ID of node */ if (cgio_get_node_id(cg->cgio, posit_id, node_name, &node_id)) { cg_io_error("cgio_get_node_id"); return CG_ERROR; } /* Get label of node to be deleted */ if (cgio_get_label(cg->cgio, node_id, node_label)) { cg_io_error("cgio_get_label"); return CG_ERROR; } /* Nodes that can't be deleted */ if ( (strcmp(posit->label,"Zone_t")==0 && strcmp(node_label,"ZoneType_t")==0 ) || (strcmp(posit->label,"ZoneSubRegion_t")==0 && (strcmp(node_name,"BCRegionName")==0 || strcmp(node_name,"GridConnectivityRegionName")==0 || strcmp(node_name,"PointList")==0 || strcmp(node_name,"PointRange")==0) ) || (strcmp(posit->label,"GridConnectivity1to1_t")==0 && (strcmp(node_name,"PointRange")==0 || strcmp(node_name,"PointRangeDonor")==0) ) || (strcmp(posit->label,"OversetHoles_t")==0 && (strcmp(node_label,"IndexRange_t")==0 || strcmp(node_name,"PointList")==0) ) || (strcmp(posit->label,"GridConnectivity_t")==0 && (strcmp(node_name,"PointRange")==0 || strcmp(node_name,"PointList")==0 || strcmp(node_name,"CellListDonor")==0 || strcmp(node_name,"PointListDonor")==0 || strcmp(node_name,"InterpolantsDonor")==0) ) || (strcmp(posit->label,"BC_t")==0 && (strcmp(node_name,"PointList")==0 || strcmp(node_name,"PointRange")==0 || strcmp(node_name,"ElementList")==0 || strcmp(node_name,"ElementRange")==0) ) || (strcmp(posit->label,"GeometryReference_t")==0 && (strcmp(node_name,"GeometryFile")==0 || strcmp(node_name,"GeometryFormat")==0) ) || (strcmp(posit->label,"Elements_t")==0 && (strcmp(node_name,"ElementRange")==0 || strcmp(node_name,"ElementConnectivity")==0) ) || (strcmp(posit->label,"Gravity_t")==0 && strcmp(node_name,"GravityVector")==0) || (strcmp(posit->label,"Axisymmetry_t")==0 && (strcmp(node_name,"AxisymmetryReferencePoint")==0 || strcmp(node_name,"AxisymmetryAxisVector")==0) ) || (strcmp(posit->label,"RotatingCoordinates_t")==0 && (strcmp(node_name,"RotationCenter")==0 || strcmp(node_name,"RotationRateVector")==0) ) || (strcmp(posit->label,"WallFunction_t")==0 && strcmp(node_label,"WallFunctionType_t")==0) || (strcmp(posit->label,"Area_t")==0 && (strcmp(node_label,"AreaType_t")==0 || strcmp(node_label,"DataArray_t")==0) ) || (strcmp(posit->label,"Periodic_t")==0 && strcmp(node_label,"DataArray_t")==0) || (strcmp(posit->label,"AverageInterface_t")==0 && strcmp(node_label,"AverageInterfaceType_t")==0) ) { cgi_error("Node '%s' under '%s' can not be deleted",node_name,posit->label); return CG_ERROR; } /* Delete node_id under posit_id */ if (cgi_delete_node(posit_id, node_id)) { /*printf("posit->label=%s, node_name=%s\n",posit->label,node_name);*/ return CG_ERROR; } /* Remove from internal database */ /* Children of CGNSBase_t */ if (strcmp(posit->label,"CGNSBase_t")==0) { cgns_base *parent = (cgns_base *)posit->posit; /* Case 1: node_label = can have multiple occurrence: */ if (strcmp(node_label, "Zone_t") == 0) { CGNS_DELETE_SHIFT(nzones, zone, cgi_free_zone) if (parent->zonemap) { /* It is costly since indexing is recomputed */ if (cgi_map_contains(parent->zonemap, node_name) == 1) { cgi_map_del_shift_item(parent->zonemap, node_name); } } } else if (strcmp(node_label, "ParticleZone_t") == 0) { CGNS_DELETE_SHIFT(npzones, pzone, cgi_free_particle) if (parent->pzonemap) { /* It is costly since indexing is recomputed */ if (cgi_map_contains(parent->pzonemap, node_name) == 1) { cgi_map_del_shift_item(parent->pzonemap, node_name); } } } else if (strcmp(node_label,"Family_t")==0) CGNS_DELETE_SHIFT(nfamilies, family, cgi_free_family) else if (strcmp(node_label,"IntegralData_t")==0) CGNS_DELETE_SHIFT(nintegrals, integral, cgi_free_integral) else if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) /* Case 2: node_label = can only occur once under parent: */ else if (strcmp(node_name,"SimulationType")==0) { parent->type = CGNS_ENUMV( SimulationTypeNull ); parent->type_id = 0; } else if (strcmp(node_label,"BaseIterativeData_t")==0) CGNS_DELETE_CHILD(biter, cgi_free_biter) else if (strcmp(node_name,"GlobalConvergenceHistory")==0) CGNS_DELETE_CHILD(converg, cgi_free_converg) else if (strcmp(node_name,"FlowEquationSet")==0) CGNS_DELETE_CHILD(equations, cgi_free_equations) else if (strcmp(node_name,"ParticleEquationSet")==0) CGNS_DELETE_CHILD(pequations, cgi_free_particle_equations) else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"ReferenceState")==0) CGNS_DELETE_CHILD(state, cgi_free_state) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"Gravity")==0) CGNS_DELETE_CHILD(gravity, cgi_free_gravity) else if (strcmp(node_name,"Axisymmetry")==0) CGNS_DELETE_CHILD(axisym, cgi_free_axisym) else if (strcmp(node_name,"RotatingCoordinates")==0) CGNS_DELETE_CHILD(rotating, cgi_free_rotating) /* Children of Zone_t */ } else if (strcmp(posit->label,"Zone_t")==0) { cgns_zone *parent = (cgns_zone *)posit->posit; if (strcmp(node_label,"GridCoordinates_t")==0) CGNS_DELETE_SHIFT(nzcoor, zcoor, cgi_free_zcoor) else if (strcmp(node_label,"DiscreteData_t")==0) CGNS_DELETE_SHIFT(ndiscrete, discrete, cgi_free_discrete) else if (strcmp(node_label,"Elements_t")==0) CGNS_DELETE_SHIFT(nsections, section, cgi_free_section) else if (strcmp(node_label,"FlowSolution_t")==0) CGNS_DELETE_SHIFT(nsols, sol, cgi_free_sol) else if (strcmp(node_label,"RigidGridMotion_t")==0) CGNS_DELETE_SHIFT(nrmotions, rmotion, cgi_free_rmotion) else if (strcmp(node_label,"ArbitraryGridMotion_t")==0) CGNS_DELETE_SHIFT(namotions, amotion, cgi_free_amotion) else if (strcmp(node_label,"IntegralData_t")==0) CGNS_DELETE_SHIFT(nintegrals, integral, cgi_free_integral) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"AdditionalFamilyName_t")==0) CGNS_DELETE_SHIFT(nfamname, famname, cgi_free_famname) else if (strcmp(node_label,"ZoneGridConnectivity_t")==0) CGNS_DELETE_SHIFT(nzconn, zconn, cgi_free_zconn) else if (strcmp(node_label,"ZoneSubRegion_t")==0) CGNS_DELETE_SHIFT(nsubreg, subreg, cgi_free_subreg) else if (strcmp(node_name,"ZoneBC")==0) CGNS_DELETE_CHILD(zboco, cgi_free_zboco) else if (strcmp(node_name,"Ordinal")==0) parent->ordinal=0; else if (strcmp(node_label,"ZoneIterativeData_t")==0) CGNS_DELETE_CHILD(ziter, cgi_free_ziter) else if (strcmp(node_name,"ReferenceState")==0) CGNS_DELETE_CHILD(state, cgi_free_state) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"FamilyName")==0) parent->family_name[0]='\0'; else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"FlowEquationSet")==0) CGNS_DELETE_CHILD(equations, cgi_free_equations) else if (strcmp(node_name,"ZoneConvergenceHistory")==0) CGNS_DELETE_CHILD(converg, cgi_free_converg) else if (strcmp(node_name,"RotatingCoordinates")==0) CGNS_DELETE_CHILD(rotating, cgi_free_rotating) /* ZoneType can not be deleted */ } else if(strcmp(posit->label,"ParticleZone_t")==0){ cgns_pzone *parent = (cgns_pzone *)posit->posit; if (strcmp(node_label,"ParticleCoordinates_t")==0) CGNS_DELETE_SHIFT(npcoor, pcoor, cgi_free_pcoor) else if (strcmp(node_label,"ParticleSolution_t")==0) CGNS_DELETE_SHIFT(nsols, sol, cgi_free_psol) else if (strcmp(node_label,"IntegralData_t")==0) CGNS_DELETE_SHIFT(nintegrals, integral, cgi_free_integral) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"AdditionalFamilyName_t")==0) CGNS_DELETE_SHIFT(nfamname, famname, cgi_free_famname) else if (strcmp(node_label,"ParticleIterativeData_t")==0) CGNS_DELETE_CHILD(piter, cgi_free_ziter) else if (strcmp(node_name,"ReferenceState")==0) CGNS_DELETE_CHILD(state, cgi_free_state) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"FamilyName")==0) parent->family_name[0]='\0'; else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"ParticleEquationSet")==0) CGNS_DELETE_CHILD(equations, cgi_free_particle_equations) /* Children of ZoneSubRegion_t */ } else if (strcmp(posit->label,"ZoneSubRegion_t")==0) { cgns_subreg *parent = (cgns_subreg *)posit->posit; if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_label,"AdditionalFamilyName_t")==0) CGNS_DELETE_SHIFT(nfamname, famname, cgi_free_famname) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"FamilyName")==0) parent->family_name[0]='\0'; else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"GridLocation")==0) parent->location=CGNS_ENUMV( GridLocationNull ); else if (strcmp(node_name,"Rind")==0) { if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can't find IndexDimension in cg_delete"); return CG_NO_INDEX_DIM; } for (n=0; n<2*index_dim; n++) parent->rind_planes[n] = 0; } /* Children of GridCoordinates_t */ } else if (strcmp(posit->label,"GridCoordinates_t")==0) { cgns_zcoor *parent = (cgns_zcoor *)posit->posit; if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(ncoords, coord, cgi_free_array) else if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"Rind")==0) { if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can't find IndexDimension in cg_delete"); return CG_NO_INDEX_DIM; } for (n=0; n<2*index_dim; n++) parent->rind_planes[n] = 0; } else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of ParticleCoordinates_t */ } else if (strcmp(posit->label,"ParticleCoordinates_t")==0) { cgns_pcoor *parent = (cgns_pcoor *)posit->posit; if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(ncoords, coord, cgi_free_array) else if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of DataArray_t */ } else if (strcmp(posit->label,"DataArray_t")==0) { cgns_array *parent = (cgns_array *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalExponents")==0) CGNS_DELETE_CHILD(exponents, cgi_free_exponents) else if (strcmp(node_name,"DataConversion")==0) CGNS_DELETE_CHILD(convert, cgi_free_convert) else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of FlowSolution_t */ } else if (strcmp(posit->label,"FlowSolution_t")==0) { cgns_sol *parent = (cgns_sol *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(nfields, field, cgi_free_array) else if (strcmp(node_name,"PointList")==0 || strcmp(node_name,"PointRange")==0) CGNS_DELETE_CHILD(ptset, cgi_free_ptset) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"GridLocation")==0) parent->location=CGNS_ENUMV( GridLocationNull ); else if (strcmp(node_name,"Rind")==0) { if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can't find IndexDimension in cg_delete"); return CG_NO_INDEX_DIM; } for (n=0; n<2*index_dim; n++) parent->rind_planes[n] = 0; } /* Children of ParticleSolution_t */ } else if (strcmp(posit->label,"ParticleSolution_t")==0) { cgns_psol *parent = (cgns_psol *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(nfields, field, cgi_free_array) else if (strcmp(node_name,"PointList")==0 || strcmp(node_name,"PointRange")==0) CGNS_DELETE_CHILD(ptset, cgi_free_ptset) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of ZoneGridConnectivity_t */ } else if (strcmp(posit->label,"ZoneGridConnectivity_t")==0) { cgns_zconn *parent = (cgns_zconn *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"GridConnectivity1to1_t")==0) CGNS_DELETE_SHIFT(n1to1, one21, cgi_free_1to1) else if (strcmp(node_label,"GridConnectivity_t")==0) CGNS_DELETE_SHIFT(nconns, conn, cgi_free_conn) else if (strcmp(node_label,"OversetHoles_t")==0) CGNS_DELETE_SHIFT(nholes, hole, cgi_free_hole) /* Children of OversetHoles_t */ } else if (strcmp(posit->label,"OversetHoles_t")==0) { cgns_hole *parent = (cgns_hole *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"GridLocation")==0) parent->location=CGNS_ENUMV( GridLocationNull ); /* IndexRange_t & IndexArray_t can't be deleted */ /* Children of GridConnectivity_t */ } else if (strcmp(posit->label,"GridConnectivity_t")==0) { cgns_conn *parent = (cgns_conn *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"InterpolantsDonor")==0) { if (parent->dptset.type==CGNS_ENUMV( CellListDonor )) { cgi_error("Node '%s' under '%s' can not be deleted", node_name,posit->label); return CG_ERROR; } else { CGNS_DELETE_SHIFT(narrays, interpolants, cgi_free_array) } } else if (strcmp(node_name,"GridLocation")==0) parent->location=CGNS_ENUMV( GridLocationNull ); else if (strcmp(node_name,"Ordinal")==0) parent->ordinal=0; else if (strcmp(node_name,"GridConnectivityType")==0) parent->type=CGNS_ENUMV( GridConnectivityTypeNull ); else if (strcmp(node_name,"GridConnectivityProperty")==0) CGNS_DELETE_CHILD(cprop, cgi_free_cprop) /* IndexArray_t & IndexRange_t can't be deleted */ /* Children of GridConnectivity1to1_t */ } else if (strcmp(posit->label,"GridConnectivity1to1_t")==0) { cgns_1to1 *parent = (cgns_1to1 *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"Ordinal")==0) parent->ordinal=0; else if (strcmp(node_name,"GridConnectivityProperty")==0) CGNS_DELETE_CHILD(cprop, cgi_free_cprop) /* PointRange, PointRangeDonor, Transform can't be deleted */ /* Children of ZoneBC_t */ } else if (strcmp(posit->label,"ZoneBC_t")==0) { cgns_zboco *parent = (cgns_zboco *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"BC_t")==0) CGNS_DELETE_SHIFT(nbocos, boco, cgi_free_boco) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"ReferenceState")==0) CGNS_DELETE_CHILD(state, cgi_free_state) /* Children of BC_t */ } else if (strcmp(posit->label,"BC_t")==0) { cgns_boco *parent = (cgns_boco *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"AdditionalFamilyName_t")==0) CGNS_DELETE_SHIFT(nfamname, famname, cgi_free_famname) else if (strcmp(node_label,"BCDataSet_t")==0) { #if 0 CGNS_DELETE_SHIFT(ndataset, dataset, cgi_free_dataset) #else for (n = 0; n < parent->ndataset && strcmp(parent->dataset[n].name, node_name); n++); if (n == parent->ndataset) { cgi_error("Error in cg_delete: Can't find node '%s'",node_name); return CG_ERROR; } if (parent->dataset[n].ptset == parent->ptset) parent->dataset[n].ptset = 0; cgi_free_dataset(&parent->dataset[n]); for (m = n+1; m < parent->ndataset; m++) parent->dataset[m-1] = parent->dataset[m]; if (--parent->ndataset == 0) { free(parent->dataset); parent->dataset = 0; } #endif } else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"GridLocation")==0) parent->location=CGNS_ENUMV( GridLocationNull ); else if (strcmp(node_name,"InwardNormalIndex")==0) { if (parent->Nindex) free(parent->Nindex); parent->Nindex=0; } else if (strcmp(node_name,"InwardNormalList")==0) CGNS_DELETE_CHILD(normal, cgi_free_array) else if (strcmp(node_name,"ReferenceState")==0) CGNS_DELETE_CHILD(state, cgi_free_state) else if (strcmp(node_name,"FamilyName")==0) parent->family_name[0]='\0'; else if (strcmp(node_name,"Ordinal")==0) parent->ordinal=0; else if (strcmp(node_name,"BCProperty")==0) CGNS_DELETE_CHILD(bprop, cgi_free_bprop) /* IndexRange_t PointRange & IndexArray_t PointList can't be deleted */ /* Children of BCDataSet_t or FamilyBCDataSet_t */ } else if (strcmp(posit->label,"BCDataSet_t")==0 || strcmp(posit->label,"FamilyBCDataSet_t")==0) { cgns_dataset *parent = (cgns_dataset *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"PointList")==0 || strcmp(node_name,"PointRange")==0) CGNS_DELETE_CHILD(ptset, cgi_free_ptset) else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"DirichletData")==0) CGNS_DELETE_CHILD(dirichlet, cgi_free_bcdata) else if (strcmp(node_name,"NeumannData")==0) CGNS_DELETE_CHILD(neumann, cgi_free_bcdata) else if (strcmp(node_name,"ReferenceState")==0) CGNS_DELETE_CHILD(state, cgi_free_state) else if (strcmp(node_name,"GridLocation")==0) parent->location=CGNS_ENUMV( GridLocationNull ); /* IndexRange_t PointRange & IndexArray_t PointList can't be deleted */ /* Children of BCData_t */ } else if (strcmp(posit->label,"BCData_t")==0) { cgns_bcdata *parent = (cgns_bcdata *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of DiscreteData_t */ } else if (strcmp(posit->label,"DiscreteData_t")==0) { cgns_discrete *parent = (cgns_discrete *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"PointList")==0 || strcmp(node_name,"PointRange")==0) CGNS_DELETE_CHILD(ptset, cgi_free_ptset) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"GridLocation")==0) parent->location=CGNS_ENUMV( GridLocationNull ); else if (strcmp(node_name,"Rind")==0) { if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can't find IndexDimension in cg_delete"); return CG_NO_INDEX_DIM; } for (n=0; n<2*index_dim; n++) parent->rind_planes[n] = 0; } /* Children of FlowEquationSet_t */ } else if (strcmp(posit->label,"FlowEquationSet_t")==0) { cgns_equations *parent = (cgns_equations *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"GoverningEquations")==0) CGNS_DELETE_CHILD(governing, cgi_free_governing) else if (strcmp(node_name,"GasModel")==0) CGNS_DELETE_CHILD(gas, cgi_free_model) else if (strcmp(node_name,"ViscosityModel")==0) CGNS_DELETE_CHILD(visc, cgi_free_model) else if (strcmp(node_name,"ThermalRelaxationModel")==0) CGNS_DELETE_CHILD(relaxation, cgi_free_model) else if (strcmp(node_name,"ThermalConductivityModel")==0) CGNS_DELETE_CHILD(conduct, cgi_free_model) else if (strcmp(node_name,"ChemicalKineticsModel")==0) CGNS_DELETE_CHILD(chemkin, cgi_free_model) else if (strcmp(node_name,"EMElectricFieldModel")==0) CGNS_DELETE_CHILD(elecfield, cgi_free_model) else if (strcmp(node_name,"EMMagneticFieldModel")==0) CGNS_DELETE_CHILD(magnfield, cgi_free_model) else if (strcmp(node_name,"EMConductivityModel")==0) CGNS_DELETE_CHILD(emconduct, cgi_free_model) else if (strcmp(node_name,"TurbulenceModel")==0) { if (parent->turbulence) { if (parent->turbulence->diffusion_model) free(parent->turbulence->diffusion_model); cgi_free_model(parent->turbulence); free(parent->turbulence); } parent->turbulence=0; } else if (strcmp(node_name,"TurbulenceClosure")==0) CGNS_DELETE_CHILD(closure, cgi_free_model) else if (strcmp(node_name,"EquationDimension")==0) parent->equation_dim=0; /* Children of GoverningEquations_t */ } else if (strcmp(posit->label,"GoverningEquations_t")==0) { cgns_governing *parent = (cgns_governing *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"DiffusionModel")==0) { if (parent->diffusion_model) free(parent->diffusion_model); parent->diffusion_model=0; } /* Children of xxxModel_t */ } else if (strcmp(posit->label,"GasModel_t")==0 || strcmp(posit->label,"ViscosityModel_t")==0 || strcmp(posit->label,"ThermalConductivityModel_t")==0 || strcmp(posit->label,"TurbulenceModel_t")==0 || strcmp(posit->label,"TurbulenceClosure_t")==0 || strcmp(posit->label,"ThermalRelaxationModel_t")==0 || strcmp(posit->label,"ChemicalKineticsModel_t")==0 || strcmp(posit->label,"EMElectricFieldModel_t")==0 || strcmp(posit->label,"EMMagneticFieldModel_t")==0 || strcmp(posit->label,"EMConductivityModel_t")==0) { cgns_model *parent = (cgns_model *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(posit->label,"TurbulenceModel_t")==0 && strcmp(node_name,"DiffusionModel")==0) { if (parent->diffusion_model) free(parent->diffusion_model); parent->diffusion_model=0; } /* Children of ParticleEquationSet_t */ } else if (strcmp(posit->label,"ParticleEquationSet_t")==0) { cgns_pequations *parent = (cgns_pequations *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"ParticleGoverningEquations")==0) CGNS_DELETE_CHILD(governing, cgi_free_particle_governing) else if (strcmp(node_name,"ParticleCollisionModel")==0) CGNS_DELETE_CHILD(collision, cgi_free_particle_model) else if (strcmp(node_name,"ParticleBreakupModel")==0) CGNS_DELETE_CHILD(breakup, cgi_free_particle_model) else if (strcmp(node_name,"ParticleForceModel")==0) CGNS_DELETE_CHILD(force, cgi_free_particle_model) else if (strcmp(node_name,"ParticleWallInteractionModel")==0) CGNS_DELETE_CHILD(wallinteract, cgi_free_particle_model) else if (strcmp(node_name,"ParticlePhaseChangeModel")==0) CGNS_DELETE_CHILD(phasechange, cgi_free_particle_model) else if (strcmp(node_name,"EquationDimension")==0) parent->equation_dim=0; /* Children of ParticleGoverningEquations_t */ } else if (strcmp(posit->label,"ParticleGoverningEquations_t")==0) { cgns_pgoverning *parent = (cgns_pgoverning *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) /* Children of xxxParticleModel_t */ } else if (strcmp(posit->label,"ParticleCollisionModel_t")==0 || strcmp(posit->label,"ParticleBreakupModel_t")==0 || strcmp(posit->label,"ParticleForceModel_t")==0 || strcmp(posit->label,"ParticleWallInteractionModel_t")==0 || strcmp(posit->label,"ParticlePhaseChangeModel_t")==0) { cgns_pmodel *parent = (cgns_pmodel *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of ConvergenceHistory_t */ }else if (strcmp(posit->label,"ConvergenceHistory_t")==0) { cgns_converg *parent = (cgns_converg *)posit->posit; if (strcmp(node_name,"NormDefinitions")==0) CGNS_DELETE_CHILD(NormDefinitions, cgi_free_descr) else if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of IntegralData_t */ } else if (strcmp(posit->label,"IntegralData_t")==0) { cgns_integral *parent = (cgns_integral *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of ReferenceState_t */ } else if (strcmp(posit->label,"ReferenceState_t")==0) { cgns_state *parent = (cgns_state *)posit->posit; if (strcmp(node_name,"ReferenceStateDescription")==0) CGNS_DELETE_CHILD(StateDescription, cgi_free_descr) else if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of Family_t */ } else if (strcmp(posit->label,"Family_t")==0) { cgns_family *parent = (cgns_family *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"GeometryReference_t")==0) CGNS_DELETE_SHIFT(ngeos, geo, cgi_free_geo) else if (strcmp(node_label,"FamilyBC_t")==0) CGNS_DELETE_SHIFT(nfambc, fambc, cgi_free_fambc) else if (strcmp(node_label,"FamilyName_t")==0) CGNS_DELETE_SHIFT(nfamname, famname, cgi_free_famname) else if (strcmp(node_name,"Ordinal")==0) parent->ordinal=0; else if (strcmp(node_name,"RotatingCoordinates")==0) CGNS_DELETE_CHILD(rotating, cgi_free_rotating) else if (strcmp(node_label,"Family_t")==0) /* ** FAMILY TREE **/ CGNS_DELETE_SHIFT(nfamilies, family, cgi_free_family) /* Children of FamilyBC_t */ } else if (strcmp(posit->label,"FamilyBC_t")==0) { cgns_fambc *parent = (cgns_fambc *)posit->posit; if (strcmp(node_label,"FamilyBCDataSet_t")==0 || strcmp(node_label,"BCDataSet_t")==0) CGNS_DELETE_SHIFT(ndataset, dataset, cgi_free_dataset) /* Children of GeometryReference_t */ } else if (strcmp(posit->label,"GeometryReference_t")==0) { cgns_geo *parent = (cgns_geo *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"GeometryEntity_t")==0) CGNS_DELETE_SHIFT(npart, part, cgi_free_part) /* GeometryFile and GeometryFormat can not be deleted */ /* Children of Elements_t */ } else if (strcmp(posit->label,"Elements_t")==0) { cgns_section *parent = (cgns_section *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"ParentElements")==0) CGNS_DELETE_CHILD(parelem, cgi_free_array) else if (strcmp(node_name,"ParentElementsPosition")==0) CGNS_DELETE_CHILD(parface, cgi_free_array) else if (strcmp(node_name,"ParentData")==0) { CGNS_DELETE_CHILD(parelem, cgi_free_array) CGNS_DELETE_CHILD(parface, cgi_free_array) } else if (strcmp(node_name,"Rind")==0) { if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can't find IndexDimension in cg_delete"); return CG_NO_INDEX_DIM; } for (n=0; n<2*index_dim; n++) parent->rind_planes[n] = 0; } /* ElementRange and ElementConnectivity can not be deleted */ /* Children of RigidGridMotion_t */ } else if (strcmp(posit->label,"RigidGridMotion_t")==0) { cgns_rmotion *parent = (cgns_rmotion *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of ArbitraryGridMotion_t */ } else if (strcmp(posit->label,"ArbitraryGridMotion_t")==0) { cgns_amotion *parent = (cgns_amotion *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_name,"GridLocation")==0) parent->location=CGNS_ENUMV( GridLocationNull ); else if (strcmp(node_name,"Rind")==0) { if (posit_base && posit_zone) { index_dim = cg->base[posit_base-1].zone[posit_zone-1].index_dim; } else { cgi_error("Can't find IndexDimension in cg_delete"); return CG_NO_INDEX_DIM; } for (n=0; n<2*index_dim; n++) parent->rind_planes[n] = 0; } /* Children of BaseIterativeData_t */ } else if (strcmp(posit->label,"BaseIterativeData_t")==0) { cgns_biter *parent = (cgns_biter *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of ZoneIterativeData_t */ } else if (strcmp(posit->label,"ZoneIterativeData_t")==0) { cgns_ziter *parent = (cgns_ziter *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of UserDefinedData_t */ } else if (strcmp(posit->label,"UserDefinedData_t")==0) { cgns_user_data *parent = (cgns_user_data *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_label,"AdditionalFamilyName_t")==0) CGNS_DELETE_SHIFT(nfamname, famname, cgi_free_famname) else if (strcmp(node_name,"PointList")==0 || strcmp(node_name,"PointRange")==0) CGNS_DELETE_CHILD(ptset, cgi_free_ptset) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"GridLocation")==0) parent->location=CGNS_ENUMV( GridLocationNull ); else if (strcmp(node_name,"FamilyName")==0) parent->family_name[0]='\0'; else if (strcmp(node_name,"Ordinal")==0) parent->ordinal=0; /* IndexRange_t PointRange & IndexArray_t PointList can't be deleted */ /* Children of Gravity_t */ } else if (strcmp(posit->label,"Gravity_t")==0) { cgns_gravity *parent = (cgns_gravity *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* Children of Axisymmetry_t */ } else if (strcmp(posit->label,"Axisymmetry_t")==0) { cgns_axisym *parent = (cgns_axisym *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* RotatingCoordinates_t */ } else if (strcmp(posit->label,"RotatingCoordinates_t")==0) { cgns_rotating *parent = (cgns_rotating *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_label,"DataArray_t")==0) CGNS_DELETE_SHIFT(narrays, array, cgi_free_array) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* BCProperty_t */ } else if (strcmp(posit->label,"BCProperty_t")==0) { cgns_bprop *parent = (cgns_bprop *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"WallFunction")==0) CGNS_DELETE_CHILD(bcwall, cgi_free_bcwall) else if (strcmp(node_name,"Area")==0) CGNS_DELETE_CHILD(bcarea, cgi_free_bcarea) /* WallFunction_t */ } else if (strcmp(posit->label,"WallFunction_t")==0) { cgns_bcwall *parent = (cgns_bcwall *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) /* node WallFunctionType can't be deleted */ /* Area_t */ } else if (strcmp(posit->label,"Area_t")==0) { cgns_bcarea *parent = (cgns_bcarea *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) /* nodes AreaType, SurfaceArea and RegionName can't be deleted */ /* GridConnectivityProperty_t */ } else if (strcmp(posit->label,"GridConnectivityProperty_t")==0) { cgns_cprop *parent = (cgns_cprop *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"Periodic")==0) CGNS_DELETE_CHILD(cperio, cgi_free_cperio) else if (strcmp(node_name,"AverageInterface")==0) CGNS_DELETE_CHILD(caverage, cgi_free_caverage) /* Periodic_t */ } else if (strcmp(posit->label,"Periodic_t")==0) { cgns_cperio *parent = (cgns_cperio *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) else if (strcmp(node_name,"DataClass")==0) parent->data_class = CGNS_ENUMV( DataClassNull ); else if (strcmp(node_name,"DimensionalUnits")==0) CGNS_DELETE_CHILD(units, cgi_free_units) /* RotationCenter, RotationAngle and Translation can't be deleted */ /* AverageInterface_t */ } else if (strcmp(posit->label,"AverageInterface_t")==0) { cgns_caverage *parent = (cgns_caverage *)posit->posit; if (strcmp(node_label,"Descriptor_t")==0) CGNS_DELETE_SHIFT(ndescr, descr, cgi_free_descr) else if (strcmp(node_label,"UserDefinedData_t")==0) CGNS_DELETE_SHIFT(nuser_data, user_data, cgi_free_user_data) /* AverageInterfaceType can't be deleted */ } else { cgi_error("Unrecognized label: '%s'",posit->label); return CG_ERROR; } return CG_OK; } /*****************************************************************************\ * Free library malloced memory \*****************************************************************************/ /** * \ingroup FreeingMemory * * \brief Release library-allocated memory * * \param[in] data Data allocated by the Mid-Level Library. * \return \ier * * \details This function does not affect the structure of a CGNS file; it is * provided as a convenience to free memory allocated by the Mid-Level Library. * This isn't necessary in Fortran; thus, an equivalent Fortran function is not provided. * * The functions that are used to allocate memory for return values are * cg_descriptor_read(), cg_convergence_read(), cg_geo_read(), cg_link_read(), and cg_state_read(). * Each of these may allocate space to contain the data returned to the application. It is * the responsibility of the application to free this data when it is no longer needed. * Calling cg_free() is identical to calling the standard C function free, however it is * probably safer in that the memory is freed in the same module in which it is created, * particularly when the Mid-Level Library is a shared library or DLL. The routine checks * for NULL data and will return CG_ERROR in this case, otherwise it returns CG_OK. * */ int cg_free(void *data) { if (data != NULL) { CGNS_FREE (data); return CG_OK; } return CG_ERROR; } CGNS-4.5.0/src/cgnslib.h000066400000000000000000002642341474000356600146530ustar00rootroot00000000000000/* ------------------------------------------------------------------------- * * CGNS - CFD General Notation System (http://www.cgns.org) * * CGNS/MLL - Mid-Level Library header file * * Please see cgnsconfig.h file for this local installation configuration * * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- * This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. * _____ __ __ _____ ____ _____ _______ _ _ _______ * |_ _| \/ | __ \ / __ \| __ \__ __|/\ | \ | |__ __| * | | | \ / | |__) | | | | |__) | | | / \ | \| | | | * | | | |\/| | ___/| | | | _ / | | / /\ \ | . ` | | | * _| |_| | | | | | |__| | | \ \ | |/ ____ \| |\ | | | * |_____|_| |_|_| \____/|_| \_\ |_/_/ \_\_| \_| |_| * * ------------------- DEVELOPER'S NOTES --------------------------- * * (1) When adding a defined constant to this file, also add the same defined * constant to cgns_f.F90 * * (2) Fortran length of names for variables is limited to 31 characters. * * ------------------------------------------------------------------------- */ /** * \defgroup CGNSInternals_FNC_CG_CONFIG Configuring CGNS Internals; valid cg_configure() options. */ #ifndef CGNSLIB_H #define CGNSLIB_H #define CGNS_VERSION 4500 #define CGNS_DOTVERS 4.50 #define CGNS_COMPATVERSION 2540 #define CGNS_COMPATDOTVERS 2.54 #include "cgnstypes.h" #if CG_BUILD_SCOPE # ifndef CGNS_SCOPE_ENUMS # define CGNS_SCOPE_ENUMS # endif #else # ifdef CGNS_SCOPE_ENUMS # undef CGNS_SCOPE_ENUMS # endif #endif #ifndef CGNSDLL # ifdef _WIN32 # if defined(BUILD_DLL) # define CGNSDLL __declspec(dllexport) # elif defined(USE_DLL) # define CGNSDLL __declspec(dllimport) # else # define CGNSDLL # endif # else # define CGNSDLL # endif #endif #ifdef CGNS_SCOPE_ENUMS /* set scope prefix for values only */ #define CGNS_ENUMV( e ) CG_ ## e /* set scope prefix for types */ #define CGNS_ENUMT( e ) CG_ ## e /* set scope prefix for defines */ #define CGNS_ENUMD( e ) CG_ ## e /* set scope prefix for variables (lowercase same as functions) */ #define CGNS_ENUMF( e ) cg_ ## e #else #define CGNS_ENUMV( e ) e #define CGNS_ENUMT( e ) e #define CGNS_ENUMD( e ) e #define CGNS_ENUMF( e ) e #endif /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * modes for cgns file * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define CG_MODE_READ 0 #define CG_MODE_WRITE 1 #define CG_MODE_MODIFY 2 /* file types */ #define CG_FILE_NONE 0 #define CG_FILE_ADF 1 #define CG_FILE_HDF5 2 #define CG_FILE_ADF2 3 /* function return codes */ #define CG_OK 0 #define CG_ERROR 1 #define CG_NODE_NOT_FOUND 2 #define CG_INCORRECT_PATH 3 #define CG_NO_INDEX_DIM 4 /* Null and UserDefined enums */ #define CG_Null 0 #define CG_UserDefined 1 /* max goto depth */ #define CG_MAX_GOTO_DEPTH 20 /* CONFIGURATION OPTIONS */ /* _______ _______ ______ _ _ _______ _____ ____ _ _ * /\|__ __|__ __| ____| \ | |__ __|_ _/ __ \| \ | | * / \ | | | | | |__ | \| | | | | || | | | \| | * / /\ \ | | | | | __| | . ` | | | | || | | | . ` | * / ____ \| | | | | |____| |\ | | | _| || |__| | |\ | * /_/ \_\_| |_| |______|_| \_| |_| |_____\____/|_| \_| * * When defining new CG_CONFIG_* options, it is essential to add a description * for documentation purposes. */ /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief This allows the user to define an error call-back function. The value should be a pointer * to a function that receives the error. The function is defined as * `void err_callback(int is_error, char *errmsg)`, or, in Fortran, * \code{.F90} SUBROUTINE err_callback(is_error, errmsg) BIND(C) INTEGER(C_INT), VALUE ::is_error CHARACTER(LEN=1), DIMENSION(*) :: errmsg \endcode * and will be called for errors and warnings. * * The first argument, `is_error`, will be 0 for warning messages, 1 for error messages, and * -1 if the program is going to terminate (i.e., a call to cg_error_exit()). The second * argument is the error or warning message. If this is defined, warning and error messages * will go to the function rather than the terminal. A `value` of NULL (Fortran, * `C_NULL_PTR` or `C_NULL_FUNPTR`) will remove the call-back function. */ #define CG_CONFIG_ERROR 1 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief This is the rewrite-upon-close setting. **Note**: Prior library versions would * automatically rewrite the CGNS file when it was closed after being opened in modify mode * if there was unused space. This is no longer done due to possible parallel I/O conflicts. * The previous behavior may be recovered by setting the value to a positive integer. In this * case, the file will be rewritten if the number of node deletions or modifications equals * or exceeds this number. Setting the `value` to a negative number will force the rewrite * when the file is closed. The default value is 0 (no rewrite). */ #define CG_CONFIG_COMPRESS 2 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Sets the search path for locating linked-to files. The argument `value` should be a * character string containing one or more directories, formatted the same as for the PATH * environment variable. This will replace any current settings. Setting `value` to NULL will * remove all paths. In Fortran, the path must terminate with a `NULL` character, `CHAR(0)` * or `C_NULL_CHAR`. */ #define CG_CONFIG_SET_PATH 3 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Adds a directory, or list of directories, to the linked-to file search path. This * is the same as `CG_CONFIG_SET_PATH`, but adds to the path instead of replacing it. In * Fortran, the path must terminate with a `NULL` character, `CHAR(0)` or `C_NULL_CHAR`. */ #define CG_CONFIG_ADD_PATH 4 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Sets the default file type for newly created CGNS files. The argument `value` should be * set to one of `CG_FILE_NONE`, `CG_FILE_ADF`, `CG_FILE_HDF5`, or `CG_FILE_ADF2`. See the * discussion above for cg_set_file_type(). */ #define CG_CONFIG_FILE_TYPE 5 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief This option affects index bounds on structured arrays with rind planes. The * SIDS * specifies that core array locations begin at index 1. Lower rind planes, if present, would * have an index of less than 1 (see * structured grid indexing conventions * ). Versions of the Mid-Level Library < 3.4 did not produce * this behavior. Index 1 always represented the start of an array: in an array with no rind * planes, the core location would have index 1; in an array with 1 rind plane, the core * location would have index 2. In version 3.4 of the Mid-Level Library, the API's behavior * was fixed to match what was specified in the SIDS: core array locations always begin at * index 1. This option allows for configuring the library to pre-3.4 indexing behavior (set * value to `CG_CONFIG_RIND_ZERO`) or the new default behavior (set value to * `CG_CONFIG_RIND_CORE`). Note that using `CG_CONFIG_RIND_ZERO` is considered obsolete but * is provided for backward compatibility. Most users should not select this option and use * the default. Values used for this option do not need to be explicitly cast as `void*`. * This option does not change the CGNS file in any way; it only modifies the API to the * library. */ #define CG_CONFIG_RIND_INDEX 6 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Sets the compression level for data written from HDF5. The default is no compression. * Setting `value` to -1 will use the default compression level of 6. The acceptable * values are 0 to 9, corresponding to gzip compression levels. **This option currently * does nothing, as compression has not yet been implemented.** */ #define CG_CONFIG_HDF5_COMPRESS 201 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Sets the MPI communicator for parallel I/O. The default is `MPI_COMM_WORLD`. The * new communicator is given by typecasting it to a `void *`. This is generally used * internally - see cgp_mpi_comm() instead. */ #define CG_CONFIG_HDF5_MPI_COMM 202 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Performs I/O directly to memory and can create temporary CGNS files that never * exist on permanent storage. The memory is written to disk depending on the state of * \ref CG_CONFIG_HDF5_DISKLESS_WRITE. CGNS will use the \p core file driver in HDF5 via * `H5Pset_fapl_core`, and the parameters associated with \ref CG_CONFIG_HDF5_DISKLESS are * associated with that API. When `value` is 1, any previously defined driver mode is * ignored. Setting `value` to 0 disables the diskless mode, enabling the previous mode. * This configuration is not a valid option when accessing the memory by more than one * process. */ #define CG_CONFIG_HDF5_DISKLESS 203 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief `Value` specifies the increment by which allocated memory is to be increased * each time more memory is required, in bytes. The default is 10MiB. Ideally, `value` * should be set large enough to minimize repeated increases. The type of `value` is * `size_t` in C and `C_SIZE_T` in Fortran. Due to a bug with gfortran, it is advisable to * use `C_LOC` or `C_FUNLOC` in-line of the call instead of using a variable. */ #define CG_CONFIG_HDF5_DISKLESS_INCR 204 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief `Value` indicates whether to write (`value`=1) the memory contents to disk when * the file is closed. Otherwise, `value`=0 does not persist the memory to disk. */ #define CG_CONFIG_HDF5_DISKLESS_WRITE 205 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Configures HDF5's `H5Pset_alignment` and sets the alignment, `value[1]`, * properties of a file access property list so that any file object greater than or equal * in size to a threshold, `value[0]`, bytes will be aligned on an address which is a * multiple of alignment. */ #define CG_CONFIG_HDF5_ALIGNMENT 206 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Configures HDF5's `H5Pset_meta_block_size` and sets the minimum size, `value (in * bytes)`, of metadata block allocations. */ #define CG_CONFIG_HDF5_MD_BLOCK_SIZE 207 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Configures HDF5's `H5Pset_buffer` and sets the maximum size, `value (in bytes)`, * for the type conversion buffer and background buffer. */ #define CG_CONFIG_HDF5_BUFFER 208 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Configures HDF5's `H5Pset_sieve_buf_size` and sets the maximum size, `value (in * bytes)`, of the data sieve buffer. */ #define CG_CONFIG_HDF5_SIEVE_BUF_SIZE 209 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief Configures HDF5's `H5Pset_elink_file_cache_size` and sets the number of files, * `value`, that can be held open in an external link open file cache. */ #define CG_CONFIG_HDF5_ELINK_CACHE_SIZE 210 /** * \ingroup CGNSInternals_FNC_CG_CONFIG * \brief `Value` indicates the configuration values to reset to their default values. * Currently, only `CG_CONFIG_RESET_HDF5` is a valid `value` and will reset all the * `CG_CONFIG_HDF5_*` parameters, excluding `CG_CONFIG_HDF5_MPI_COMM` and * `CG_CONFIG_HDF5_DISKLESS`, to their default values. */ #define CG_CONFIG_RESET 1000 #define CG_CONFIG_RESET_HDF5 1 /* HDF5 dataset storage layout */ #define CG_CONTIGUOUS 0 #define CG_COMPACT 1 #define CG_CHUNKED 2 /* note: CG_CONFIG_RIND_ZERO is obsolete and considered a bug. Users are given * the option only for backwards compatibility */ #define CG_CONFIG_RIND_ZERO (void*)0 #define CG_CONFIG_RIND_CORE (void*)1 #ifdef __cplusplus extern "C" { #endif /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Enumerations: if any of this enumerations need to be modified, * * the corresponding namelist must also be updated. * * * * Any addition to an enum should be done as an addition at end of list * * with an explicit declaration of the corresponding integer. * * This is required for enums stored as integers in the CGNS file or * * used in applications. * * * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Dimensional Units * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( MassUnitsNull ) =CG_Null, CGNS_ENUMV( MassUnitsUserDefined )=CG_UserDefined, CGNS_ENUMV( Kilogram ) =2, CGNS_ENUMV( Gram ) =3, CGNS_ENUMV( Slug ) =4, CGNS_ENUMV( PoundMass ) =5 } CGNS_ENUMT( MassUnits_t ); typedef enum { CGNS_ENUMV( LengthUnitsNull ) =CG_Null, CGNS_ENUMV( LengthUnitsUserDefined )=CG_UserDefined, CGNS_ENUMV( Meter ) =2, CGNS_ENUMV( Centimeter ) =3, CGNS_ENUMV( Millimeter ) =4, CGNS_ENUMV( Foot ) =5, CGNS_ENUMV( Inch ) =6 } CGNS_ENUMT( LengthUnits_t ); typedef enum { CGNS_ENUMV( TimeUnitsNull ) =CG_Null, CGNS_ENUMV( TimeUnitsUserDefined )=CG_UserDefined, CGNS_ENUMV( Second ) =2 } CGNS_ENUMT( TimeUnits_t ); typedef enum { CGNS_ENUMV( TemperatureUnitsNull ) =CG_Null, CGNS_ENUMV( TemperatureUnitsUserDefined )=CG_UserDefined, CGNS_ENUMV( Kelvin ) =2, CGNS_ENUMV( Celsius ) =3, CGNS_ENUMV( Rankine ) =4, CGNS_ENUMV( Fahrenheit ) =5 } CGNS_ENUMT( TemperatureUnits_t ); typedef enum { CGNS_ENUMV( AngleUnitsNull ) =CG_Null, CGNS_ENUMV( AngleUnitsUserDefined )=CG_UserDefined, CGNS_ENUMV( Degree ) =2, CGNS_ENUMV( Radian ) =3 } CGNS_ENUMT( AngleUnits_t ); typedef enum { CGNS_ENUMV( ElectricCurrentUnitsNull ) =CG_Null, CGNS_ENUMV( ElectricCurrentUnitsUserDefined )=CG_UserDefined, CGNS_ENUMV( Ampere ) =2, CGNS_ENUMV( Abampere ) =3, CGNS_ENUMV( Statampere ) =4, CGNS_ENUMV( Edison ) =5, CGNS_ENUMV( auCurrent ) =6 } CGNS_ENUMT( ElectricCurrentUnits_t ); typedef enum { CGNS_ENUMV( SubstanceAmountUnitsNull ) =CG_Null, CGNS_ENUMV( SubstanceAmountUnitsUserDefined )=CG_UserDefined, CGNS_ENUMV( Mole ) =2, CGNS_ENUMV( Entities ) =3, CGNS_ENUMV( StandardCubicFoot ) =4, CGNS_ENUMV( StandardCubicMeter ) =5 } CGNS_ENUMT( SubstanceAmountUnits_t ); typedef enum { CGNS_ENUMV( LuminousIntensityUnitsNull ) =CG_Null, CGNS_ENUMV( LuminousIntensityUnitsUserDefined )=CG_UserDefined, CGNS_ENUMV( Candela ) =2, CGNS_ENUMV( Candle ) =3, CGNS_ENUMV( Carcel ) =4, CGNS_ENUMV( Hefner ) =5, CGNS_ENUMV( Violle ) =6 } CGNS_ENUMT( LuminousIntensityUnits_t ); #define NofValidMassUnits 6 #define NofValidLengthUnits 7 #define NofValidTimeUnits 3 #define NofValidTemperatureUnits 6 #define NofValidAngleUnits 4 #define NofValidElectricCurrentUnits 7 #define NofValidSubstanceAmountUnits 6 #define NofValidLuminousIntensityUnits 7 extern CGNSDLL const char * MassUnitsName[NofValidMassUnits]; extern CGNSDLL const char * LengthUnitsName[NofValidLengthUnits]; extern CGNSDLL const char * TimeUnitsName[NofValidTimeUnits]; extern CGNSDLL const char * TemperatureUnitsName[NofValidTemperatureUnits]; extern CGNSDLL const char * AngleUnitsName[NofValidAngleUnits]; extern CGNSDLL const char * ElectricCurrentUnitsName[NofValidElectricCurrentUnits]; extern CGNSDLL const char * SubstanceAmountUnitsName[NofValidSubstanceAmountUnits]; extern CGNSDLL const char * LuminousIntensityUnitsName[NofValidLuminousIntensityUnits]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Data Class * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( DataClassNull ) =CG_Null, CGNS_ENUMV( DataClassUserDefined ) =CG_UserDefined, CGNS_ENUMV( Dimensional ) =2, CGNS_ENUMV( NormalizedByDimensional ) =3, CGNS_ENUMV( NormalizedByUnknownDimensional ) =4, CGNS_ENUMV( NondimensionalParameter ) =5, CGNS_ENUMV( DimensionlessConstant ) =6 } CGNS_ENUMT( DataClass_t ); #define NofValidDataClass 7 extern CGNSDLL const char * DataClassName[NofValidDataClass]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Grid Location \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( GridLocationNull ) =CG_Null, CGNS_ENUMV( GridLocationUserDefined ) =CG_UserDefined, CGNS_ENUMV( Vertex ) =2, CGNS_ENUMV( CellCenter ) =3, CGNS_ENUMV( FaceCenter ) =4, CGNS_ENUMV( IFaceCenter ) =5, CGNS_ENUMV( JFaceCenter ) =6, CGNS_ENUMV( KFaceCenter ) =7, CGNS_ENUMV( EdgeCenter ) =8 } CGNS_ENUMT( GridLocation_t ); #define NofValidGridLocation 9 extern CGNSDLL const char * GridLocationName[NofValidGridLocation]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * BCData Types: Can not add types and stay forward compatible * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( BCDataTypeNull ) =CG_Null, CGNS_ENUMV( BCDataTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( Dirichlet ) =2, CGNS_ENUMV( Neumann ) =3 } CGNS_ENUMT( BCDataType_t ); #define NofValidBCDataTypes 4 extern CGNSDLL const char * BCDataTypeName[NofValidBCDataTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Grid Connectivity Types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( GridConnectivityTypeNull ) =CG_Null, CGNS_ENUMV( GridConnectivityTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( Overset ) =2, CGNS_ENUMV( Abutting ) =3, CGNS_ENUMV( Abutting1to1 ) =4 } CGNS_ENUMT( GridConnectivityType_t ); #define NofValidGridConnectivityTypes 5 extern CGNSDLL const char * GridConnectivityTypeName[NofValidGridConnectivityTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Point Set Types: Can't add types and stay forward compatible \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( PointSetTypeNull ) =CG_Null, CGNS_ENUMV( PointSetTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( PointList ) =2, CGNS_ENUMV( PointListDonor ) =3, CGNS_ENUMV( PointRange ) =4, CGNS_ENUMV( PointRangeDonor ) =5, CGNS_ENUMV( ElementRange ) =6, CGNS_ENUMV( ElementList ) =7, CGNS_ENUMV( CellListDonor ) =8 } CGNS_ENUMT( PointSetType_t ); #define NofValidPointSetTypes 9 extern CGNSDLL const char * PointSetTypeName[NofValidPointSetTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Governing Equations and Physical Models Types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( GoverningEquationsNull ) =CG_Null, CGNS_ENUMV( GoverningEquationsUserDefined ) =CG_UserDefined, CGNS_ENUMV( FullPotential ) =2, CGNS_ENUMV( Euler ) =3, CGNS_ENUMV( NSLaminar ) =4, CGNS_ENUMV( NSTurbulent ) =5, CGNS_ENUMV( NSLaminarIncompressible ) =6, CGNS_ENUMV( NSTurbulentIncompressible ) =7, CGNS_ENUMV( LatticeBoltzmann ) =8 } CGNS_ENUMT( GoverningEquationsType_t ); /* Any model type will accept both ModelTypeNull and ModelTypeUserDefined. ** The following models will accept these values as valid... ** ** GasModel_t: Ideal, VanderWaals, CaloricallyPerfect, ThermallyPerfect, ** ConstantDensity, RedlichKwong ** ** ViscosityModel_t: Constant, PowerLaw, SutherlandLaw ** ** ThermalConductivityModel_t: PowerLaw, SutherlandLaw, ConstantPrandtl ** ** TurbulenceModel_t: Algebraic_BaldwinLomax, Algebraic_CebeciSmith, ** HalfEquation_JohnsonKing, OneEquation_BaldwinBarth, ** OneEquation_SpalartAllmaras, TwoEquation_JonesLaunder, ** TwoEquation_MenterSST,TwoEquation_Wilcox ** ** TurbulenceClosure_t: EddyViscosity, ReynoldsStress, ReynoldsStressAlgebraic ** ** ThermalRelaxationModel_t: Frozen, ThermalEquilib, ThermalNonequilib ** ** ChemicalKineticsModel_t: Frozen, ChemicalEquilibCurveFit, ** ChemicalEquilibMinimization, ChemicalNonequilib ** ** EMElectricFieldModel_t: Voltage, Interpolated, Constant, Frozen ** ** EMMagneticFieldModel_t: Interpolated, Constant, Frozen ** ** EMConductivityModel_t: Constant, Frozen, Equilibrium_LinRessler, ** Chemistry_LinRessler */ typedef enum { CGNS_ENUMV( ModelTypeNull ) =CG_Null, CGNS_ENUMV( ModelTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( Ideal ) =2, CGNS_ENUMV( VanderWaals ) =3, CGNS_ENUMV( Constant ) =4, CGNS_ENUMV( PowerLaw ) =5, CGNS_ENUMV( SutherlandLaw ) =6, CGNS_ENUMV( ConstantPrandtl ) =7, CGNS_ENUMV( EddyViscosity ) =8, CGNS_ENUMV( ReynoldsStress ) =9, CGNS_ENUMV( ReynoldsStressAlgebraic ) =10, CGNS_ENUMV( Algebraic_BaldwinLomax ) =11, CGNS_ENUMV( Algebraic_CebeciSmith ) =12, CGNS_ENUMV( HalfEquation_JohnsonKing ) =13, CGNS_ENUMV( OneEquation_BaldwinBarth ) =14, CGNS_ENUMV( OneEquation_SpalartAllmaras ) =15, CGNS_ENUMV( TwoEquation_JonesLaunder ) =16, CGNS_ENUMV( TwoEquation_MenterSST ) =17, CGNS_ENUMV( TwoEquation_Wilcox ) =18, CGNS_ENUMV( CaloricallyPerfect ) =19, CGNS_ENUMV( ThermallyPerfect ) =20, CGNS_ENUMV( ConstantDensity ) =21, CGNS_ENUMV( RedlichKwong ) =22, CGNS_ENUMV( Frozen ) =23, CGNS_ENUMV( ThermalEquilib ) =24, CGNS_ENUMV( ThermalNonequilib ) =25, CGNS_ENUMV( ChemicalEquilibCurveFit ) =26, CGNS_ENUMV( ChemicalEquilibMinimization ) =27, CGNS_ENUMV( ChemicalNonequilib ) =28, CGNS_ENUMV( EMElectricField ) =29, CGNS_ENUMV( EMMagneticField ) =30, CGNS_ENUMV( EMConductivity ) =31, CGNS_ENUMV( Voltage ) =32, CGNS_ENUMV( Interpolated ) =33, CGNS_ENUMV( Equilibrium_LinRessler ) =34, CGNS_ENUMV( Chemistry_LinRessler ) =35 } CGNS_ENUMT( ModelType_t ); typedef enum { CGNS_ENUMV( ParticleGoverningEquationsNull ) =CG_Null, CGNS_ENUMV( ParticleGoverningEquationsUserDefined ) =CG_UserDefined, CGNS_ENUMV( DEM ) =2, CGNS_ENUMV( DSMC ) =3, CGNS_ENUMV( SPH ) =4, } CGNS_ENUMT( ParticleGoverningEquationsType_t ); /* Any particle model type will accept both ParticleModelTypeNull and ParticleModelTypeUserDefined. ** The following particle models will accept these values as valid... ** ** ParticleCollisionModelType_t: Linear, NonLinear, HardSphere, SoftSphere, ** LinearSpringDashpot, Pair, HertzMindlin, HertzKuwabaraKono, ORourke, ** Stochastic, NonStochastic, NTC ** ** ParticleBreakupModel_t: KelvinHelmholtz, KelvinHelmholtzACT, RayleighTaylor, ** KelvinHelmholtzRayleighTaylor, TAB, ETAB, LISA, SHF, PilchErdman, ReitzDiwakar ** ** ParticleForceModel_t: Sphere, NonShpere, Tracer, BeetstraVanDerHoefKuipers, ** Ergun, CliftGrace, Gidaspow, HaiderLevenspiel, PlessisMasliyah, ** SyamlalOBrien, SaffmanMei, TennetiGargSubramaniam, Tomiyama, Stokes, ** StokesCunningham, WenYu ** ** ParticleWallInteractionModel_t: Linear, NonLinear, HardSphere, SoftSphere, ** LinearSpringDashpot, BaiGosman, Pair, HertzMindlin, HertzKuwabaraKono, Khunke, ** ORourke, Stochastic, NonStochastic, NTC ** ** ParticlePhaseChangeModel_t: Boil, Condense, Flash, Nucleate, Chiang, Frossling, uchsKnudsen */ typedef enum { CGNS_ENUMV( ParticleModelTypeNull ) =CG_Null, CGNS_ENUMV( ParticleModelTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( Linear ) =2, CGNS_ENUMV( NonLinear ) =3, CGNS_ENUMV( HardSphere ) =4, CGNS_ENUMV( SoftSphere ) =5, CGNS_ENUMV( LinearSpringDashpot ) =6, CGNS_ENUMV( Pair ) =7, CGNS_ENUMV( HertzMindlin ) =8, CGNS_ENUMV( HertzKuwabaraKono ) =9, CGNS_ENUMV( ORourke ) =10, CGNS_ENUMV( Stochastic ) =11, CGNS_ENUMV( NonStochastic ) =12, CGNS_ENUMV( NTC ) =13, CGNS_ENUMV( KelvinHelmholtz ) =14, CGNS_ENUMV( KelvinHelmholtzACT ) =15, CGNS_ENUMV( RayleighTaylor ) =16, CGNS_ENUMV( KelvinHelmholtzRayleighTaylor ) =17, CGNS_ENUMV( ReitzKHRT ) = 18, CGNS_ENUMV( TAB ) =19, CGNS_ENUMV( ETAB ) =20, CGNS_ENUMV( LISA ) =21, CGNS_ENUMV( SHF ) =22, CGNS_ENUMV( PilchErdman ) =23, CGNS_ENUMV( ReitzDiwakar ) =24, CGNS_ENUMV( Sphere ) =25, CGNS_ENUMV( NonSphere ) =26, CGNS_ENUMV( Tracer ) =27, CGNS_ENUMV( BeetstraVanDerHoefKuipers ) =28, CGNS_ENUMV( Ergun ) =29, CGNS_ENUMV( CliftGrace ) =30, CGNS_ENUMV( Gidaspow ) =31, CGNS_ENUMV( HaiderLevenspiel ) =32, CGNS_ENUMV( PlessisMasliyah ) =33, CGNS_ENUMV( SyamlalOBrien ) =34, CGNS_ENUMV( SaffmanMei ) =35, CGNS_ENUMV( TennetiGargSubramaniam ) =36, CGNS_ENUMV( Tomiyama ) =37, CGNS_ENUMV( Stokes ) =38, CGNS_ENUMV( StokesCunningham ) =39, CGNS_ENUMV( WenYu ) =40, CGNS_ENUMV( BaiGosman ) = 41, CGNS_ENUMV( Khunke ) = 42, CGNS_ENUMV( Boil ) =43, CGNS_ENUMV( Condense ) =44, CGNS_ENUMV( Flash ) =45, CGNS_ENUMV( Nucleate ) =46, CGNS_ENUMV( Chiang ) =47, CGNS_ENUMV( Frossling ) =48, CGNS_ENUMV( FuchsKnudsen ) =49, } CGNS_ENUMT( ParticleModelType_t); #define NofValidGoverningEquationsTypes 9 #define NofValidModelTypes 36 #define NofValidParticleGoverningEquationsTypes 5 #define NofValidParticleModelTypes 50 extern CGNSDLL const char * GoverningEquationsTypeName[NofValidGoverningEquationsTypes]; extern CGNSDLL const char * ModelTypeName[NofValidModelTypes]; extern CGNSDLL const char * ParticleGoverningEquationsTypeName[NofValidParticleGoverningEquationsTypes]; extern CGNSDLL const char * ParticleModelTypeName[NofValidParticleModelTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Boundary Condition Types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( BCTypeNull ) =CG_Null, CGNS_ENUMV( BCTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( BCAxisymmetricWedge ) =2, CGNS_ENUMV( BCDegenerateLine ) =3, CGNS_ENUMV( BCDegeneratePoint ) =4, CGNS_ENUMV( BCDirichlet ) =5, CGNS_ENUMV( BCExtrapolate ) =6, CGNS_ENUMV( BCFarfield ) =7, CGNS_ENUMV( BCGeneral ) =8, CGNS_ENUMV( BCInflow ) =9, CGNS_ENUMV( BCInflowSubsonic ) =10, CGNS_ENUMV( BCInflowSupersonic ) =11, CGNS_ENUMV( BCNeumann ) =12, CGNS_ENUMV( BCOutflow ) =13, CGNS_ENUMV( BCOutflowSubsonic ) =14, CGNS_ENUMV( BCOutflowSupersonic ) =15, CGNS_ENUMV( BCSymmetryPlane ) =16, CGNS_ENUMV( BCSymmetryPolar ) =17, CGNS_ENUMV( BCTunnelInflow ) =18, CGNS_ENUMV( BCTunnelOutflow ) =19, CGNS_ENUMV( BCWall ) =20, CGNS_ENUMV( BCWallInviscid ) =21, CGNS_ENUMV( BCWallViscous ) =22, CGNS_ENUMV( BCWallViscousHeatFlux ) =23, CGNS_ENUMV( BCWallViscousIsothermal ) =24, CGNS_ENUMV( FamilySpecified ) =25 } CGNS_ENUMT( BCType_t ); #define NofValidBCTypes 26 extern CGNSDLL const char * BCTypeName[NofValidBCTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Data types: Can not add data types and stay forward compatible * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( DataTypeNull ) =CG_Null, CGNS_ENUMV( DataTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( Integer ) =2, CGNS_ENUMV( RealSingle ) =3, CGNS_ENUMV( RealDouble ) =4, CGNS_ENUMV( Character ) =5, CGNS_ENUMV( LongInteger ) =6, CGNS_ENUMV( ComplexSingle ) =7, CGNS_ENUMV( ComplexDouble ) =8 } CGNS_ENUMT( DataType_t ); #define NofValidDataTypes 9 extern CGNSDLL const char * DataTypeName[NofValidDataTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Element types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* PLEASE ALSO UPDATE the cgnslib.h/el_size static table */ typedef enum { CGNS_ENUMV( ElementTypeNull ) =CG_Null, CGNS_ENUMV( ElementTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( NODE ) =2, CGNS_ENUMV( BAR_2 ) =3, CGNS_ENUMV( BAR_3 ) =4, CGNS_ENUMV( TRI_3 ) =5, CGNS_ENUMV( TRI_6 ) =6, CGNS_ENUMV( QUAD_4 ) =7, CGNS_ENUMV( QUAD_8 ) =8, CGNS_ENUMV( QUAD_9 ) =9, CGNS_ENUMV( TETRA_4 ) =10, CGNS_ENUMV( TETRA_10 ) =11, CGNS_ENUMV( PYRA_5 ) =12, CGNS_ENUMV( PYRA_14 ) =13, CGNS_ENUMV( PENTA_6 ) =14, CGNS_ENUMV( PENTA_15 ) =15, CGNS_ENUMV( PENTA_18 ) =16, CGNS_ENUMV( HEXA_8 ) =17, CGNS_ENUMV( HEXA_20 ) =18, CGNS_ENUMV( HEXA_27 ) =19, CGNS_ENUMV( MIXED ) =20, CGNS_ENUMV( PYRA_13 ) =21, CGNS_ENUMV( NGON_n ) =22, CGNS_ENUMV( NFACE_n ) =23, CGNS_ENUMV( BAR_4 ) =24, CGNS_ENUMV( TRI_9 ) =25, CGNS_ENUMV( TRI_10 ) =26, CGNS_ENUMV( QUAD_12 ) =27, CGNS_ENUMV( QUAD_16 ) =28, CGNS_ENUMV( TETRA_16 ) =29, CGNS_ENUMV( TETRA_20 ) =30, CGNS_ENUMV( PYRA_21 ) =31, CGNS_ENUMV( PYRA_29 ) =32, CGNS_ENUMV( PYRA_30 ) =33, CGNS_ENUMV( PENTA_24 ) =34, CGNS_ENUMV( PENTA_38 ) =35, CGNS_ENUMV( PENTA_40 ) =36, CGNS_ENUMV( HEXA_32 ) =37, CGNS_ENUMV( HEXA_56 ) =38, CGNS_ENUMV( HEXA_64 ) =39, CGNS_ENUMV( BAR_5 )=40, CGNS_ENUMV( TRI_12 )=41, CGNS_ENUMV( TRI_15 )=42, CGNS_ENUMV( QUAD_P4_16 )=43, CGNS_ENUMV( QUAD_25 )=44, CGNS_ENUMV( TETRA_22 )=45, CGNS_ENUMV( TETRA_34 )=46, CGNS_ENUMV( TETRA_35 )=47, CGNS_ENUMV( PYRA_P4_29 )=48, CGNS_ENUMV( PYRA_50 )=49, CGNS_ENUMV( PYRA_55 )=50, CGNS_ENUMV( PENTA_33 )=51, CGNS_ENUMV( PENTA_66 )=52, CGNS_ENUMV( PENTA_75 )=53, CGNS_ENUMV( HEXA_44 )=54, CGNS_ENUMV( HEXA_98 )=55, CGNS_ENUMV( HEXA_125 )=56 } CGNS_ENUMT( ElementType_t ); #define NofValidElementTypes 57 extern CGNSDLL const char * ElementTypeName[NofValidElementTypes]; #ifdef CGNS_SCOPE_ENUMS #define CG_NPE_NODE 1 #define CG_NPE_BAR_2 2 #define CG_NPE_BAR_3 3 #define CG_NPE_TRI_3 3 #define CG_NPE_TRI_6 6 #define CG_NPE_QUAD_4 4 #define CG_NPE_QUAD_8 8 #define CG_NPE_QUAD_9 9 #define CG_NPE_TETRA_4 4 #define CG_NPE_TETRA_10 10 #define CG_NPE_PYRA_5 5 #define CG_NPE_PYRA_13 13 #define CG_NPE_PYRA_14 14 #define CG_NPE_PENTA_6 6 #define CG_NPE_PENTA_15 15 #define CG_NPE_PENTA_18 18 #define CG_NPE_HEXA_8 8 #define CG_NPE_HEXA_20 20 #define CG_NPE_HEXA_27 27 #define CG_NPE_MIXED 0 #define CG_NPE_NGON_n 0 #define CG_NPE_NFACE_n 0 #define CG_NPE_BAR_4 4 #define CG_NPE_TRI_9 9 #define CG_NPE_TRI_10 10 #define CG_NPE_QUAD_12 12 #define CG_NPE_QUAD_16 16 #define CG_NPE_TETRA_16 16 #define CG_NPE_TETRA_20 20 #define CG_NPE_PYRA_21 21 #define CG_NPE_PYRA_29 29 #define CG_NPE_PYRA_30 30 #define CG_NPE_PENTA_24 24 #define CG_NPE_PENTA_38 38 #define CG_NPE_PENTA_40 40 #define CG_NPE_HEXA_32 32 #define CG_NPE_HEXA_56 56 #define CG_NPE_HEXA_64 64 #define CG_NPE_BAR_5 5 #define CG_NPE_TRI_12 12 #define CG_NPE_TRI_15 15 #define CG_NPE_QUAD_P4_16 16 #define CG_NPE_QUAD_25 25 #define CG_NPE_TETRA_22 22 #define CG_NPE_TETRA_34 34 #define CG_NPE_TETRA_35 35 #define CG_NPE_PYRA_P4_29 29 #define CG_NPE_PYRA_50 50 #define CG_NPE_PYRA_55 55 #define CG_NPE_PENTA_33 33 #define CG_NPE_PENTA_66 66 #define CG_NPE_PENTA_75 75 #define CG_NPE_HEXA_44 44 #define CG_NPE_HEXA_98 98 #define CG_NPE_HEXA_125 125 #else #define NPE_NODE 1 #define NPE_BAR_2 2 #define NPE_BAR_3 3 #define NPE_TRI_3 3 #define NPE_TRI_6 6 #define NPE_QUAD_4 4 #define NPE_QUAD_8 8 #define NPE_QUAD_9 9 #define NPE_TETRA_4 4 #define NPE_TETRA_10 10 #define NPE_PYRA_5 5 #define NPE_PYRA_13 13 #define NPE_PYRA_14 14 #define NPE_PENTA_6 6 #define NPE_PENTA_15 15 #define NPE_PENTA_18 18 #define NPE_HEXA_8 8 #define NPE_HEXA_20 20 #define NPE_HEXA_27 27 #define NPE_MIXED 0 #define NPE_NGON_n 0 #define NPE_NFACE_n 0 #define NPE_BAR_4 4 #define NPE_TRI_9 9 #define NPE_TRI_10 10 #define NPE_QUAD_12 12 #define NPE_QUAD_16 16 #define NPE_TETRA_16 16 #define NPE_TETRA_20 20 #define NPE_PYRA_21 21 #define NPE_PYRA_29 29 #define NPE_PYRA_30 30 #define NPE_PENTA_24 24 #define NPE_PENTA_38 38 #define NPE_PENTA_40 40 #define NPE_HEXA_32 32 #define NPE_HEXA_56 56 #define NPE_HEXA_64 64 #define NPE_BAR_5 5 #define NPE_TRI_12 12 #define NPE_TRI_15 15 #define NPE_QUAD_P4_16 16 #define NPE_QUAD_25 25 #define NPE_TETRA_22 22 #define NPE_TETRA_34 34 #define NPE_TETRA_35 35 #define NPE_PYRA_P4_29 29 #define NPE_PYRA_50 50 #define NPE_PYRA_55 55 #define NPE_PENTA_33 33 #define NPE_PENTA_66 66 #define NPE_PENTA_75 75 #define NPE_HEXA_44 44 #define NPE_HEXA_98 98 #define NPE_HEXA_125 125 #endif /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Zone types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( ZoneTypeNull ) =CG_Null, CGNS_ENUMV( ZoneTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( Structured ) =2, CGNS_ENUMV( Unstructured ) =3 } CGNS_ENUMT( ZoneType_t ); #define NofValidZoneTypes 4 extern CGNSDLL const char * ZoneTypeName[NofValidZoneTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Rigid Grid Motion types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( RigidGridMotionTypeNull ) =CG_Null, CGNS_ENUMV( RigidGridMotionTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( ConstantRate ) =2, CGNS_ENUMV( VariableRate ) =3 } CGNS_ENUMT( RigidGridMotionType_t ); #define NofValidRigidGridMotionTypes 4 extern CGNSDLL const char * RigidGridMotionTypeName[NofValidRigidGridMotionTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Arbitrary Grid Motion types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( ArbitraryGridMotionTypeNull ) =CG_Null, CGNS_ENUMV( ArbitraryGridMotionTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( NonDeformingGrid ) =2, CGNS_ENUMV( DeformingGrid ) =3 } CGNS_ENUMT( ArbitraryGridMotionType_t ); #define NofValidArbitraryGridMotionTypes 4 extern CGNSDLL const char * ArbitraryGridMotionTypeName[NofValidArbitraryGridMotionTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Simulation types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( SimulationTypeNull ) =CG_Null, CGNS_ENUMV( SimulationTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( TimeAccurate ) =2, CGNS_ENUMV( NonTimeAccurate ) =3 } CGNS_ENUMT( SimulationType_t ); #define NofValidSimulationTypes 4 extern CGNSDLL const char * SimulationTypeName[NofValidSimulationTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * BC Property types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( WallFunctionTypeNull ) =CG_Null, CGNS_ENUMV( WallFunctionTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( Generic ) =2 } CGNS_ENUMT( WallFunctionType_t ); typedef enum { CGNS_ENUMV( AreaTypeNull ) =CG_Null, CGNS_ENUMV( AreaTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( BleedArea ) =2, CGNS_ENUMV( CaptureArea ) =3 } CGNS_ENUMT( AreaType_t ); #define NofValidWallFunctionTypes 3 #define NofValidAreaTypes 4 extern CGNSDLL const char * WallFunctionTypeName[NofValidWallFunctionTypes]; extern CGNSDLL const char * AreaTypeName[NofValidAreaTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Grid Connectivity Property types * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef enum { CGNS_ENUMV( AverageInterfaceTypeNull ) =CG_Null, CGNS_ENUMV( AverageInterfaceTypeUserDefined ) =CG_UserDefined, CGNS_ENUMV( AverageAll ) =2, CGNS_ENUMV( AverageCircumferential ) =3, CGNS_ENUMV( AverageRadial ) =4, CGNS_ENUMV( AverageI ) =5, CGNS_ENUMV( AverageJ ) =6, CGNS_ENUMV( AverageK ) =7 } CGNS_ENUMT( AverageInterfaceType_t ); #define NofValidAverageInterfaceTypes 8 extern CGNSDLL const char * AverageInterfaceTypeName[NofValidAverageInterfaceTypes]; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * LIBRARY FUNCTIONS * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_is_cgns(const char *filename, int *file_type); CGNSDLL int cg_open(const char * filename, int mode, int *fn); CGNSDLL int cg_version(int fn, float *FileVersion); CGNSDLL int cg_precision(int fn, int *precision); CGNSDLL int cg_close(int fn); CGNSDLL int cg_save_as(int fn, const char *filename, int file_type, int follow_links); CGNSDLL int cg_set_file_type(int file_type); CGNSDLL int cg_get_file_type(int fn, int *file_type); CGNSDLL int cg_root_id(int fn, double *rootid); CGNSDLL int cg_get_cgio(int fn, int *cgio_num); CGNSDLL int cg_configure(int what, void *value); CGNSDLL int cg_error_handler(void (*)(int, char *)); CGNSDLL int cg_set_compress(int compress); CGNSDLL int cg_get_compress(int *compress); CGNSDLL int cg_set_path(const char *path); CGNSDLL int cg_add_path(const char *path); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * typedef names * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #undef type CGNSDLL const char *cg_get_name(int nnames, const char **names, int type); CGNSDLL const char *cg_MassUnitsName(CGNS_ENUMT( MassUnits_t ) type); CGNSDLL const char *cg_LengthUnitsName(CGNS_ENUMT( LengthUnits_t ) type); CGNSDLL const char *cg_TimeUnitsName(CGNS_ENUMT( TimeUnits_t ) type); CGNSDLL const char *cg_TemperatureUnitsName(CGNS_ENUMT( TemperatureUnits_t ) type); CGNSDLL const char *cg_AngleUnitsName(CGNS_ENUMT( AngleUnits_t ) type); CGNSDLL const char *cg_ElectricCurrentUnitsName(CGNS_ENUMT( ElectricCurrentUnits_t ) type); CGNSDLL const char *cg_SubstanceAmountUnitsName(CGNS_ENUMT( SubstanceAmountUnits_t ) type); CGNSDLL const char *cg_LuminousIntensityUnitsName(CGNS_ENUMT( LuminousIntensityUnits_t ) type); CGNSDLL const char *cg_DataClassName(CGNS_ENUMT( DataClass_t ) type); CGNSDLL const char *cg_GridLocationName(CGNS_ENUMT( GridLocation_t ) type); CGNSDLL const char *cg_BCDataTypeName(CGNS_ENUMT( BCDataType_t ) type); CGNSDLL const char *cg_GridConnectivityTypeName(CGNS_ENUMT( GridConnectivityType_t ) type); CGNSDLL const char *cg_PointSetTypeName(CGNS_ENUMT( PointSetType_t ) type); CGNSDLL const char *cg_GoverningEquationsTypeName(CGNS_ENUMT( GoverningEquationsType_t ) type); CGNSDLL const char *cg_ModelTypeName(CGNS_ENUMT( ModelType_t ) type); CGNSDLL const char *cg_BCTypeName(CGNS_ENUMT( BCType_t ) type); CGNSDLL const char *cg_DataTypeName(CGNS_ENUMT( DataType_t ) type); CGNSDLL const char *cg_ElementTypeName(CGNS_ENUMT( ElementType_t ) type); CGNSDLL const char *cg_ZoneTypeName(CGNS_ENUMT( ZoneType_t ) type); CGNSDLL const char *cg_RigidGridMotionTypeName(CGNS_ENUMT( RigidGridMotionType_t ) type); CGNSDLL const char *cg_ArbitraryGridMotionTypeName(CGNS_ENUMT( ArbitraryGridMotionType_t ) type); CGNSDLL const char *cg_SimulationTypeName(CGNS_ENUMT( SimulationType_t ) type); CGNSDLL const char *cg_WallFunctionTypeName(CGNS_ENUMT( WallFunctionType_t ) type); CGNSDLL const char *cg_AreaTypeName(CGNS_ENUMT( AreaType_t ) type); CGNSDLL const char *cg_AverageInterfaceTypeName(CGNS_ENUMT( AverageInterfaceType_t ) type); CGNSDLL const char *cg_ParticleGoverningEquationsTypeName(CGNS_ENUMT( ParticleGoverningEquationsType_t ) type); CGNSDLL const char *cg_ParticleModelTypeName(CGNS_ENUMT( ParticleModelType_t ) type); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write CGNSBase_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nbases(int fn, int *nbases); CGNSDLL int cg_base_read(int file_number, int B, char *basename, int *cell_dim, int *phys_dim); CGNSDLL int cg_base_id(int fn, int B, double *base_id); CGNSDLL int cg_base_write(int file_number, const char * basename, int cell_dim, int phys_dim, int *B); CGNSDLL int cg_cell_dim(int fn, int B, int *cell_dim); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Zone_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nzones(int fn, int B, int *nzones); CGNSDLL int cg_zone_read(int fn, int B, int Z, char *zonename, cgsize_t *size); CGNSDLL int cg_zone_type(int file_number, int B, int Z, CGNS_ENUMT(ZoneType_t) *type); CGNSDLL int cg_zone_id(int fn, int B, int Z, double *zone_id); CGNSDLL int cg_zone_write(int fn, int B, const char * zonename, const cgsize_t * size, CGNS_ENUMT(ZoneType_t) type, int *Z); CGNSDLL int cg_index_dim(int fn, int B, int Z, int *index_dim); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Family_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nfamilies(int file_number, int B, int *nfamilies); CGNSDLL int cg_family_read(int file_number, int B, int F, char *family_name, int *nboco, int *ngeos); CGNSDLL int cg_family_write(int file_number, int B, const char * family_name, int *F); CGNSDLL int cg_nfamily_names(int file_number, int B, int F, int *nnames); CGNSDLL int cg_family_name_read(int file_number, int B, int F, int N, char *name, char *family); CGNSDLL int cg_family_name_write(int file_number, int B, int F, const char *name, const char *family); /* FamilyTree extension */ /* ** FAMILY TREE ** */ CGNSDLL int cg_node_family_write( const char* family_name, int* F); CGNSDLL int cg_node_nfamilies( int* nfamilies ); CGNSDLL int cg_node_family_read( int F, char* family_name, int* nFamBC, int *nGeo ); CGNSDLL int cg_node_family_name_write( const char* node_name, const char* family_name ); CGNSDLL int cg_node_nfamily_names( int* nnames ); CGNSDLL int cg_node_family_name_read(int N, char* node_name, char* family_name ); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write FamilyName_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_famname_read(char *family_name); CGNSDLL int cg_famname_write(const char * family_name); CGNSDLL int cg_nmultifam(int *nfams); CGNSDLL int cg_multifam_read(int N, char *name, char *family); CGNSDLL int cg_multifam_write(const char *name, const char *family); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write FamilyBC_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_fambc_read(int file_number, int B, int F, int BC, char *fambc_name, CGNS_ENUMT(BCType_t) *bocotype); CGNSDLL int cg_fambc_write(int file_number, int B, int F, const char * fambc_name, CGNS_ENUMT(BCType_t) bocotype, int *BC); /* FamilyTree extension */ /* ** FAMILY TREE ** */ CGNSDLL int cg_node_fambc_read( int BC, char* fambc_name, CGNS_ENUMT(BCType_t) *bocotype); CGNSDLL int cg_node_fambc_write( const char* fambc_name, CGNS_ENUMT(BCType_t) bocotype, int *BC ); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GeometryReference_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_geo_read(int file_number, int B, int F, int G, char *geo_name, char **geo_file, char *CAD_name, int *npart); CGNSDLL int cg_geo_write(int file_number, int B, int F, const char * geo_name, const char * filename, const char * CADname, int *G); /* FamilyTree extension */ /* ** FAMILY TREE ** */ CGNSDLL int cg_node_geo_read( int G, char *geo_name, char **geo_file, char *CAD_name, int *npart ); CGNSDLL int cg_node_geo_write( const char *geo_name, const char *filename, const char *CADname, int *G); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GeometryEntity_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_part_read(int file_number, int B, int F, int G, int P, char *part_name); CGNSDLL int cg_part_write(int file_number, int B, int F, int G, const char * part_name, int *P); /* FamilyTree extension */ /* ** FAMILY TREE ** */ CGNSDLL int cg_node_part_read(int G, int P, char *part_name); CGNSDLL int cg_node_part_write(int G, const char * part_name, int *P); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridCoordinates_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_ngrids(int file_number, int B, int Z, int *ngrids); CGNSDLL int cg_grid_read(int file_number, int B, int Z, int G, char *gridname); CGNSDLL int cg_grid_write(int file_number, int B, int Z, const char * zcoorname, int *G); CGNSDLL int cg_grid_bounding_box_read(int file_number, int B, int Z, int G, CGNS_ENUMT(DataType_t) type, void* boundingbox); CGNSDLL int cg_grid_bounding_box_write(int file_number, int B, int Z, int G, CGNS_ENUMT(DataType_t) type, void* boundingbox); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridCoordinates_t/DataArray_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_ncoords(int fn, int B, int Z, int *ncoords); CGNSDLL int cg_coord_info(int fn, int B, int Z, int C, CGNS_ENUMT(DataType_t) *type, char *coordname); CGNSDLL int cg_coord_read(int fn, int B, int Z, const char * coordname, CGNS_ENUMT(DataType_t) type, const cgsize_t * rmin, const cgsize_t * rmax, void *coord); CGNSDLL int cg_coord_general_read(int fn, int B, int Z, const char * coordname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, int m_numdim, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *coord_ptr); CGNSDLL int cg_coord_id(int fn, int B, int Z, int C, double *coord_id); CGNSDLL int cg_coord_write(int fn, int B, int Z, CGNS_ENUMT(DataType_t) type, const char * coordname, const void * coord_ptr, int *C); CGNSDLL int cg_coord_partial_write(int fn, int B, int Z, CGNS_ENUMT(DataType_t) type, const char * coordname, const cgsize_t *rmin, const cgsize_t *rmax, const void * coord_ptr, int *C); CGNSDLL int cg_coord_general_write(int fn, int B, int Z, const char *coordname, CGNS_ENUMT(DataType_t) s_type, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, int m_numdim, const cgsize_t *m_dims, const cgsize_t *m_rmin, const cgsize_t *m_rmax, const void *coord_ptr, int *C); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Elements_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nsections(int file_number, int B, int Z, int *nsections); CGNSDLL int cg_section_read(int file_number, int B, int Z, int S, char *SectionName, CGNS_ENUMT(ElementType_t) *type, cgsize_t *start, cgsize_t *end, int *nbndry, int *parent_flag); CGNSDLL int cg_elements_read(int file_number, int B, int Z, int S, cgsize_t *elements, cgsize_t *parent_data); CGNSDLL int cg_poly_elements_read(int file_number, int B, int Z, int S, cgsize_t *elements, cgsize_t *connect_offset, cgsize_t *parent_data); CGNSDLL int cg_section_write(int file_number, int B, int Z, const char * SectionName, CGNS_ENUMT(ElementType_t) type, cgsize_t start, cgsize_t end, int nbndry, const cgsize_t * elements, int *S); CGNSDLL int cg_poly_section_write(int file_number, int B, int Z, const char * SectionName, CGNS_ENUMT(ElementType_t) type, cgsize_t start, cgsize_t end, int nbndry, const cgsize_t * elements, const cgsize_t * connect_offset, int *S); CGNSDLL int cg_section_general_write(int file_number, int B, int Z, const char * SectionName, const CGNS_ENUMT(ElementType_t) type, const CGNS_ENUMT(DataType_t) elementDataType, cgsize_t start, cgsize_t end, cgsize_t elementDataSize, int nbndry, int *S); CGNSDLL int cg_section_initialize(int file_number, int B, int Z, int S); CGNSDLL int cg_parent_data_write(int file_number, int B, int Z, int S, const cgsize_t * parent_data); CGNSDLL int cg_npe( CGNS_ENUMT(ElementType_t) type, int *npe); CGNSDLL int cg_ElementDataSize(int file_number, int B, int Z, int S, cgsize_t *ElementDataSize); CGNSDLL int cg_section_partial_write(int file_number, int B, int Z, const char * SectionName, CGNS_ENUMT(ElementType_t) type, cgsize_t start, cgsize_t end, int nbndry, int *S); CGNSDLL int cg_elements_partial_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *elements); CGNSDLL int cg_elements_general_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, const void *elements); CGNSDLL int cg_poly_elements_partial_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *elements, const cgsize_t *connect_offset); CGNSDLL int cg_poly_elements_general_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, const void *elements, const void *connect_offset); CGNSDLL int cg_parent_data_partial_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *ParentData); CGNSDLL int cg_elements_partial_read(int file_number, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *elements, cgsize_t *parent_data); CGNSDLL int cg_poly_elements_partial_read(int file_number, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *elements, cgsize_t *connect_offset, cgsize_t *parent_data); /* For reading with a datatype different from cgsize_t. Use at your own risk */ CGNSDLL int cg_elements_general_read(int file_number, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* elements); CGNSDLL int cg_poly_elements_general_read(int file_number, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* elements, void* connect_offset); CGNSDLL int cg_parent_elements_general_read(int file_number, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* parelem); CGNSDLL int cg_parent_elements_position_general_read(int file_number, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* parface); CGNSDLL int cg_ElementPartialSize(int file_number, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *ElementDataSize); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write FlowSolution_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nsols(int fn, int B, int Z, int *nsols); CGNSDLL int cg_sol_info(int fn, int B, int Z, int S, char *solname, CGNS_ENUMT(GridLocation_t) *location); CGNSDLL int cg_sol_id(int fn, int B, int Z,int S, double *sol_id); CGNSDLL int cg_sol_write(int fn, int B, int Z, const char * solname, CGNS_ENUMT(GridLocation_t) location, int *S); CGNSDLL int cg_sol_size(int fn, int B, int Z, int S, int *data_dim, cgsize_t *dim_vals); CGNSDLL int cg_sol_ptset_info(int fn, int B, int Z, int S, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts); CGNSDLL int cg_sol_ptset_read(int fn, int B, int Z, int S, cgsize_t *pnts); CGNSDLL int cg_sol_ptset_write(int fn, int B, int Z, const char *solname, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts, int *S); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write solution DataArray_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nfields(int fn, int B, int Z, int S, int *nfields); CGNSDLL int cg_field_info(int fn,int B,int Z,int S, int F, CGNS_ENUMT(DataType_t) *type, char *fieldname); CGNSDLL int cg_field_read(int fn, int B, int Z, int S, const char *fieldname, CGNS_ENUMT(DataType_t) type, const cgsize_t *rmin, const cgsize_t *rmax, void *field_ptr); CGNSDLL int cg_field_general_read(int fn, int B, int Z, int S, const char *fieldname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, int m_numdim, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *field_ptr); CGNSDLL int cg_field_id(int fn, int B, int Z,int S, int F, double *field_id); CGNSDLL int cg_field_write(int fn,int B,int Z,int S, CGNS_ENUMT(DataType_t) type, const char * fieldname, const void * field_ptr, int *F); CGNSDLL int cg_field_partial_write(int fn, int B, int Z, int S, CGNS_ENUMT(DataType_t) type, const char * fieldname, const cgsize_t *rmin, const cgsize_t *rmax, const void * field_ptr, int *F); CGNSDLL int cg_field_general_write(int fn, int B, int Z, int S, const char * fieldname, CGNS_ENUMT(DataType_t) s_type, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, int m_numdim, const cgsize_t *m_dims, const cgsize_t *m_rmin, const cgsize_t *m_rmax, const void *field_ptr, int *F); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ZoneSubRegion_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nsubregs(int fn, int B, int Z, int *nsubreg); CGNSDLL int cg_subreg_info(int fn, int B, int Z, int S, char *regname, int *dimension, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, int *bcname_len, int *gcname_len); CGNSDLL int cg_subreg_ptset_read(int fn, int B, int Z, int S, cgsize_t *pnts); CGNSDLL int cg_subreg_bcname_read(int fn, int B, int Z, int S, char *bcname); CGNSDLL int cg_subreg_gcname_read(int fn, int B, int Z, int S, char *gcname); CGNSDLL int cg_subreg_ptset_write(int fn, int B, int Z, const char *regname, int dimension, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts, int *S); CGNSDLL int cg_subreg_bcname_write(int fn, int B, int Z, const char *regname, int dimension, const char *bcname, int *S); CGNSDLL int cg_subreg_gcname_write(int fn, int B, int Z, const char *regname, int dimension, const char *gcname, int *S); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ZoneGridConnectivity_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nzconns(int fn, int B, int Z, int *nzconns); CGNSDLL int cg_zconn_read(int fn, int B, int Z, int C, char *name); CGNSDLL int cg_zconn_write(int fn, int B, int Z, const char *name, int *C); CGNSDLL int cg_zconn_get(int fn, int B, int Z, int *C); CGNSDLL int cg_zconn_set(int fn, int B, int Z, int C); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write OversetHoles_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nholes(int fn, int B, int Z, int *nholes); CGNSDLL int cg_hole_info(int fn, int B, int Z, int Ii, char *holename, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, int *nptsets, cgsize_t *npnts); CGNSDLL int cg_hole_read(int fn, int B, int Z, int Ii, cgsize_t *pnts); CGNSDLL int cg_hole_id(int fn, int B, int Z, int Ii, double *hole_id); CGNSDLL int cg_hole_write(int fn, int B, int Z, const char * holename, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, int nptsets, cgsize_t npnts, const cgsize_t * pnts, int *Ii); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridConnectivity_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nconns(int fn, int B, int Z, int *nconns); CGNSDLL int cg_conn_info(int file_number, int B, int Z, int Ii, char *connectname, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(GridConnectivityType_t) *type, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, char *donorname, CGNS_ENUMT(ZoneType_t) *donor_zonetype, CGNS_ENUMT(PointSetType_t) *donor_ptset_type, CGNS_ENUMT(DataType_t) *donor_datatype, cgsize_t *ndata_donor); CGNSDLL int cg_conn_read(int file_number, int B, int Z, int Ii, cgsize_t *pnts, CGNS_ENUMT(DataType_t) donor_datatype, cgsize_t *donor_data); CGNSDLL int cg_conn_id(int fn, int B, int Z, int Ii, double *conn_id); CGNSDLL int cg_conn_write(int file_number, int B, int Z, const char * connectname, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(GridConnectivityType_t) type, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts, const char * donorname, CGNS_ENUMT(ZoneType_t) donor_zonetype, CGNS_ENUMT(PointSetType_t) donor_ptset_type, CGNS_ENUMT(DataType_t) donor_datatype, cgsize_t ndata_donor, const cgsize_t *donor_data, int *Ii); CGNSDLL int cg_conn_write_short(int file_number, int B, int Z, const char * connectname, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(GridConnectivityType_t) type, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts, const char * donorname, int *Ii); CGNSDLL int cg_conn_read_short(int file_number, int B, int Z, int Ii, cgsize_t *pnts); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridConnectivity1to1_t Nodes in a zone * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_n1to1(int fn, int B, int Z, int *n1to1); CGNSDLL int cg_1to1_read(int fn, int B, int Z, int Ii, char *connectname, char *donorname, cgsize_t *range, cgsize_t *donor_range, int *transform); CGNSDLL int cg_1to1_id(int fn, int B, int Z, int Ii, double *one21_id); CGNSDLL int cg_1to1_write(int fn, int B, int Z, const char * connectname, const char * donorname, const cgsize_t * range, const cgsize_t * donor_range, const int * transform, int *Ii); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read all GridConnectivity1to1_t Nodes of a base * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_n1to1_global(int fn, int B, int *n1to1_global); CGNSDLL int cg_1to1_read_global(int fn, int B, char **connectname, char **zonename, char **donorname, cgsize_t **range, cgsize_t **donor_range, int **transform); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BC_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nbocos(int fn, int B, int Z, int *nbocos); CGNSDLL int cg_boco_info(int fn, int B, int Z, int BC, char *boconame, CGNS_ENUMT(BCType_t) *bocotype, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, int *NormalIndex, cgsize_t *NormalListSize, CGNS_ENUMT(DataType_t) *NormalDataType, int *ndataset); CGNSDLL int cg_boco_read(int fn, int B, int Z, int BC, cgsize_t *pnts, void *NormalList); CGNSDLL int cg_boco_id(int fn, int B, int Z, int BC, double *boco_id); CGNSDLL int cg_boco_write(int file_number, int B, int Z, const char * boconame, CGNS_ENUMT(BCType_t) bocotype, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts, int *BC); CGNSDLL int cg_boco_normal_write(int file_number, int B, int Z, int BC, const int * NormalIndex, int NormalListFlag, CGNS_ENUMT(DataType_t) NormalDataType, const void * NormalList); CGNSDLL int cg_boco_gridlocation_read(int file_number, int B, int Z, int BC, CGNS_ENUMT(GridLocation_t) *location); CGNSDLL int cg_boco_gridlocation_write(int file_number, int B, int Z, int BC, CGNS_ENUMT(GridLocation_t) location); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BCDataSet_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_dataset_read(int fn, int B, int Z, int BC, int DS, char *name, CGNS_ENUMT(BCType_t) *BCType, int *DirichletFlag, int *NeumannFlag); CGNSDLL int cg_dataset_write(int file_number, int B, int Z, int BC, const char * name, CGNS_ENUMT(BCType_t) BCType, int *Dset); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write FamilyBCDataSet_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_bcdataset_write(const char *name, CGNS_ENUMT(BCType_t) BCType, CGNS_ENUMT(BCDataType_t) BCDataType); CGNSDLL int cg_bcdataset_info(int *n_dataset); CGNSDLL int cg_bcdataset_read(int index, char *name, CGNS_ENUMT(BCType_t) *BCType, int *DirichletFlag, int *NeumannFlag); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BCData_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_bcdata_write(int file_number, int B, int Z, int BC, int Dset, CGNS_ENUMT(BCDataType_t) BCDataType); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write DiscreteData_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_ndiscrete(int file_number, int B, int Z, int *ndiscrete); CGNSDLL int cg_discrete_read(int file_number, int B, int Z, int D, char *discrete_name); CGNSDLL int cg_discrete_write(int file_number, int B, int Z, const char * discrete_name, int *D); CGNSDLL int cg_discrete_size(int fn, int B, int Z, int D, int *data_dim, cgsize_t *dim_vals); CGNSDLL int cg_discrete_ptset_info(int fn, int B, int Z, int D, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts); CGNSDLL int cg_discrete_ptset_read(int fn, int B, int Z, int D, cgsize_t *pnts); CGNSDLL int cg_discrete_ptset_write(int fn, int B, int Z, const char *discrete_name, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts, int *D); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write RigidGridMotion_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_n_rigid_motions(int file_number, int B, int Z, int *n_rigid_motions); CGNSDLL int cg_rigid_motion_read(int file_number, int B, int Z, int R, char *name, CGNS_ENUMT(RigidGridMotionType_t) *type); CGNSDLL int cg_rigid_motion_write(int file_number, int B, int Z, const char * name, CGNS_ENUMT(RigidGridMotionType_t) type, int *R); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ArbitraryGridMotion_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_n_arbitrary_motions(int file_number, int B, int Z, int *n_arbitrary_motions); CGNSDLL int cg_arbitrary_motion_read(int file_number, int B, int Z, int A, char *name, CGNS_ENUMT(ArbitraryGridMotionType_t) *type); CGNSDLL int cg_arbitrary_motion_write(int file_number, int B, int Z, const char * amotionname, CGNS_ENUMT(ArbitraryGridMotionType_t) type, int *A); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write SimulationType_t Node * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_simulation_type_read(int file_number, int B, CGNS_ENUMT(SimulationType_t) *type); CGNSDLL int cg_simulation_type_write(int file_number, int B, CGNS_ENUMT(SimulationType_t) type); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BaseIterativeData_t Node * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_biter_read(int file_number, int B, char *bitername, int *nsteps); CGNSDLL int cg_biter_write(int file_number, int B, const char * bitername, int nsteps); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ZoneIterativeData_t Node * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_ziter_read(int file_number, int B, int Z, char *zitername); CGNSDLL int cg_ziter_write(int file_number, int B, int Z, const char * zitername); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ParticleIterativeData_t Node * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_piter_read(int file_number, int B, int P, char *pitername); CGNSDLL int cg_piter_write(int file_number, int B, int P, const char *pitername); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Gravity_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_gravity_read(int file_number, int B, float *gravity_vector); CGNSDLL int cg_gravity_write(int file_number, int B, float const *gravity_vector); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Axisymmetry_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_axisym_read(int file_number, int B, float *ref_point, float *axis); CGNSDLL int cg_axisym_write(int file_number, int B, float const *ref_point, float const *axis); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write RotatingCoordinates_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_rotating_read(float *rot_rate, float *rot_center); CGNSDLL int cg_rotating_write(float const *rot_rate, float const *rot_center); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BCProperty_t/WallFunction_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_bc_wallfunction_read(int file_number, int B, int Z, int BC, CGNS_ENUMT(WallFunctionType_t) *WallFunctionType); CGNSDLL int cg_bc_wallfunction_write(int file_number, int B, int Z, int BC, CGNS_ENUMT(WallFunctionType_t) WallFunctionType); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write BCProperty_t/Area_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_bc_area_read(int file_number, int B, int Z, int BC, CGNS_ENUMT(AreaType_t) *AreaType, float *SurfaceArea, char *RegionName); CGNSDLL int cg_bc_area_write(int file_number, int B, int Z, int BC, CGNS_ENUMT(AreaType_t) AreaType, float SurfaceArea, const char *RegionName); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridConnectivityProperty_t/Periodic_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_conn_periodic_read(int file_number, int B, int Z, int Ii, float *RotationCenter, float *RotationAngle, float *Translation); CGNSDLL int cg_conn_periodic_write(int file_number, int B, int Z, int Ii, float const *RotationCenter, float const *RotationAngle, float const *Translation); CGNSDLL int cg_1to1_periodic_write(int file_number, int B, int Z, int Ii, float const *RotationCenter, float const *RotationAngle, float const *Translation); CGNSDLL int cg_1to1_periodic_read(int file_number, int B, int Z, int Ii, float *RotationCenter, float *RotationAngle, float *Translation); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridConnectivityProperty_t/AverageInterface_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_conn_average_read(int file_number, int B, int Z, int Ii, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType); CGNSDLL int cg_conn_average_write(int file_number, int B, int Z, int Ii, CGNS_ENUMT(AverageInterfaceType_t) AverageInterfaceType); CGNSDLL int cg_1to1_average_write(int file_number, int B, int Z, int Ii, CGNS_ENUMT(AverageInterfaceType_t) AverageInterfaceType); CGNSDLL int cg_1to1_average_read(int file_number, int B, int Z, int Ii, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ParticleZone_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nparticle_zones(int file_number, int B, int *nparticlezones); CGNSDLL int cg_particle_id(int file_number, int B, int P, double *particle_id); CGNSDLL int cg_particle_read(int file_number, int B, int P, char *particlename, cgsize_t *size); CGNSDLL int cg_particle_write(int file_number, int B, const char* particlename, const cgsize_t size, int *P); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ParticleCoordinates_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_particle_ncoord_nodes(int file_number, int B, int P, int *ncoord_nodes); CGNSDLL int cg_particle_coord_node_read(int file_number, int B, int P, int C, char *name); CGNSDLL int cg_particle_coord_node_write(int file_number, int B, int P, const char *name, int *C); CGNSDLL int cg_particle_bounding_box_read(int fn, int B, int P, int C, CGNS_ENUMT(DataType_t) datatype, void* boundingbox); CGNSDLL int cg_particle_bounding_box_write(int fn, int B, int P, int C, CGNS_ENUMT(DataType_t) datatype, void* boundingbox); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ParticleCoordinates_t/DataArray_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_particle_ncoords(int fn, int B, int P, int *ncoords); CGNSDLL int cg_particle_coord_info(int fn, int B, int P, int C, CGNS_ENUMT(DataType_t) *type, char *coordname); CGNSDLL int cg_particle_coord_read(int fn, int B, int P, const char *coordname, CGNS_ENUMT(DataType_t) type, const cgsize_t * rmin, const cgsize_t * rmax, void *coord); CGNSDLL int cg_particle_coord_general_read(int fn, int B, int P, const char *coordname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *coord_ptr); CGNSDLL int cg_particle_coord_id(int fn, int B, int P, int C, double *coord_id); CGNSDLL int cg_particle_coord_write(int fn, int B, int P, CGNS_ENUMT(DataType_t) type, const char *coordname, const void *coord_ptr, int *C); CGNSDLL int cg_particle_coord_partial_write(int fn, int B, int P, CGNS_ENUMT(DataType_t) type, const char *coordname, const cgsize_t *rmin, const cgsize_t *rmax, const void *coord_ptr, int *C); CGNSDLL int cg_particle_coord_general_write(int fn, int B, int P, const char *coordname, CGNS_ENUMT(DataType_t) s_type, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, const cgsize_t *m_dims, const cgsize_t *m_rmin, const cgsize_t *m_rmax, const void *coord_ptr, int *C); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ParticleSolution_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_particle_nsols(int fn, int B, int P, int *nsols); CGNSDLL int cg_particle_sol_info(int fn, int B, int P, int S, char *solname); CGNSDLL int cg_particle_sol_id(int fn, int B, int P,int S, double *sol_id); CGNSDLL int cg_particle_sol_write(int fn, int B, int P, const char * solname, int *S); CGNSDLL int cg_particle_sol_size(int fn, int B, int P, int S, cgsize_t *size); CGNSDLL int cg_particle_sol_ptset_info(int fn, int B, int P, int S, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts); CGNSDLL int cg_particle_sol_ptset_read(int fn, int B, int P, int S, cgsize_t *pnts); CGNSDLL int cg_particle_sol_ptset_write(int fn, int B, int P, const char *solname, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts, int *S); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write particle solution DataArray_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_particle_nfields(int fn, int B, int P, int S, int *nfields); CGNSDLL int cg_particle_field_info(int fn,int B,int P,int S, int F, CGNS_ENUMT(DataType_t) *type, char *fieldname); CGNSDLL int cg_particle_field_read(int fn, int B, int P, int S, const char *fieldname, CGNS_ENUMT(DataType_t) type, const cgsize_t *rmin, const cgsize_t *rmax, void *field_ptr); CGNSDLL int cg_particle_field_general_read(int fn, int B, int P, int S, const char *fieldname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *field_ptr); CGNSDLL int cg_particle_field_id(int fn, int B, int P,int S, int F, double *field_id); CGNSDLL int cg_particle_field_write(int fn,int B,int P,int S, CGNS_ENUMT(DataType_t) type, const char * fieldname, const void * field_ptr, int *F); CGNSDLL int cg_particle_field_partial_write(int fn, int B, int P, int S, CGNS_ENUMT(DataType_t) type, const char * fieldname, const cgsize_t *rmin, const cgsize_t *rmax, const void * field_ptr, int *F); CGNSDLL int cg_particle_field_general_write(int fn, int B, int P, int S, const char * fieldname, CGNS_ENUMT(DataType_t) s_type, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, const cgsize_t *m_dims, const cgsize_t *m_rmin, const cgsize_t *m_rmax, const void *field_ptr, int *F); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Variable Argument List Functions * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_goto(int file_number, int B, ...); CGNSDLL int cg_goto_f08(int file_number, int B, ...); CGNSDLL int cg_gorel(int file_number, ...); CGNSDLL int cg_gorel_f08(int file_number, ...); CGNSDLL int cg_gopath(int file_number, const char *path); CGNSDLL int cg_golist(int file_number, int B, int depth, char **label, int *num); CGNSDLL int cg_where(int *file_number, int *B, int *depth, char **label, int *num); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ConvergenceHistory_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_convergence_read(int *iterations, char **NormDefinitions); CGNSDLL int cg_convergence_write(int iterations, const char * NormDefinitions); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ReferenceState_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_state_read(char **StateDescription); CGNSDLL int cg_state_write(const char * StateDescription); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write FlowEquationSet_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_equationset_read(int *EquationDimension, int *GoverningEquationsFlag, int *GasModelFlag, int *ViscosityModelFlag, int *ThermalConductivityModelFlag, int *TurbulenceClosureFlag, int *TurbulenceModelFlag); CGNSDLL int cg_equationset_chemistry_read(int *ThermalRelaxationFlag, int *ChemicalKineticsFlag); CGNSDLL int cg_equationset_elecmagn_read(int *ElecFldModelFlag, int *MagnFldModelFlag, int *ConductivityModelFlag); CGNSDLL int cg_equationset_write(int EquationDimension); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ParticleEquationSet_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_particle_equationset_read(int *EquationDimension, int *ParticleGoverningEquationsFlag, int *CollisionModelFlag, int *BreakupModelFlag, int *ForceModelFlag, int *WallInteractionModelFlag, int *PhaseChangeModelFlag); CGNSDLL int cg_particle_equationset_write(int EquationDimension); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GoverningEquations_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_governing_read(CGNS_ENUMT(GoverningEquationsType_t) *EquationsType); CGNSDLL int cg_governing_write(CGNS_ENUMT(GoverningEquationsType_t) Equationstype); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Diffusion Model Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_diffusion_read(int *diffusion_model); CGNSDLL int cg_diffusion_write(const int * diffusion_model); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GasModel_t, ViscosityModel_t, * * ThermalConductivityModel_t, TurbulenceClosure_t, * * TurbulenceModel_t, ThermalRelaxationModel_t, * * ChemicalKineticsModel_t, EMElectricFieldModel_t, * * EMMagneticFieldModel_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_model_read(const char *ModelLabel, CGNS_ENUMT(ModelType_t) *ModelType); CGNSDLL int cg_model_write(const char * ModelLabel, CGNS_ENUMT(ModelType_t) ModelType); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ParticleGoverningEquations_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_particle_governing_read(CGNS_ENUMT(ParticleGoverningEquationsType_t) *ParticleEquationsType); CGNSDLL int cg_particle_governing_write(CGNS_ENUMT(ParticleGoverningEquationsType_t) ParticleEquationstype); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write ParticleCollisionModel_t, * * ParticleBreakupModel_t, ParticleForceModel_t, * * ParticleWallInteractionModel_t and * * ParticlePhaseChangeModel_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_particle_model_read(const char *ModelLabel, CGNS_ENUMT(ParticleModelType_t) *ModelType); CGNSDLL int cg_particle_model_write(const char * ModelLabel, CGNS_ENUMT(ParticleModelType_t) ModelType); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write DataArray_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_narrays(int *narrays); CGNSDLL int cg_array_info(int A, char *ArrayName, CGNS_ENUMT(DataType_t) *DataType, int *DataDimension, cgsize_t *DimensionVector); CGNSDLL int cg_array_read(int A, void *Data); CGNSDLL int cg_array_read_as(int A, CGNS_ENUMT(DataType_t) type, void *Data); CGNSDLL int cg_array_general_read(int A, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, int m_numdim, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *data); CGNSDLL int cg_array_write(const char * ArrayName, CGNS_ENUMT(DataType_t) DataType, int DataDimension, const cgsize_t * DimensionVector, const void * Data); CGNSDLL int cg_array_general_write(const char *arrayname, CGNS_ENUMT(DataType_t) s_type, int s_numdim, const cgsize_t *s_dimvals, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, int m_numdim, const cgsize_t *m_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, const void *data); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write UserDefinedData_t Nodes - new in version 2.1 * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nuser_data(int *nuser_data); CGNSDLL int cg_user_data_read(int Index, char *user_data_name); CGNSDLL int cg_user_data_write(const char * user_data_name); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write IntegralData_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nintegrals(int *nintegrals); CGNSDLL int cg_integral_read(int IntegralDataIndex, char *IntegralDataName); CGNSDLL int cg_integral_write(const char * IntegralDataName); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Rind_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_rind_read(int *RindData); CGNSDLL int cg_rind_write(const int * RindData); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Descriptor_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_ndescriptors(int *ndescriptors); CGNSDLL int cg_descriptor_read(int descr_no, char *descr_name, char **descr_text); CGNSDLL int cg_descriptor_write(const char * descr_name, const char * descr_text); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write DimensionalUnits_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_nunits(int *nunits); CGNSDLL int cg_units_read (CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, CGNS_ENUMT(TemperatureUnits_t) *temperature, CGNS_ENUMT(AngleUnits_t) *angle); CGNSDLL int cg_units_write (CGNS_ENUMT(MassUnits_t) mass, CGNS_ENUMT(LengthUnits_t) length, CGNS_ENUMT(TimeUnits_t) time, CGNS_ENUMT(TemperatureUnits_t) temperature, CGNS_ENUMT(AngleUnits_t) angle); CGNSDLL int cg_unitsfull_read (CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, CGNS_ENUMT(TemperatureUnits_t) *temperature, CGNS_ENUMT(AngleUnits_t) *angle, CGNS_ENUMT(ElectricCurrentUnits_t) *current, CGNS_ENUMT(SubstanceAmountUnits_t) *amount, CGNS_ENUMT(LuminousIntensityUnits_t) *intensity); CGNSDLL int cg_unitsfull_write(CGNS_ENUMT(MassUnits_t) mass, CGNS_ENUMT(LengthUnits_t) length, CGNS_ENUMT(TimeUnits_t) time, CGNS_ENUMT(TemperatureUnits_t) temperature, CGNS_ENUMT(AngleUnits_t) angle, CGNS_ENUMT(ElectricCurrentUnits_t) current, CGNS_ENUMT(SubstanceAmountUnits_t) amount, CGNS_ENUMT(LuminousIntensityUnits_t) intensity); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write DimensionalExponents_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_exponents_info(CGNS_ENUMT(DataType_t) *DataType); CGNSDLL int cg_nexponents(int *numexp); CGNSDLL int cg_exponents_read(void *exponents); CGNSDLL int cg_exponents_write(CGNS_ENUMT(DataType_t) DataType, const void * exponents); CGNSDLL int cg_expfull_read(void *exponents); CGNSDLL int cg_expfull_write(CGNS_ENUMT(DataType_t) DataType, const void * exponents); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write DataConversion_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_conversion_info(CGNS_ENUMT(DataType_t) *DataType); CGNSDLL int cg_conversion_read(void *ConversionFactors); CGNSDLL int cg_conversion_write(CGNS_ENUMT(DataType_t) DataType, const void * ConversionFactors); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write DataClass_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_dataclass_read(CGNS_ENUMT(DataClass_t) *dataclass); CGNSDLL int cg_dataclass_write(CGNS_ENUMT(DataClass_t) dataclass); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write GridLocation_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_gridlocation_read(CGNS_ENUMT(GridLocation_t) *GridLocation); CGNSDLL int cg_gridlocation_write(CGNS_ENUMT(GridLocation_t) GridLocation); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write Ordinal_t Nodes * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_ordinal_read(int *Ordinal); CGNSDLL int cg_ordinal_write(int Ordinal); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Read and write IndexArray/Range_t Nodes - new in version 2.4 * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_ptset_info(CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts); CGNSDLL int cg_ptset_write(CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts); CGNSDLL int cg_ptset_read(cgsize_t *pnts); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Link Handling Functions - new in version 2.1 * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_is_link(int *path_length); CGNSDLL int cg_link_read(char **filename, char **link_path); CGNSDLL int cg_link_write(const char * nodename, const char * filename, const char * name_in_file); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * General Delete Function * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_delete_node(const char *node_name); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Free library malloced memory * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL int cg_free(void *data); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *\ * Error Handling Functions * \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ CGNSDLL const char *cg_get_error(void); CGNSDLL void cg_error_exit(void); CGNSDLL void cg_error_print(void); #ifdef __cplusplus } #endif #endif CGNS-4.5.0/src/cgnstools/000077500000000000000000000000001474000356600150615ustar00rootroot00000000000000CGNS-4.5.0/src/cgnstools/CMakeLists.txt000066400000000000000000000063171474000356600176300ustar00rootroot00000000000000############# # cgnstools # ############# # get X11 in case it is not in a standard location if (NOT WIN32) include(FindX11) find_package(X11 REQUIRED) # Xmu doesn't appear to be included in FindX11 find_library(X11_Xmu_LIB Xmu) if (X11_Xmu_LIB) mark_as_advanced(FORCE X11_Xmu_LIB) endif () endif () if (WIN32) include(FindHTMLHelp) endif () set(Missing "") if (NOT APPLE) include(FindOpenGL) if (OPENGL_FOUND) mark_as_advanced(FORCE OPENGL_INCLUDE_PATH OPENGL_gl_LIBRARY) else () mark_as_advanced(CLEAR OPENGL_INCLUDE_PATH OPENGL_gl_LIBRARY) list(APPEND Missing "OPENGL_gl") endif () if (OPENGL_GLU_FOUND) mark_as_advanced(FORCE OPENGL_glu_LIBRARY) else () mark_as_advanced(CLEAR OPENGL_glu_LIBRARY) list(APPEND Missing "OPENGL_glu") endif () endif () if (X11_FOUND) if (APPLE) find_path (X11_GL_INCLUDE_PATH GL/glx.h ${X11_INC_SEARCH_PATH}) if (NOT X11_GL_INCLUDE_PATH) list(APPEND Missing "GL/glx.h") set (X11_FOUND FALSE) endif () set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_GL_INCLUDE_PATH}) find_library (X11_GL_LIB GL ${X11_LIB_SEARCH_PATH}) if (NOT X11_GL_LIB) list(APPEND Missing "OPENGL_gl") set (X11_FOUND FALSE) endif () find_library (X11_GLU_LIB GLU ${X11_LIB_SEARCH_PATH}) if (NOT X11_GLU_LIB) list(APPEND Missing "OPENGL_glu") set (X11_FOUND FALSE) endif () else () set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}) set (X11_GL_LIB ${OPENGL_gl_LIBRARY}) set (X11_GLU_LIB ${OPENGL_glu_LIBRARY}) endif () endif () include(FindTCL) if (TCL_FOUND) mark_as_advanced(FORCE TCL_INCLUDE_PATH TCL_LIBRARY) else () mark_as_advanced(CLEAR TCL_INCLUDE_PATH TCL_LIBRARY) list(APPEND Missing "TCL") endif () if (TK_FOUND) mark_as_advanced(FORCE TK_INCLUDE_PATH TK_LIBRARY) else () mark_as_advanced(CLEAR TK_INCLUDE_PATH TK_LIBRARY) list(APPEND Missing "TK") endif () if (Missing) message(SEND_ERROR "The path and library needs to be defined for: ${Missing}") else () add_subdirectory(cgnsview) add_subdirectory(calclib) add_subdirectory(cgnscalc) add_subdirectory(cgnsplot) add_subdirectory(common) add_subdirectory(utilities) endif () if (WIN32) file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX} WIN_INSTALL_DIR) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cgconfig.bat "set CG_BIN_DIR=${WIN_INSTALL_DIR}\\bin set CG_LIB_DIR=${WIN_INSTALL_DIR}\\share ") # don't need this since dll is put in the bin directory # if (CGNS_USE_SHARED) # file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cgconfig.bat # "set PATH=${WIN_INSTALL_DIR}\\lib;%PATH%" # ) # endif (CGNS_USE_SHARED) # add Tcl path for dll's if (TK_WISH) get_filename_component(TK_DLL ${TK_WISH} PATH) file(TO_NATIVE_PATH ${TK_DLL} TK_DLL_DIR) file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cgconfig.bat "set PATH=${TK_DLL_DIR};%PATH%" ) endif () install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cgconfig.bat DESTINATION bin) else () file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cgconfig "CG_BIN_DIR=${CMAKE_INSTALL_PREFIX}/bin; export CG_BIN_DIR CG_LIB_DIR=${CMAKE_INSTALL_PREFIX}/share/cgnstools; export CG_LIB_DIR ") install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cgconfig DESTINATION bin) endif () CGNS-4.5.0/src/cgnstools/LICENSE000066400000000000000000000014651474000356600160740ustar00rootroot00000000000000This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. CGNS-4.5.0/src/cgnstools/Makefile.in000066400000000000000000000042301474000356600171250ustar00rootroot00000000000000# makefile to build CGNS tools include make.defs DOMAKE=$(MAKE) -f Makefile.unix # if OGL was not found, cgnsplot will not be included in the # default build, otherwise this target is the same as for all default : @PROGLIST@ install : @INSTLIST@ all : cgnsview cgnscalc cgnsplot utilities install-all : install-cgnsview install-cgnscalc install-cgnsplot \ install-utilities clean : @for d in cgnsview cgnscalc cgnsplot utilities calclib tkogl ; do \ echo "----- $$d -----"; \ cd $$d; $(DOMAKE) clean; cd ..; \ done; allclean : distclean distclean : clean -@$(RM) config.* -@$(RM) make.defs Makefile cgconfig cgnsview : prog-cgnsview cgnscalc : prog-cgnscalc cgnsplot : prog-cgnsplot utilities : prog-utilities uninstall : @for d in cgnsview cgnscalc cgnsplot utilities ; do \ echo "----- $$d -----"; \ cd $$d; $(DOMAKE) uninstall; cd ..; \ done; @if [ -f $(EXE_INSTALL_DIR)/cgconfig ] ; then \ /bin/rm -f $(EXE_INSTALL_DIR)/cgconfig; \ fi; -@if [ -d $(WSH_INSTALL_DIR) ] ; then \ rmdir $(WSH_INSTALL_DIR); \ fi; -@if [ -d $(EXE_INSTALL_DIR) -a \ ! $(EXE_INSTALL_DIR) = $(BIN_INSTALL_DIR) ] ; then \ rmdir $(EXE_INSTALL_DIR); \ fi; -@if [ -d $(LIB_INSTALL_DIR)/help ] ; then \ rmdir $(LIB_INSTALL_DIR)/help; \ fi; -@if [ -d $(LIB_INSTALL_DIR) ] ; then \ rmdir $(LIB_INSTALL_DIR); \ fi; prog-cgnsview : @echo "----- cgnsview -----" @cd cgnsview && $(DOMAKE) prog-cgnscalc : lib-calclib @echo "----- cgnscalc -----" @cd cgnscalc && $(DOMAKE) prog-cgnsplot : lib-tkogl @echo "----- cgnsplot -----" @cd cgnsplot && $(DOMAKE) prog-utilities : lib-calclib @echo "----- utilities -----" @cd utilities && $(DOMAKE) lib-calclib : @echo "----- calclib -----" @cd calclib && $(DOMAKE) lib-tkogl : @echo "----- tkogl -----" @cd tkogl && $(DOMAKE) install-cgnsview : @echo "----- cgnsview -----" @cd cgnsview && $(DOMAKE) install install-cgnscalc : lib-calclib @echo "----- cgnscalc -----" @cd cgnscalc && $(DOMAKE) install install-cgnsplot : lib-tkogl @echo "----- cgnsplot -----" @cd cgnsplot && $(DOMAKE) install install-utilities : lib-calclib @echo "----- utilities -----" @cd utilities && $(DOMAKE) install CGNS-4.5.0/src/cgnstools/calclib/000077500000000000000000000000001474000356600164525ustar00rootroot00000000000000CGNS-4.5.0/src/cgnstools/calclib/CMakeLists.txt000066400000000000000000000005331474000356600212130ustar00rootroot00000000000000########### # calclib # ########### set(calclib_FILES calc.c vec.c vecsym.c) add_library(calclib STATIC ${calclib_FILES}) if (CGNS_USE_SHARED) target_link_libraries(calclib PUBLIC cgns_shared) else () target_link_libraries(calclib PUBLIC cgns_static) endif () if (NOT WIN32) target_link_libraries(calclib PUBLIC m) endif() # Add test CGNS-4.5.0/src/cgnstools/calclib/Makefile.unix000066400000000000000000000016501474000356600210760ustar00rootroot00000000000000# Makefile for Unix/Linux include ../make.defs CALCLIB = libcgnscalc.$(A) COPTS = $(CFLAGS) $(CALCOPTS) -I$(CGNSDIR) lib : $(CALCLIB) all : $(CALCLIB) calctest$(EXE) install : $(CALCLIB) #---------------------------------------------------- $(CALCLIB) : calc.$(O) vec.$(O) vecsym.$(O) $(AR) $@ calc.$(O) vec.$(O) vecsym.$(O) $(RANLIB) $@ #---------------------------------------------------- calctest$(EXE) : calctest.$(O) $(CALCLIB) $(CC) $(LDFLAGS) -o $@ calctest.$(O) $(CALCLIB) \ $(CGNSLIB) $(BUILDLIBS) -lm $(STRIP) $@ calctest.$(O) : calctest.c #--------------------------------------------------- calc.$(O) : calc.c calc.h vecerr.h vec.$(O) : vec.c vec.h vecsym.h vecerr.h vecsym.$(O) : vecsym.c vec.h vecsym.h calc.h : vecsym.h vecsym.h : vec.h #--------------------------------------------------------------- .c.$(O) : $(CC) $(COPTS) -c $< clean: -$(RM) $(CALCLIB) *.$(O) *~ *.bak calctest$(EXE) CGNS-4.5.0/src/cgnstools/calclib/Makefile.win000066400000000000000000000017431474000356600207130ustar00rootroot00000000000000include ..\make.win CALCLIB = cgnscalc.lib COPTS = $(CFLAGS) -I$(CGNSDIR) READ_NODE = -DREAD_NODE lib : $(CALCLIB) all : $(CALCLIB) calctest.exe install : $(CALCLIB) #-------------------------------------------------- $(CALCLIB) : calc.obj vec.obj vecsym.obj $(LINK) /lib /out:$@ calc.obj vec.obj vecsym.obj #-------------------------------------------------- calctest.exe : calctest.obj $(CALCLIB) $(LINK) $(LFLAGS) /out:$@ calctest.obj $(CALCLIB) \ $(CGNSLIB) $(BUILDLIBS) $(CLIBS) calctest.obj : calctest.c #-------------------------------------------------- vec.obj : vec.c vec.h vecsym.h vecerr.h $(CC) $(COPTS) $(MATHERR) -c vec.c vecsym.obj : vecsym.c vec.h vecsym.h calc.obj : calc.c calc.h vecerr.h $(CC) $(COPTS) $(READ_NODE) -c calc.c calc.h : vecsym.h vecsym.h : vec.h #-------------------------------------------------- .c.obj : $(CC) $(COPTS) -Fo$@ -c $< clean: -$(RM) *.obj -$(RM) *.lib -$(RM) *.pdb -$(RM) *.ilk -$(RM) *.bak -$(RM) *.exe CGNS-4.5.0/src/cgnstools/calclib/calc.c000066400000000000000000001144261474000356600175300ustar00rootroot00000000000000#include #include #include #include #include #include "cgnslib.h" #include "calc.h" #include "vecerr.h" #if CGNS_VERSION < 3000 # define Celsius Celcius #endif #ifndef CG_MODE_READ # define CG_MODE_READ MODE_READ # define CG_MODE_MODIFY MODE_MODIFY #endif #ifdef READ_NODE #include "cgns_header.h" #include "cgns_io.h" #endif #ifndef CGNSTYPES_H # define cgsize_t int # define cglong_t long # define cgulong_t unsigned long #endif #ifndef CGNS_ENUMT # define CGNS_ENUMT(e) e # define CGNS_ENUMV(e) e #endif #ifndef CG_MAX_INT32 # define CG_MAX_INT32 0x7FFFFFFF #endif int cgnsFile = 0; /*--- base data ---*/ int NumBases = 0; int cgnsBase; char BaseName[33]; int CellDim, PhyDim; int BaseClass, BaseUnits[5]; /*--- zone data ---*/ int NumZones = 0; int cgnsZone; char ZoneName[33]; int ZoneType; int ZoneDims[6]; int ZoneClass, ZoneUnits[5]; int GridClass, GridUnits[5]; /*--- solution data ---*/ int NumSolns = 0; int cgnsSoln; char SolnName[33]; int SolnLocation; int SolnDims[3], SolnRind[6]; int SolnClass, SolnUnits[5]; /*--- field data ---*/ int NumReference = 0; Variable *reference; int NumCoordinates = 0; Variable *coordinates; int NumVariables = 0; Variable *variables; /*--- local variables ---*/ static int cmdstrlen = 0; static char *cmdstr; static int VectorLen = 100; /* unit specifications */ typedef struct { char *name; int type; int value; } UnitSpec; static UnitSpec unitspec[] = { {"cel", 3, CGNS_ENUMV(Celsius}), {"cen", 1, CGNS_ENUMV(Centimeter}), {"cm", 1, CGNS_ENUMV(Centimeter}), {"c", 3, CGNS_ENUMV(Celsius}), {"d", 4, CGNS_ENUMV(Degree}), {"fa", 3, CGNS_ENUMV(Fahrenheit}), {"fo", 1, CGNS_ENUMV(Foot}), {"ft", 1, CGNS_ENUMV(Foot}), {"f", 3, CGNS_ENUMV(Fahrenheit}), {"g", 0, CGNS_ENUMV(Gram}), {"in", 1, CGNS_ENUMV(Inch}), {"ke", 3, CGNS_ENUMV(Kelvin}), {"ki", 0, CGNS_ENUMV(Kilogram}), {"kg", 0, CGNS_ENUMV(Kilogram}), {"k", 3, CGNS_ENUMV(Kelvin}), {"lb", 0, CGNS_ENUMV(PoundMass}), {"me", 1, CGNS_ENUMV(Meter}), {"mi", 1, CGNS_ENUMV(Millimeter}), {"mm", 1, CGNS_ENUMV(Millimeter}), {"m", 1, CGNS_ENUMV(Meter}), {"p", 0, CGNS_ENUMV(PoundMass}), {"rad", 4, CGNS_ENUMV(Radian}), {"ran", 3, CGNS_ENUMV(Rankine}), {"r", 3, CGNS_ENUMV(Rankine}), {"se", 2, CGNS_ENUMV(Second}), {"sl", 0, CGNS_ENUMV(Slug}), {"s", 2, CGNS_ENUMV(Second}) }; #define NUM_UNITSPEC (sizeof(unitspec)/sizeof(UnitSpec)) /*---------- read_node --------------------------------------------- * read a node from the CGNS file *------------------------------------------------------------------*/ #ifdef READ_NODE static VECDATA *read_node (char *nodename) { cgns_file *cgfile; int n, bytes, dt, cgio; int ndim; cgsize_t np, dims[CGIO_MAX_DIMENSIONS]; char *values; char type[CGIO_MAX_DATATYPE_LENGTH+1]; char errmsg[CGIO_MAX_ERROR_LENGTH+1]; double rootid, nodeid; VECDATA *vd; static struct dataTypes { char *name; int bytes; } data_types[6] = { {"I4", 4}, {"I8", 8}, {"U4", 4}, {"U8", 8}, {"R4", 4}, {"R8", 8} }; /* get node ID for node */ cgfile = cgi_get_file (cgnsFile); cgio = cgfile->cgio; rootid = cgfile->rootid; if (cgio_get_node_id (cgio, rootid, nodename, &nodeid)) { cgio_error_message (errmsg); cgnsCalcFatal (errmsg); } /* get the type of data */ if (cgio_get_data_type (cgio, nodeid, type)) { cgio_error_message (errmsg); cgnsCalcFatal (errmsg); } for (n = 0; n < CGIO_MAX_DATATYPE_LENGTH && type[n]; n++) { if (islower (type[n])) type[n] = toupper (type[n]); } for (bytes = 0, dt = 0; dt < 6; dt++) { if (0 == strncmp (type, data_types[dt].name, 2)) { bytes = data_types[dt].bytes; break; } } if (bytes == 0) { sprintf (errmsg, "can't handle data type %s", type); cgnsCalcFatal (errmsg); } /* get data dimensions */ if (cgio_get_dimensions (cgio, nodeid, &ndim, dims)) { cgio_error_message (errmsg); cgnsCalcFatal (errmsg); } np = 0; if (ndim > 0) { for (np = 1, n = 0; n < ndim; n++) np *= dims[n]; } if (np == 0) cgnsCalcFatal ("no data for node"); if (np > CG_MAX_INT32) cgnsCalcFatal ("exceeded 32-bit integer"); /* read the data */ values = (char *) malloc ((size_t)(np * bytes)); if (NULL == values) cgnsCalcFatal ("malloc failed for node data"); if (cgio_read_all_data_type (cgio, nodeid, type, values)) { cgio_error_message (errmsg); cgnsCalcFatal (errmsg); } if (np == 1) { vd = vec_create (VEC_VALUE, 0, 1); if (dt == 0) { int *data = (int *)values; vd->f.val = (VECFLOAT)*data; } else if (dt == 1) { cglong_t *data = (cglong_t *)values; vd->f.val = (VECFLOAT)*data; } else if (dt == 2) { unsigned int *data = (unsigned int *)values; vd->f.val = (VECFLOAT)*data; } else if (dt == 3) { cgulong_t *data = (cgulong_t *)values; vd->f.val = (VECFLOAT)*data; } else if (dt == 4) { float *data = (float *)values; vd->f.val = (VECFLOAT)*data; } else { double *data = (double *)values; vd->f.val = (VECFLOAT)*data; } } else { vd = vec_create (VEC_VECTOR, (int)np, 1); if (dt == 0) { int *data = (int *)values; for (n = 0; n < np; n++) vd->f.vec[n] = (VECFLOAT)data[n]; } else if (dt == 1) { cglong_t *data = (cglong_t *)values; for (n = 0; n < np; n++) vd->f.vec[n] = (VECFLOAT)data[n]; } else if (dt == 2) { unsigned int *data = (unsigned int *)values; for (n = 0; n < np; n++) vd->f.vec[n] = (VECFLOAT)data[n]; } else if (dt == 3) { cgulong_t *data = (cgulong_t *)values; for (n = 0; n < np; n++) vd->f.vec[n] = (VECFLOAT)data[n]; } else if (dt == 4) { float *data = (float *)values; for (n = 0; n < np; n++) vd->f.vec[n] = (VECFLOAT)data[n]; } else { double *data = (double *)values; for (n = 0; n < np; n++) vd->f.vec[n] = (VECFLOAT)data[n]; } } free (values); return vd; } #endif /*---------- read_units ----------------------------------------------- * read unit specifications *---------------------------------------------------------------------*/ static int read_units (int units[5]) { int n; CGNS_ENUMT(MassUnits_t) mass; CGNS_ENUMT(LengthUnits_t) length; CGNS_ENUMT(TimeUnits_t) time; CGNS_ENUMT(TemperatureUnits_t) temp; CGNS_ENUMT(AngleUnits_t) angle; if (cg_units_read (&mass, &length, &time, &temp, &angle)) { for (n = 0; n < 5; n++) units[n] = 0; return 0; } units[0] = mass; units[1] = length; units[2] = time; units[3] = temp; units[4] = angle; return 1; } /*---------- read_class ----------------------------------------------- * get data class, units and conversion factors *---------------------------------------------------------------------*/ static void read_class (Variable *var, int dataclass, int units[5]) { int i; CGNS_ENUMT(DataType_t) datatype; if (cg_dataclass_read ((CGNS_ENUMT(DataClass_t) *)&var->dataclass)) var->dataclass = dataclass; var->hasunits = read_units (var->units); if (!var->hasunits) { for (i = 0; i < 5; i++) var->units[i] = units[i]; } if (cg_conversion_info (&datatype) || (datatype != CGNS_ENUMV(RealSingle) && datatype != CGNS_ENUMV(RealDouble))) { var->hasconv = 0; var->dataconv[0] = 1.0; var->dataconv[1] = 0.0; } else { var->hasconv = datatype; if (datatype == CGNS_ENUMV(RealSingle)) { float conv[2]; if (cg_conversion_read (conv)) cgnsCalcFatal ((char *)cg_get_error()); for (i = 0; i < 2; i++) var->dataconv[i] = conv[i]; } else { if (cg_conversion_read (var->dataconv)) cgnsCalcFatal ((char *)cg_get_error()); } } if (cg_exponents_info (&datatype) || (datatype != CGNS_ENUMV(RealSingle) && datatype != CGNS_ENUMV(RealDouble))) { var->hasexp = 0; for (i = 0; i < 5; i++) var->exponent[i] = 0.0; } else { var->hasexp = datatype; if (datatype == CGNS_ENUMV(RealSingle)) { float exp[5]; if (cg_exponents_read (exp)) cgnsCalcFatal ((char *)cg_get_error()); for (i = 0; i < 5; i++) var->exponent[i] = exp[i]; } else { if (cg_exponents_read (var->exponent)) cgnsCalcFatal ((char *)cg_get_error()); } } } /*---------- read_reference -------------------------------------------- * read reference conditions *----------------------------------------------------------------------*/ static void read_reference (void) { int n, narrays, na, dim; cgsize_t vec[12]; CGNS_ENUMT(DataType_t) datatype; char name[33]; NumReference = 0; if (cg_goto (cgnsFile, cgnsBase, "ReferenceState_t", 1, "end") || cg_narrays (&narrays) || narrays < 1) return; for (na = 1; na <= narrays; na++) { if (cg_array_info (na, name, &datatype, &dim, vec)) cgnsCalcFatal ((char *)cg_get_error()); if (datatype != CGNS_ENUMV(Character) && dim >= 1 && vec[0] >= 1) NumReference++; } if (!NumReference) return; reference = (Variable *) malloc (NumReference * sizeof(Variable)); if (NULL == reference) cgnsCalcFatal ("malloc failed for reference variables"); for (n = 0, na = 1; na <= narrays; na++) { if (cg_array_info (na, name, &datatype, &dim, vec)) cgnsCalcFatal ((char *)cg_get_error()); if (datatype != CGNS_ENUMV(Character) && dim >= 1 && vec[0] >= 1) { dim *= vec[0]; strcpy (reference[n].name, name); reference[n].type = 0; reference[n].id = na; reference[n].len = dim; reference[n].valid = 1; reference[n].datatype = datatype; if (dim == 1) { reference[n].vd = vec_create (VEC_VALUE, 0, 0); if (cg_array_read_as (na, CGNS_ENUMV(RealDouble), &reference[n].vd->f.val)) cgnsCalcFatal ((char *)cg_get_error()); } else { reference[n].vd = vec_create (VEC_VECTOR, dim, 0); if (cg_array_read_as (na, CGNS_ENUMV(RealDouble), reference[n].vd->f.vec)) cgnsCalcFatal ((char *)cg_get_error()); } if (cg_goto (cgnsFile, cgnsBase, "ReferenceState_t", 1, "DataArray_t", na, "end")) cgnsCalcFatal ((char *)cg_get_error()); read_class (&reference[n], BaseClass, BaseUnits); cg_goto (cgnsFile, cgnsBase, "ReferenceState_t", 1, "end"); n++; } } } /*---------- get_variable ---------------------------------------------- * return variable data - read if necessary *----------------------------------------------------------------------*/ static VECDATA *get_variable (Variable *var) { if (var->vd == NULL) { int n; cgsize_t min[3], max[3]; for (n = 0; n < 3; n++) { min[n] = 1; max[n] = SolnDims[n]; } var->vd = vec_create (VEC_VECTOR, var->len, 0); if (cg_field_read (cgnsFile, cgnsBase, cgnsZone, cgnsSoln, var->name, CGNS_ENUMV(RealDouble), min, max, var->vd->f.vec)) cgnsCalcFatal ((char *)cg_get_error()); } return var->vd; } /*---------- get_coordinate -------------------------------------------- * return coordinate data - read if necessary *----------------------------------------------------------------------*/ static VECDATA *get_coordinate (Variable *var) { if (var->vd == NULL) { int n; cgsize_t min[3], max[3]; for (n = 0; n < 3; n++) { min[n] = 1; max[n] = ZoneDims[n]; } var->vd = vec_create (VEC_VECTOR, var->len, 0); if (cg_coord_read (cgnsFile, cgnsBase, cgnsZone, var->name, CGNS_ENUMV(RealDouble), min, max, var->vd->f.vec)) cgnsCalcFatal ((char *)cg_get_error()); } return var->vd; } /*---------- print_error --------------------------------------------- * print error message on parsing error *--------------------------------------------------------------------*/ static void print_error (int errnum, char *errmsg, int pos, char *str) { printf (errnum < 0 ? "FATAL:" : "ERROR:"); if (NULL != str) { printf ("%s\n ", str); while (pos-- > 0) putchar ('-'); putchar ('^'); } printf ("%s\n", errmsg); } /*---------- get_name ----------------------------------------------- * get symbol name from string *-------------------------------------------------------------------*/ static char *get_name (char **str) { int n; char *p = *str; static char name[SYMNAME_MAXLEN+1]; if (*p == '"') { for (++p, n = 0; n < SYMNAME_MAXLEN && *p; n++) { if (*p == '"') break; name[n] = *p++; } if (*p++ != '"') return NULL; } else if (!isalpha (*p) && *p != '_') return (NULL); else { for (n = 0; n < SYMNAME_MAXLEN && *p; n++) { if (!isalnum(*p) && *p != '_') break; name[n] = *p++; } } name[n] = 0; *str = p; return name; } /*---------- print_symbols ------------------------------------------ * print symbol names *-------------------------------------------------------------------*/ static int print_symbols (VECSYM *sym, void *data) { FILE *fp = (FILE *)data; if (VECSYM_EQUSTR == vecsym_type(sym)) fprintf (fp, "%s{%d}\n", vecsym_name(sym), vecsym_nargs(sym)); else if (VECSYM_MACRO == vecsym_type(sym)) fprintf (fp, "%s<%d>\n", vecsym_name(sym), vecsym_nargs(sym)); else if (VECSYM_FUNC == vecsym_type(sym)) { if (vecsym_nargs(sym) < 0) fprintf (fp, "%s(...)\n", vecsym_name(sym)); else fprintf (fp, "%s(%d)\n", vecsym_name(sym), vecsym_nargs(sym)); } else if (VECSYM_VECTOR == vecsym_type(sym)) fprintf (fp, "%s[%ld]\n", vecsym_name(sym), (long)vecsym_veclen(sym)); else fprintf (fp, "%s\n", vecsym_name(sym)); return 0; } /*---------- delete_units ------------------------------------------- * called when symbol deleted *-------------------------------------------------------------------*/ static void delete_units (VECSYM *sym) { if (vecsym_user(sym) != NULL) free (vecsym_user(sym)); } /*---------- callback ----------------------------------------------- * callback function for vector parser *-------------------------------------------------------------------*/ static VECDATA *callback (int check, char **pp, char **err) { int n, type = 0; char *p = *pp, *name; /* check for reading node data */ #ifdef READ_NODE if (*p == '{') { char nodename[257]; for (n = 0; n < 256; n++) { if (!*++p || *p == '}') break; nodename[n] = *p; } if (n == 256) { *err = "internal node name length exceeded"; return NULL; } if (!n || *p != '}') { *err = "incomplete node name specification"; return NULL; } *pp = ++p; return read_node (nodename); } #endif /* check for reference or coordinate data */ if (*p == '~' || *p == '\'') type = *p++; /* get name */ if ((name = get_name (&p)) != NULL) { /* check for variable */ if (!type) { for (n = 0; n < NumVariables; n++) { if (0 == strcmp (variables[n].name, name)) { *pp = p; return get_variable (&variables[n]); } } } /* check for grid coordinates */ if (type != '~') { for (n = 0; n < NumCoordinates; n++) { if (0 == strcmp (coordinates[n].name, name)) { *pp = p; return get_coordinate (&coordinates[n]); } } } /* check for reference quantity */ if (type != '\'') { for (n = 0; n < NumReference; n++) { if (0 == strcmp (reference[n].name, name)) { *pp = p; return reference[n].vd; } } } } return (NULL); } /*---------- parse_units ------------------------------------------- * get unit specification *------------------------------------------------------------------*/ static Units *parse_units (char **pp) { int n, par, div; char *p = *pp, name[33]; float exp; Units units, *u; UnitSpec *us; for (n = 0; n < 5; n++) { units.units[n] = 0; units.exps[n] = 0.0; } par = div = 0; while (1) { while (*p && isspace (*p)) p++; if (*p == '*' || *p == '-') { p++; continue; } if (*p == '/') { div++; p++; continue; } if (*p == '(') { par++; p++; continue; } if (*p == ')') { if (!par--) return NULL; if (div) div--; p++; continue; } n = 0; while (*p && isalpha (*p)) { if (n < 32) name[n++] = tolower (*p); p++; } if (!n) break; name[n] = 0; for (n = 0; n < NUM_UNITSPEC; n++) { if (name[0] == unitspec[n].name[0]) break; } us = NULL; while (n < NUM_UNITSPEC) { if (name[0] != unitspec[n].name[0]) break; if (!strncmp (name, unitspec[n].name, strlen(unitspec[n].name))) { us = &unitspec[n]; break; } n++; } if (us == NULL) return NULL; while (*p && isspace (*p)) p++; if (*p == '^') { if (1 != sscanf (++p, "%f%n", &exp, &n)) return NULL; for (p += n; *p && isspace(*p); p++) ; } else exp = 1.0; units.units[us->type] = us->value; if (div) { units.exps[us->type] -= exp; if (*p != '-' && div > par) div--; } else units.exps[us->type] += exp; } u = (Units *) malloc (sizeof(Units)); if (u == NULL) cgnsCalcFatal ("malloc failed for unit specification"); for (n = 0; n < 5; n++) { u->units[n] = units.units[n]; u->exps[n] = units.exps[n]; } *pp = p; return u; } /*---------- free_all ---------------------------------------------- * free all data *------------------------------------------------------------------*/ static void free_all (void) { int n; if (NumReference) { for (n = 0; n < NumReference; n++) vec_destroy (reference[n].vd); free (reference); NumReference = 0; } if (NumCoordinates) { for (n = 0; n < NumCoordinates; n++) vec_destroy (coordinates[n].vd); free (coordinates); NumCoordinates = 0; } if (NumVariables) { for (n = 0; n < NumVariables; n++) vec_destroy (variables[n].vd); free (variables); NumVariables = 0; } } /*---------- cgnsCalcFatal ----------------------------------------- * terminate with error message *------------------------------------------------------------------*/ void cgnsCalcFatal (char *errmsg) { cgnsCalcDone (); if (NULL != errmsg && *errmsg) { if (NULL == vec_errhandler) print_error (-1, errmsg, 0, NULL); else (*vec_errhandler) (-1, errmsg, 0, NULL); } exit (-1); } /*---------- cgnsCalcError ----------------------------------------- * print error message *------------------------------------------------------------------*/ void cgnsCalcError (char *errmsg) { if (NULL != errmsg && *errmsg) { if (NULL == vec_errhandler) print_error (0, errmsg, 0, NULL); else (*vec_errhandler) (0, errmsg, 0, NULL); } } /*---------- cgnsCalcReset ----------------------------------------- * reset calculator (symbol table) *------------------------------------------------------------------*/ void cgnsCalcReset (void) { sym_free (); #ifdef EXTERN_FUNCS add_funcs (); #endif VectorLen = 100; } /*---------- cgnsCalcInit ------------------------------------------ * load CGNS file and initialize *------------------------------------------------------------------*/ int cgnsCalcInit (char *cgnsfile, int modify, void (*errhandler)(int,char *,int,char *)) { cgnsCalcDone (); /* set up error handler */ if (NULL == errhandler) vec_errhandler = print_error; else vec_errhandler = errhandler; /* callback to delete unit data */ sym_delfunc = delete_units; /* open CGNS file */ if (modify) { if (cg_open (cgnsfile, CG_MODE_MODIFY, &cgnsFile)) cgnsCalcFatal ("couldn't open file in modify mode"); } else { if (cg_open (cgnsfile, CG_MODE_READ, &cgnsFile)) cgnsCalcFatal ("couldn't open file in read mode"); } if (cg_nbases (cgnsFile, &NumBases)) cgnsCalcFatal ((char *)cg_get_error()); if (NumBases < 1) cgnsCalcFatal ("no bases found in CGNS file"); cgnsCalcBase (1); /* return number of bases */ return NumBases; } /*---------- cgnsCalcDone ------------------------------------------ * close CGNS file *------------------------------------------------------------------*/ void cgnsCalcDone (void) { if (cgnsFile) { cg_close (cgnsFile); cgnsFile = 0; } free_all (); cgnsBase = NumBases = 0; cgnsZone = NumZones = 0; cgnsSoln = NumSolns = 0; } /*---------- cgnsCalcBase ------------------------------------------ * set base for calculations *------------------------------------------------------------------*/ int cgnsCalcBase (int base) { if (base < 1 || base > NumBases) cgnsCalcFatal ("invalid base specified"); if (cg_base_read (cgnsFile, base, BaseName, &CellDim, &PhyDim)) cgnsCalcFatal ((char *)cg_get_error()); free_all (); cgnsBase = base; cgnsZone = NumZones = 0; cgnsSoln = NumSolns = 0; /* read base class and units */ if (cg_goto (cgnsFile, cgnsBase, "end")) cgnsCalcFatal ((char *)cg_get_error()); if (cg_dataclass_read ((CGNS_ENUMT(DataClass_t) *)&BaseClass)) BaseClass = 0; read_units (BaseUnits); /* read reference conditions */ read_reference (); /* get number of zones and initialize */ if (cg_nzones (cgnsFile, cgnsBase, &NumZones)) cgnsCalcFatal ((char *)cg_get_error()); if (NumZones) cgnsCalcZone (1); return NumZones; } /*---------- cgnsCalcZone ------------------------------------------ * set zone for calculations *------------------------------------------------------------------*/ int cgnsCalcZone (int zone) { int n, nc, size = 1; cgsize_t dims[9]; CGNS_ENUMT(DataType_t) datatype; char name[33]; if (zone < 1 || zone > NumZones) cgnsCalcFatal ("invalid zone specified"); if (cg_zone_read (cgnsFile, cgnsBase, zone, ZoneName, dims) || cg_zone_type (cgnsFile, cgnsBase, zone, (CGNS_ENUMT(ZoneType_t) *)&ZoneType)) cgnsCalcFatal ((char *)cg_get_error()); cgnsZone = zone; cgnsSoln = NumSolns = 0; for (n = 0; n < 6; n++) ZoneDims[n] = 1; if (ZoneType == CGNS_ENUMV(Structured)) { for (n = 0; n < CellDim; n++) { ZoneDims[n] = dims[n]; ZoneDims[n+3] = dims[n+CellDim]; size *= dims[n]; } } else if (ZoneType == CGNS_ENUMV(Unstructured)) { ZoneDims[0] = dims[0]; ZoneDims[3] = dims[1]; size = dims[0]; } else cgnsCalcFatal ("invalid zone type"); VectorLen = size; /* free-up previous data */ if (NumCoordinates) { for (n = 0; n < NumCoordinates; n++) vec_destroy (coordinates[n].vd); free (coordinates); NumCoordinates = 0; } if (NumVariables) { for (n = 0; n < NumVariables; n++) vec_destroy (variables[n].vd); free (variables); NumVariables = 0; } /* read zone class and units */ if (cg_goto (cgnsFile, cgnsBase, "Zone_t", cgnsZone, "end")) cgnsCalcFatal ((char *)cg_get_error()); if (cg_dataclass_read ((CGNS_ENUMT(DataClass_t) *)&ZoneClass)) ZoneClass = BaseClass; if (!read_units (ZoneUnits)) { for (n = 0; n < 5; n++) ZoneUnits[n] = BaseUnits[n]; } GridClass = ZoneClass; for (n = 0; n < 5; n++) GridUnits[n] = ZoneUnits[n]; /* get coordinate info */ if (cg_ncoords (cgnsFile, cgnsBase, cgnsZone, &nc)) cgnsCalcFatal ((char *)cg_get_error()); if (nc > 0) { /* read grid class and units */ if (cg_goto (cgnsFile, cgnsBase, "Zone_t", cgnsZone, "GridCoordinates_t", 1, "end")) cgnsCalcFatal ((char *)cg_get_error()); if (cg_dataclass_read ((CGNS_ENUMT(DataClass_t) *)&GridClass)) GridClass = ZoneClass; if (!read_units (GridUnits)) { for (n = 0; n < 5; n++) GridUnits[n] = ZoneUnits[n]; } /* read coordinates */ NumCoordinates = nc; coordinates = (Variable *) malloc (NumCoordinates * sizeof(Variable)); if (NULL == coordinates) cgnsCalcFatal ("malloc failed for coordinate info"); for (n = 0; n < NumCoordinates; n++) { if (cg_coord_info (cgnsFile, cgnsBase, cgnsZone, n+1, &datatype, name)) cgnsCalcFatal ((char *)cg_get_error()); strcpy (coordinates[n].name, name); coordinates[n].type = 1; coordinates[n].id = n + 1; coordinates[n].len = size; coordinates[n].valid = 1; coordinates[n].datatype = datatype; if (cg_goto (cgnsFile, cgnsBase, "Zone_t", cgnsZone, "GridCoordinates_t", 1, "DataArray_t", n+1, "end")) cgnsCalcFatal ((char *)cg_get_error()); read_class (&coordinates[n], GridClass, GridUnits); coordinates[n].vd = NULL; } } /* get number of solutions and initialize */ if (cg_nsols (cgnsFile, cgnsBase, cgnsZone, &NumSolns)) cgnsCalcFatal ((char *)cg_get_error()); if (NumSolns) cgnsCalcSoln (1); return NumSolns; } /*---------- cgnsCalcSoln ------------------------------------------ * set solution for calculations *------------------------------------------------------------------*/ int cgnsCalcSoln (int soln) { int i, n, size, nflds; CGNS_ENUMT(DataType_t) datatype; char name[33]; if (soln < 1 || soln > NumSolns) cgnsCalcFatal ("invalid solution specified"); if (cg_sol_info (cgnsFile, cgnsBase, cgnsZone, soln, SolnName, (CGNS_ENUMT(GridLocation_t) *)&SolnLocation)) cgnsCalcFatal ((char *)cg_get_error()); cgnsSoln = soln; for (n = 0; n < 3; n++) SolnDims[n] = 1; if (ZoneType == CGNS_ENUMV(Structured)) { size = 1; if (SolnLocation == CGNS_ENUMV(CellCenter)) { if (cg_goto (cgnsFile, cgnsBase, "Zone_t", cgnsZone, "FlowSolution_t", cgnsSoln, "end")) cgnsCalcFatal ((char *)cg_get_error()); if (cg_rind_read (SolnRind)) { for (n = 0; n < 6; n++) SolnRind[n] = 0; } for (i = 0, n = 0; n < CellDim; n++, i += 2) { SolnDims[n] = ZoneDims[n] - 1 + SolnRind[i] + SolnRind[i+1]; size *= SolnDims[n]; } } else { for (n = 0; n < 6; n++) SolnRind[n] = 0; for (n = 0; n < CellDim; n++) { SolnDims[n] = ZoneDims[n]; size *= SolnDims[n]; } } } else { for (n = 0; n < 6; n++) SolnRind[n] = 0; size = SolnLocation == CGNS_ENUMV(CellCenter) ? ZoneDims[3] : ZoneDims[0]; SolnDims[0] = size; } VectorLen = size; /* free-up previous data */ if (NumVariables) { for (n = 0; n < NumVariables; n++) vec_destroy (variables[n].vd); free (variables); NumVariables = 0; } /* read solution class and units */ if (cg_goto (cgnsFile, cgnsBase, "Zone_t", cgnsZone, "FlowSolution_t", cgnsSoln, "end")) cgnsCalcFatal ((char *)cg_get_error()); if (cg_dataclass_read ((CGNS_ENUMT(DataClass_t) *)&SolnClass)) SolnClass = ZoneClass; if (!read_units (SolnUnits)) { for (n = 0; n < 5; n++) SolnUnits[n] = ZoneUnits[n]; } /* get field info */ if (cg_nfields (cgnsFile, cgnsBase, cgnsZone, cgnsSoln, &nflds)) cgnsCalcFatal ((char *)cg_get_error()); if (nflds > 0) { NumVariables = nflds; variables = (Variable *) malloc (NumVariables * sizeof(Variable)); if (NULL == variables) cgnsCalcFatal ("malloc failed for field info"); for (n = 0; n < NumVariables; n++) { if (cg_field_info (cgnsFile, cgnsBase, cgnsZone, cgnsSoln, n+1, &datatype, name)) cgnsCalcFatal ((char *)cg_get_error()); strcpy (variables[n].name, name); variables[n].type = 2; variables[n].id = n + 1; variables[n].len = size; variables[n].valid = 1; variables[n].datatype = datatype; if (cg_goto (cgnsFile, cgnsBase, "Zone_t", cgnsZone, "FlowSolution_t", cgnsSoln, "DataArray_t", n+1, "end")) cgnsCalcFatal ((char *)cg_get_error()); read_class (&variables[n], SolnClass, SolnUnits); variables[n].vd = NULL; } } return NumVariables; } /*---------- cgnsCalcCheck ----------------------------------------- * check expression *------------------------------------------------------------------*/ int cgnsCalcCheck (char *expression) { int length = (int)strlen (expression); char *p, *cmd, *name; Units *units; if (length > cmdstrlen) { if (cmdstrlen == 0) { cmdstrlen = length > 256 ? length : 256; cmdstr = (char *) malloc (cmdstrlen + 1); } else { cmdstrlen = length + 32; cmdstr = (char *) realloc (cmdstr, cmdstrlen + 1); } if (cmdstr == NULL) cgnsCalcFatal ("malloc failed for cmdstr"); } cmd = strcpy (cmdstr, expression); for (p = cmd + strlen(cmd) - 1; p >= cmd && isspace(*p); p--) ; *++p = 0; while (*cmd && isspace(*cmd)) cmd++; if (!*cmd) return (0); p = cmd; if ((name = get_name (&p)) != NULL) { int nargs = -1; char *equ; for (equ = p; *equ && isspace(*equ); equ++) ; /* check for units */ if ('[' == *equ) { equ++; units = parse_units (&equ); if (units == NULL || *equ != ']') { cgnsCalcError ("bad units specification"); if (units != NULL) free (units); return 0; } free (units); while (*++equ && isspace (*equ)) ; if (!*equ) { if (find_symbol (name, 0) != NULL) return 1; } } /* check for equation */ if ('(' == *equ) { char *arg = equ; while (*++arg && (isspace (*arg) || isdigit(*arg))) ; if (')' == *arg) { nargs = atoi (equ + 1); for (equ = arg+1; *equ && isspace (*equ); equ++) ; } } if ('=' == *equ && '=' != *++equ) { for (cmd = equ; *cmd && isspace(*cmd); cmd++) ; if (nargs > 9) { cgnsCalcError ("invalid number of equation arguments"); return 0; } } } return vec_check (cmd, VectorLen, callback); } /*---------- cgnsCalcCommand --------------------------------------- * parse expression and return results *------------------------------------------------------------------*/ VECSYM *cgnsCalcCommand (char *expression) { int n, length = (int)strlen (expression); char *p, *cmd, *name, sym[SYMNAME_MAXLEN+1]; VECDATA *vd; Units *units = NULL; if (length > cmdstrlen) { if (cmdstrlen == 0) { cmdstrlen = length > 256 ? length : 256; cmdstr = (char *) malloc (cmdstrlen + 1); } else { cmdstrlen = length + 32; cmdstr = (char *) realloc (cmdstr, cmdstrlen + 1); } if (cmdstr == NULL) cgnsCalcFatal ("malloc failed for cmdstr"); } cmd = strcpy (cmdstr, expression); /* skip leading and trailing space */ for (p = cmd + strlen(cmd) - 1; p >= cmd && isspace(*p); p--) ; *++p = 0; while (*cmd && isspace(*cmd)) cmd++; /* empty string */ if (!*cmd) return (NULL); /* check for defining a new symbol */ p = cmd; strcpy (sym, "_temp_"); if ((name = get_name (&p)) != NULL) { int nargs = -1; char *equ; for (equ = p; *equ && isspace(*equ); equ++) ; /* check for units */ if ('[' == *equ) { equ++; units = parse_units (&equ); if (units == NULL || *equ != ']') { cgnsCalcError ("bad units specification"); if (units != NULL) free (units); return (NULL); } while (*++equ && isspace (*equ)) ; if (!*equ) { VECSYM *symbol = find_symbol (name, 0); if (symbol != NULL) { if (vecsym_user(symbol) != NULL) free (vecsym_user(symbol)); vecsym_user(symbol) = units; return (symbol); } } } /* check for equation */ if ('(' == *equ) { char *arg = equ; while (*++arg && (isspace (*arg) || isdigit(*arg))) ; if (')' == *arg) { nargs = atoi (equ + 1); for (equ = arg+1; *equ && isspace (*equ); equ++) ; } } if ('=' == *equ && '=' != *++equ) { strcpy (sym, name); for (cmd = equ; *cmd && isspace(*cmd); cmd++) ; /* add equation as string */ if (nargs >= 0) { if (nargs > 9) { cgnsCalcError ("invalid number of equation arguments"); return (NULL); } n = sym_addequ (sym, nargs, cmd, units); if (n) { cgnsCalcError (sym_errmsg (n)); return (NULL); } return (find_symbol (sym, 1)); } } } vd = vec_parse (cmd, VectorLen, callback); if (NULL == vd) { if (NULL != units) free (units); return (NULL); } /* add to symbol table */ if (VEC_VALUE == vd->type) n = sym_addval (sym, vd->f.val, units); else n = sym_addvec (sym, vd->len, vd->f.vec, units); vec_destroy (vd); if (!n) return (find_symbol (sym, 0)); cgnsCalcError (sym_errmsg (n)); return (NULL); } /*---------- cgnsCalcVarGet ---------------------------------------- * return a variable *------------------------------------------------------------------*/ Variable *cgnsCalcVarGet (char *varname) { int n, type = 0; char *name = varname; if (name == NULL || !*name) return NULL; if (*name == '~' || *name == '\'') type = *name++; /* check for variable */ if (!type) { for (n = 0; n < NumVariables; n++) { if (0 == strcmp (variables[n].name, name)) return &variables[n]; } } /* check for grid coordinates */ if (type != '~') { for (n = 0; n < NumCoordinates; n++) { if (0 == strcmp (coordinates[n].name, name)) return &coordinates[n]; } } /* check for reference quantity */ if (type != '\'') { for (n = 0; n < NumReference; n++) { if (0 == strcmp (reference[n].name, name)) return &reference[n]; } } return NULL; } /*---------- cgnsCalcVarList --------------------------------------- * print variables *------------------------------------------------------------------*/ void cgnsCalcVarList (FILE *fp) { int n; if (NULL == fp) fp = stdout; if (NumReference) { fprintf (fp, "=== Reference ===\n"); for (n = 0; n < NumReference; n++) { if (reference[n].len > 1) fprintf (fp, "~%s[%d]\n", reference[n].name, reference[n].len); else fprintf (fp, "~%s\n", reference[n].name); } } if (NumCoordinates) { fprintf (fp, "=== Coordinates ===\n"); for (n = 0; n < NumCoordinates; n++) fprintf (fp, "'%s[%d]\n", coordinates[n].name, coordinates[n].len); } if (NumVariables) { fprintf (fp, "=== Solution ===\n"); for (n = 0; n < NumVariables; n++) fprintf (fp, "%s[%d]\n", variables[n].name, variables[n].len); } } /*---------- cgnsCalcSymList --------------------------------------- * print list of symbols *------------------------------------------------------------------*/ void cgnsCalcSymList (FILE *fp) { if (NULL == fp) fp = stdout; fprintf (fp, "=== Symbols ===\n"); sym_list (0, print_symbols, fp); } CGNS-4.5.0/src/cgnstools/calclib/calc.h000066400000000000000000000057171474000356600175370ustar00rootroot00000000000000#ifndef _CALC_H_ #define _CALC_H_ #include #include "vecsym.h" extern int cgnsFile; /*--- base data ---*/ extern int NumBases, cgnsBase; extern char BaseName[33]; extern int CellDim, PhyDim; extern int BaseClass, BaseUnits[5]; /*--- zone data ---*/ extern int NumZones, cgnsZone; extern char ZoneName[33]; extern int ZoneType, ZoneDims[6]; extern int ZoneClass, ZoneUnits[5]; extern int GridClass, GridUnits[5]; /*--- solution data ---*/ extern int NumSolns, cgnsSoln; extern char SolnName[33]; extern int SolnLocation; extern int SolnDims[3], SolnRind[6]; extern int SolnClass, SolnUnits[5]; /*--- solution field data ---*/ typedef struct { int units[5]; float exps[5]; } Units; typedef struct { char name[33]; int type; int id; int valid; int len; int datatype; int dataclass; int hasunits; int units[5]; int hasconv; double dataconv[2]; int hasexp; double exponent[5]; VECDATA *vd; } Variable; /*----- variables -----*/ extern Variable *variables; extern int NumVariables; /*----- reference conditions -----*/ extern Variable *reference; extern int NumReference; /*----- mesh -----*/ extern Variable *coordinates; extern int NumCoordinates; /*----- external functions -----*/ #ifdef EXTERN_FUNCS extern void add_funcs ( void ); #endif /*----- functions -----*/ void cgnsCalcFatal ( /* terminate with error message */ char *errmsg /* error message */ ); void cgnsCalcError ( /* print error message */ char *errmsg /* error message */ ); void cgnsCalcReset ( /* reset calculator (symbol table) */ void ); int cgnsCalcInit ( /* load CGNS file and initialize */ char *cgnsfile, /* CGNS file */ int modify, /* set for modify mode */ void (*errhandler)( /* calculator error callback */ int errnum, /* error number */ char *errmsg, /* error message */ int pos, /* location in string */ char *str /* string being parsed */ ) ); void cgnsCalcDone ( /* close CGNS file */ void ); int cgnsCalcBase ( /* set base for calculations */ int base /* base number */ ); int cgnsCalcZone ( /* set zone for calculations */ int zone /* zone number */ ); int cgnsCalcSoln ( /* set solution for calculations */ int soln /* solution number */ ); int cgnsCalcCheck ( /* parse command and check for errors */ char *expression /* expression to be parsed */ ); VECSYM *cgnsCalcCommand (/* parse command string and return results */ char *expression /* expression to be parsed */ ); Variable *cgnsCalcVarGet (/* return a variable */ char *varname ); void cgnsCalcVarList ( /* print variables */ FILE *fp /* output file (NULL gives stdout) */ ); void cgnsCalcSymList ( /* print list of symbols */ FILE *fp /* output file (NULL gives stdout) */ ); #endif /* _CALC_H_ */ CGNS-4.5.0/src/cgnstools/calclib/calctest.c000066400000000000000000000251401474000356600204220ustar00rootroot00000000000000#include #include #include #include #include #include "calc.h" static int verbose = 0; static int recurs = 0; static char buff[1025]; static char errmsg[513]; /*===================================================================== * main *=====================================================================*/ #define PROMPT "\n$ " static char *commands[] = { "cmd = execute command 'cmd'", "> cmd = execute command 'cmd' with output", "< cmdfile = read command file 'cmdfile'", "& cgnsfile = load CGNS file 'cgnsfile'", "%> = turn on output", "%< = turn off output", "%% = reset calculator", "%b base = set base number 'base'", "%z zone = set zone number 'zone'", "%s soln = set solution number 'soln'", "?n = list number of bases,zones and solutions", "?[rcvsi] = list Reference,Coordinates,Variables,Symbols,Intrinsics", "?% = show base,zone,solution and output state", "** = exit", NULL }; /*---------- next_line ---------------------------------------------- * return next input line, handling blanks, comments and continuations *-------------------------------------------------------------------*/ static char *next_line (FILE *fp) { int n = 0, len; char *p, line[257]; while (fgets (line, sizeof(line), fp) != NULL) { line[sizeof(line)-1] = 0; p = line + strlen(line); while (--p >= line && isspace(*p)) ; *++p = 0; for (p = line; *p && isspace(*p); p++) ; if (!*p) continue; strcpy (buff, p); n = strlen (buff); while (buff[n-1] == '\\') { for (n -= 2; n >= 0 && isspace(buff[n]); n--) ; buff[++n] = 0; if (fgets (line, sizeof(line), fp) == NULL) break; line[sizeof(line)-1] = 0; p = line + strlen(line); while (--p >= line && isspace(*p)) ; *++p = 0; for (p = line; *p && isspace(*p); p++) ; if (!*p) break; len = strlen (p); if (n + len >= sizeof(buff)) cgnsCalcFatal ("internal command buffer length exceeded"); strcpy (&buff[n], p); n += len; } if ((p = strchr (buff, '#')) != NULL) *p = 0; for (p = buff+strlen(buff)-1; p >= buff && isspace(*p); p--) ; *++p = 0; for (p = buff; *p && isspace(*p); p++) ; if (*p) return (p); } return (NULL); } /*---------- process_command --------------------------------------- * extract prefix/suffix and process command *------------------------------------------------------------------*/ static void process_command (char *expression) { int echo = verbose; char *p, *cmd = expression; VECSYM *sym; /* skip leading and trailing space */ for (p = cmd + strlen(cmd) - 1; p >= cmd && isspace(*p); p--) ; *++p = 0; while (*cmd && isspace(*cmd)) cmd++; if (!*cmd) return; /* check for echo */ if (*cmd == '>') { echo = 1; while (*++cmd && isspace (*cmd)) ; } /* empty string */ if (!*cmd) { if (echo) putchar ('\n'); return; } /* evaluate the expression */ if (NULL == (sym = cgnsCalcCommand (cmd)) || !echo) return; /* value */ if (vecsym_type(sym) == VECSYM_VALUE) { printf ("%s = %g\n", vecsym_name(sym), vecsym_value(sym)); return; } /* vector */ if (vecsym_type(sym) == VECSYM_VECTOR) { int n, len = vecsym_veclen(sym); VECFLOAT vmin, vmax, *vec = vecsym_vector(sym); vmin = vmax = *vec; for (n = 1; n < len; n++) { if (vmin > vec[n]) vmin = vec[n]; if (vmax < vec[n]) vmax = vec[n]; } printf ("%s = %d:%g->%g\n", vecsym_name(sym), len, vmin, vmax); return; } /* equation or macro */ if (vecsym_type(sym) == VECSYM_EQUSTR || vecsym_type(sym) == VECSYM_MACRO) { printf ("%s(%d) %s %s\n", vecsym_name(sym), vecsym_nargs(sym), vecsym_type(sym) == VECSYM_MACRO ? ":=" : "=", vecsym_equstr(sym)); } } /*---------- parse_commands --------------------------------------------- * process command lines *-----------------------------------------------------------------------*/ static void parse_commands (FILE *fp, char *pmt) { int n, len; char *p; if (++recurs == 10) cgnsCalcFatal ("too many recursions"); while (1) { if (NULL != pmt && *pmt) printf (pmt); if ((p = next_line (fp)) == NULL) break; /* quit */ if (*p == '*') { if (*++p == '*') { cgnsCalcDone (); exit (0); } continue; } /* set output */ else if (*p == '%') { switch (*++p) { case '>': verbose = 1; break; case '<': verbose = 0; break; case '%': cgnsCalcReset (); break; case 'b': n = atoi (++p); if (n < 1 || n > NumBases) { sprintf (errmsg, "base %d invalid\n", n); cgnsCalcError (errmsg); } else cgnsCalcBase (n); break; case 'z': n = atoi (++p); if (n < 1 || n > NumZones) { sprintf (errmsg, "zone %d invalid\n", n); cgnsCalcError (errmsg); } else cgnsCalcZone (n); break; case 's': n = atoi (++p); if (n < 1 || n > NumSolns) { sprintf (errmsg, "solution %d invalid\n", n); cgnsCalcError (errmsg); } else cgnsCalcSoln (n); break; } continue; } /* help */ if (*p == '?') { if (!*++p) { for (n = 0; commands[n] != NULL; n++) printf ("%s\n", commands[n]); continue; } while (*p) { switch (*p) { case 'n': printf ("number of bases = %d\n", NumBases); printf (" zones = %d\n", NumZones); printf (" solns = %d\n", NumSolns); break; case 'r': printf ("=== Reference ===\n"); for (n = 0; n < NumReference; n++) { if (reference[n].len > 1) printf ("%s[%d]\n", reference[n].name, reference[n].len); else printf ("%s\n", reference[n].name); } break; case 'c': printf ("=== Coordinates ===\n"); for (n = 0; n < NumCoordinates; n++) printf ("%s[%d]\n", coordinates[n].name, coordinates[n].len); break; case 'v': printf ("=== Solution ===\n"); for (n = 0; n < NumVariables; n++) printf ("%s[%d]\n", variables[n].name, variables[n].len); break; case 'i': { char **in = vec_list (); printf ("=== Intrinsics ===\n"); for (n = 0; in[n] != NULL; n++) printf ("%s\n", in[n]); break; } case 's': cgnsCalcSymList (stdout); break; case '%': printf ("current base = %d\n", cgnsBase); printf (" zone = %d\n", cgnsZone); printf (" soln = %d\n", cgnsSoln); printf ("output is %s\n", verbose ? "on" : "off"); break; default: break; } p++; } continue; } /* load CGNS file */ if (*p == '&') { while (*++p && isspace(*p)) ; if (!*p) continue; if (access (p, 0)) { sprintf (errmsg, "results file <%s> does not exist", p); cgnsCalcError (errmsg); } else cgnsCalcInit (p, 0, NULL); continue; } /* load command file */ if (*p == '<') { FILE *file; while (*++p && isspace (*p)) ; if (!*p) continue; if (access (p, 0)) { sprintf (errmsg, "command file <%s> does not exist", p); cgnsCalcError (errmsg); } else if ((file = fopen (p, "r")) == NULL) { sprintf (errmsg, "couldn't open command file <%s>", p); cgnsCalcError (errmsg); } else { parse_commands (file, NULL); fclose (file); } continue; } /* process command */ process_command (p); } recurs--; } /*================================================================*/ int main (int argc, char *argv[]) { int n = 1; if (n < argc) { cgnsCalcInit (argv[n++], 0, NULL); if (n < argc) { FILE *fp = fopen (argv[n], "r"); if (NULL == fp) { sprintf (errmsg, "couldn't open command file <%s>", argv[n]); cgnsCalcFatal (errmsg); } parse_commands (fp, NULL); } } if (isatty(fileno(stdin)) && isatty(fileno(stdout))) { putchar ('\n'); for (n = 0; commands[n] != NULL; n++) printf ("%s\n", commands[n]); parse_commands (stdin, PROMPT); } else parse_commands (stdin, NULL); cgnsCalcDone (); return 0; } CGNS-4.5.0/src/cgnstools/calclib/vec.c000066400000000000000000002030371474000356600174000ustar00rootroot00000000000000/* * vec.c - array processor for an equation */ #include #include #include #include #include #include #include #include #include "vec.h" #include "vecsym.h" #define INCLUDE_ERRDATA #include "vecerr.h" /*----- machine dependent defines -----*/ #ifndef SIGNAL #define SIGNAL void #endif /* #ifndef sgi #define USE_MATHERR #endif */ #ifndef SIG_ERR # ifdef BADSIG # define SIG_ERR BADSIG # else # define SIG_ERR ((SIGNAL (*)())-1) # endif #endif /*----- defined data values -----*/ #define STACK_INC 50 /* amount to increase size of op stack */ #define MAX_ARGS 9 /* maximum function arguments */ #define E 2.71828182845904523536 #ifndef PI # define PI 3.14159265358979323846 #endif #define TOLERANCE 0.0000000001 #define OPERATORS "^*/%+-<>=!&|?:),]" enum Tokens { /* operation tokens */ OP_NEGATE = 1, OP_POWER, OP_MULTIPLY, OP_DIVIDE, OP_MODULUS, OP_PLUS, OP_MINUS, OP_LESS, OP_LESS_EQ, OP_GREATER, OP_GREATER_EQ, OP_EQUALS, OP_NOT_EQUAL, OP_AND, OP_OR, OP_NOT, OP_IF, OP_ELSE, OP_ENDIF, OP_BEGIN_FUNC, OP_NOP, OP_VECTOR, OP_NUMBER, OP_INTEGER, OP_INDEX, OP_COUNTER, /* function tokens */ FUNC_ABS, FUNC_ACOS, FUNC_ACOSH, FUNC_ASIN, FUNC_ASINH, FUNC_ATAN, FUNC_ATAN2, FUNC_ATANH, FUNC_CEIL, FUNC_COS, FUNC_COSH, FUNC_DEG, FUNC_EXP, FUNC_FACT, FUNC_FLOOR, FUNC_LOG, FUNC_LOG10, FUNC_MOD, FUNC_POW, FUNC_POW10, FUNC_RAD, FUNC_RAND, FUNC_ROUND, FUNC_SIN, FUNC_SINH, FUNC_SQR, FUNC_SQRT, FUNC_TAN, FUNC_TANH, FUNC_AVG, FUNC_MAX, FUNC_MIN, FUNC_SUM, FUNC_SIZE, FUNC_LEN }; /*----- operation stack -----*/ struct op_stack_ { int op; size_t len; union { int ival; double num; VECFLOAT *vec; } op_val; }; static struct op_stack_ *op_start; /* operation stack */ static int op_size = 0; /* current size of operation stack */ static int op_pos; /* current position in stack */ static int op_index; /* counter for processing */ /*----- variable stack -----*/ static double *var_stack; /* processing stack */ static int var_size = 0; /* size of processing stack */ static int var_pos; /* current position in stack */ /*----- constant values -----*/ static double constants[] = { #define CONSTANT_E 0 E, #define CONSTANT_PI 1 PI, #define CONSTANT_TOL 2 TOLERANCE }; #define CONSTANT_DIM 3 /*----- intrinsic symbol table -----*/ #define VEC_ACROSS 0 #define VEC_ALONG 1 #define VEC_VARIABLE 2 static struct intrinsic_ { char *name; int type; int nargs; int op; } intrinsics[] = { {"abs", VEC_ACROSS, 1, FUNC_ABS }, {"acos", VEC_ACROSS, 1, FUNC_ACOS }, {"acosh", VEC_ACROSS, 1, FUNC_ACOSH }, {"asin", VEC_ACROSS, 1, FUNC_ASIN }, {"asinh", VEC_ACROSS, 1, FUNC_ASINH }, {"atan", VEC_ACROSS, 1, FUNC_ATAN }, {"atan2", VEC_ACROSS, 2, FUNC_ATAN2 }, {"atanh", VEC_ACROSS, 1, FUNC_ATANH }, {"avg", VEC_ALONG, 1, FUNC_AVG }, {"ceil", VEC_ACROSS, 1, FUNC_CEIL }, {"cos", VEC_ACROSS, 1, FUNC_COS }, {"cosh", VEC_ACROSS, 1, FUNC_COSH }, {"deg", VEC_ACROSS, 1, FUNC_DEG }, {"dim", CONSTANT_DIM, 0, OP_NUMBER }, {"e", CONSTANT_E, 0, OP_NUMBER }, {"exp", VEC_ACROSS, 1, FUNC_EXP }, {"fact", VEC_ACROSS, 1, FUNC_FACT }, {"floor", VEC_ACROSS, 1, FUNC_FLOOR }, {"index", VEC_VARIABLE, 0, OP_COUNTER }, {"len", VEC_ALONG, 1, FUNC_LEN }, {"log", VEC_ACROSS, 1, FUNC_LOG }, {"log10", VEC_ACROSS, 1, FUNC_LOG10 }, {"mag", VEC_ALONG, 1, FUNC_SIZE }, {"max", VEC_ALONG, 1, FUNC_MAX }, {"min", VEC_ALONG, 1, FUNC_MIN }, {"mod", VEC_ACROSS, 2, FUNC_MOD }, {"pi", CONSTANT_PI, 0, OP_NUMBER }, {"pow", VEC_ACROSS, 2, FUNC_POW }, {"pow10", VEC_ACROSS, 1, FUNC_POW10 }, {"rad", VEC_ACROSS, 1, FUNC_RAD }, {"rand", VEC_ACROSS, 0, FUNC_RAND }, {"round", VEC_ACROSS, 1, FUNC_ROUND }, {"sin", VEC_ACROSS, 1, FUNC_SIN }, {"sinh", VEC_ACROSS, 1, FUNC_SINH }, {"sqr", VEC_ACROSS, 1, FUNC_SQR }, {"sqrt", VEC_ACROSS, 1, FUNC_SQRT }, {"sum", VEC_ALONG, 1, FUNC_SUM }, {"tan", VEC_ACROSS, 1, FUNC_TAN }, {"tanh", VEC_ACROSS, 1, FUNC_TANH }, {"tol", CONSTANT_TOL, 0, OP_NUMBER } }; #define NUM_INTRINSICS sizeof(intrinsics)/sizeof(struct intrinsic_) /*----- list of intrinsics -----*/ static char *in_list[] = { "Intrinsic operators in order of precedence:", "Operator Type Operators", "-------------------------", "Expression () const func()", "Unary - !", "Exponential ^ **", "Multiplicative * / %", "Additive + -", "Relational < <= > >= == !=", "Logical &[&] |[|] ?:", "", "Defined constants:", "Name Value", "---------------------", "pi 3.14159265358979323846", "e 2.71828182845904523536", "tol 0.0000000001", "index current array index", "dim minimum array len", " any constant", "", "Defined functions:", "Name Operation", "-------------------------", "abs() absolute value", "acos() arc cosine (radians)", "acosh() arc hyperbolic cosine", "asin() arc sine (radians)", "asinh() arc hyperbolic sine", "atan() arc tangent (radians)", "atanh() arc hyperbolic tangent", "avg() average value in a vector", "ceil() next largest integer", "cos() cosine (radians)", "cosh() hyperbolic cosine", "deg() convert from radians to degrees", "exp() power of e", "fact() factorial of a number", "floor() next smallest integer", "len() length of a vector", "log() natural log", "log10() base 10 log", "size() magnitude of a vector", "max() maximum value in a vector", "min() minimum value in a vector", "pow10() power of 10", "rad() convert from degrees to radians", "rand() random number between 0 and 1", "round() round a number to integer", "sin() sine (radians)", "sinh() hyperbolic sine", "sqr() square a number", "sqrt() take square root of a number", "sum() sum of values in a vector", "tan() tangent (radians)", "tanh() hyperbolic tangent", NULL }; /*----- error handling -----*/ int vec_maxerr = VECERR_INVALID; int vec_errnum = 0; void (*vec_errhandler)(int,char *,int,char *) = NULL; typedef SIGNAL (*SIGHANDLER)(int); /*----- temporary vectors -----*/ typedef struct veclist_ { VECDATA *v; struct veclist_ *prev; } VECLIST; static VECLIST *veclist = NULL; /*----- defined macros -----*/ #define advance(amt) exp_ptr+=(amt) #define skip_space(p) while(*(p) && isspace(*(p)))(p)++ #define skip_int(p) while(*(p) && isdigit(*(p)))(p)++ /*----- parsing data -----*/ static int num_calls = 0; /* recursion counter */ static int max_calls = VEC_MAXCALLS;/* maximum recursive calls */ static size_t max_len = 0; /* maximum vector length */ static size_t counter_len = 0; /* min length of counter */ static VECCALL usr_func; /* pointer to user supplied function */ static char *exp_start = NULL; /* start of string being parsed */ static char *exp_ptr; /* location in string being parsed */ static SIGHANDLER old_fpe_sig; /* old SIGFPE handler */ static jmp_buf env_ptr; /* environment for return from longjmp() */ static int nest_level; /* nesting count for if-then-else */ static int vec_op; /* doing operations on array lengths */ static int num_args = 0; /* number arguments for equation */ static VECDATA *arglist[MAX_ARGS];/* equation argument list */ static int checking = 0; /* set if checking equation only */ /*----- function prototypes -----*/ static VECDATA *parse(); static void *handle_error(); static void clean_up(); static int do_intrinsic(); static int do_symbol(); static int get_args(); static void chk_index(); static void add_op(); static void logical(); static void relational(); static void additive(); static void multiplicative(); static void exponential(); static void unary(); static void expression(); static void push_var(); static void pop_var(); static double process_op(); static SIGNAL fpe_err (int signum); /*================================================================== * user callable routines *==================================================================*/ /*---------- vec_create -------------------------------------------- * creates a vector data structure *------------------------------------------------------------------*/ VECDATA *vec_create (int type, size_t len, int temp) { VECDATA *vdata; if (type == VEC_VECTOR) { if (len < 1 && temp >= 0) return (handle_error (VECERR_ZEROLEN)); } else if (type == VEC_VALUE) len = 0; else return (handle_error (VECERR_VECTYPE)); vdata = (VECDATA *) calloc (1, sizeof(VECDATA)); if (vdata == NULL) return (handle_error (VECERR_MALLOC)); if (len && temp >= 0) { vdata->f.vec = (VECFLOAT *) calloc (len, sizeof(VECFLOAT)); if (vdata->f.vec == NULL) { free (vdata); return (handle_error (VECERR_MALLOC)); } } else vdata->f.vec = NULL; vdata->type = type; vdata->len = len; /* add to temporary list */ if (temp) { VECLIST *vl = (VECLIST *) malloc (sizeof(VECLIST)); if (vl == NULL) { if (len) free (vdata->f.vec); free (vdata); return (handle_error (VECERR_MALLOC)); } vl->v = vdata; vl->prev = veclist; veclist = vl; } return (vdata); } /*---------- vec_destroy ------------------------------------------- * destroys a vector data structure *------------------------------------------------------------------*/ void vec_destroy (VECDATA *vdata) { if (vdata != NULL) { vec_remove (vdata); if (vdata->type == VEC_VECTOR && vdata->f.vec != NULL) free (vdata->f.vec); free (vdata); } } /*---------- vec_add ----------------------------------------------- * add vector to temporary vector list *------------------------------------------------------------------*/ int vec_add (VECDATA *vd) { VECLIST *vl = veclist; if (vd == NULL) return (0); /* check if already in list */ while (vl != NULL) { if (vl->v == vd) return (1); vl = vl->prev; } /* it's not, so add it */ if ((vl = (VECLIST *) malloc (sizeof(VECLIST))) == NULL) return (0); vl->v = vd; vl->prev = veclist; veclist = vl; return (1); } /*---------- vec_remove -------------------------------------------- * remove temporary vector from list *------------------------------------------------------------------*/ void vec_remove (VECDATA *vd) { VECLIST *prev, *vlist = veclist; if (vd == NULL || vlist == NULL) return; if (vlist->v == vd) { veclist = vlist->prev; free (vlist); return; } prev = vlist->prev; while (prev != NULL) { if (prev->v == vd) { vlist->prev = prev->prev; free (prev); return; } vlist = prev; prev = vlist->prev; } } /*---------- vec_free ---------------------------------------------- * releases internal resources *------------------------------------------------------------------*/ void vec_free (void) { /* free operation stack */ if (op_size) { op_size = 0; free (op_start); } /* free variable stack */ if (var_size) { var_size = 0; free (var_stack); } } /*---------- vec_maxcalls ------------------------------------------ * sets maximum recursive calls *------------------------------------------------------------------*/ void vec_maxcalls (int val) { max_calls = val > 0 ? val : VEC_MAXCALLS; } /*---------- vec_errmsg -------------------------------------------- * returns error message *------------------------------------------------------------------*/ char *vec_errmsg (void) { if (vec_errnum < 0 || vec_errnum >= VECERR_INVALID) vec_errnum = VECERR_INVALID; return (err_msg[vec_errnum]); } /*---------- vec_list ---------------------------------------------- * return list of intrinsics *------------------------------------------------------------------*/ char **vec_list (void) { return (in_list); } /*---------- vec_parse --------------------------------------------- * parse and process equation string *------------------------------------------------------------------*/ VECDATA *vec_parse (char *str, int min_len, VECCALL func) { VECDATA *vd; size_t old_len = counter_len; VECCALL old_func = usr_func; char *old_ptr = exp_ptr; char *old_start = exp_start; /* is there a string ? */ exp_start = NULL; if (str != NULL) skip_space (str); if (str == NULL || !*str) return (handle_error (VECERR_NOEXPR)); /* create operation stack if not done */ if (op_size == 0) { op_start = (struct op_stack_ *) malloc (STACK_INC * sizeof(struct op_stack_)); if (op_start == NULL) return (handle_error (VECERR_OP_STK)); op_size = STACK_INC; } /* create processing stack if not already done */ if (var_size == 0) { var_stack = (double *) malloc (STACK_INC * sizeof(double)); if (var_stack == NULL) return (handle_error (VECERR_VAR_STK)); var_size = STACK_INC; } /* install the SIGFPE handler */ if (num_calls == 0) { checking = op_pos = var_pos = op_index = 0; max_len = 0; old_fpe_sig = signal (SIGFPE, fpe_err); vec_randinit ((int) time (NULL)); /* jump here on parsing error */ vec_errnum = setjmp (env_ptr); if (vec_errnum != 0) { clean_up (); return (handle_error (vec_errnum)); } } usr_func = func; exp_ptr = str; exp_start = str; counter_len = min_len > 0 ? min_len : 1; vd = parse (); if (*exp_ptr) longjmp (env_ptr, VECERR_MISSING); vec_remove (vd); if (num_calls == 0) clean_up (); else { counter_len = old_len; usr_func = old_func; exp_ptr = old_ptr; exp_start = old_start; } return (vd); } /*---------- vec_check --------------------------------------------- * parse equation string and check for errors *------------------------------------------------------------------*/ size_t vec_check (char *str, int min_len, VECCALL func) { VECDATA *vd; size_t len; size_t old_len = counter_len; VECCALL old_func = usr_func; char *old_ptr = exp_ptr; char *old_start = exp_start; /* is there a string ? */ exp_start = NULL; if (str != NULL) skip_space (str); if (str == NULL || !*str) { handle_error (VECERR_NOEXPR); return (0); } /* create operation stack if not done */ if (op_size == 0) { op_start = (struct op_stack_ *) malloc (STACK_INC * sizeof(struct op_stack_)); if (op_start == NULL) { handle_error (VECERR_OP_STK); return (0); } op_size = STACK_INC; } /* create processing stack if not already done */ if (var_size == 0) { var_stack = (double *) malloc (STACK_INC * sizeof(double)); if (var_stack == NULL) { handle_error (VECERR_VAR_STK); return (0); } var_size = STACK_INC; } /* install the SIGFPE handler */ if (num_calls == 0) { checking = 1; max_len = op_pos = var_pos = op_index = 0; old_fpe_sig = signal (SIGFPE, fpe_err); vec_randinit ((int) time (NULL)); /* jump here on parsing error */ vec_errnum = setjmp (env_ptr); if (vec_errnum != 0) { clean_up (); handle_error (vec_errnum); return (0); } } usr_func = func; exp_ptr = str; exp_start = str; counter_len = min_len > 0 ? min_len : 1; vd = parse (); if (*exp_ptr) longjmp (env_ptr, VECERR_MISSING); len = vd->len ? vd->len : 1; if (num_calls == 0) clean_up (); else { counter_len = old_len; usr_func = old_func; exp_ptr = old_ptr; exp_start = old_start; } return (len); } /*=================================================================== * support routines callable by user *===================================================================*/ /*---------- vec_number -------------------------------------------- * gets a double and advances string pointer * This is similar to 'strtod, but I know what it's doing * Expects a number of the form : * [whitespace][{+|-}][digits][.digits][{d|D|e|E}[sign]digits] *------------------------------------------------------------------*/ int vec_number (double *dval, char **sp) { register char *p, c; char *start; int point = 0; p = start = *sp; *dval = 0.0; /* skip whitespace */ while (*p && isspace (*p)) p++; /* get to first required digit */ if (*p == '-' || *p == '+') p++; if (*p == '.') { point++; p++; } /* next character needs to be digit */ if (!*p || !isdigit (*p)) return (0); /* get past the number */ while (*p && (isdigit (*p) || *p == '.')) { if (*p == '.') { if (point) { *p = 0; *dval = (double) atof (*sp); *p = '.'; *sp = p; return (1); } point++; } p++; } *sp = p; /* check for an exponent */ if (*p == 'd' || *p == 'D' || *p == 'e' || *p == 'E') { if (*++p == '+' || *p == '-') p++; if (isdigit (*p)) { while (*++p && isdigit (*p)) ; *sp = p; } } c = **sp; **sp = 0; *dval = atof (start); **sp = c; return (1); } /*------------------------------------------------------------------- * system independent random number generator from Kluth *-------------------------------------------------------------------*/ #define MBIG 1000000000 #define MSEED 161803398 static int Rand_ext = 0; static int Rand_extp = 31; static long Rand_ma[56] = { 0,473269125,708359770,742015427, 65602533,275831218, 24831226, 897336983,199633574,555982024,514994949,279315436,156002375,334914356, 270182445,993586635,796323046,222779050,530019863,240216188,246247465, 251350083, 27923555, 17362715,286349234,561741882, 61883183, 25293241, 182316584,384320687, 97284929,343171996,939345275,385350967,340911449, 606343026,885561620,105803147,288011295,407490891,632823362,921005485, 393546951,638589878,430524660, 1651896,884594510,251198018,883223679, 254238950,266438063,664142955,409571047,306976444,378529592,649134132 }; /*---------- vec_randinit ------------------------------------------- * initialize the random number generator *-------------------------------------------------------------------*/ void vec_randinit (int seed) { int i, k; long mj, mk; mj = MSEED - (seed < 0 ? -seed : seed); mj %= MBIG; Rand_ma[55] = mj; mk = 1; for (i = 1; i <= 54; i++) { k = (21 * i) % 55; Rand_ma[k] = mk; mk = mj - mk; if (mk < 0) mk += MBIG; mj = Rand_ma[k]; } for (k = 1; k <= 4; k++) { for (i = 1; i <= 55; i++) { Rand_ma[i] -= Rand_ma[1+(i+30) % 55]; if (Rand_ma[i] < 0) Rand_ma[i] += MBIG; } } Rand_ext = 0; Rand_extp = 31; } /*---------- vec_rand ----------------------------------------------- * return random number between 0 and 1 *-------------------------------------------------------------------*/ double vec_rand (void) { long mj; if (++Rand_ext == 56) Rand_ext = 1; if (++Rand_extp == 56) Rand_extp = 1; mj = Rand_ma[Rand_ext] - Rand_ma[Rand_extp]; if (mj < 0) mj += MBIG; Rand_ma[Rand_ext] = mj; return ((double) mj / (double) MBIG); } /*================================================================== * parsing routines *==================================================================*/ /*---------- parse -------------------------------------------------- * does the parsing and evaluation of the string *-------------------------------------------------------------------*/ static VECDATA *parse () { size_t n; size_t cur_len = max_len; int cur_op = op_pos; int cur_index = op_index; int cur_var = var_pos; VECDATA *vd; if (++num_calls == max_calls) longjmp (env_ptr, VECERR_CALLS); max_len = 0; logical (); skip_space (exp_ptr); if (checking) { if (max_len == 1) vd = vec_create (VEC_VALUE, 0, -1); else vd = vec_create (VEC_VECTOR, max_len, -1); } else { vd = vec_create (VEC_VECTOR, max_len, 1); /* process the variables */ for (n = 0; n < max_len; n++) { var_pos = cur_var; op_index = cur_op; nest_level = vec_op = 0; vd->f.vec[n] = (VECFLOAT)process_op (n); } if (max_len == 1) { VECFLOAT f = vd->f.vec[0]; free (vd->f.vec); vd->type = VEC_VALUE; vd->len = 0; vd->f.val = f; } } max_len = cur_len; op_pos = cur_op; op_index = cur_index; var_pos = cur_var; num_calls--; return (vd); } /*---------- handle_error ------------------------------------------- * handle error message *-------------------------------------------------------------------*/ static void *handle_error (err) int err; { int pos = -1; char *str = exp_start; if (num_calls) longjmp (env_ptr, vec_errnum); if (err < 0 || err >= VECERR_INVALID) vec_errnum = VECERR_INVALID; else vec_errnum = err; exp_start = NULL; if (str != NULL) { pos = (int) (exp_ptr - str); if (pos < 0 || pos > (int)strlen (str)) { pos = -1; str = NULL; } } if (vec_errhandler != NULL) (*vec_errhandler) (vec_errnum, err_msg[vec_errnum], pos, str); else { if (str != NULL) { fprintf (stderr, "%s\n", str); while (pos-- > 0) putc ('-', stderr); putc ('^', stderr); } fprintf (stderr, "%s\n", err_msg[vec_errnum]); } return (NULL); } /*---------- reset_recurs ------------------------------------------ * reset recursion flags for equation symbols - called from sym_list *------------------------------------------------------------------*/ static int reset_recurs (VECSYM *sym, void *userdata) { if (vecsym_nargs(sym) < 0) vecsym_nargs(sym) = 0; return (0); } /*---------- clean_up ---------------------------------------------- * clean up on error or parsing completion *------------------------------------------------------------------*/ static void clean_up () { VECLIST *prev; if (old_fpe_sig != SIG_ERR) signal (SIGFPE, old_fpe_sig); (void) sym_list (VECSYM_EQUSTR, reset_recurs, NULL); while (veclist != NULL) { prev = veclist->prev; if (veclist->v->type == VEC_VECTOR && veclist->v->f.vec != NULL) free (veclist->v->f.vec); free (veclist->v); free (veclist); veclist = prev; } num_calls = num_args = 0; } /*---------- do_intrinsic ------------------------------------------ * process an intrinsic variable *------------------------------------------------------------------*/ static int do_intrinsic () { char c, *p = exp_ptr; int lo, hi, n, m; struct intrinsic_ *ins; if (!isalpha (*p)) return (0); while (*++p && (isalnum (*p) || *p == '_')) ; c = *p; *p = 0; lo = 0; hi = NUM_INTRINSICS - 1; n = hi / 2; ins = &intrinsics[n]; while (1) { if ((m = strcmp (exp_ptr, ins->name)) == 0) break; if (lo >= hi) break; if (m < 0) hi = n - 1; else lo = n + 1; n = (lo + hi) / 2; ins = &intrinsics[n]; } *p = c; if (m) return (0); exp_ptr = p; if (ins->op == OP_NUMBER) { if (ins->type == CONSTANT_DIM) { double dval = counter_len; add_op (OP_NUMBER, &dval); } else add_op (OP_NUMBER, &constants[ins->type]); } else if (ins->type == VEC_VARIABLE) add_op (ins->op, NULL); else if (ins->type == VEC_ALONG) { size_t msave = max_len; add_op (OP_BEGIN_FUNC, NULL); (void) get_args (ins->nargs); add_op (ins->op, NULL); max_len = msave ? msave : 1; } else { (void) get_args (ins->nargs); add_op (ins->op, NULL); } return (1); } /*---------- get_args ---------------------------------------------- * extracts arguments for intrinsic function *------------------------------------------------------------------*/ static int get_args (nargs) int nargs; { int n = 0; skip_space (exp_ptr); if (*exp_ptr != '(') longjmp (env_ptr, VECERR_FUNC); advance (1); skip_space (exp_ptr); if (*exp_ptr == ')') { if (nargs > 0) longjmp (env_ptr, VECERR_ARGS); advance (1); return (0); } while (1) { skip_space (exp_ptr); logical (); n++; skip_space (exp_ptr); if (*exp_ptr == ')') break; if (*exp_ptr == ',') { if (n == nargs) longjmp (env_ptr, VECERR_ARGS); if (n == FUNC_MAXARGS) longjmp (env_ptr, VECERR_MAXARGS); advance (1); } else longjmp (env_ptr, VECERR_ARGS); } if (nargs > 0 && n != nargs) longjmp (env_ptr, VECERR_ARGS); advance (1); return (n); } /*---------- do_symbol --------------------------------------------- * processes a user symbol *------------------------------------------------------------------*/ static int do_symbol () { int c, is_func; char symname[SYMNAME_MAXLEN+2], *p = exp_ptr; VECSYM *sym; /* check for replaceable argument */ if (*p == '$') { if (*++p && isdigit (*p)) { c = *p - '1'; if (c < 0 || c >= num_args) longjmp (env_ptr, VECERR_EQUARG); exp_ptr = p; advance (1); if (arglist[c]->type == VEC_VALUE) { double dval = arglist[c]->f.val; add_op (OP_NUMBER, &dval); } else if (arglist[c]->type == VEC_VECTOR) add_op (OP_VECTOR, arglist[c]); else longjmp (env_ptr, VECERR_VECTYPE); return (1); } return (0); } /* get symbol name */ if (*p == '\\') p++; if (!*p || (!isalpha (*p) && *p != '_' && *p != '"')) return (0); symname[0] = '.'; if (*p == '"') { for (++p, c = 1; c <= SYMNAME_MAXLEN; c++) { if (!*p || *p == '"') break; symname[c] = *p++; } if (*p++ != '"') return 0; } else { for (c = 1; c <= SYMNAME_MAXLEN; c++) { symname[c] = *p++; if (!*p || (!isalnum (*p) && *p != '_')) break; } } if (c > SYMNAME_MAXLEN) return (0); symname[++c] = 0; /* check if function */ while (*p && isspace (*p)) p++; is_func = *p == '('; /* find symbol */ if (*exp_ptr == '\\' || (sym = find_symbol (symname, is_func)) == NULL) sym = find_symbol (&symname[1], is_func); /*--- symbol not found ---*/ if (sym == NULL) return (0); /*--- value ---*/ if (vecsym_type(sym) == VECSYM_VALUE) { double val = vecsym_value(sym); add_op (OP_NUMBER, &val); exp_ptr = p; return (1); } /*--- vector ---*/ if (vecsym_type(sym) == VECSYM_VECTOR) { VECDATA vdat; exp_ptr = p; vdat.len = vecsym_veclen(sym); vdat.f.vec = vecsym_vector(sym); chk_index (&vdat); return (1); } /*--- equation ---*/ if (vecsym_type(sym) == VECSYM_EQUSTR) { char *s; int nargs = 0; VECDATA *vd[9], *vtmp; if (vecsym_nargs(sym) < 0) longjmp (env_ptr, VECERR_RECURSE); if (vecsym_nargs(sym) == 0) { vecsym_nargs(sym) = -1; if (is_func) { p++; skip_space (p); if (*p != ')') longjmp (env_ptr, VECERR_PAREN); p++; } } else { exp_ptr = p; if (*exp_ptr++ != '(') longjmp (env_ptr, VECERR_FUNC); skip_space (exp_ptr); while (*exp_ptr && *exp_ptr != ')') { if (nargs == vecsym_nargs(sym)) longjmp (env_ptr, VECERR_MAXARGS); vd[nargs++] = parse (); if (*exp_ptr == ',') advance (1); skip_space (exp_ptr); } if (*exp_ptr != ')' || nargs != vecsym_nargs(sym)) longjmp (env_ptr, VECERR_ARGS); advance (1); p = exp_ptr; } for (c = 0; c < 9; c++) { vtmp = arglist[c]; arglist[c] = vd[c]; vd[c] = vtmp; } c = nargs; nargs = num_args; num_args = c; s = exp_start; exp_start = exp_ptr = vecsym_equstr(sym); logical (); if (*exp_ptr) longjmp (env_ptr, VECERR_MISSING); if (vecsym_nargs(sym) < 0) vecsym_nargs(sym) = 0; exp_start = s; exp_ptr = p; num_args = nargs; for (c = 0; c < num_args; c++) arglist[c] = vd[c]; return (1); } /*--- function ---*/ if (vecsym_type(sym) == VECSYM_FUNC) { int nargs = 0; VECDATA *vd[FUNC_MAXARGS+1]; exp_ptr = p; if (*exp_ptr++ != '(') longjmp (env_ptr, VECERR_FUNC); skip_space (exp_ptr); if (*exp_ptr != ')') { while (1) { vd[nargs] = parse (); if (++nargs > FUNC_MAXARGS) longjmp (env_ptr, VECERR_MAXARGS); if (*exp_ptr == ',') advance (1); else if (*exp_ptr != ')') longjmp (env_ptr, VECERR_ARGS); else break; } } advance (1); if (vecsym_nargs(sym) >= 0 && vecsym_nargs(sym) != nargs) longjmp (env_ptr, VECERR_ARGS); p = NULL; vd[nargs] = (*vecsym_func(sym)) (checking, nargs, vd, &p); if (vd[nargs] == NULL) { if (p == NULL || !*p) longjmp (env_ptr, VECERR_SYMBOL); else { err_msg[VECERR_USER] = p; longjmp (env_ptr, VECERR_USER); } } if (vd[nargs]->type == VEC_VALUE) { double dval = vd[nargs]->f.val; add_op (OP_NUMBER, &dval); } else if (vd[nargs]->type == VEC_VECTOR) add_op (OP_VECTOR, vd[nargs]); else longjmp (env_ptr, VECERR_VECTYPE); for (c = 0; c < nargs; c++) vec_destroy (vd[c]); return (1); } /*--- unknown ---*/ return (0); } /*---------- chk_index --------------------------------------------- * check for a vector index *------------------------------------------------------------------*/ static void chk_index (vdata) VECDATA *vdata; { if (*exp_ptr == '[') { advance (1); logical (); skip_space (exp_ptr); if (*exp_ptr != ']') longjmp (env_ptr, VECERR_BRACKET); advance (1); add_op (OP_INDEX, NULL); if (max_len <= 1) { add_op (OP_VECTOR, vdata); max_len = 1; return; } } add_op (OP_VECTOR, vdata); } /*---------- do_userfunc ------------------------------------------- * call user routine *------------------------------------------------------------------*/ static int do_userfunc () { char *p, *s; double dval; VECDATA *vd; if (usr_func == NULL) return (0); p = exp_ptr; s = NULL; if ((vd = (*usr_func) (checking, &p, &s)) == NULL) { if (s == NULL || !*s) return (0); err_msg[VECERR_USER] = s; longjmp (env_ptr, VECERR_USER); } if (p <= exp_ptr) longjmp (env_ptr, VECERR_POINTER); exp_ptr = p; if (vd->type == VEC_VALUE) { dval = vd->f.val; add_op (OP_NUMBER, (void *)&dval); } else if (vd->type == VEC_VECTOR) { skip_space (exp_ptr); chk_index (vd); } else longjmp (env_ptr, VECERR_VECTYPE); return (1); } /*---------- add_op ------------------------------------------------ * adds operation to the stack *------------------------------------------------------------------*/ static void add_op (op, op_val) int op; void *op_val; { if (op_pos >= op_size) { op_size += STACK_INC; op_start = (struct op_stack_ *) realloc (op_start, op_size * sizeof(struct op_stack_)); if (op_start == NULL) longjmp (env_ptr, VECERR_OP_STK); } switch (op) { case OP_INTEGER: op_start[op_pos].len = 1; op_start[op_pos].op_val.ival = *((int *)op_val); break; case OP_NUMBER: op_start[op_pos].len = 1; op_start[op_pos].op_val.num = *((double *)op_val); break; case OP_VECTOR: { VECDATA *vdat = (VECDATA *)op_val; op_start[op_pos].len = vdat->len; op_start[op_pos].op_val.vec = vdat->f.vec; /* if (counter_len < vdat->len)*/ counter_len = vdat->len; break; } case OP_INDEX: case FUNC_RAND: op_start[op_pos].len = 1; break; case OP_COUNTER: op_start[op_pos].len = counter_len; break; default: op_start[op_pos].len = 0; break; } op_start[op_pos].op = op; if (max_len < op_start[op_pos].len) max_len = op_start[op_pos].len; op_pos++; } /*---------- logical ----------------------------------------------- * evaluates logical operations *------------------------------------------------------------------*/ static void logical () { relational (); while (1) { skip_space (exp_ptr); if (*exp_ptr == '?') { advance (1); add_op (OP_IF, NULL); logical (); skip_space (exp_ptr); if (*exp_ptr != ':') longjmp (env_ptr, VECERR_IFELSE); advance (1); add_op (OP_ELSE, NULL); logical (); add_op (OP_ENDIF, NULL); } else if (*exp_ptr == '&') { advance (1); if (*exp_ptr == '&') advance (1); relational (); add_op (OP_AND, NULL); } else if (*exp_ptr == '|') { advance (1); if (*exp_ptr == '|') advance (1); relational (); add_op (OP_OR, NULL); } else break; } } /*---------- relational -------------------------------------------- * evaluates relational operators *------------------------------------------------------------------*/ static void relational () { additive (); while (1) { skip_space (exp_ptr); if (*exp_ptr == '<') { advance (1); if (*exp_ptr == '=') { advance (1); additive (); add_op (OP_LESS_EQ, NULL); } else { additive (); add_op (OP_LESS, NULL); } } else if (*exp_ptr == '>') { advance (1); if (*exp_ptr == '=') { advance (1); additive (); add_op (OP_GREATER_EQ, NULL); } else { additive (); add_op (OP_GREATER, NULL); } } else if (*exp_ptr == '=') { advance (1); if (*exp_ptr != '=') longjmp (env_ptr, VECERR_EQUALS); advance (1); additive (); add_op (OP_EQUALS, NULL); } else if (*exp_ptr == '!') { advance (1); if (*exp_ptr != '=') longjmp (env_ptr, VECERR_NOTEQS); advance (1); additive (); add_op (OP_NOT_EQUAL, NULL); } else break; } } /*---------- additive ---------------------------------------------- * evaluates additive operators *------------------------------------------------------------------*/ static void additive () { multiplicative (); while (1) { skip_space (exp_ptr); if (*exp_ptr == '+') { advance (1); multiplicative (); add_op (OP_PLUS, NULL); } else if (*exp_ptr == '-') { advance (1); multiplicative (); add_op (OP_MINUS, NULL); } else break; } } /*---------- multiplicative ---------------------------------------- * evaluates multiplicative operators *------------------------------------------------------------------*/ static void multiplicative () { exponential (); while (1) { skip_space (exp_ptr); if (*exp_ptr == '*') { advance (1); exponential (); add_op (OP_MULTIPLY, NULL); } else if (*exp_ptr == '/') { advance (1); exponential (); add_op (OP_DIVIDE, NULL); } else if (*exp_ptr == '%') { advance (1); exponential (); add_op (OP_MODULUS, NULL); } else if (strchr (OPERATORS, *exp_ptr) == NULL) { exponential (); add_op (OP_MULTIPLY, NULL); } else break; } } /*---------- exponential ------------------------------------------- * evaluates exponential operators *------------------------------------------------------------------*/ static void exponential () { unary (); while (1) { skip_space (exp_ptr); if (*exp_ptr == '^') { advance (1); unary (); add_op (OP_POWER, NULL); } else if (*exp_ptr == '*' && *(exp_ptr+1) == '*') { advance (2); unary (); add_op (OP_POWER, NULL); } else break; } } /*---------- unary ------------------------------------------------- * evaluates unary operations *------------------------------------------------------------------*/ static void unary () { skip_space (exp_ptr); if (*exp_ptr == '-') { advance (1); expression (); add_op (OP_NEGATE, NULL); } else if (*exp_ptr == '!') { advance (1); expression (); add_op (OP_NOT, NULL); } else expression (); } /*---------- expression -------------------------------------------- * evaluates an expression *------------------------------------------------------------------*/ static void expression () { char *p; int i; size_t ii; double dval; VECDATA *vd; skip_space (exp_ptr); if (*exp_ptr == '(') { advance (1); logical (); skip_space (exp_ptr); if (*exp_ptr != ')') longjmp (env_ptr, VECERR_PAREN); advance (1); } else if (*exp_ptr == '[') { advance (1); p = exp_ptr; i = 0; while (*exp_ptr && *exp_ptr != ']' && vec_number (&dval, &exp_ptr)) { i++; skip_space (exp_ptr); if (*exp_ptr == ',') advance(1); } if (!i || *exp_ptr != ']') longjmp (env_ptr, VECERR_BADVEC); advance (1); vd = vec_create (VEC_VECTOR, i, 1); for (ii = 0; ii < vd->len; ii++) { vec_number (&dval, &p); vd->f.vec[ii] = (VECFLOAT)dval; skip_space (p); if (*p == ',') p++; } add_op (OP_VECTOR, (void *)vd); } else if (isdigit (*exp_ptr) || *exp_ptr == '.') { if (!vec_number (&dval, &exp_ptr)) longjmp (env_ptr, VECERR_BADNUM); add_op (OP_NUMBER, (void *)&dval); } else if (*exp_ptr == '\\') { advance (1); if (!do_userfunc() && !do_symbol() && !do_intrinsic()) longjmp (env_ptr, VECERR_SYMBOL); } else if (!do_intrinsic() && !do_symbol() && !do_userfunc()) longjmp (env_ptr, VECERR_SYMBOL); } /*================================================================== * processing routines *==================================================================*/ /*---------- push_var ---------------------------------------------- * push a variable on the stack *------------------------------------------------------------------*/ static void push_var (v) double v; { if (var_pos >= var_size) { var_size += STACK_INC; var_stack = (double *) realloc (var_stack, var_size * sizeof(double)); if (var_stack == NULL) longjmp (env_ptr, VECERR_PUSH); } var_stack[var_pos++] = v; } /*---------- pop_var ------------------------------------------------ * pop a variable from the stack *------------------------------------------------------------------*/ static void pop_var (v) double *v; { if (--var_pos < 0) longjmp (env_ptr, VECERR_POP); *v = var_stack[var_pos]; } /*---------- process_op -------------------------------------------- * processes the operation stack for given variables *------------------------------------------------------------------*/ static double process_op (n) int n; { int m, done = 0, level, index = 0; long j; struct op_stack_ *op; double f1, f2; while (op_index < op_pos && !done) { op = &op_start[op_index++]; switch (op->op) { case OP_NOP: case OP_BEGIN_FUNC: break; case OP_INTEGER: push_var ((double)op->op_val.ival); break; case OP_COUNTER: push_var ((double)(n + 1)); break; case OP_INDEX: pop_var (&f1); index = (int)(f1 + TOLERANCE); if (index < 1) longjmp (env_ptr, VECERR_BADINDX); if (op_index == op_pos) longjmp (env_ptr, VECERR_POP); op = &op_start[op_index++]; if (op->op != OP_VECTOR) longjmp (env_ptr, VECERR_INDEX); case OP_VECTOR: { VECFLOAT *vec = op->op_val.vec; if (!index) index = n + 1; if (--index < 0 || index >= (int)op->len) longjmp (env_ptr, VECERR_BADINDX); push_var ((double)(vec[index])); index = 0; break; } case OP_NUMBER: push_var (op->op_val.num); break; /* unary operations */ case OP_NEGATE: pop_var (&f1); push_var (-f1); break; case OP_NOT: pop_var (&f1); push_var ((double)(f1 == 0.0 ? 1 : 0)); break; /* arithmetic operations */ case OP_POWER: pop_var (&f2); pop_var (&f1); push_var (pow (f1, f2)); break; case OP_MULTIPLY: pop_var (&f2); pop_var (&f1); push_var (f1 * f2); break; case OP_DIVIDE: pop_var (&f2); pop_var (&f1); if (f2 == 0.0) longjmp (env_ptr, VECERR_DIVIDE); push_var (f1 / f2); break; case OP_MODULUS: pop_var (&f2); pop_var (&f1); push_var (fmod (f1, f2)); break; case OP_PLUS: pop_var (&f2); pop_var (&f1); push_var (f1 + f2); break; case OP_MINUS: pop_var (&f2); pop_var (&f1); push_var (f1 - f2); break; /* comparisons */ case OP_LESS: pop_var (&f2); pop_var (&f1); push_var ((double)(f1 < f2 ? 1 : 0)); break; case OP_LESS_EQ: pop_var (&f2); pop_var (&f1); push_var ((double)(f1 <= f2 ? 1 : 0)); break; case OP_GREATER: pop_var (&f2); pop_var (&f1); push_var ((double)(f1 > f2 ? 1 : 0)); break; case OP_GREATER_EQ: pop_var (&f2); pop_var (&f1); push_var ((double)(f1 >= f2 ? 1 : 0)); break; case OP_EQUALS: pop_var (&f2); pop_var (&f1); push_var ((double)(f1 == f2 ? 1 : 0)); break; case OP_NOT_EQUAL: pop_var (&f2); pop_var (&f1); push_var ((double)(f1 != f2 ? 1 : 0)); break; case OP_AND: pop_var (&f2); pop_var (&f1); push_var ((double)(f1 && f2 ? 1 : 0)); break; case OP_OR: pop_var (&f2); pop_var (&f1); push_var ((double)(f1 || f2 ? 1 : 0)); break; /* if-then operation */ case OP_IF: level = ++nest_level; pop_var (&f1); if (f1 == 0.0) { /* skip if(TRUE) operations */ while (1) { op = &op_start[op_index++]; if (op->op == OP_ELSE) { if (level == nest_level) break; level--; } else if (op->op == OP_IF) level++; } } push_var (process_op (n)); nest_level--; break; case OP_ELSE: level = nest_level; while (1) { op = &op_start[op_index++]; if (op->op == OP_ENDIF) { if (level == nest_level) break; level--; } else if (op->op == OP_IF) level++; } case OP_ENDIF: if (nest_level) done = 1; break; /* functions which operate on the vectors */ case FUNC_MAX: case FUNC_MIN: case FUNC_SUM: case FUNC_AVG: case FUNC_SIZE: case FUNC_LEN: /* if currently processing vector, return */ if (vec_op) { done = 1; break; } /* else, first time here - find start of operations */ /* also check that all vectors are the same length */ index = op_index - 1; level = m = 0; while (op_start[--op_index].op != OP_BEGIN_FUNC) { if (op_start[op_index].op == OP_VECTOR) { if (!level) level = op_start[op_index].len; else if (level != op_start[op_index].len) longjmp (env_ptr, VECERR_VECLEN); } else if (op_start[op_index].op == OP_COUNTER) m = op_start[op_index].len; } if (!level && m) level = m; /* set BEGIN_FUNC op to NOP and set start of processing */ op_start[op_index].op = OP_NOP; vec_op = ++op_index; /* evaluate intrinsic function */ pop_var (&f1); if (op->op == FUNC_LEN) f1 = level ? level : 1; else { for (m = 1; m < level; m++) { op_index = vec_op; f2 = process_op (m); switch (op->op) { case FUNC_MAX: if (f1 < f2) f1 = f2; break; case FUNC_MIN: if (f1 > f2) f1 = f2; break; case FUNC_AVG: case FUNC_SUM: f1 += f2; break; case FUNC_SIZE: f1 += (f2 * f2); break; } } if (op->op == FUNC_AVG) f1 /= (double)(level ? level : 1); else if (op->op == FUNC_SIZE) f1 = sqrt (f1); } /* set stack ops to NOP */ for (m = vec_op; m < index; m++) op_start[m].op = OP_NOP; op = &op_start[index]; op_index = index + 1; vec_op = index = 0; /* put final result on stack */ op->op = OP_NUMBER; op->op_val.num = f1; push_var (f1); break; /* function operations */ case FUNC_ABS: pop_var (&f1); push_var (fabs (f1)); break; case FUNC_ACOS: pop_var (&f1); push_var (acos (f1)); break; case FUNC_ACOSH: pop_var (&f1); if (f1 < 1.0) longjmp (env_ptr, VECERR_ACOSH); push_var (log (f1 + sqrt (f1 * f1 - 1.0))); break; case FUNC_ASIN: pop_var (&f1); push_var (asin (f1)); break; case FUNC_ASINH: pop_var (&f1); push_var (log (f1 + sqrt (f1 * f1 + 1.0))); break; case FUNC_ATAN: pop_var (&f1); push_var (atan (f1)); break; case FUNC_ATAN2: pop_var (&f2); pop_var (&f1); push_var (atan2 (f1, f2)); break; case FUNC_ATANH: pop_var (&f1); if (f1 <= -1.0 || f1 >= 1.0) longjmp (env_ptr, VECERR_ATANH); push_var (0.5 * log ((1.0 + f1) / (1.0 - f1))); break; case FUNC_CEIL: pop_var (&f1); push_var (ceil (f1)); break; case FUNC_COSH: pop_var (&f1); push_var (cosh (f1)); break; case FUNC_COS: pop_var (&f1); push_var (cos (f1)); break; case FUNC_DEG: pop_var (&f1); push_var (f1 * 180.0 / PI); break; case FUNC_EXP: pop_var (&f1); push_var (exp (f1)); break; case FUNC_FACT: pop_var (&f1); j = (int)f1; f2 = j; if (j == 0) f2 = 1; else if (j > 0) { while (--j) f2 *= (double)j; } else { while (++j) f2 *= (double)j; } push_var (f2); break; case FUNC_FLOOR: pop_var (&f1); push_var (floor (f1)); break; case FUNC_LOG10: pop_var (&f1); push_var (log10 (f1)); break; case FUNC_LOG: pop_var (&f1); push_var (log (f1)); break; case FUNC_MOD: pop_var (&f2); pop_var (&f1); push_var (fmod (f1, f2)); break; case FUNC_POW: pop_var (&f2); pop_var (&f1); push_var (pow (f1, f2)); break; case FUNC_POW10: pop_var (&f1); push_var (pow (10.0, f1)); break; case FUNC_RAD: pop_var (&f1); push_var (f1 * PI / 180.0); break; case FUNC_RAND: push_var (vec_rand ()); break; case FUNC_ROUND: pop_var (&f1); if (fmod (f1, 1.0) >= 0.5) push_var (ceil (f1)); else push_var (floor (f1)); break; case FUNC_SINH: pop_var (&f1); push_var (sinh (f1)); break; case FUNC_SIN: pop_var (&f1); push_var (sin (f1)); break; case FUNC_SQRT: pop_var (&f1); push_var (sqrt (f1)); break; case FUNC_SQR: pop_var (&f1); push_var (f1 * f1); break; case FUNC_TANH: pop_var (&f1); push_var (tanh (f1)); break; case FUNC_TAN: pop_var (&f1); push_var (tan (f1)); break; default: longjmp (env_ptr, VECERR_OPERR); } } pop_var (&f1); return (f1); } /*=================================================================== * math exception handling *===================================================================*/ #ifdef _WIN32 #include #endif /*---------- fpe_err ----------------------------------------------- * signal handler for arithmetic exceptions *------------------------------------------------------------------*/ static SIGNAL fpe_err (int signum) { strcpy (err_msg[VECERR_MATH], "arithmetic exception (SIGFPE)"); #if defined(__MSDOS__) || defined(MSDOS) || defined(_WIN32) _fpreset (); #endif longjmp (env_ptr, VECERR_MATH); } #ifdef USE_MATHERR #ifdef _WIN32 #define matherr _matherr #define exception _exception #endif /*---------- matherr ----------------------------------------------- * use this math error handler, instead of library * This handles errors generated by math function calls *------------------------------------------------------------------*/ int matherr (e) struct exception *e; { switch (e->type) { case DOMAIN: sprintf (err_msg[VECERR_MATH], "%s : argument domain error", e->name); break; case SING: sprintf (err_msg[VECERR_MATH], "%s : argument singularity", e->name); break; case OVERFLOW: sprintf (err_msg[VECERR_MATH], "%s : overflow range error", e->name); break; case UNDERFLOW: sprintf (err_msg[VECERR_MATH], "%s : underflow range error", e->name); break; case PLOSS: sprintf (err_msg[VECERR_MATH], "%s : partial loss of significance", e->name); break; case TLOSS: sprintf (err_msg[VECERR_MATH], "%s : total loss of significance", e->name); break; default: sprintf (err_msg[VECERR_MATH], "%s : unknown error", e->name); break; } longjmp (env_ptr, VECERR_MATH); return (0); /* quite compiler */ } #endif /* USE_MATHERR */ /*========== print_op ============================================== * debug print out of operation stack *==================================================================*/ #ifdef VEC_DEBUG static char HEADER1[] = "op code pop push stack\n"; static char HEADER2[] = "------- --- ---- -----\n"; static char FORMAT[] = "%-20s%7d%7d%10d\n"; static char NUMFORM[] = "%-20.3g%7d%7d%10d\n"; void print_op (fp) FILE *fp; { int m, push, pop, stack_size = 0; char *opname; struct op_stack_ *op; if (op_size == 0) fprintf (fp, "OP STACK not created\n"); else if (op_pos == 0) fprintf (fp, "OP STACK is empty\n"); else { fprintf (fp, HEADER1); fprintf (fp, HEADER2); op_index = 0; while (op_index < op_pos) { op = &op_start[op_index++]; push = pop = 1; switch (op->op) { case OP_NOP: push = pop = 0; opname = "nop"; break; case OP_BEGIN_FUNC: push = pop = 0; opname = "beginfunc"; break; case OP_INTEGER: pop = 0; opname = "integer"; break; case OP_COUNTER: pop = 0; opname = "counter"; break; case OP_INDEX: push = 0; opname = "index"; break; case OP_VECTOR: pop = 0; opname = "vector"; break; case OP_NUMBER: pop = 0; opname = "number"; break; /* unary operations */ case OP_NEGATE: opname = "negate"; break; case OP_NOT: opname = "not"; break; /* arithmetic operations */ case OP_POWER: pop = 2; opname = "power"; break; case OP_MULTIPLY: pop = 2; opname = "multiply"; break; case OP_DIVIDE: pop = 2; opname = "divide"; break; case OP_MODULUS: pop = 2; opname = "modulus"; break; case OP_PLUS: pop = 2; opname = "plus"; break; case OP_MINUS: pop = 2; opname = "minus"; break; /* comparisons */ case OP_LESS: pop = 2; opname = "<"; break; case OP_LESS_EQ: pop = 2; opname = "<="; break; case OP_GREATER: pop = 2; opname = ">"; break; case OP_GREATER_EQ: pop = 2; opname = ">="; break; case OP_EQUALS: pop = 2; opname = "=="; break; case OP_NOT_EQUAL: pop = 2; opname = "!="; break; case OP_AND: pop = 2; opname = "and"; break; case OP_OR: pop = 2; opname = "or"; break; /* if-then operation */ case OP_IF: opname = "if"; break; case OP_ELSE: push = pop = 0; opname = "else"; break; case OP_ENDIF: push = pop = 0; opname = "endif"; break; /* functions which operate on the vectors */ case FUNC_MAX: opname = "max()"; break; case FUNC_MIN: opname = "min()"; break; case FUNC_SUM: opname = "sum()"; break; case FUNC_AVG: opname = "avg()"; break; case FUNC_SIZE: opname = "size()"; break; case FUNC_LEN: opname = "len()"; break; /* function operations */ case FUNC_ABS: opname = "abs()"; break; case FUNC_ACOS: opname = "acos()"; break; case FUNC_ACOSH: opname = "acosh()"; break; case FUNC_ASIN: opname = "asin()"; break; case FUNC_ASINH: opname = "asinh()"; break; case FUNC_ATAN: opname = "atan()"; break; case FUNC_ATANH: opname = "atanh()"; break; case FUNC_CEIL: opname = "ceil()"; break; case FUNC_COSH: opname = "cosh()"; break; case FUNC_COS: opname = "cos()"; break; case FUNC_DEG: opname = "deg()"; break; case FUNC_EXP: opname = "exp()"; break; case FUNC_FACT: opname = "fact()"; break; case FUNC_FLOOR: opname = "floor()"; break; case FUNC_LOG10: opname = "log10()"; break; case FUNC_LOG: opname = "log()"; break; case FUNC_POW10: opname = "pow10()"; break; case FUNC_RAD: opname = "rad()"; break; case FUNC_RAND: pop = 0; opname = "rand()"; break; case FUNC_ROUND: opname = "round()"; break; case FUNC_SINH: opname = "sinh()"; break; case FUNC_SIN: opname = "sin()"; break; case FUNC_SQRT: opname = "sqrt()"; break; case FUNC_SQR: opname = "sqr()"; break; case FUNC_TANH: opname = "tanh()"; break; case FUNC_TAN: opname = "tan()"; break; default: fprintf (fp, "UNREGOGNIZED op code\n"); return; } stack_size += (push - pop); fprintf (fp, FORMAT, opname, pop, push, stack_size); } fprintf (fp, FORMAT, "RESULT", 1, 0, --stack_size); } if (veclist == NULL) fprintf (fp, "Vector list is clear\n"); else { VECLIST *vl = veclist; m = 0; while (vl != NULL) { m++; vl = vl->prev; } fprintf (fp, "%d Vectors in vector list\n", m); } } #endif /* VEC_DEBUG */ CGNS-4.5.0/src/cgnstools/calclib/vec.h000066400000000000000000000053111474000356600174000ustar00rootroot00000000000000/* * vec.h */ #ifndef _VEC_H_ #define _VEC_H_ #define VEC_MAXCALLS 10 /* max recursive calls */ /*----- vector data structure -----*/ #define VEC_VALUE 0 #define VEC_VECTOR 1 #define VEC_COMPLEX 2 typedef double VECFLOAT; typedef struct { int type; /* type of data */ size_t len; /* length of vector */ union { VECFLOAT val; /* single data value */ VECFLOAT *vec; /* vector data */ } f; } VECDATA; /*--- function prototypes ---*/ #ifdef __cplusplus extern "C" { #endif typedef VECDATA *(*VECFUNC)( int checking, /* set if checking string instead of parsing */ int nv, /* number of arguments */ VECDATA **v, /* arguments */ char **errmsg /* returned error message */ ); typedef VECDATA *(*VECCALL)( int checking, /* set if checking string instead of parsing */ char **pos, /* pointer to position in equation string */ char **errmsg /* returned error message */ ); VECDATA *vec_create ( /* create a vector data structure */ int type, /* type of data */ size_t len, /* length of vector */ int temp /* set if temporary */ ); void vec_destroy ( /* destroy a vector data structure */ VECDATA *vdata /* structure to destroy */ ); int vec_add ( /* add vector to temporary list */ VECDATA *vdata /* data to add */ ); void vec_remove ( /* remove vector from temporary list */ VECDATA *vdata /* data to remove */ ); void vec_free ( /* free internal memory */ void ); void vec_maxcalls ( /* sets maximum number recursive calls */ int maxcalls /* max recursive calls */ ); char *vec_errmsg ( /* returns error messages */ void ); char **vec_list ( /* return list of intrinsics */ void ); VECDATA *vec_parse ( /* parse and process equation */ char *str, /* equation string */ int min_len, /* minimum length of vector for counter */ VECCALL func /* user call-back for unknown symbols */ ); size_t vec_check ( /* parse equation and check for errors */ char *str, /* equation string */ int min_len, /* minimum length of vector for counter */ VECCALL func /* user call-back for unknown symbols */ ); int vec_number ( /* get floating point number from string */ double *dval, /* returned number */ char **sp /* updated string pointer */ ); void vec_randinit ( /* initialize random number generator */ int seed /* initialization seed */ ); double vec_rand ( /* return random floating point number */ void ); #ifdef __cplusplus } #endif #endif /* _VEC_H_ */ CGNS-4.5.0/src/cgnstools/calclib/vecerr.h000066400000000000000000000074531474000356600201220ustar00rootroot00000000000000#ifndef _VECERR_H_ #define _VECERR_H_ extern int vec_maxerr; /* max error code */ extern int vec_errnum; /* error number */ /*----- user error handler -----*/ extern void (*vec_errhandler) ( /* user error handler */ int errnum, /* error number */ char *errmsg, /* error message */ int offset, /* offset in parse string */ char *exp /* expression being parsed */ ); /*----- error codes -----*/ enum VecErrors { VECERR_NOERR=0, /* successful evaluation */ VECERR_SYMBOL, /* unrecognized or invalid symbol */ VECERR_BADEXPR, /* bad expression */ VECERR_NOEXPR, /* NULL or blank expression string argument */ VECERR_FUNC, /* function name not followed by '(' */ VECERR_DIVIDE, /* math error: divide by 0 */ VECERR_PAREN, /* '(' without ')' */ VECERR_IFELSE, /* if (?) without else (:) */ VECERR_EQUALS, /* '=' instead of '==' */ VECERR_NOTEQS, /* '!' instead of '!=' */ VECERR_MATH, /* general math error */ VECERR_MISSING, /* missing operator */ VECERR_POINTER, /* user function did not update pointer */ VECERR_CALLS, /* too many recursive calls */ VECERR_BADNUM, /* single '.' not preceded/followed by digit */ VECERR_RECURSE, /* recursion in expression detected */ VECERR_ARGS, /* function argument list error */ VECERR_MAXARGS, /* user function has too many arguments */ VECERR_MALLOC, /* malloc failed */ VECERR_OPERR, /* internal error - op code */ VECERR_PUSH, /* out of space for variable stack */ VECERR_POP, /* tried to pop empty variable stack */ VECERR_OP_STK, /* couldn't malloc/realloc operation stack */ VECERR_VAR_STK, /* couldn't malloc variable stack */ VECERR_BRACKET, /* '[' without ']' */ VECERR_NOVECT, /* couldn't malloc vector data */ VECERR_VECLEN, /* vector lengths not the same */ VECERR_INDEX, /* index not associated with a variable */ VECERR_BADINDX, /* index out of range of vector data */ VECERR_VECTYPE, /* bad vector data type */ VECERR_ZEROLEN, /* vector len < 1 */ VECERR_EQUARG, /* equation argument out of range */ VECERR_ACOSH, /* argument to acosh < 1 */ VECERR_ATANH, /* argument to atanh <= -1 or >= 1 */ VECERR_BADVEC, /* bad vector specification */ VECERR_USER, /* user call-back function error */ VECERR_INVALID /* invalid error message number */ }; #ifdef INCLUDE_ERRDATA /*----- error messages -----*/ static char *err_msg[] = { "successful evaluation", "unrecognized or invalid symbol", "bad expression", "NULL or blank expression string argument", "function name not followed by '('", "math error: divide by 0", "'(' without ')'", "if (?) without else (:)", "'=' instead of '=='", "'!' instead of '!='", " ", "missing operator", "user function did not update pointer", "too many recursive calls", "single '.' not preceded or followed by digit", "recursion in expression detected", "function argument list error", "user function has too many arguments", "malloc failed", "internal error - op code", "out of space for variable stack", "tried to pop empty variable stack", "couldn't malloc/realloc operation stack", "couldn't malloc variable stack", "'[' without ']'", "couldn't malloc vector data", "vector lengths not the same", "index not associated with a variable", "index out of range of vector data", "bad vector data type", "vector len < 1", "equation argument out of range", "argument to acosh() < 1", "argument to atanh() <= -1 or >= 1", "bad vector specification", NULL, "invalid error message number" }; #endif /* INCLUDE_ERRDATA */ #endif /* _VECERR_H_ */ CGNS-4.5.0/src/cgnstools/calclib/vecsym.c000066400000000000000000000361041474000356600201300ustar00rootroot00000000000000/* * vecsym.c - symbol table for vector processor */ #include #include #include #include #include "vecsym.h" #define HASH_SIZE 127 /* size of hash table */ static VECSYM *hash_table[HASH_SIZE];/* user symbol hash table */ static int num_symbols = 0; /* number symbols in hash table */ static int max_namelen = 0; /* max length of user symbol name */ /*----- error messages -----*/ static char *errmsg[] = { "no error", "NULL or blank symbol name", "NULL or blank equation string", "failed to add new symbol to symbol table", "malloc failed - out of space", "NULL function pointer", "user function has too many arguments", "0 length or NULL vector", "symbol name too long", "invalid error code" }; /*----- callback for deleting symbol -----*/ void (*sym_delfunc) (struct symbol_ *) = NULL; /*----- local functions -----*/ static void init_hash(void); static int hash_name(char *name); static VECSYM *add_symbol(char *name); /*================================================================== * these routines are needed by vec.c *==================================================================*/ /*---------- find_symbol ------------------------------------------- * find a symbol in the hash table *------------------------------------------------------------------*/ VECSYM *find_symbol (char *name, int is_func) { VECSYM *sym; if (!num_symbols) return (NULL); sym = hash_table[hash_name (name)]; while (sym != NULL) { if (strcmp (name, vecsym_name(sym)) == 0) { if (vecsym_type(sym) == VECSYM_FUNC) return (is_func ? sym : NULL); if (vecsym_type(sym) == VECSYM_EQUSTR || vecsym_type(sym) == VECSYM_MACRO) { if (vecsym_nargs(sym) > 0) return (is_func ? sym : NULL); return (sym); } return (is_func ? NULL : sym); } sym = sym->next; } return (NULL); } /*================================================================== * hashing routines for user symbols *==================================================================*/ /*---------- init_hash --------------------------------------------- * initialize hash table *------------------------------------------------------------------*/ static void init_hash (void) { int n; for (n = 0; n < HASH_SIZE; n++) hash_table[n] = NULL; } /*---------- hash_name --------------------------------------------- * hashing routine *------------------------------------------------------------------*/ static int hash_name (char *name) { unsigned long hash = 0; while (*name) hash += *name++; return ((int)(hash % HASH_SIZE)); } /*---------- add_symbol -------------------------------------------- * add a symbol to the hash table *------------------------------------------------------------------*/ static VECSYM *add_symbol (char *name) { int hash = hash_name (name); VECSYM *sym = hash_table[hash]; while (sym != NULL) { if (strcmp (name, vecsym_name(sym)) == 0) { if (vecsym_type(sym) == VECSYM_EQUSTR) free (vecsym_equstr(sym)); else if (vecsym_type(sym) == VECSYM_MACRO) free (vecsym_macro(sym)); else if (vecsym_type(sym) == VECSYM_VECTOR) free (vecsym_vector(sym)); return (sym); } sym = sym->next; } sym = (VECSYM *) malloc (sizeof(VECSYM)); if (sym != NULL) { int len = (int)strlen (name); strcpy (vecsym_name(sym), name); sym->next = hash_table[hash]; hash_table[hash] = sym; num_symbols++; if (max_namelen < len) max_namelen = len; } return (sym); } /*---------- sym_free ---------------------------------------------- * free symbol table resources *------------------------------------------------------------------*/ void sym_free (void) { int n; VECSYM *sym, *next; if (!num_symbols) return; for (n = 0; n < HASH_SIZE; n++) { sym = hash_table[n]; while (sym != NULL) { next = sym->next; if (sym_delfunc != NULL) (*sym_delfunc) (sym); if (vecsym_type(sym) == VECSYM_EQUSTR) free (vecsym_equstr(sym)); else if (vecsym_type(sym) == VECSYM_MACRO) free (vecsym_macro(sym)); else if (vecsym_type(sym) == VECSYM_VECTOR) free (vecsym_vector(sym)); free (sym); sym = next; } hash_table[n] = NULL; } num_symbols = 0; max_namelen = 0; } /*---------- sym_errmsg --------------------------------------------- * returns error message *-------------------------------------------------------------------*/ char *sym_errmsg (int errnum) { if (errnum >= 0 && errnum < SYMERR_INVALID) return (errmsg[errnum]); return (errmsg[SYMERR_INVALID]); } /*---------- sym_addval -------------------------------------------- * adds a value to user symbol table *------------------------------------------------------------------*/ int sym_addval (char *name, VECFLOAT val, void *user) { VECSYM *sym; if (name == NULL || !*name) return (SYMERR_NONAME); if (strlen (name) > SYMNAME_MAXLEN) return (SYMERR_TOOLONG); if (!num_symbols) init_hash (); if ((sym = add_symbol (name)) == NULL) return (SYMERR_SYMTABLE); vecsym_type(sym) = VECSYM_VALUE; vecsym_nargs(sym) = 0; vecsym_veclen(sym) = 0; vecsym_value(sym) = val; vecsym_user(sym) = user; return (0); } /*---------- sym_addvec -------------------------------------------- * adds a vector to user symbol table *------------------------------------------------------------------*/ int sym_addvec (char *name, size_t len, VECFLOAT *vec, void *user) { VECSYM *sym; if (name == NULL || !*name) return (SYMERR_NONAME); if (strlen (name) > SYMNAME_MAXLEN) return (SYMERR_TOOLONG); if (len < 1 || vec == NULL) return (SYMERR_NOVEC); if (!num_symbols) init_hash (); if ((sym = add_symbol (name)) == NULL) return (SYMERR_SYMTABLE); vecsym_vector(sym) = (VECFLOAT *) malloc (len * sizeof(VECFLOAT)); if (vecsym_vector(sym) == NULL) { vecsym_type(sym) = VECSYM_VALUE; sym_delsym (name); return (SYMERR_MALLOC); } vecsym_type(sym) = VECSYM_VECTOR; vecsym_nargs(sym) = 0; vecsym_veclen(sym) = len; vecsym_user(sym) = user; memcpy (vecsym_vector(sym), vec, len * sizeof(VECFLOAT)); return (0); } /*---------- sym_addequ -------------------------------------------- * adds an equation to user symbol table *------------------------------------------------------------------*/ int sym_addequ (char *name, int nargs, char *equ, void *user) { VECSYM *sym; if (name == NULL || !*name) return (SYMERR_NONAME); if (strlen (name) > SYMNAME_MAXLEN) return (SYMERR_TOOLONG); if (equ == NULL) return (SYMERR_NOEXPR); while (*equ && isspace (*equ)) equ++; if (!*equ) return (SYMERR_NOEXPR); if (!num_symbols) init_hash (); if ((sym = add_symbol (name)) == NULL) return (SYMERR_SYMTABLE); vecsym_equstr(sym) = (char *) malloc (strlen (equ) + 1); if (vecsym_equstr(sym) == NULL) { vecsym_type(sym) = VECSYM_VALUE; sym_delsym (name); return (SYMERR_MALLOC); } vecsym_type(sym) = VECSYM_EQUSTR; vecsym_nargs(sym) = nargs; vecsym_user(sym) = user; strcpy (vecsym_equstr(sym), equ); return (0); } /*---------- sym_addfunc ------------------------------------------- * adds a function to user symbol table *------------------------------------------------------------------*/ int sym_addfunc (char *name, int nargs, VECFUNC func, void *user) { VECSYM *sym; if (name == NULL || !*name) return (SYMERR_NONAME); if (strlen (name) > SYMNAME_MAXLEN) return (SYMERR_TOOLONG); if (func == NULL) return (SYMERR_NOFUNC); if (nargs > FUNC_MAXARGS) return (SYMERR_MAXARGS); if (!num_symbols) init_hash (); if ((sym = add_symbol (name)) == NULL) return (SYMERR_SYMTABLE); vecsym_type(sym) = VECSYM_FUNC; vecsym_nargs(sym) = nargs; vecsym_func(sym) = func; vecsym_user(sym) = user; return (0); } /*---------- sym_addmacro ------------------------------------------ * adds a macro to user symbol table *------------------------------------------------------------------*/ int sym_addmacro (char *name, int nargs, char *macro, void *user) { VECSYM *sym; if (name == NULL || !*name) return (SYMERR_NONAME); if (strlen (name) > SYMNAME_MAXLEN) return (SYMERR_TOOLONG); if (macro == NULL) return (SYMERR_NOEXPR); while (*macro && isspace (*macro)) macro++; if (!*macro) return (SYMERR_NOEXPR); if (!num_symbols) init_hash (); if ((sym = add_symbol (name)) == NULL) return (SYMERR_SYMTABLE); vecsym_macro(sym) = (char *) malloc (strlen (macro) + 1); if (vecsym_macro(sym) == NULL) { vecsym_type(sym) = VECSYM_VALUE; sym_delsym (name); return (SYMERR_MALLOC); } vecsym_type(sym) = VECSYM_MACRO; vecsym_nargs(sym) = nargs; vecsym_user(sym) = user; strcpy (vecsym_macro(sym), macro); return (0); } /*---------- sym_adddata ------------------------------------------- * adds user data to user symbol table *------------------------------------------------------------------*/ int sym_adddata (char *name, void *data, void *user) { VECSYM *sym; if (name == NULL || !*name) return (SYMERR_NONAME); if (strlen (name) > SYMNAME_MAXLEN) return (SYMERR_TOOLONG); if (!num_symbols) init_hash (); if ((sym = add_symbol (name)) == NULL) return (SYMERR_SYMTABLE); vecsym_type(sym) = VECSYM_DATA; vecsym_nargs(sym) = 0; vecsym_data(sym) = data; vecsym_user(sym) = user; return (0); } /*---------- sym_delsym ---------------------------------------------- * delete a symbol from the symbol table *--------------------------------------------------------------------*/ void sym_delsym (char *name) { VECSYM *sym, *prev; int hash; if (!num_symbols || name == NULL || !*name) return; hash = hash_name (name); if ((prev = hash_table[hash]) == NULL) return; if (strcmp (name, vecsym_name(prev)) == 0) { hash_table[hash] = prev->next; if (sym_delfunc != NULL) (*sym_delfunc) (prev); if (vecsym_type(prev) == VECSYM_EQUSTR) free (vecsym_equstr(prev)); else if (vecsym_type(prev) == VECSYM_MACRO) free (vecsym_macro(prev)); else if (vecsym_type(prev) == VECSYM_VECTOR) free (vecsym_vector(prev)); free (prev); return; } sym = prev->next; while (sym != NULL) { if (strcmp (name, vecsym_name(sym)) == 0) { prev->next = sym->next; if (sym_delfunc != NULL) (*sym_delfunc) (sym); if (vecsym_type(sym) == VECSYM_EQUSTR) free (vecsym_equstr(sym)); else if (vecsym_type(sym) == VECSYM_MACRO) free (vecsym_macro(sym)); else if (vecsym_type(sym) == VECSYM_VECTOR) free (vecsym_vector(sym)); free (sym); return; } prev = sym; sym = prev->next; } } /*---------- sym_count --------------------------------------------- * return number of symbols of given type *------------------------------------------------------------------*/ int sym_count (int type) { int n, cnt = 0; VECSYM *sym; if (num_symbols) { for (n = 0; n < HASH_SIZE; n++) { sym = hash_table[n]; while (sym != NULL) { if (!type || vecsym_type(sym) == type) cnt++; sym = sym->next; } } } return (cnt); } /*---------- sym_names --------------------------------------------- * return list of symbol names *------------------------------------------------------------------*/ char **sym_names (int type) { int n, cnt = sym_count (type); VECSYM *sym; char **names = NULL; if (cnt) { names = (char **) malloc ((cnt+1) * sizeof(char *)); if (NULL == names) return (NULL); for (n = 0, cnt = 0; n < HASH_SIZE; n++) { sym = hash_table[n]; while (sym != NULL) { if (!type || vecsym_type(sym) == type) names[cnt++] = vecsym_name(sym); sym = sym->next; } } names[cnt] = NULL; } return (names); } /*---------- sym_list ---------------------------------------------- * lists symbols *------------------------------------------------------------------*/ int sym_list (int type, int (*func)(struct symbol_ *, void *), void *userdata) { int n, cnt = 0; VECSYM *sym; if (num_symbols && NULL != func) { for (n = 0; n < HASH_SIZE; n++) { sym = hash_table[n]; while (sym != NULL) { if (!type || vecsym_type(sym) == type) cnt += (*func) (sym, userdata); sym = sym->next; } } } return (cnt); } /*---------- sym_print --------------------------------------------- * print symbol list *------------------------------------------------------------------*/ void sym_print (FILE *fp) { int i, fld; VECSYM *sym; if (!num_symbols) { fprintf (fp, "\nNo Symbols defined\n"); return; } fld = max_namelen > 5 ? max_namelen : 5; fprintf (fp, "Defined Symbols:\n"); fprintf (fp, "%-*s Type Nargs/Expression/Value/Length\n", fld, "Name"); i = fld + 43; while (i--) putc ('-', fp); putc ('\n', fp); for (i = 0; i < HASH_SIZE; i++) { sym = hash_table[i]; while (sym != NULL) { fprintf (fp, "%-*.*s ", fld, fld, vecsym_name(sym)); if (vecsym_type(sym) == VECSYM_VALUE) fprintf (fp, "value %g\n", vecsym_value(sym)); else if (vecsym_type(sym) == VECSYM_VECTOR) fprintf (fp, "vector %ld\n", (long)vecsym_veclen(sym)); else if (vecsym_type(sym) == VECSYM_EQUSTR) fprintf (fp, "equation %s\n", vecsym_equstr(sym)); else if (vecsym_type(sym) == VECSYM_MACRO) fprintf (fp, "macro %s\n", vecsym_macro(sym)); else if (vecsym_type(sym) == VECSYM_FUNC) { fprintf (fp, "function "); if (vecsym_nargs(sym) < 0) fprintf (fp, "variable\n"); else fprintf (fp, "%d\n", vecsym_nargs(sym)); } else if (vecsym_type(sym) == VECSYM_DATA) fprintf (fp, "user data\n"); else fprintf (fp, "unknown type\n"); sym = sym->next; } } } CGNS-4.5.0/src/cgnstools/calclib/vecsym.h000066400000000000000000000113651474000356600201370ustar00rootroot00000000000000/* * vecsym.h - symbol table interface for vec.c */ #ifndef _VECSYM_H_ #define _VECSYM_H_ /*=================================================================== * none of this is used directly by vec.c * The symbol structure is used indirectly, however, through * the macros defined below *===================================================================*/ #include #ifndef _VEC_H_ #include "vec.h" /* for definition of VECDATA */ #endif /*----- error return codes -----*/ enum SymErrors { SYMERR_NOERR=0, /* no error */ SYMERR_NONAME, /* NULL or blank symbol name */ SYMERR_NOEXPR, /* NULL or blank equation string */ SYMERR_SYMTABLE,/* failed to add new symbol to symbol table */ SYMERR_MALLOC, /* malloc failed - out of space */ SYMERR_NOFUNC, /* NULL function pointer */ SYMERR_MAXARGS, /* user function has too many arguments */ SYMERR_NOVEC, /* 0 length or NULL vector */ SYMERR_TOOLONG, /* symbol name too long */ SYMERR_INVALID /* invalid error code */ }; /*----- symbol table structure -----*/ #define SYMNAME_MAXLEN 32 struct symbol_ { char name[SYMNAME_MAXLEN+1]; int type; int nargs; size_t len; union { VECFLOAT val; VECFLOAT *vec; char *equ; VECFUNC func; void *data; } op; void *user; struct symbol_ *next; }; /*----- callback for deleting a symbol -----*/ extern void (*sym_delfunc) (struct symbol_ *); /*----- function prototypes -----*/ void sym_free (void); /* free symbol table */ char *sym_errmsg ( /* get error message */ int errnum /* error number */ ); int sym_addval ( /* add value symbol */ char *name, /* symbol name */ VECFLOAT val, /* symbol value */ void *user /* user data */ ); int sym_addvec ( /* add vector symbol */ char *name, /* symbol name */ size_t len, /* vector length */ VECFLOAT *vec, /* vector */ void *user /* user data */ ); int sym_addequ ( /* add equation symbol */ char *name, /* symbol name */ int nargs, /* number of arguments */ char *equ, /* equation string */ void *user /* user data */ ); int sym_addfunc ( /* add function symbol */ char *name, /* symbol name */ int nargs, /* number of arguments */ VECFUNC func, /* function pointer */ void *user /* user data */ ); int sym_addmacro ( /* add macro symbol */ char *name, /* symbol name */ int nargs, /* number of arguments */ char *equ, /* macro string */ void *user /* user data */ ); int sym_adddata ( /* add user data symbol */ char *name, /* symbol name */ void *data, /* symbol data */ void *user /* user data */ ); void sym_delsym ( /* remove symbol */ char *name /* symbol name */ ); int sym_count ( /* count number of symbols */ int type /* symbol type (0 for all) */ ); char **sym_names ( /* return NULL terminated list of symbol names */ int type /* symbol type (0 for all) */ ); int sym_list ( /* list symbols */ int type, /* symbol type (0 for all) */ int (*func) ( /* callback function for list */ struct symbol_ *, /* symbol */ void * /* user data */ ), void *userdata /* user data */ ); void sym_print ( /* print list of symbols */ FILE *fp /* where output goes */ ); /*=================================================================== * the following need to be defined for use by vec.c *===================================================================*/ /*----- symbol definition -----*/ typedef struct symbol_ VECSYM; /*----- maximum arguments to a function -----*/ #define FUNC_MAXARGS 5 /*----- symbol types -----*/ #define VECSYM_VALUE 1 /* constant value */ #define VECSYM_VECTOR 2 /* vector */ #define VECSYM_EQUSTR 3 /* equation string */ #define VECSYM_FUNC 4 /* user function */ #define VECSYM_MACRO 5 /* macro string */ #define VECSYM_DATA 6 /* user data */ /*----- macros for accessing symbols -----*/ #define vecsym_name(SYM) ((SYM)->name) #define vecsym_type(SYM) ((SYM)->type) #define vecsym_user(SYM) ((SYM)->user) #define vecsym_value(SYM) ((SYM)->op.val) #define vecsym_veclen(SYM) ((SYM)->len) #define vecsym_vector(SYM) ((SYM)->op.vec) #define vecsym_nargs(SYM) ((SYM)->nargs) #define vecsym_equstr(SYM) ((SYM)->op.equ) #define vecsym_macro(SYM) ((SYM)->op.equ) #define vecsym_func(SYM) ((SYM)->op.func) #define vecsym_data(SYM) ((SYM)->op.data) /*----- function prototypes -----*/ VECSYM *find_symbol ( /* find a symbol */ char *name, /* symbol name */ int is_func /* non-zero if symbol is a function */ ); #endif /* _VECSYM_H_ */ CGNS-4.5.0/src/cgnstools/cgconfig.in000066400000000000000000000023631474000356600171740ustar00rootroot00000000000000#--------------------------------------------------------------------- # this is where the executables and tcl scripts # may be found after installation #--------------------------------------------------------------------- CG_BIN_DIR=@CG_BIN_DIR@; export CG_BIN_DIR CG_LIB_DIR=@CG_LIB_DIR@; export CG_LIB_DIR #--------------------------------------------------------------------- # you may need to set the paths to the Tcl/Tk scripts # if the system can't find them. If using shared libraries, # you may also need to modify LD_LIBRARY_PATH to include # the directories where libtcl.so and libtk.so are located # # for example, if Tcl/Tk built locally under Unix/Linux # using shared libraries, then set # # TCL_ROOT=$HOME/tcl8.3 # TK_ROOT=$HOME/tk8.3 # export TCL_LIBRARY=$TCL_ROOT/library # export TK_LIBRARY=$TK_ROOT/library # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TCL_ROOT/unix:$TK_ROOT/unix # # running under Cygwin, may need (assuming Tcl/Tk 8.0) # # sharedir=`cygpath -m /usr/share` # export TCL_LIBRARY=$sharedir/tcl8.0 # export TK_LIBRARY=$sharedir/tk8.0 # # under SGI, may need LD_LIBRARYN32_PATH instead #---------------------------------------------------------------------- @TCL_LIBRARY_SPEC@ @TK_LIBRARY_SPEC@ @LIBRARY_PATH_SPEC@ CGNS-4.5.0/src/cgnstools/cgnscalc/000077500000000000000000000000001474000356600166365ustar00rootroot00000000000000CGNS-4.5.0/src/cgnstools/cgnscalc/CMakeLists.txt000066400000000000000000000046271474000356600214070ustar00rootroot00000000000000############ # cgnscalc # ############ # Define source files if (WIN32) if (HTML_HELP_INCLUDE_PATH AND HTML_HELP_LIBRARY) set(cgnscalc_FILES calctcl.c winmain.c ../common/winhtml.c) else () set(cgnscalc_FILES calctcl.c winmain.c) endif () else () set(cgnscalc_FILES calctcl.c calcwish.c) endif () add_executable(calcwish ${cgnscalc_FILES}) target_include_directories(calcwish PRIVATE ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH}) target_include_directories(calcwish PRIVATE ../calclib) if (CGNS_USE_SHARED) target_link_libraries(calcwish PRIVATE cgns_shared) else () target_link_libraries(calcwish PRIVATE cgns_static) endif () target_link_libraries(calcwish PRIVATE calclib ${TCL_LIBRARY} ${TK_LIBRARY}) if (CGNS_ENABLE_HDF5 AND HDF5_LIBRARY) target_link_libraries(calcwish PRIVATE ${HDF5_LIBRARY}) if(HDF5_NEED_ZLIB AND ZLIB_LIBRARY) target_link_libraries(calcwish PRIVATE ${ZLIB_LIBRARY}) endif() if(HDF5_NEED_SZIP AND SZIP_LIBRARY) target_link_libraries(calcwish PRIVATE ${SZIP_LIBRARY}) endif() if(HDF5_NEED_MPI AND MPI_LIBS) target_link_libraries(calcwish PRIVATE ${MPI_LIBS}) endif() endif () if (WIN32) if (HTML_HELP_INCLUDE_PATH AND HTML_HELP_LIBRARY) add_definitions(-DUSE_HTMLHELP) target_include_directories(calcwish PRIVATE ${HTML_HELP_INCLUDE_PATH}) target_link_libraries(calcwish PRIVATE ${HTML_HELP_LIBRARY}) endif () else () target_include_directories(calcwish PRIVATE ${X11_X11_INCLUDE_PATH}) target_link_libraries(calcwish PRIVATE ${X11_X11_LIB} m) endif () if (WIN32) set_target_properties(calcwish PROPERTIES LINK_FLAGS /subsystem:windows) endif () if (WIN32) install(TARGETS calcwish RUNTIME DESTINATION bin) install(PROGRAMS cgnscalc.bat unitconv.bat DESTINATION bin) install(FILES cgnscalc.tcl unitconv.tcl cgnscalc.ico cgnscalc.png cgnscalc-icon.xbm cgnscalc-mask.xbm unitconv.ico unitconv.png unitconv.xbm DESTINATION share) else () install(TARGETS calcwish RUNTIME DESTINATION bin/cgnstools) install(PROGRAMS cgnscalc.sh DESTINATION bin RENAME cgnscalc) install(PROGRAMS cgnscalc.desktop DESTINATION bin) install(PROGRAMS unitconv.sh DESTINATION bin RENAME unitconv) install(PROGRAMS unitconv.desktop DESTINATION bin) install(FILES cgnscalc.tcl unitconv.tcl cgnscalc.ico cgnscalc.png cgnscalc-icon.xbm cgnscalc-mask.xbm unitconv.ico unitconv.png unitconv.xbm DESTINATION share/cgnstools) endif () CGNS-4.5.0/src/cgnstools/cgnscalc/Makefile.unix000066400000000000000000000055361474000356600212710ustar00rootroot00000000000000# Makefile for Unix/Linux include ../make.defs CALCDIR = ../calclib CALCLIB = $(CALCDIR)/libcgnscalc.$(A) COPTS = $(CFLAGS) -I$(CGNSDIR) -I$(CALCDIR) $(TKINCS) LDLIST = $(CALCLIB) $(CGNSLIB) $(BUILDLIBS) $(TKLIBS) $(X11LIBS) $(CLIBS) #-------------------------------------------------- calcwish$(EXE) : calcwish.$(O) calctcl.$(O) $(CALCLIB) $(CC) $(LDFLAGS) -o $@ calcwish.$(O) calctcl.$(O) $(LDLIST) $(STRIP) $@ calcwish.$(O) : calcwish.c calctcl.$(O) : calctcl.c $(CALCLIB) : cd $(CALCDIR) && $(MAKE) #--------------------------------------------------------------- SCRIPTS = cgnscalc.tcl unitconv.tcl ICONS = cgnscalc.ico cgnscalc.png cgnscalc-icon.xbm cgnscalc-mask.xbm \ unitconv.ico unitconv.png unitconv.xbm install : install-dirs install-prog install-wish install-script install-dirs : @for d in \ $(BIN_INSTALL_DIR) \ $(EXE_INSTALL_DIR) \ $(WSH_INSTALL_DIR) \ $(LIB_INSTALL_DIR) ; do \ if [ ! -d $$d ] ; then \ echo "Making directory $$d"; \ mkdir -p $$d; \ chmod 755 $$d; \ fi; \ done; install-prog : @echo "installing cgnscalc shell scripts to $(BIN_INSTALL_DIR)" @$(INSTALL_PROG) cgnscalc.sh $(BIN_INSTALL_DIR)/cgnscalc @$(INSTALL_PROG) cgnscalc.desktop $(BIN_INSTALL_DIR)/ @chmod +x $(BIN_INSTALL_DIR)/cgnscalc $(BIN_INSTALL_DIR)/cgnscalc.desktop @$(INSTALL_PROG) unitconv.sh $(BIN_INSTALL_DIR)/unitconv @$(INSTALL_PROG) unitconv.desktop $(BIN_INSTALL_DIR)/ @chmod +x $(BIN_INSTALL_DIR)/unitconv $(BIN_INSTALL_DIR)/unitconv.desktop @if [ ! -f $(EXE_INSTALL_DIR)/cgconfig ] ; then \ echo "installing configuration file to $(EXE_INSTALL_DIR)"; \ $(INSTALL_DATA) ../cgconfig $(EXE_INSTALL_DIR)/cgconfig; \ fi; install-wish : calcwish$(EXE) @echo "installing calcwish executable to $(WSH_INSTALL_DIR)" @$(INSTALL_PROG) calcwish$(EXE) $(WSH_INSTALL_DIR) install-script : @echo "installing tcl scripts to $(LIB_INSTALL_DIR)" @for i in $(SCRIPTS) ; do \ $(INSTALL_DATA) $$i $(LIB_INSTALL_DIR); \ done; @echo "installing icons to $(LIB_INSTALL_DIR)" @for i in $(ICONS) ; do \ $(INSTALL_DATA) $$i $(LIB_INSTALL_DIR); \ done; uninstall : @echo "uninstalling cgnscalc executables" @for i in cgnscalc unitconv ; do \ if [ -f $(BIN_INSTALL_DIR)/$$i ] ; then \ /bin/rm -f $(BIN_INSTALL_DIR)/$$i; \ fi; \ done; @if [ -f $(WSH_INSTALL_DIR)/calcwish$(EXE) ] ; then \ /bin/rm -f $(WSH_INSTALL_DIR)/calcwish$(EXE); \ fi; @echo "uninstalling cgnscalc tcl scripts" @for i in $(SCRIPTS) ; do \ if [ -f $(LIB_INSTALL_DIR)/$$i ] ; then \ /bin/rm -f $(LIB_INSTALL_DIR)/$$i; \ fi; \ done; @echo "uninstalling cgnscalc icons" @for i in $(ICONS) ; do \ if [ -f $(LIB_INSTALL_DIR)/$$i ] ; then \ /bin/rm -f $(LIB_INSTALL_DIR)/$$i; \ fi; \ done; #--------------------------------------------------------------- .c.$(O) : $(CC) $(COPTS) -c $< clean: -$(RM) *.$(O) *~ *.bak calcwish$(EXE) CGNS-4.5.0/src/cgnstools/cgnscalc/Makefile.win000066400000000000000000000032441474000356600210750ustar00rootroot00000000000000include ..\make.win CALCDIR = ..\calclib CALCLIB = $(CALCDIR)\cgnscalc.lib COPTS = $(CFLAGS) -I$(CGNSDIR) -I$(CALCDIR) $(TCLINC) #-------------------------------------------------- all : calcwish.exe dll : calctcl.dll install : calcwish.exe $(BINDIR) $(SHAREDIR) -$(INSTALL) cgnscalc.bat $(BINDIR) -$(INSTALL) calcwish.exe $(BINDIR) -$(INSTALL) unitconv.bat $(BINDIR) -$(INSTALL) cgnscalc.tcl $(SHAREDIR) -$(INSTALL) unitconv.tcl $(SHAREDIR) -$(INSTALL) *.ico $(SHAREDIR) $(BINDIR) : $(INSTALLDIR) -mkdir $(BINDIR) $(SHAREDIR) : $(INSTALLDIR) -mkdir $(SHAREDIR) $(INSTALLDIR) : -mkdir $(INSTALLDIR) #-------------------------------------------------- calcwish.exe : winmain.obj calctcl.obj $(CALCLIB) $(WINHTML_OBJ) $(LINK) $(LFLAGS) /nodefaultlib /subsystem:windows \ -out:$@ winmain.obj calctcl.obj $(WINHTML_OBJ) $(CALCLIB) \ $(CGNSLIB) $(BUILDLIBS) $(CLIBS) $(TCLLIB) $(TKLIB) \ $(guilibs) $(WINHTML_LIB) calctcl.obj : calctcl.c winmain.obj : winmain.c $(CC) $(COPTS) $(WINHTML_OPT) -c winmain.c #-------------------------------------------------- calctcl.dll : calctcl-dll.obj $(CALCLIB) $(CGNSLIB) $(LINK) -dll -out:calctcl.dll calctcl-dll.obj \ $(CALCLIB) $(CGNSLIB) $(BUILDLIBS) $(CLIBS) $(TCLLIB) $(TKLIB) $(dlllibs) calctcl-dll.obj : calctcl.c $(CC) $(COPTS) -DBUILD_DLL -Fo$@ -c calctcl.c #-------------------------------------------------- winhtml.obj : ..\common\winhtml.c $(CC) $(COPTS) $(WINHTML_INC) -Fowinhtml.obj -c ..\common\winhtml.c #-------------------------------------------------- .c.obj : $(CC) $(COPTS) -Fo$@ -c $< clean: -$(RM) *.obj -$(RM) *.lib -$(RM) *.exp -$(RM) *.exe -$(RM) *.pdb -$(RM) *.ilk -$(RM) *.dll -$(RM) *.bak CGNS-4.5.0/src/cgnstools/cgnscalc/calctcl.c000066400000000000000000000631721474000356600204200ustar00rootroot00000000000000#include #include #include #include #include #include "tcl.h" #include "calc.h" #include "cgnslib.h" #ifndef CONST # define CONST #endif static Tcl_Interp *global_interp; static char message[1024] = ""; /*---------- get_error ----------------------------------------------- * gets error message on parsing error *--------------------------------------------------------------------*/ static void get_error (int errnum, char *errmsg, int pos, char *str) { char *p = message; if (errnum < 0) { sprintf (message, "error_exit {%s}", errmsg); Tcl_Eval (global_interp, message); } if (NULL != str) { sprintf (p, "%s\n", str); p += strlen (p); while (pos-- > 0) *p++ = '-'; *p++ = '^'; } strcpy (p, errmsg); } /*---------- get_names ---------------------------------------------- * collect symbol names into Tcl interp result *-------------------------------------------------------------------*/ static int get_names (VECSYM *sym, void *data) { Tcl_Interp *interp = (Tcl_Interp *)data; if (VECSYM_EQUSTR == vecsym_type(sym)) { if (vecsym_nargs(sym) > 0) sprintf (message, "%s(%d)", vecsym_name(sym), vecsym_nargs(sym)); else strcpy (message, vecsym_name(sym)); } else if (VECSYM_FUNC == vecsym_type(sym)) { if (vecsym_nargs(sym) < 0) sprintf (message, "%s(...)", vecsym_name(sym)); else sprintf (message, "%s(%d)", vecsym_name(sym), vecsym_nargs(sym)); } else if (VECSYM_VECTOR == vecsym_type(sym)) sprintf (message, "%s[%ld]", vecsym_name(sym), (long)vecsym_veclen(sym)); else strcpy (message, vecsym_name(sym)); Tcl_AppendElement (interp, message); return 0; } /*---------- CalcReset --------------------------------------------- * reset calculator (symbol table) *------------------------------------------------------------------*/ static int CalcReset (ClientData data, Tcl_Interp *interp, int argc, char **argv) { cgnsCalcReset (); return TCL_OK; } /*---------- CalcInit ---------------------------------------------- * load CGNS file and initialize *------------------------------------------------------------------*/ static int CalcInit (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int nb, idum, modify = 0; char name[33]; Tcl_ResetResult (interp); if (argc != 3) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " mode CGNSfile\"", NULL); return TCL_ERROR; } if (argv[1][0] == 'w' || argv[1][0] == 'm') modify = 1; cgnsCalcInit (argv[2], modify, get_error); for (nb = 1; nb <= NumBases; nb++) { if (cg_base_read (cgnsFile, nb, name, &idum, &idum)) cgnsCalcFatal ((char *)cg_get_error()); Tcl_AppendElement (interp, name); } return TCL_OK; } /*---------- CalcDone ---------------------------------------------- * close CGNS file *------------------------------------------------------------------*/ static int CalcDone (ClientData data, Tcl_Interp *interp, int argc, char **argv) { cgnsCalcDone (); return TCL_OK; } /*---------- CalcBase ---------------------------------------------- * set base for calculations *------------------------------------------------------------------*/ static int CalcBase (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int nb, nz; cgsize_t sizes[9]; char name[33]; Tcl_ResetResult (interp); if (2 != argc) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " base\"", NULL); return TCL_ERROR; } nb = atoi (argv[1]); if (nb < 1 || nb > NumBases) { sprintf (message, "base number %d out of range", nb); Tcl_SetResult (interp, message, TCL_STATIC); return TCL_ERROR; } if (nb != cgnsBase) cgnsCalcBase (nb); for (nz = 1; nz <= NumZones; nz++) { if (cg_zone_read (cgnsFile, cgnsBase, nz, name, sizes)) cgnsCalcFatal ((char *)cg_get_error()); Tcl_AppendElement (interp, name); } return TCL_OK; } /*---------- CalcBaseInfo ------------------------------------------ * get current base information *------------------------------------------------------------------*/ static int CalcBaseInfo (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char *p = message; Tcl_ResetResult (interp); if (!cgnsBase) return TCL_OK; sprintf (p, "Name : %s\n", BaseName); p += strlen (p); sprintf (p, "Phy Dim : %d\nCell Dim : %d\n", PhyDim, CellDim); p += strlen (p); sprintf (p, "Zones : %d\nRef Values: %d\n", NumZones, NumReference); p += strlen (p); #if CGNS_VERSION >= 2500 sprintf (p, "Data Class: %s\n", cg_DataClassName(BaseClass)); p += strlen (p); sprintf (p, "Units : %s %s %s %s %s", cg_MassUnitsName(BaseUnits[0]), cg_LengthUnitsName(BaseUnits[1]), cg_TimeUnitsName(BaseUnits[2]), cg_TemperatureUnitsName(BaseUnits[3]), cg_AngleUnitsName(BaseUnits[4])); #else sprintf (p, "Data Class: %s\n", DataClassName[BaseClass]); p += strlen (p); sprintf (p, "Units : %s %s %s %s %s", MassUnitsName[BaseUnits[0]], LengthUnitsName[BaseUnits[1]], TimeUnitsName[BaseUnits[2]], TemperatureUnitsName[BaseUnits[3]], AngleUnitsName[BaseUnits[4]]); #endif Tcl_SetResult (interp, message, TCL_STATIC); return TCL_OK; } /*---------- CalcZone ---------------------------------------------- * set zone for calculations *------------------------------------------------------------------*/ static int CalcZone (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int nz, ns; char name[33]; CGNS_ENUMT(GridLocation_t) location; Tcl_ResetResult (interp); if (2 != argc) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " zone\"", NULL); return TCL_ERROR; } nz = atoi (argv[1]); if (nz < 1 || nz > NumZones) { sprintf (message, "zone number %d out of range", nz); Tcl_SetResult (interp, message, TCL_STATIC); return TCL_ERROR; } if (nz != cgnsZone) cgnsCalcZone (nz); for (ns = 1; ns <= NumSolns; ns++) { if (cg_sol_info (cgnsFile, cgnsBase, cgnsZone, ns, name, &location)) cgnsCalcFatal ((char *)cg_get_error()); Tcl_AppendElement (interp, name); } return TCL_OK; } /*---------- CalcZoneInfo ------------------------------------------ * get current zone information *------------------------------------------------------------------*/ static int CalcZoneInfo (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char *p = message; int n, dim; Tcl_ResetResult (interp); if (!cgnsZone) return TCL_OK; sprintf (p, "Name : %s\nType : %s\n", ZoneName, #if CGNS_VERSION >= 2500 cg_ZoneTypeName(ZoneType)); #else ZoneTypeName[ZoneType]); #endif p += strlen (p); dim = ZoneType == CGNS_ENUMV(Structured) ? CellDim : 1; sprintf (p, "Dimensions: %d", ZoneDims[0]); p += strlen(p); for (n = 1; n < dim; n++) { sprintf (p, " x %d", ZoneDims[n]); p += strlen(p); } sprintf (p, "\nCoords : %d\nSolutions : %d\n", NumCoordinates, NumSolns); p += strlen (p); #if CGNS_VERSION >= 2500 sprintf (p, "Data Class: %s\n", cg_DataClassName(ZoneClass)); p += strlen (p); sprintf (p, "Units : %s %s %s %s %s", cg_MassUnitsName(ZoneUnits[0]), cg_LengthUnitsName(ZoneUnits[1]), cg_TimeUnitsName(ZoneUnits[2]), cg_TemperatureUnitsName(ZoneUnits[3]), cg_AngleUnitsName(ZoneUnits[4])); #else sprintf (p, "Data Class: %s\n", DataClassName[ZoneClass]); p += strlen (p); sprintf (p, "Units : %s %s %s %s %s", MassUnitsName[ZoneUnits[0]], LengthUnitsName[ZoneUnits[1]], TimeUnitsName[ZoneUnits[2]], TemperatureUnitsName[ZoneUnits[3]], AngleUnitsName[ZoneUnits[4]]); #endif Tcl_SetResult (interp, message, TCL_STATIC); return TCL_OK; } /*---------- CalcSoln ---------------------------------------------- * set solution for calculations *------------------------------------------------------------------*/ static int CalcSoln (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int ns, nv; Tcl_ResetResult (interp); if (2 != argc) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " soln\"", NULL); return TCL_ERROR; } ns = atoi (argv[1]); if (ns < 1 || ns > NumSolns) { sprintf (message, "solution number %d out of range", ns); Tcl_SetResult (interp, message, TCL_STATIC); return TCL_ERROR; } if (ns != cgnsSoln) cgnsCalcSoln (ns); for (nv = 0; nv < NumVariables; nv++) Tcl_AppendElement (interp, variables[nv].name); return TCL_OK; } /*---------- CalcSolnInfo ------------------------------------------ * get current solution information *------------------------------------------------------------------*/ static int CalcSolnInfo (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char *p = message; int n; Tcl_ResetResult (interp); if (!cgnsSoln) return TCL_OK; sprintf (p, "Name : %s\nLocation : %s\n", SolnName, #if CGNS_VERSION >= 2500 cg_GridLocationName(SolnLocation)); #else GridLocationName[SolnLocation]); #endif p += strlen (p); if (ZoneType == CGNS_ENUMV(Structured)) { sprintf (p, "Dimensions: %d", SolnDims[0]); p += strlen(p); for (n = 1; n < CellDim; n++) { sprintf (p, " x %d", SolnDims[n]); p += strlen(p); } sprintf (p, "\nRind Cells: %d %d %d %d %d %d\n", SolnRind[0], SolnRind[1], SolnRind[2], SolnRind[3], SolnRind[4], SolnRind[5]); } else sprintf (p, "Dimensions: %d\n", SolnDims[0]); p += strlen (p); sprintf (p, "Fields : %d\n", NumVariables); p += strlen (p); #if CGNS_VERSION >= 2500 sprintf (p, "Data Class: %s\n", cg_DataClassName(SolnClass)); p += strlen (p); sprintf (p, "Units : %s %s %s %s %s", cg_MassUnitsName(SolnUnits[0]), cg_LengthUnitsName(SolnUnits[1]), cg_TimeUnitsName(SolnUnits[2]), cg_TemperatureUnitsName(SolnUnits[3]), cg_AngleUnitsName(SolnUnits[4])); #else sprintf (p, "Data Class: %s\n", DataClassName[SolnClass]); p += strlen (p); sprintf (p, "Units : %s %s %s %s %s", MassUnitsName[SolnUnits[0]], LengthUnitsName[SolnUnits[1]], TimeUnitsName[SolnUnits[2]], TemperatureUnitsName[SolnUnits[3]], AngleUnitsName[SolnUnits[4]]); #endif Tcl_SetResult (interp, message, TCL_STATIC); return TCL_OK; } /*---------- CalcRegList ------------------------------------------- * return list of regions *------------------------------------------------------------------*/ static int CalcRegList (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n, dim; char *p = message; Tcl_ResetResult (interp); if (!NumZones || !cgnsZone) return TCL_OK; dim = ZoneType == CGNS_ENUMV(Structured) ? CellDim : 1; sprintf (p, "[%d", ZoneDims[0]); p += strlen(p); for (n = 1; n < dim; n++) { sprintf (p, ",%d", ZoneDims[n]); p += strlen(p); } strcpy (p, "]"); Tcl_AppendElement (interp, message); return TCL_OK; } /*---------- CalcRegInfo ------------------------------------------- * return region information *------------------------------------------------------------------*/ static int CalcRegInfo (ClientData data, Tcl_Interp *interp, int argc, char **argv) { Tcl_ResetResult (interp); return TCL_OK; } /*---------- CalcVarList ------------------------------------------- * return list of variables *------------------------------------------------------------------*/ static int CalcVarList (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n, i; Tcl_ResetResult (interp); #if 0 for (n = 0; n < NumCoordinates; n++) { for (i = 0; i < NumVariables; i++) { if (0 == strcmp (coordinates[n].name, variables[i].name)) break; } if (i < NumVariables) sprintf (message, "'%s[%d]", coordinates[n].name, coordinates[n].len); else sprintf (message, "%s[%d]", coordinates[n].name, coordinates[n].len); Tcl_AppendElement (interp, message); } for (n = 0; n < NumVariables; n++) { sprintf (message, "%s[%d]", variables[n].name, variables[n].len); Tcl_AppendElement (interp, message); } for (n = 0; n < NumReference; n++) { if (reference[n].len > 1) sprintf (message, "~%s[%d]", reference[n].name, reference[n].len); else sprintf (message, "~%s", reference[n].name); Tcl_AppendElement (interp, message); } #else for (n = 0; n < NumCoordinates; n++) { for (i = 0; i < NumVariables; i++) { if (0 == strcmp (coordinates[n].name, variables[i].name)) break; } if (i < NumVariables) { sprintf (message, "'%s", coordinates[n].name); Tcl_AppendElement (interp, message); } else Tcl_AppendElement (interp, coordinates[n].name); } for (n = 0; n < NumVariables; n++) Tcl_AppendElement (interp, variables[n].name); for (n = 0; n < NumReference; n++) { sprintf (message, "~%s", reference[n].name); Tcl_AppendElement (interp, message); } #endif return TCL_OK; } /*---------- CalcVarInfo ------------------------------------------- * return variable information *------------------------------------------------------------------*/ static int CalcVarInfo (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char *p = message; Variable *var; Tcl_ResetResult (interp); if (2 != argc) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " varname\"", NULL); return TCL_ERROR; } var = cgnsCalcVarGet (argv[1]); if (var == NULL) { Tcl_AppendResult (interp, "variable \"", argv[1], "\" not found", NULL); return TCL_ERROR; } sprintf (p, "Name : %s\n", var->name); p += strlen (p); if (var->type == 0) { sprintf (p, "Type : Reference\n"); p += strlen(p); if (var->len > 1) sprintf (p, "Size : %d\n", var->len); else sprintf (p, "Value : %g\n", var->vd->f.val); } else if (var->type == 1 || SolnLocation == CGNS_ENUMV(Vertex)) { sprintf (p, "Type : %s\nLocation : Vertex\n", var->type == 1 ? "Coordinate" : "Solution"); p += strlen (p); if (ZoneType == CGNS_ENUMV(Structured)) sprintf (p, "Size : %d (%d x %d x %d)\n", var->len, ZoneDims[0], ZoneDims[1], ZoneDims[2]); else sprintf (p, "Size : %d\n", var->len); } else { sprintf (p, "Type : Solution\nLocation : %s\n", #if CGNS_VERSION >= 2500 cg_GridLocationName(SolnLocation)); #else GridLocationName[SolnLocation]); #endif p += strlen (p); if (ZoneType == CGNS_ENUMV(Structured)) { sprintf (p, "Size : %d (%d x %d x %d)\n", var->len, SolnDims[0], SolnDims[1], SolnDims[2]); p += strlen (p); sprintf (p, "Rind Cells: %d %d %d %d %d %d\n", SolnRind[0], SolnRind[1], SolnRind[2], SolnRind[3], SolnRind[4], SolnRind[5]); } else sprintf (p, "Size : %d\n", var->len); } p += strlen (p); sprintf (p, "Data Class: %s\nData Type : %s\n", #if CGNS_VERSION >= 2500 cg_DataClassName(var->dataclass), cg_DataTypeName(var->datatype)); #else DataClassName[var->dataclass], DataTypeName[var->datatype]); #endif p += strlen (p); if (var->hasunits) sprintf (p, "Units : %s %s %s %s %s\n", #if CGNS_VERSION >= 2500 cg_MassUnitsName(var->units[0]), cg_LengthUnitsName(var->units[1]), cg_TimeUnitsName(var->units[2]), cg_TemperatureUnitsName(var->units[3]), cg_AngleUnitsName(var->units[4])); #else MassUnitsName[var->units[0]], LengthUnitsName[var->units[1]], TimeUnitsName[var->units[2]], TemperatureUnitsName[var->units[3]], AngleUnitsName[var->units[4]]); #endif else sprintf (p, "Units : not specified\n"); p += strlen (p); if (var->hasexp) sprintf (p, "Exponents : %g %g %g %g %g\n", var->exponent[0], var->exponent[1], var->exponent[2], var->exponent[3], var->exponent[4]); else sprintf (p, "Exponents : not specified\n"); p += strlen (p); if (var->hasconv) sprintf (p, "Conversion: %g %g", var->dataconv[0], var->dataconv[1]); else sprintf (p, "Conversion: not specified"); Tcl_SetResult (interp, message, TCL_STATIC); return TCL_OK; } /*---------- CalcSymList ------------------------------------------- * return list of symbols *------------------------------------------------------------------*/ static int CalcSymList (ClientData data, Tcl_Interp *interp, int argc, char **argv) { Tcl_ResetResult (interp); sym_list (0, get_names, interp); return TCL_OK; } /*---------- CalcSymInfo ------------------------------------------- * return symbol information *------------------------------------------------------------------*/ static int CalcSymInfo (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char *p = message; VECSYM *sym; Units *units; Tcl_ResetResult (interp); if (2 != argc) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " symname\"", NULL); return TCL_ERROR; } sym = find_symbol (argv[1], 0); if (sym == NULL) { sym = find_symbol (argv[1], 1); if (sym == NULL) { Tcl_AppendResult (interp, "symbol \"", argv[1], "\" not found", NULL); return TCL_ERROR; } } sprintf (p, "Name : %s\n", vecsym_name(sym)); p += strlen (p); if (vecsym_type(sym) == VECSYM_EQUSTR) { sprintf (p, "Type : equation\n"); p += strlen(p); if (vecsym_nargs(sym) > 0) sprintf (p, "Arguments : %d", vecsym_nargs(sym)); else sprintf (p, "Arguments : none"); } else if (vecsym_type(sym) == VECSYM_FUNC) { sprintf (p, "Type : function\n"); p += strlen(p); if (vecsym_nargs(sym) < 0) sprintf (p, "Arguments : variable"); else sprintf (p, "Arguments : %d", vecsym_nargs(sym)); } else if (vecsym_type(sym) == VECSYM_VECTOR) sprintf (p, "Type : vector\nSize : %ld", (long)vecsym_veclen(sym)); else sprintf (p, "Type : value\nValue : %g", vecsym_value(sym)); if (vecsym_user(sym) != NULL) { units = (Units *)vecsym_user(sym); p += strlen(p); sprintf (p, "\nUnits : %s %s %s %s %s\n", #if CGNS_VERSION >= 2500 cg_MassUnitsName(units->units[0]), cg_LengthUnitsName(units->units[1]), cg_TimeUnitsName(units->units[2]), cg_TemperatureUnitsName(units->units[3]), cg_AngleUnitsName(units->units[4])); #else MassUnitsName[units->units[0]], LengthUnitsName[units->units[1]], TimeUnitsName[units->units[2]], TemperatureUnitsName[units->units[3]], AngleUnitsName[units->units[4]]); #endif p += strlen(p); sprintf (p, "Exponents : %g %g %g %g %g", units->exps[0], units->exps[1], units->exps[2], units->exps[3], units->exps[4]); } Tcl_SetResult (interp, message, TCL_STATIC); return TCL_OK; } /*---------- CalcCommand ------------------------------------------- * parse expression and return results *------------------------------------------------------------------*/ static int CalcCommand (ClientData data, Tcl_Interp *interp, int argc, char **argv) { size_t n; VECFLOAT *f, fmin, fmax; VECSYM *sym; Tcl_ResetResult (interp); if (2 != argc) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " command\"", NULL); return TCL_ERROR; } sym = cgnsCalcCommand (argv[1]); if (NULL == sym) { Tcl_SetResult (interp, message, TCL_STATIC); return TCL_ERROR; } if (VECSYM_EQUSTR == vecsym_type(sym)) { if (vecsym_nargs(sym) > 0) sprintf (message, "%s(%d)", vecsym_name(sym), vecsym_nargs(sym)); else strcpy (message, vecsym_name(sym)); } else if (VECSYM_FUNC == vecsym_type(sym)) { if (vecsym_nargs(sym) < 0) sprintf (message, "%s(...)", vecsym_name(sym)); else sprintf (message, "%s(%d)", vecsym_name(sym), vecsym_nargs(sym)); } else if (VECSYM_VALUE == vecsym_type(sym)) sprintf (message, "%s = %g", vecsym_name(sym), vecsym_value(sym)); else if (VECSYM_VECTOR == vecsym_type(sym)) { f = vecsym_vector(sym); fmin = fmax = f[0]; for (n = 1; n < vecsym_veclen(sym); n++) { if (fmin > f[n]) fmin = f[n]; if (fmax < f[n]) fmax = f[n]; } sprintf (message, "%s -> len = %ld, min = %g, max = %g", vecsym_name(sym), (long)vecsym_veclen(sym), fmin, fmax); } else strcpy (message, vecsym_name(sym)); Tcl_SetResult (interp, message, TCL_STATIC); return TCL_OK; } /*---------- CalcDelete -------------------------------------------- * delete symbols *------------------------------------------------------------------*/ static int CalcDelete (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int i, n, nargs; CONST char **args; for (n = 1; n < argc; n++) { if (TCL_OK == Tcl_SplitList (interp, argv[n], &nargs, &args)) { for (i = 0; i < nargs; i++) sym_delsym ((char *)args[i]); Tcl_Free ((char *)args); } else sym_delsym (argv[n]); } return TCL_OK; } /*---------- CalcSave ---------------------------------------------- * save computed variables to results file *------------------------------------------------------------------*/ static int CalcSave (ClientData data, Tcl_Interp *interp, int argc, char **argv) { Tcl_SetResult (interp, "not implemented yet", TCL_STATIC); return TCL_ERROR; } /*---------- ADFtcl_Init --------------------------------------- * Initialize and create the commands *--------------------------------------------------------------*/ #if defined(_WIN32) && defined(BUILD_DLL) __declspec(dllexport) #endif int Calctcl_Init(Tcl_Interp *interp) { global_interp = interp; Tcl_CreateCommand (interp, "CalcReset", (Tcl_CmdProc *)CalcReset, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcInit", (Tcl_CmdProc *)CalcInit, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcDone", (Tcl_CmdProc *)CalcDone, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcBase", (Tcl_CmdProc *)CalcBase, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcBaseInfo", (Tcl_CmdProc *)CalcBaseInfo, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcZone", (Tcl_CmdProc *)CalcZone, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcZoneInfo", (Tcl_CmdProc *)CalcZoneInfo, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcSoln", (Tcl_CmdProc *)CalcSoln, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcSolnInfo", (Tcl_CmdProc *)CalcSolnInfo, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcRegList", (Tcl_CmdProc *)CalcRegList, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcRegInfo", (Tcl_CmdProc *)CalcRegInfo, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcVarList", (Tcl_CmdProc *)CalcVarList, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcVarInfo", (Tcl_CmdProc *)CalcVarInfo, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcSymList", (Tcl_CmdProc *)CalcSymList, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcSymInfo", (Tcl_CmdProc *)CalcSymInfo, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcCommand", (Tcl_CmdProc *)CalcCommand, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcDelete", (Tcl_CmdProc *)CalcDelete, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CalcSave", (Tcl_CmdProc *)CalcSave, (ClientData)0, (Tcl_CmdDeleteProc *)0); return TCL_OK; } CGNS-4.5.0/src/cgnstools/cgnscalc/calcwish.c000066400000000000000000000100421474000356600205740ustar00rootroot00000000000000/* * tkAppInit.c -- * * Provides a default version of the Tcl_AppInit procedure for * use in wish and similar Tk-based applications. * * Copyright (c) 1993 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #include "tk.h" #include "locale.h" #ifdef TK_TEST extern int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp)); extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp)); #endif /* TK_TEST */ extern int Calctcl_Init _ANSI_ARGS_((Tcl_Interp *interp)); /* *---------------------------------------------------------------------- * * main -- * * This is the main program for the application. * * Results: * None: Tk_Main never returns here, so this procedure never * returns either. * * Side effects: * Whatever the application does. * *---------------------------------------------------------------------- */ int main(argc, argv) int argc; /* Number of command-line arguments. */ char **argv; /* Values of command-line arguments. */ { /* * The following #if block allows you to change the AppInit * function by using a #define of TCL_LOCAL_APPINIT instead * of rewriting this entire file. The #if checks for that * #define and uses Tcl_AppInit if it doesn't exist. */ #ifndef TK_LOCAL_APPINIT #define TK_LOCAL_APPINIT Tcl_AppInit #endif extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp)); /* * The following #if block allows you to change how Tcl finds the startup * script, prime the library or encoding paths, fiddle with the argv, * etc., without needing to rewrite Tk_Main() */ #ifdef TK_LOCAL_MAIN_HOOK extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); TK_LOCAL_MAIN_HOOK(&argc, &argv); #endif Tk_Main(argc, argv, TK_LOCAL_APPINIT); return 0; /* Needed only to prevent compiler warning. */ } /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in the interp's result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(interp) Tcl_Interp *interp; /* Interpreter for application. */ { if (Tcl_Init(interp) == TCL_ERROR) { return TCL_ERROR; } if (Tk_Init(interp) == TCL_ERROR) { return TCL_ERROR; } Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit); #ifdef TK_TEST if (Tcltest_Init(interp) == TCL_ERROR) { return TCL_ERROR; } Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init, (Tcl_PackageInitProc *) NULL); if (Tktest_Init(interp) == TCL_ERROR) { return TCL_ERROR; } Tcl_StaticPackage(interp, "Tktest", Tktest_Init, (Tcl_PackageInitProc *) NULL); #endif /* TK_TEST */ /* * Call the init procedures for included packages. Each call should * look like this: * * if (Mod_Init(interp) == TCL_ERROR) { * return TCL_ERROR; * } * * where "Mod" is the name of the module. */ if (Calctcl_Init(interp) == TCL_ERROR) return TCL_ERROR; /* * Call Tcl_CreateCommand for application-specific commands, if * they weren't already created by the init procedures called above. */ /* * Specify a user-specific startup file to invoke if the application * is run interactively. Typically the startup file is "~/.apprc" * where "app" is the name of the application. If this line is deleted * then no user-specific startup file will be run under any conditions. */ Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); return TCL_OK; } CGNS-4.5.0/src/cgnstools/cgnscalc/cgnscalc-icon.xbm000066400000000000000000000016171474000356600220560ustar00rootroot00000000000000#define cgnscalc-icon_width 32 #define cgnscalc-icon_height 32 static unsigned char cgnscalc-icon_bits[] = { 0x03, 0x00, 0x00, 0xff, 0xfb, 0xff, 0x7f, 0xfe, 0xfb, 0xff, 0x7f, 0xfd, 0xfb, 0xdf, 0x73, 0xfb, 0xfb, 0xcf, 0x6d, 0xf7, 0xab, 0xd8, 0x6f, 0xef, 0xdb, 0xdf, 0x73, 0xc0, 0xdb, 0xd8, 0x3d, 0xd4, 0xab, 0x5f, 0xe1, 0xce, 0xfb, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0x7c, 0xd1, 0xfb, 0x7f, 0x3b, 0xd7, 0xab, 0x78, 0x7b, 0xdb, 0xab, 0x4f, 0x7b, 0xdb, 0xab, 0x78, 0x7b, 0xdb, 0xdb, 0xff, 0x6c, 0xdb, 0xdb, 0xff, 0xff, 0xdf, 0xeb, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xdf, 0xfb, 0x8f, 0xcd, 0xd7, 0xfb, 0xef, 0xb4, 0xd3, 0x8b, 0xc8, 0xbd, 0xd7, 0xbb, 0xbf, 0xcd, 0xd7, 0xeb, 0xb8, 0xf5, 0xd7, 0x8b, 0xcf, 0x85, 0xd6, 0xfb, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xdf, 0x03, 0x00, 0x00, 0xc0}; CGNS-4.5.0/src/cgnstools/cgnscalc/cgnscalc-mask.xbm000066400000000000000000000016171474000356600220610ustar00rootroot00000000000000#define cgnscalc-mask_width 32 #define cgnscalc-mask_height 32 static unsigned char cgnscalc-mask_bits[] = { 0xfc, 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff, 0x01, 0xfc, 0xff, 0xff, 0x03, 0xfc, 0xff, 0xff, 0x07, 0xfc, 0xff, 0xff, 0x0f, 0xfc, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f}; CGNS-4.5.0/src/cgnstools/cgnscalc/cgnscalc.bat000066400000000000000000000015721474000356600211100ustar00rootroot00000000000000@echo off setlocal set dir=%~dps0 if exist %dir%cgconfig.bat ( call %dir%cgconfig.bat goto getwish ) if exist %dir%..\cgconfig.bat call %dir%..\cgconfig.bat :getwish if "%CG_BIN_DIR%" == "" set CG_BIN_DIR=%dir% if exist %dir%calcwish.exe ( set wish=%dir%calcwish.exe goto getscript ) if exist %dir%cgnstools\calcwish.exe ( set wish=%dir%cgnstools\calcwish.exe goto getscript ) echo calcwish.exe not found pause goto done :getscript if exist %dir%cgnscalc.tcl ( set script=%dir%cgnscalc.tcl goto run ) if not "%CG_LIB_DIR%" == "" ( if exist %CG_LIB_DIR%\cgnscalc.tcl ( set script=%CG_LIB_DIR%\cgnscalc.tcl goto run ) ) if exist %dir%..\share\cgnscalc.tcl ( if "%CG_LIB_DIR%" == "" set CG_LIB_DIR=%dir%..\share set script=%dir%..\share\cgnscalc.tcl goto run ) echo cgnscalc.tcl not found pause goto done :run start /b %wish% %script% %1 :done endlocal CGNS-4.5.0/src/cgnstools/cgnscalc/cgnscalc.desktop000077500000000000000000000003041474000356600220060ustar00rootroot00000000000000[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=Application Name=CGNScalc GenericName=CGNS calculator Terminal=false Categories=Development; Exec="./cgnscalc" Icon=../share/cgnstools/cgnscalc.png CGNS-4.5.0/src/cgnstools/cgnscalc/cgnscalc.ico000066400000000000000000000020661474000356600211130ustar00rootroot00000000000000 è&(( @€€€€€€€€€€ÀÀÀ€€€ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿððððÿÿððÿÿÿððÿÿÿÿðÿÿÿððÿðÿÿÿððÿÿÿÿÿðÿÿðÿÿÿÿðÿÿÿððÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿððÿÿÿÿÿÿÿÿÿÿÿððÿÿÿÿÿÿðÿðÿðÿÿðÿðÿÿðÿÿðÿðÿðÿÿðÿðÿÿÿÿÿðÿÿÿððÿÿÿÿÿÿÿÿðððÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿðÿÿðððÿÿðÿðÿðÿÿðððÿÿÿðÿÿÿðÿÿÿðÿÿÿÿÿÿÿðÿðÿðÿÿÿÿðÿÿÿðÿÿÿÿÿÿÿÿÿÿððÿÿÿÿÿÿÿÿÿðÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ?À( À€€€€€€€€€ÀÀÀ€€€ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿðÿðÿÿÿÿÿðð€€€€€€€€€€€€€€€€CGNS-4.5.0/src/cgnstools/cgnscalc/cgnscalc.png000066400000000000000000000005341474000356600211230ustar00rootroot00000000000000‰PNG  IHDR szzôsBIT|dˆIDATX…í–Á ƒÁÏ÷åzͺ„dxY.N¶Ñ¿ÐfÔò••ëT37Ìl-C­‡¸â±4"$E³›p™}ÆØx1  ‚›Y1³aˆ@›1;V'ÙÚaOöPËhdrèQ ·À¯€z¦m’Jè´m²Ì¤¸RˆïùÕô‰\êJoˆZʈtü Ðëå%Ëz¨º"ˆœ0+ÛuòÌDl|V!@v)—Œ| pï™óMŒÊÃÿêE‹p—%S€Á)ÀnMɼ/øëÈQSEˆÛ䃫nPP´1‹(ãL¥÷îQÀ ªÍT·Œ:¥<’©£VO3-Lk³ýxàê>Và±_·ØdxÌ IEND®B`‚CGNS-4.5.0/src/cgnstools/cgnscalc/cgnscalc.sh000066400000000000000000000022361474000356600207520ustar00rootroot00000000000000#!/bin/sh # sh script to launch CGNS calculator dir=`dirname $0` # source the setup script for d in $dir $dir/cgnstools $dir/.. ; do if test -f $d/cgconfig ; then . $d/cgconfig break fi done # get the calcwish executable calcwish="" for d in $CG_BIN_DIR $dir $dir/cgnstools $dir/cgnscalc \ /usr/local/bin /usr/local/bin/cgnstools ; do if test -x $d/calcwish ; then calcwish=$d/calcwish break fi if test -x $d/cgnswish/calcwish ; then calcwish=$d/cgnswish/calcwish break fi done if test -z "$calcwish" ; then echo "Error: calcwish executable not found" exit 1 fi # find the cgnscalc tcl script cgnscalc="" for d in $CG_LIB_DIR $dir $dir/cgnstools $dir/cgnscalc \ /usr/local/share /usr/local/share/cgnstools ; do if test -f $d/cgnscalc.tcl ; then cgnscalc=$d/cgnscalc.tcl break fi done if test -z "$cgnscalc" ; then echo "Error: cgnscalc.tcl script not found" exit 1 fi # check that display is set #if test -z "$DISPLAY" ; then # echo "Error: DISPLAY environment variable not set" # exit 1 #fi # execute if test "$#" = 0 ; then exec $calcwish $cgnscalc else exec $calcwish $cgnscalc "$@" fi CGNS-4.5.0/src/cgnstools/cgnscalc/cgnscalc.tcl000066400000000000000000000764601474000356600211340ustar00rootroot00000000000000#!/bin/sh # the next line restarts using wish \ exec calcwish -f "$0" "$@" proc error_exit {msg} { wm withdraw . tk_dialog .error Error $msg error 0 Exit exit 1 } if {[catch {package require Tk 8.0} msg]} { error_exit $msg } #----- get startup directory and name set cmd_name [file tail $argv0] set cmd_dir [file dirname $argv0] if {![file exists $argv0] || [file isdirectory $argv0]} { if {$tcl_platform(platform) == "windows"} { set sep ";" } else { set sep ":" } foreach i [split $env(PATH) $sep] { if {$sep == ";"} { set i [join [split $i \\] /] } if {[file exists $i/$cmd_name] && ![file isdirectory $i/$cmd_name]} { set cmd_dir $i break; } } } set curdir [pwd] if ![catch {cd $cmd_dir}] { set cmd_dir [pwd] cd $curdir } if {$tcl_platform(platform) == "windows"} { set cmd_dir [file attributes $cmd_dir -shortname] } #----- set path to tcl scripts set auto_path "$cmd_dir $cmd_dir/../common $auto_path" if {[info exists env(TCL_PROC_DIR)]} { set auto_path "$env(TCL_PROC_DIR) $auto_path" } #---------- initialize if {$tcl_platform(platform) == "windows"} { set vers [join [split $tcl_version .] {}] if {[info commands CalcInit] == {}} { if {[catch {load calctcl$vers} msg]} { error_exit $msg } } catch {load tclreg$vers registry} if {[info exists env(USERPROFILE)]} { set home [join [split $env(USERPROFILE) \\] /] } elseif {[info exists env(HOME)]} { set home [join [split $env(HOME) \\] /] } else { set home ~ } set InitCmds "$home/_cgnsCalc.clc" } else { if {[info commands CalcInit] == {}} { error_exit "need to run script with calcwish" } set InitCmds "~/.cgnsCalc.clc" } if [catch {config_defaults 1} msg] {error_exit $msg} set butw 5 #----- initialize set Prefix "" set Suffix "" set Count 0 set Index 0 set History(-1) "" array set ProgData { CMDfile {} CGNSfile {} base "" zone "" solution "" regs "" vars "" syms "" cmds "" symlist {} readonly 0 reg,file ".cgnstools" reg,base "HKEY_CURRENT_USER/Software/CGNS" reg,key "CGNScalc" reg,vals {CMDfile CGNSfile} } if {[tclreg_init -base $ProgData(reg,base) -fname $ProgData(reg,file)]} { foreach i $ProgData(reg,vals) { if {![catch {tclreg_get $ProgData(reg,key) $i} val] && $val != ""} { set ProgData($i) $val } } catch units_read } #----- window title wm title . "CGNScalc" wm protocol . WM_DELETE_WINDOW do_quit bind . {select_history -1} bind . {select_history +1} bind . delete_symbol #----- pull-down menu menubar_create {File Options Commands Plot Help} # file menu set m [menubar_get File] $m add command -label "Load CGNS File..." -command {load_cgns ""} $m add command -label "Save Variables..." -command save_cgns \ -state disabled $m add command -label "Edit File..." -command {do_edit ""} $m add separator $m add command -label "Quit" -command do_quit # options menu set m [menubar_get Options] $m add command -label "Delete Symbols" -command delete_symbol $m add command -label "Reset Calculator" -command do_reset # commands menu set m [menubar_get Commands] $m add command -label "Command History..." -command do_history $m add separator $m add command -label "Load Command File..." -command {do_load ""} $m add cascade -label "Save Command File..." -command do_save # plot menu # help menu set m [menubar_get Help] $m add command -label "CGNScalc Help..." \ -command {help_show cgnstools/cgnscalc/index.html} $m add command -label "CGNS Help..." -command {help_show} $m add separator $m add command -label "Configure Help..." -command help_setup $m add separator $m add command -label "Unit Conversions..." -command units_convert $m add command -label "About..." -underline 0 -command do_about image create photo img_about -data {\ R0lGODlhIAAgALMAAAAAAP///8DAwP//////////////////////////////////////////\ /////////yH5BAEAAAIALAAAAAAgACAAAASoUAhAq70YyM1n+GAoilTHAWOaoprpqQEKUvPX\ dvKay/xssrEYLUiyhW6S3igntGVORqGS6KSxoMAiq1JzQmHg5TdMjo3LYCQTrVKXhzWuOzyF\ XzfALXNK5GGpTn1HUW55cIJdfnhRbUqOX2tsPouRkjZnliSYmZNJMFx9a3eebTNZO6MeclY7\ g3FjlY6iZpSmrUGxtJ6gpnFyRnOcmovCw0kZyMkVEhEAADs=} proc do_about {} { global ProgData dialog .about -1 -1 "About CGNScalc" \ "CGNScalc Version 1.1 Bruce Wedan leavingdust@gmail.com" img_about 0 Close } #---------- toolbar frame .toolbar pack .toolbar -side top -pady 2 -fill x set f [frame .toolbar.but] pack $f -side left #--- image create photo img_open -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQ4EMlJKwJvZcC7BxdnSV04nCgKjtR6vZgmZ49L\ bmlus7xV9j4QQPYRtWbI3RCXU10WgKaTVPQAexEAOw==} image create photo img_save -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAQwQ90MlJqwRjgM13BpeGjOSIgQ6mdYCphW1Jtugp\ z2/6sVye8rwLMKiL3Tiwm6smUp5Cmaj0A+Utq6yrZTuJAAA7} image create photo img_edit -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAQwRT0DkwK6VSHsR7H8sAjMdjnigCEMxTouOpZiXw\ 2Ph9S8SLpiNG72cCPUSYjWc5y9hKUNeORgQ6WEpmZ/Vg+KrI1RdlHBwo2c9oTa2ampK1XJ5x\ RAAAOw==} set b [frame $f.b1] pack $b -side left -padx 5 button $b.open -image img_open -command {load_cgns ""} set_balloon $b.open "Open a CGNS File..." button $b.save -image img_save -command save_cgns -state disabled set_balloon $b.save "Save Selected Results to CGNS File..." button $b.edit -image img_edit -command {do_edit ""} set_balloon $b.edit "Edit a File..." pack $b.open $b.save $b.edit -side left -padx 1 #--- image create photo img_delete -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQoEMlJqwVYZqv3phjAXSE5IuWYgmfbiSq4ojAX\ fup9zjjda5WazWWJAAA7} image create photo img_reset -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQwEMlJqwUY24mT91rVfV/IkShAAWirSmxLvkgs\ g+eNw/rO3zSYbRYUpoqrDHLDbDIjADs=} set b [frame $f.b2] pack $b -side left -padx 5 button $b.delete -image img_delete -command delete_symbol set_balloon $b.delete "Delete Selected Symbols" button $b.reset -image img_reset -command do_reset set_balloon $b.reset "Reset Calculator" pack $b.delete $b.reset -side left -padx 1 #--- image create photo img_history -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQeEMlJq7046827/xogjqRIleSFltXKTi6golk8\ glIEADs=} image create photo img_read -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAAARBEMgJnL0XjMNHpUi2dRVWOtqgehgqrmwmWdoU\ Z6J9tig19xNeC/Ao/oSoBzGIJBaNyOREGXU+d0OlhNp8Qps+QAQAOw==} image create photo img_write -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAAAQ/EEjpqr0OvE3zRJYmdmG4nQCWVqN4TezJqeb0\ rFgs4/nksz5Sb3AoDngqohH5GjidzNATmpNOjlXWUYLNBiURADs=} set b [frame $f.b3] pack $b -side left -padx 5 button $b.history -image img_history -command do_history set_balloon $b.history "Command History..." button $b.read -image img_read -command {do_load ""} set_balloon $b.read "Read a Command File..." button $b.write -image img_write -command do_save set_balloon $b.write "Write Commands to File..." pack $b.history $b.read $b.write -side left -padx 1 #--- image create photo img_plot -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQyEMlJq70W4KsvQwnVVUwZTiN5otsqpZT7Wow8\ Ix+e5JVW1juMJkHc3IwogHLJhCGflggAOw==} button $f.plot -image img_plot -state disabled set_balloon $f.plot "Plot Data..." pack $f.plot -side left -padx 6 #--- image create photo img_convert -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAQwQt0MlJq70VSO349B0ghhwYntuIXZ7YUmaWxeu3\ 3eTb4Sld8yngztYDuYbC3yQCADs=} button $f.convert -image img_convert -command "units_convert $f.convert" set_balloon $f.convert "Unit Conversions..." pack $f.convert -side left -padx 6 #--- image create photo img_help -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQiEMlJq50kX5kJ1hvShd+4mSJ4qmTrXl28ehw7\ t+j75joVAQA7} button $f.help -image img_help \ -command {help_show cgnstools/cgnscalc/index.html} set_balloon $f.help "CGNScalc Help..." pack $f.help -side left -padx 6 frame .toolsep -bd 1 -height 2 -relief sunken pack .toolsep -side top -fill x #----- base/zone/solution selection frame .loc pack .loc -side top -fill x -expand 1 -pady 3 foreach i {Base Zone Solution} { set j [string tolower $i] set f [frame .loc.$j] pack $f -side left -fill x -expand 1 -padx 5 label $f.lab -text $i pack $f.lab -side left set ProgData($j) [ComboboxCreate $f.cb -width 10 -edit 0 -command "set_$j"] pack $f.cb -side left -fill x -expand 1 bind $f.cb.ent "location_info $i $f.cb.ent" } proc location_info {type w} { global Font if {$type == "Solution"} { set msg [CalcSolnInfo] } else { set msg [Calc${type}Info] } if {$msg != ""} { popup_message $msg -parent $w -font $Font(fixed) -wrap 0 } } frame .locsep -bd 1 -height 2 -relief sunken pack .locsep -side top -fill x #----- top panel set top [frame .top] pack $top -side top -fill x -anchor n #----- create region list set list [frame $top.regs] pack $list -side left -fill both -expand 1 -padx 2 -pady 2 label $list.lab -text "Regions" pack $list.lab -side top -fill x scrollbar $list.vs -relief sunken -command "$list.list yview" pack $list.vs -side right -fill y scrollbar $list.hs -relief sunken -command "$list.list xview" -orient horiz pack $list.hs -side bottom -fill x set ProgData(regs) [listbox $list.list -relief sunken -width 15 -height 5 \ -exportselection 0 -yscroll "$list.vs set" -xscroll "$list.hs set"] pack $list.list -side left -fill both -expand 1 bind $list.list load_variables bind $list.list {region_properties %W %X %y} proc load_regions {} { global ProgData set sel [$ProgData(regs) curselection] if {$sel != ""} { set sel [$ProgData(regs) get $sel] } set index "" $ProgData(regs) delete 0 end set n 0 foreach v [CalcRegList] { $ProgData(regs) insert end $v if {$v == $sel} { set index $n } incr n } if {$index != ""} { $ProgData(regs) selection set $index $index $ProgData(regs) see $index } } proc region_properties {w x y} { global Font set reg [lindex [split [$w get [$w nearest $y]] "\["] 0] if {$reg == ""} return set msg [CalcRegInfo $reg] if {$msg != ""} { incr y [winfo rooty $w] popup_message $msg -parent $w -position "$x $y" -font $Font(fixed) -wrap 0 } } #----- create variable list set list [frame $top.vars] pack $list -side left -fill both -expand 1 -padx 2 -pady 2 label $list.lab -text "Variables" pack $list.lab -side top -fill x scrollbar $list.vs -relief sunken -command "$list.list yview" pack $list.vs -side right -fill y scrollbar $list.hs -relief sunken -command "$list.list xview" -orient horiz pack $list.hs -side bottom -fill x set ProgData(vars) [listbox $list.list -relief sunken -width 15 -height 5 \ -exportselection 0 -yscroll "$list.vs set" -xscroll "$list.hs set"] pack $list.list -side left -fill both -expand 1 bind $list.list add_variable bind $list.list {variable_properties %W %X %y} proc load_variables {} { global ProgData set sel [$ProgData(vars) curselection] if {$sel != ""} { set sel [$ProgData(vars) get $sel] } set index "" $ProgData(vars) delete 0 end set n 0 foreach v [CalcVarList] { $ProgData(vars) insert end $v if {$v == $sel} { set index $n } incr n } if {$index != ""} { $ProgData(vars) selection set $index $index $ProgData(vars) see $index } } proc variable_properties {w x y} { global Font set var [lindex [split [$w get [$w nearest $y]] "\["] 0] if {$var == ""} return set msg [CalcVarInfo $var] if {$msg != ""} { incr y [winfo rooty $w] popup_message $msg -parent $w -position "$x $y" -font $Font(fixed) -wrap 0 } } #----- symbol list set list [frame $top.syms] pack $list -side left -fill both -expand 1 -padx 2 -pady 2 label $list.lab -text "Symbols" pack $list.lab -side top -fill x scrollbar $list.vs -relief sunken -command "$list.list yview" pack $list.vs -side right -fill y scrollbar $list.hs -relief sunken -command "$list.list xview" -orient horiz pack $list.hs -side bottom -fill x set ProgData(syms) [listbox $list.list -relief sunken -width 15 -height 5 \ -exportselection 0 -yscroll "$list.vs set" -xscroll "$list.hs set"] pack $list.list -side left -fill both -expand 1 bind $list.list { set n [%W curselection] if {$n != ""} {add_symbol [%W get $n]} } bind $list.list {symbol_properties %W %X %y} proc sort_symbols {sym1 sym2} { if {[string first "(" $sym1] >= 0} { if {[string first "(" $sym2] >= 0} { return [string compare $sym1 $sym2] } return 1 } if {[string first "\[" $sym1] >= 0} { if {[string first "(" $sym2] >= 0} { return -1 } if {[string first "\[" $sym2] >= 0} { return [string compare $sym1 $sym2] } return 1 } if {[string first "(" $sym2] >= 0 || [string first "\[" $sym2] >= 0} { return -1 } return [string compare $sym1 $sym2] } proc load_symbols {} { global ProgData $ProgData(syms) delete 0 end set ProgData(symlist) [list] foreach s [lsort -command sort_symbols [CalcSymList]] { $ProgData(syms) insert end $s lappend ProgData(symlist) [lindex [split $s "\["] 0] } } proc delete_symbol {} { global ProgData set syms {} foreach i [$ProgData(syms) curselection] { lappend syms [lindex [split [lindex \ [split [$ProgData(syms) get $i] "\("] 0] "\["] 0] } if {$syms != {}} { if {![dialog .delsym . {} "Delete Symbols" \ "Delete the symbols:\n$syms" question 0 Yes No]} { catch {CalcDelete $syms} load_symbols } } } proc symbol_properties {w x y} { global Font set sym [lindex [split [lindex \ [split [$w get [$w nearest $y]] "\("] 0] "\["] 0] if {$sym == ""} return set msg [CalcSymInfo $sym] if {$msg != ""} { incr y [winfo rooty $w] popup_message $msg -parent $w -position "$x $y" -font $Font(fixed) -wrap 0 } } #----- create function buttons set func [frame $top.func] pack $func -side right -padx 2 -pady 2 set f [frame $func.s] pack $f -side top -fill x -padx 2 -pady 2 label $f.lab -text "Scalar Functions" pack $f.lab -side top -fill x foreach s {avg sum min max len mag} { button $f.$s -relief raised -text $s -width $butw \ -command "add_function $s" pack $f.$s -side left -expand 1 } set f [frame $func.v] pack $f -side top -fill x -padx 2 -pady 2 label $f.lab -text "Vector Functions" pack $f.lab -side top -fill x set i 0 set j 0 foreach v { \ {deg deg add_function} \ {arc a set_prefix} \ {exp exp add_function} \ {rad rad add_function} \ {hyp h set_suffix} \ {log log add_function} \ {abs abs add_function} \ {sin sin add_trigfunc} \ {pow10 pow10 add_function} \ {round round add_function} \ {cos cos add_trigfunc} \ {log10 log10 add_function} \ {ceil ceil add_function} \ {tan tan add_trigfunc} \ {sqr sqr add_function} \ {floor floor add_function} \ {fact fact add_function} \ {sqrt sqrt add_function}} { if !$i { incr j 1 set ff [frame $f.$j] pack $ff -side left -fill y } incr i 1 button $ff.$i -relief raised -text [lindex $v 0] -width $butw \ -command "[lindex $v 2] [lindex $v 1]" pack $ff.$i -side top -fill x -expand 1 if {$i == 3} { set i 0 } } #----- intrinsic constants set f [frame $func.c] pack $f -side top -fill x -padx 2 -pady 2 label $f.lab -text "Intrinsic Constants" pack $f.lab -side top -fill x set n 0 foreach b { \ {PI pi} \ {E e} \ {TOL tol} \ {DIM dim} \ {index index} \ {rand rand()}} { incr n 1 button $f.$n -relief raised -text [lindex $b 0] -width $butw \ -command "add_name [lindex $b 1]" pack $f.$n -side left -expand 1 } #----- create operator buttons set oper [frame .oper] pack $oper -side top -fill x -padx 2 -pady 2 -anchor n set f [frame $oper.but] pack $f -side left -fill both -expand 1 button $f.1 -relief raised -text "Bksp" -width 4 -command command_backspace button $f.2 -relief raised -text "Clear" -width 4 -command command_clear pack $f.1 $f.2 -side top -fill x -expand 1 set operators { {0 5} {1 6} {2 7} {3 8} {4 9} {" " .} {= ,} {+ -} {* /} {^ **} {! %} {\( \)} {\[ \]} {< >} {<= >=} {== !=} {& |} {? :} {\" ~} } set n 0 foreach o $operators { incr n 1 set f [frame $oper.$n] pack $f -side left -fill both -expand 1 button $f.1 -relief raised -text [lindex $o 0] -width 1 \ -command "add_name {[lindex $o 0]}" button $f.2 -relief raised -text [lindex $o 1] -width 1 \ -command "add_name {[lindex $o 1]}" pack $f.1 $f.2 -side top -fill x -expand 1 } #----- command input line image create bitmap dnimage -foreground $fgColor(button) -data " \#define down_width 16 \#define down_height 16 static char down_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0xfc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; " image create bitmap upimage -foreground $fgColor(button) -data " \#define up_width 16 \#define up_height 16 static char up_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; " set com [frame .com] pack $com -side top -fill x -padx 2 -pady 2 -anchor n button $com.but -text "Command" -command do_command pack $com.but -side left -anchor w button $com.down -image dnimage -state disabled \ -command {select_history +1} pack $com.down -side right -fill y button $com.up -image upimage -state disabled \ -command {select_history -1} pack $com.up -side right -fill y set ProgData(cmds) [entry $com.e -relief sunken] pack $com.e -side left -anchor w -fill x -expand 1 -padx 2 bind $com.e {do_command} bind $com.e {%W delete 0 end} bind $com.e add_variable #focus $com.e #----- output window set msg [frame .msg -relief groove -bd 3] pack $msg -side top -fill both -expand 1 -padx 2 -pady 2 scrollbar $msg.scroll -relief sunken -command "$msg.text yview" pack $msg.scroll -side right -fill y text $msg.text -height 10 -yscroll "$msg.scroll set" -cursor {} pack $msg.text -side left -fill both -expand 1 bind $msg.text "focus $com.e" #----- help proc help_menu {} { if [help_valid] { menubar_state Help normal 0 menubar_state Help normal 1 .toolbar.but.help configure -state normal } else { menubar_state Help disabled 0 menubar_state Help disabled 1 .toolbar.but.help configure -state disabled } } help_init #----- procedures proc command_insert {text} { global ProgData if {[$ProgData(cmds) selection present]} { set first [$ProgData(cmds) index sel.first] set last [$ProgData(cmds) index sel.last] $ProgData(cmds) selection clear $ProgData(cmds) delete $first $last $ProgData(cmds) icursor $first } $ProgData(cmds) insert insert $text focus $ProgData(cmds) } proc command_clear {} { global ProgData if {[$ProgData(cmds) selection present]} { set first [$ProgData(cmds) index sel.first] set last [$ProgData(cmds) index sel.last] $ProgData(cmds) selection clear $ProgData(cmds) delete $first $last $ProgData(cmds) icursor $first } else { $ProgData(cmds) delete 0 end } } proc command_backspace {} { global ProgData set n [$ProgData(cmds) index insert] if {$n > 0} { $ProgData(cmds) delete [expr $n - 1] $n } } proc writemsg {msg} { .msg.text insert end "$msg\n" .msg.text yview -pickplace end update idletasks } proc add_variable {} { global ProgData set n [$ProgData(vars) curselection] if {$n == ""} return set name [lindex [split [$ProgData(vars) get $n] "\["] 0] if {[lsearch -exact $ProgData(symlist) $name] >= 0} { add_name "\\$name" } else { add_name $name } } proc add_name {name} { set_prefix "" set_suffix "" command_insert "$name" } proc add_function {name} { set_prefix "" set_suffix "" command_insert "$name\(" } proc add_symbol {sym} { if {[string first \[ $sym] != -1} { add_name [lindex [split $sym \[] 0] } elseif {[string first \( $sym] != -1} { if [string match "*(0)" $sym] { add_name "[lindex [split $sym \(] 0]\(\)" } else { add_function [lindex [split $sym \(] 0] } } else { add_name $sym } } proc set_prefix {p} { global Prefix if {$p != "" && $p == $Prefix} {set p ""} if {$p == ""} { .top.func.v.1.2 configure -relief raised } else { .top.func.v.1.2 configure -relief sunken } set Prefix $p } proc set_suffix {s} { global Suffix if {$s != "" && $s == $Suffix} {set s ""} if {$s == ""} { .top.func.v.2.2 configure -relief raised } else { .top.func.v.2.2 configure -relief sunken } set Suffix $s } proc add_trigfunc {name} { global Prefix Suffix command_insert "$Prefix$name$Suffix\(" set_prefix "" set_suffix "" } proc do_quit {} { global ProgData CalcDone foreach i $ProgData(reg,vals) { catch {tclreg_set $ProgData(reg,key) $i $ProgData($i)} } catch units_write catch tclreg_close destroy . exit 0 } #----- reset calculator proc do_reset {} { global ProgData if [dialog .reset $ProgData(vars) {} Reset \ "This will delete all symbols and clear the output window. Do you wish to proceed ?" question 0 Yes No] return CalcReset $ProgData(cmds) delete 0 end .msg.text delete 1.0 end load_symbols clear_history } #----- command history proc update_history {} { global Index Count if {$Index <= 0} { .com.up configure -state disabled } else { .com.up configure -state normal } if {$Index >= $Count} { .com.down configure -state disabled } else { .com.down configure -state normal } } proc add_history {cmd} { global Index Count History set History($Count) $cmd incr Count set Index $Count if {[winfo exists .histlist]} { .histlist.top.list insert end $cmd .histlist.top.list selection clear 0 end .histlist.top.list see end } update_history } proc clear_history {} { global Index Count History set Index 0 set Count 0 catch {array unset History} set History(-1) "" if {[winfo exists .histlist]} { .histlist.top.list delete 0 end } update_history } proc select_history {dir} { global ProgData Index Count History set n [expr $Index$dir] if {$n >= 0 && $n <= $Count} { set Index $n $ProgData(cmds) delete 0 end if {$Index < $Count} { command_insert $History($Index) } if {[winfo exists .histlist]} { .histlist.top.list selection clear 0 end if {$Index < $Count} { .histlist.top.list selection set $Index } } update_history } } proc set_history {} { global ProgData Index Count History set n [.histlist.top.list curselection] if {$n != ""} { set Index $n $ProgData(cmds) delete 0 end command_insert $History($Index) update_history } } proc do_history {} { global Index Count History set w .histlist if {[winfo exists $w]} { wm deiconify $w focus $w return } toplevel $w wm title $w "Command History" frame $w.top pack $w.top -fill both -padx 2 -pady 2 -expand 1 scrollbar $w.top.ys -command "$w.top.list yview" pack $w.top.ys -side right -fill y scrollbar $w.top.xs -orient horizontal -command "$w.top.list xview" pack $w.top.xs -side bottom -fill x listbox $w.top.list -width 40 -height 10 -selectmode single \ -exportselection 0 -xscroll "$w.top.xs set" -yscroll "$w.top.ys set" pack $w.top.list -side left -fill both for {set n 0} {$n < $Count} {incr n} { $w.top.list insert end $History($n) } if {$Index >= 0 && $Index < $Count} { $w.top.list selection set $Index $w.top.list see $Index } else { $w.top.list see end } bind $w.top.list set_history frame $w.but pack $w.but -side bottom -fill x button $w.but.select -text Select -width 8 -command set_history button $w.but.clear -text Clear -width 8 -command clear_history button $w.but.close -text Close -width 8 -command "destroy $w" pack $w.but.select $w.but.clear $w.but.close -side left \ -padx 5 -pady 2 -expand 1 center_window $w . focus $w } #----- process command proc is_equation {cmd} { regsub -all "\[ \t\]+" $cmd {} newcmd set s [split $newcmd "="] if {[llength $s] > 1 && [lindex $s 1] != "" && [string match "\[_a-zA-Z\]*\(\[0-9\]\)" [lindex $s 0]]} { return 1 } return 0 } proc do_command {} { global ProgData set cmd [string trim [$ProgData(cmds) get]] set n [string first "\#" $cmd] if {$n >= 0} { if {$n == 0} { set cmd "" } else { incr n -1 set cmd [string trim [string range $cmd 0 $n]] } } if {$cmd == ""} return if {[string first @ $cmd] > 0} { set l [split $cmd @] set cmd [string trim [lindex $l 0]] set reg "@[string trim [lindex $l 1]]" } else { set regnum [$ProgData(regs) curselection] if {$regnum != "" && $regnum > 0 && ![is_equation $cmd]} { set regname [$ProgData(regs) get $regnum] set n [string last "\[" $regname] if {$n < 0} { set n [string last "\{" $regname] } set reg "@[string range $regname 0 [expr $n - 1]]" } else { set reg "" } } writemsg "\nCOMMAND: $cmd$reg" add_history $cmd if [catch {CalcCommand $cmd$reg} result] { foreach line [split $result '\n'] { writemsg "ERROR : $line" } } else { writemsg "RESULT : $result" $ProgData(cmds) delete 0 end load_symbols } } #----- load/save command file proc do_load {filename} { global ProgData if {$filename == {}} { set filename [FileOpen "Load Command File" $ProgData(CMDfile) . \ {{{CMD Files} {.clc .cmd}} {{All Files} {*}}}] } if {$filename == ""} return update if {![file isfile $filename]} { errormsg "$filename is not a regular file" return } if [catch {open $filename r} f] { errormsg $f return } writemsg "LOADING: $filename" set region "" while {[gets $f cmd] >= 0} { while (1) { set n [expr [string length $cmd] - 1] if {[string index $cmd $n] != "\\"} break set cmd [string trim [string range $cmd 0 [expr $n - 1]]] if {[gets $f str] < 0} break append cmd [string trim $str] } set n [string first "\#" $cmd] if {$n >= 0} { if {$n == 0} { set cmd "" } else { incr n -1 set cmd [string trim [string range $cmd 0 $n]] } } else { set cmd [string trim $cmd] } switch [string index $cmd 0] { "%" continue "?" continue "*" continue "@" { set region [string trim [string range $cmd 1 end]] continue } "&" { set cgnsfile [string trim [string range $cmd 1 end]] if {$cgnsfile != ""} { load_cgns $cgnsfile } } "<" { set cmdfile [string trim [string range $cmd 1 end]] if {$cmdfile != ""} { do_load $cmdfile } } ">" {set cmd [string trim [string range $cmd 1 end]]} } if {$cmd != ""} { add_history $cmd if {$region != "" && [string first "@" $cmd] < 0} { append cmd "@$region" } writemsg "\nCOMMAND: $cmd" if [catch {CalcCommand $cmd} result] { foreach line [split $result '\n'] { writemsg "ERROR : $line" } } else { writemsg "RESULT : $result" } } } close $f load_symbols set ProgData(CMDfile) $filename } proc do_save {} { global ProgData set filename [FileSave "Save Command File" $ProgData(CMDfile) . \ {{{Command Files} {.clc .cmd .cnv}} {{All Files} {*}}}] if {$filename == ""} return if [catch {open $filename w+} f] { errormsg $f return } writemsg "\nSAVING : $filename" set cmd "" foreach line [split [.msg.text get 1.0 end] "\n"] { if {$line == ""} { set cmd "" puts $f "" } else { puts $f "\#$line" set prompt [string range $line 0 7] if {$prompt == "COMMAND:"} { set cmd [string trim [string range $line 8 end]] } elseif {$prompt == "RESULT :"} { if {$cmd != ""} { puts $f $cmd set cmd "" } } else { set cmd "" } } } close $f set ProgData(CMDfile) $filename } #----- set base, zone and solution proc set_base {w base} { global ProgData foreach f {regs vars} { $ProgData($f) delete 0 end } ComboboxConfig $ProgData(solution) -values {} if {[catch {CalcBase [expr $base + 1]} zones]} { errormsg $zones set zones "" } else { ComboboxConfig $w -index $base } ComboboxConfig $ProgData(zone) -values $zones if {$zones == ""} { load_variables } else { set_zone $ProgData(zone) 0 } return "" } proc set_zone {w zone} { global ProgData foreach f {regs vars} { $ProgData($f) delete 0 end } if {[catch {CalcZone [expr $zone + 1]} solns]} { errormsg $solns set solns "" } else { ComboboxConfig $w -index $zone } ComboboxConfig $ProgData(solution) -values $solns load_regions if {$solns == ""} { load_variables } else { set_solution $ProgData(solution) 0 } return "" } proc set_solution {w soln} { global ProgData $ProgData(vars) delete 0 end if {[catch {CalcSoln [expr $soln + 1]} vars] || $vars == ""} { errormsg $vars } else { ComboboxConfig $w -index $soln } load_variables return "" } #----- load/save CGNS file proc load_cgns {fname} { global ProgData if {$fname == ""} { set fname [FileOpen "Load CGNS File" $ProgData(CGNSfile) . \ {{{CGNS Files} {.cgns .cga .cgh .cgx}} {{All Files} *}}] if {$fname == ""} return } if {![file isfile $fname]} { errormsg "$fname is not a regular file" return } foreach f {regs vars syms} { $ProgData($f) delete 0 end } foreach i {base zone solution} { ComboboxConfig $ProgData($i) -values {} } if 0 { if {[file writable $fname]} { set ProgData(readonly) 0 set mode w } else { set ProgData(readonly) 1 set mode r } } else { set ProgData(readonly) 1 set mode r } dialog .open -1 -1 "Opening..." \ "Opening and reading [file tail $fname]" hourglass 0 {} .open configure -cursor watch . configure -cursor watch update if {[catch {CalcInit $mode $fname} bases]} { set msg $bases } else { set msg "" } destroy .open . configure -cursor {} if {$msg != ""} { errormsg $bases return } if {$bases == ""} { errormsg "no bases defined in CGNS file" return } if {$ProgData(readonly)} { wm title . "CGNScalc : [file tail $fname] (read only)" } else { wm title . "CGNScalc : [file tail $fname]" } set ProgData(CGNSfile) $fname ComboboxConfig $ProgData(base) -values $bases set_base $ProgData(base) 0 } proc save_cgns {} { } wm withdraw . update idletasks wm minsize . [winfo reqwidth .] [winfo reqheight .] catch { config_icon . [list cgnscalc cgns] \ [list $cmd_dir $cmd_dir/images $cmd_dir/../common] } focus $ProgData(cmds) wm deiconify . if {$argc} { set file [lindex $argv [expr $argc - 1]] if {[string index $file 0] != "-" && [file exists $file]} { load_cgns $file } } if {[file exists $InitCmds] && [file readable $InitCmds]} { do_load $InitCmds } CGNS-4.5.0/src/cgnstools/cgnscalc/unitconv.bat000066400000000000000000000021651474000356600211770ustar00rootroot00000000000000@echo off setlocal rem the standard wish command will work for this rem set wish=c:\progra~1\tcl\bin\wish83.exe set dir=%~dps0 if exist %dir%cgconfig.bat ( call %dir%cgconfig.bat goto getwish ) if exist %dir%..\cgconfig.bat call %dir%..\cgconfig.bat :getwish if not "%wish%" == "" goto getscript if exist %dir%calcwish.exe ( set wish=%dir%calcwish.exe goto getscript ) if exist %dir%cgnstools\calcwish.exe ( set wish=%dir%cgnstools\calcwish.exe goto getscript ) if exist %dir%cgiowish.exe ( set wish=%dir%cgiowish.exe goto getscript ) if exist %dir%cgnstools\cgiowish.exe ( set wish=%dir%cgnstools\cgiowish.exe goto getscript ) echo calcwish.exe or cgiowish.exe not found pause goto done :getscript if exist %dir%unitconv.tcl ( set script=%dir%unitconv.tcl goto run ) if not "%CG_LIB_DIR%" == "" ( if exist %CG_LIB_DIR%\unitconv.tcl ( set script=%CG_LIB_DIR%\unitconv.tcl goto run ) ) if exist %dir%..\share\unitconv.tcl ( set CG_LIB_DIR=%dir%..\share set script=%dir%..\share\unitconv.tcl goto run ) echo unitconv.tcl not found pause goto done :run start /b %wish% %script% %1 :done endlocal CGNS-4.5.0/src/cgnstools/cgnscalc/unitconv.desktop000077500000000000000000000003161474000356600221010ustar00rootroot00000000000000[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=Application Name=CGNSunitconv GenericName=Unit conversions tool Terminal=false Categories=Development; Exec="./unitconv" Icon=../share/cgnstools/unitconv.png CGNS-4.5.0/src/cgnstools/cgnscalc/unitconv.ico000066400000000000000000000020661474000356600212030ustar00rootroot00000000000000 è&(( @€€€€€€€€€€ÀÀÀ€€€ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ( À€€€€€€€€€ÀÀÀ€€€ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿðÿððÿÿÿÿðÿÿÿÿðÿððÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿðÿðÿÿðÿðÿÿðÿðÿðÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿCGNS-4.5.0/src/cgnstools/cgnscalc/unitconv.png000066400000000000000000000004171474000356600212130ustar00rootroot00000000000000‰PNG  IHDR szzôsBIT|dˆÆIDATX…íWÑ„ »^üÿ_æž0ZW@§1×7t£Ôn¢”R>‰øf&Ÿ¢€…vëzC*î¶à$=XE´Þaí_¨ò¦VÀ)&¬ýóiÀ ňºš÷1Àà“³¦Ò@„·<$„mB>ïãP‰+Ò5ð/@vÑÃr·Ñ^Rq™³SáÐ yÝcÂk#óh€'ïÉ£œÏmDÞQM D6š`”Q7·‹0ú?Åd ²ˆ°n¨Äú¸ôØ ™ˆZHwÂô~IŸm8¦èùßIEND®B`‚CGNS-4.5.0/src/cgnstools/cgnscalc/unitconv.sh000077500000000000000000000022711474000356600210440ustar00rootroot00000000000000#!/bin/sh # sh script to launch unit converter dir=`dirname $0` # source the setup script for d in $dir $dir/cgnstools $dir/.. ; do if test -f $d/cgconfig ; then . $d/cgconfig break fi done # The normal wish will work here, but calcwish should # be available, and may also be used calcwish="" for d in $CG_BIN_DIR $dir $dir/cgnstools $dir/cgnscalc \ /usr/local/bin /usr/local/bin/cgnstools ; do if test -x $d/calcwish ; then calcwish=$d/calcwish break fi if test -x $d/cgnswish/calcwish ; then calcwish=$d/cgnswish/calcwish break fi done if test -z "$calcwish" ; then echo "Error: calcwish executable not found" exit 1 fi # find the unitconv tcl script unitconv="" for d in $CG_LIB_DIR $dir $dir/cgnstools $dir/cgnscalc \ $dir/../share/cgnstools \ /usr/local/share /usr/local/share/cgnstools ; do if test -f $d/unitconv.tcl ; then unitconv=$d/unitconv.tcl break fi done if test -z "$unitconv" ; then echo "Error: unitconv.tcl script not found" exit 1 fi # check that display is set if test -z "$DISPLAY" ; then echo "Error: DISPLAY environment variable not set" exit 1 fi # execute exec $calcwish $unitconv CGNS-4.5.0/src/cgnstools/cgnscalc/unitconv.tcl000066400000000000000000000027271474000356600212170ustar00rootroot00000000000000#!/bin/sh # the next line restarts using wish \ exec wish -f "$0" "$@" proc error_exit {msg} { wm withdraw . tk_dialog .error Error $msg error 0 Exit exit 1 } if {[catch {package require Tk 8.0} msg]} { error_exit $msg } #----- get startup directory and name set cmd_name [file tail $argv0] set cmd_dir [file dirname $argv0] if {![file exists $argv0] || [file isdirectory $argv0]} { if {$tcl_platform(platform) == "windows"} { set sep ";" } else { set sep ":" } foreach i [split $env(PATH) $sep] { if {$sep == ";"} { set i [join [split $i \\] /] } if {[file exists $i/$cmd_name] && ![file isdirectory $i/$cmd_name]} { set cmd_dir $i break; } } } set curdir [pwd] if ![catch {cd $cmd_dir}] { set cmd_dir [pwd] cd $curdir } if {$tcl_platform(platform) == "windows"} { set cmd_dir [file attributes $cmd_dir -shortname] } #----- set path to tcl scripts set auto_path "$cmd_dir $cmd_dir/../common $auto_path" if {[info exists env(TCL_PROC_DIR)]} { set auto_path "$env(TCL_PROC_DIR) $auto_path" } #---------- initialize if [catch {config_defaults 1} msg] {error_exit $msg} if {$tcl_platform(platform) == "windows"} { set vers [join [split $tcl_version .] {}] catch {load tclreg$vers registry} } if {[tclreg_init -base "HKEY_CURRENT_USER/Software/CGNS" \ -fname ".cgnstools"]} { units_read } units:create . catch { config_icon . [list unitconv cgns] \ [list $cmd_dir $cmd_dir/images $cmd_dir/../common] } CGNS-4.5.0/src/cgnstools/cgnscalc/unitconv.xbm000066400000000000000000000016001474000356600212100ustar00rootroot00000000000000#define unitconv_width 32 #define unitconv_height 32 static unsigned char unitconv_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3c, 0x00, 0x00, 0xf8, 0x7f, 0xf0, 0x07, 0x0c, 0xc3, 0xf0, 0x0f, 0x0c, 0xc3, 0xf0, 0x0f, 0x0c, 0xc3, 0x00, 0x0c, 0x0c, 0xc3, 0x00, 0x0c, 0x0c, 0xc3, 0x00, 0x3f, 0x0c, 0xc3, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x80, 0x0f, 0x03, 0x30, 0xc0, 0x0f, 0x03, 0xfc, 0xc0, 0x00, 0x03, 0xfc, 0xc0, 0x00, 0x03, 0x30, 0xc0, 0xc0, 0x3f, 0x30, 0xc0, 0xcf, 0x3f, 0xf0, 0xcf, 0x0f, 0x03, 0xf0, 0xcf, 0x00, 0x03, 0xe0, 0xcf, 0x00, 0x03, 0x00, 0xc0, 0x00, 0x03, 0x00, 0xc0, 0x00, 0x3f, 0x00, 0xc0, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; CGNS-4.5.0/src/cgnstools/cgnscalc/winmain.c000066400000000000000000000203611474000356600204460ustar00rootroot00000000000000/* * winMain.c -- * * Main entry point for wish and other Tk-based applications. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright (c) 1998-1999 by Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN #include #include "tkWinInt.h" #include #include extern int Calctcl_Init _ANSI_ARGS_((Tcl_Interp *interp)); #ifdef USE_HTMLHELP extern int WinHtml_Init _ANSI_ARGS_((Tcl_Interp *interp)); #endif /* * Forward declarations for procedures defined later in this file: */ static void setargv _ANSI_ARGS_((int *argcPtr, char ***argvPtr)); static void WishPanic _ANSI_ARGS_(TCL_VARARGS(char *,format)); static int Proc_LoadIcon _ANSI_ARGS_((ClientData data, Tcl_Interp *interp, int argc, char **argv)); static HINSTANCE myInstance; /* *---------------------------------------------------------------------- * * WinMain -- * * Main entry point from Windows. * * Results: * Returns false if initialization fails, otherwise it never * returns. * * Side effects: * Just about anything, since from here we call arbitrary Tcl code. * *---------------------------------------------------------------------- */ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { char **argv; int argc; char buffer[MAX_PATH+1]; char *p; Tcl_SetPanicProc((Tcl_PanicProc *)WishPanic); /* * Increase the application queue size from default value of 8. * At the default value, cross application SendMessage of WM_KILLFOCUS * will fail because the handler will not be able to do a PostMessage! * This is only needed for Windows 3.x, since NT dynamically expands * the queue. */ SetMessageQueue(64); /* * Set up the default locale to be standard "C" locale so parsing * is performed correctly. */ setlocale(LC_ALL, "C"); setargv(&argc, &argv); /* * Replace argv[0] with full pathname of executable, and forward * slashes substituted for backslashes. */ GetModuleFileName(NULL, buffer, sizeof(buffer)); argv[0] = buffer; for (p = buffer; *p != '\0'; p++) { if (*p == '\\') { *p = '/'; } } myInstance = hInstance; Tk_Main(argc, argv, Tcl_AppInit); return 1; } /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in the interp's result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(Tcl_Interp *interp) { if (Tcl_Init(interp) == TCL_ERROR) { goto error; } if (Tk_Init(interp) == TCL_ERROR) { goto error; } Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit); if (Calctcl_Init(interp) == TCL_ERROR) goto error; #ifdef USE_HTMLHELP if (WinHtml_Init(interp) == TCL_ERROR) goto error; #endif Tcl_CreateCommand (interp, "LoadIcon", (Tcl_CmdProc *)Proc_LoadIcon, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_SetVar(interp, "tcl_rcFileName", "~/wishrc.tcl", TCL_GLOBAL_ONLY); return TCL_OK; error: MessageBeep(MB_ICONEXCLAMATION); MessageBox(NULL, Tcl_GetStringResult(interp), "Error in Wish", MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); ExitProcess(1); /* we won't reach this, but we need the return */ return TCL_ERROR; } /* *---------------------------------------------------------------------- * * WishPanic -- * * Display a message and exit. * * Results: * None. * * Side effects: * Exits the program. * *---------------------------------------------------------------------- */ void WishPanic TCL_VARARGS_DEF(char *,arg1) { va_list argList; char buf[1024]; char *format; format = TCL_VARARGS_START(char *,arg1,argList); vsprintf(buf, format, argList); MessageBeep(MB_ICONEXCLAMATION); MessageBox(NULL, buf, "Fatal Error in Wish", MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); #ifdef _MSC_VER DebugBreak(); #endif ExitProcess(1); } /* *------------------------------------------------------------------------- * * setargv -- * * Parse the Windows command line string into argc/argv. Done here * because we don't trust the builtin argument parser in crt0. * Windows applications are responsible for breaking their command * line into arguments. * * 2N backslashes + quote -> N backslashes + begin quoted string * 2N + 1 backslashes + quote -> literal * N backslashes + non-quote -> literal * quote + quote in a quoted string -> single quote * quote + quote not in quoted string -> empty string * quote -> begin quoted string * * Results: * Fills argcPtr with the number of arguments and argvPtr with the * array of arguments. * * Side effects: * Memory allocated. * *-------------------------------------------------------------------------- */ static void setargv(int *argcPtr, char ***argvPtr) { char *cmdLine, *p, *arg, *argSpace; char **argv; int argc, size, inquote, copy, slashes; cmdLine = GetCommandLine(); /* INTL: BUG */ /* * Precompute an overly pessimistic guess at the number of arguments * in the command line by counting non-space spans. */ size = 2; for (p = cmdLine; *p != '\0'; p++) { if ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */ size++; while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */ p++; } if (*p == '\0') { break; } } } argSpace = (char *) Tcl_Alloc( (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1)); argv = (char **) argSpace; argSpace += size * sizeof(char *); size--; p = cmdLine; for (argc = 0; argc < size; argc++) { argv[argc] = arg = argSpace; while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */ p++; } if (*p == '\0') { break; } inquote = 0; slashes = 0; while (1) { copy = 1; while (*p == '\\') { slashes++; p++; } if (*p == '"') { if ((slashes & 1) == 0) { copy = 0; if ((inquote) && (p[1] == '"')) { p++; copy = 1; } else { inquote = !inquote; } } slashes >>= 1; } while (slashes) { *arg = '\\'; arg++; slashes--; } if ((*p == '\0') || (!inquote && ((*p == ' ') || (*p == '\t')))) { /* INTL: ISO space. */ break; } if (copy != 0) { *arg = *p; arg++; } p++; } *arg = '\0'; argSpace = arg + 1; } argv[argc] = NULL; *argcPtr = argc; *argvPtr = argv; } /*---------------------------------------------------------------------- * set the toplevel window icon *----------------------------------------------------------------------*/ typedef struct TkWmInfo { TkWindow *winPtr; HWND hwnd; } WmInfo; static int Proc_LoadIcon(ClientData data, Tcl_Interp *interp, int argc, char **argv) { TkWindow *winPtr; HANDLE hIcon; HWND hwnd = NULL; if (2 != argc) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " iconname\"", (char *) NULL); return TCL_ERROR; } winPtr = (TkWindow *) Tk_MainWindow (interp); if (NULL != winPtr && NULL != winPtr->wmInfoPtr) hwnd = winPtr->wmInfoPtr->hwnd; if (!hwnd) { Tcl_SetResult (interp, "toplevel window has not been created/mapped", TCL_STATIC); return TCL_ERROR; } if (argv[1][0] == '@') hIcon = LoadImage (NULL, &argv[1][1], IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE); else hIcon = (HANDLE) LoadIcon (myInstance, argv[1]); if (!hIcon) { Tcl_SetResult (interp, "icon not found", TCL_STATIC); return TCL_ERROR; } SetClassLongPtr (hwnd, GCLP_HICON, (LONG_PTR)hIcon); Tcl_ResetResult (interp); return TCL_OK; } CGNS-4.5.0/src/cgnstools/cgnsplot/000077500000000000000000000000001474000356600167125ustar00rootroot00000000000000CGNS-4.5.0/src/cgnstools/cgnsplot/CMakeLists.txt000066400000000000000000000044461474000356600214620ustar00rootroot00000000000000############ # cgnsplot # ############ # Define source files if (WIN32) if (HTML_HELP_INCLUDE_PATH AND HTML_HELP_LIBRARY) set(cgnsplot_FILES cgnstcl.c winmain.c ../common/hash.c ../common/winhtml.c) else () set(cgnsplot_FILES cgnstcl.c winmain.c ../common/hash.c) endif () else () set(cgnsplot_FILES cgnstcl.c plotwish.c ../common/hash.c) endif () # Define executable and dependencies add_subdirectory(../tkogl tkogl) add_executable(plotwish ${cgnsplot_FILES}) if (CGNS_USE_SHARED) set(PLOT_LK_LIBS cgns_shared) else () set(PLOT_LK_LIBS cgns_static) endif () if (CGNS_ENABLE_HDF5 AND HDF5_LIBRARY) list(APPEND PLOT_LK_LIBS ${HDF5_LIBRARY}) if(HDF5_NEED_ZLIB AND ZLIB_LIBRARY) list(APPEND PLOT_LK_LIBS ${ZLIB_LIBRARY}) endif() if(HDF5_NEED_SZIP AND SZIP_LIBRARY) list(APPEND PLOT_LK_LIBS ${SZIP_LIBRARY}) endif() if(HDF5_NEED_MPI AND MPI_LIBS) list(APPEND PLOT_LK_LIBS ${MPI_LIBS}) endif() endif () if (WIN32) if (HTML_HELP_INCLUDE_PATH AND HTML_HELP_LIBRARY) add_definitions(-DUSE_HTMLHELP) target_include_directories(plotwish PRIVATE ${HTML_HELP_INCLUDE_PATH}) list(APPEND PLOT_LK_LIBS ${HTML_HELP_LIBRARY}) endif () else () target_include_directories(plotwish PRIVATE ${X11_X11_INCLUDE_PATH}) list(APPEND PLOT_LK_LIBS ${X11_X11_LIB} ${X11_Xmu_LIB} ${X11_SM_LIB} m) endif () target_link_libraries(plotwish PRIVATE tkogl ${PLOT_LK_LIBS} OpenGL::GL) #target_include_directories(plotwish PRIVATE ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR}) #if (X11_FOUND) # target_include_directories(plotwish PRIVATE ${X11_INCLUDE_DIR}) #endif() #target_include_directories(plotwish PRIVATE ../common) if (WIN32) set_target_properties(plotwish PROPERTIES LINK_FLAGS /subsystem:windows) endif () if (WIN32) install(TARGETS plotwish RUNTIME DESTINATION bin) install(PROGRAMS cgnsplot.bat DESTINATION bin) install(FILES cgnsplot.tcl cgnsplot.ico cgnsplot.png cgnsplot-icon.xbm cgnsplot-mask.xbm DESTINATION share) else () install(TARGETS plotwish RUNTIME DESTINATION bin/cgnstools) install(PROGRAMS cgnsplot.sh DESTINATION bin RENAME cgnsplot) install(PROGRAMS cgnsplot.desktop DESTINATION bin) install(FILES cgnsplot.tcl cgnsplot.ico cgnsplot.png cgnsplot-icon.xbm cgnsplot-mask.xbm DESTINATION share/cgnstools) endif () CGNS-4.5.0/src/cgnstools/cgnsplot/Makefile.unix000066400000000000000000000051401474000356600213340ustar00rootroot00000000000000# Makefile for Unix/Linux include ../make.defs COPTS = $(CFLAGS) -I../common -I$(CGNSDIR) $(TKINCS) $(OGLINCS) LDLIST = $(CGNSLIB) $(BUILDLIBS) $(TKOGLLIB) $(TKLIBS) \ $(OGLLIBS) $(X11LIBS) $(TKOGLXLIB) $(CLIBS) #-------------------------------------------------- plotwish$(EXE) : plotwish.$(O) cgnstcl.$(O) hash.$(O) $(TKOGLLIB) $(CC) $(LDFLAGS) -o $@ plotwish.$(O) cgnstcl.$(O) hash.$(O) $(LDLIST) $(STRIP) $@ plotwish.$(O) : plotwish.c cgnstcl.$(O) : cgnstcl.c $(CC) $(COPTS) $(PLOTOPTS) -c cgnstcl.c hash.$(O) : ../common/hash.c ../common/hash.h $(CC) $(COPTS) -o hash.$(O) -c ../common/hash.c #--------------------------------------------------------------- ICONS = cgnsplot.ico cgnsplot.png cgnsplot-icon.xbm cgnsplot-mask.xbm install : install-dirs install-prog install-wish install-script install-dirs : @for d in \ $(BIN_INSTALL_DIR) \ $(EXE_INSTALL_DIR) \ $(WSH_INSTALL_DIR) \ $(LIB_INSTALL_DIR) ; do \ if [ ! -d $$d ] ; then \ echo "Making directory $$d"; \ mkdir -p $$d; \ chmod 755 $$d; \ fi; \ done; install-prog : @echo "installing cgnsplot shell scripts to $(BIN_INSTALL_DIR)" @$(INSTALL_PROG) cgnsplot.sh $(BIN_INSTALL_DIR)/cgnsplot @$(INSTALL_PROG) cgnsplot.desktop $(BIN_INSTALL_DIR)/ @chmod +x $(BIN_INSTALL_DIR)/cgnsplot $(BIN_INSTALL_DIR)/cgnsplot.desktop @if [ ! -f $(EXE_INSTALL_DIR)/cgconfig ] ; then \ echo "installing configuration file to $(EXE_INSTALL_DIR)"; \ $(INSTALL_DATA) ../cgconfig $(EXE_INSTALL_DIR)/cgconfig; \ fi; install-wish : plotwish$(EXE) @echo "installing plotwish executable to $(WSH_INSTALL_DIR)" @$(INSTALL_PROG) plotwish$(EXE) $(WSH_INSTALL_DIR) install-script : @echo "installing cgnsplot tcl scripts to $(LIB_INSTALL_DIR)" @$(INSTALL_DATA) cgnsplot.tcl $(LIB_INSTALL_DIR) @echo "installing icons to $(LIB_INSTALL_DIR)" @for i in $(ICONS) ; do \ $(INSTALL_DATA) $$i $(LIB_INSTALL_DIR); \ done; uninstall : @echo "uninstalling cgnsplot executables" @if [ -f $(BIN_INSTALL_DIR)/cgnsplot ] ; then \ /bin/rm -f $(BIN_INSTALL_DIR)/cgnsplot; \ fi; @if [ -f $(WSH_INSTALL_DIR)/plotwish$(EXE) ] ; then \ /bin/rm -f $(WSH_INSTALL_DIR)/plotwish$(EXE); \ fi; @echo "uninstalling cgnsplot tcl scripts" @if [ -f $(LIB_INSTALL_DIR)/cgnsplot.tcl ] ; then \ /bin/rm -f $(LIB_INSTALL_DIR)/cgnsplot.tcl; \ fi; @echo "uninstalling cgnsplot icons" @for i in $(ICONS) ; do \ if [ -f $(LIB_INSTALL_DIR)/$$i ] ; then \ /bin/rm -f $(LIB_INSTALL_DIR)/$$i; \ fi; \ done; #--------------------------------------------------------------- .c.$(O) : $(CC) $(COPTS) -c $< clean: -$(RM) *.$(O) *~ *.bak plotwish$(EXE) CGNS-4.5.0/src/cgnstools/cgnsplot/Makefile.win000066400000000000000000000035071474000356600211530ustar00rootroot00000000000000include ..\make.win COPTS = $(CFLAGS) -I..\common -I$(CGNSDIR) $(TCLINC) #-------------------------------------------------- all : plotwish.exe dll : cgnstcl.dll install : plotwish.exe $(BINDIR) $(SHAREDIR) -$(INSTALL) plotwish.exe $(BINDIR) -$(INSTALL) cgnsplot.bat $(BINDIR) -$(INSTALL) cgnsplot.tcl $(SHAREDIR) -$(INSTALL) *.ico $(SHAREDIR) $(BINDIR) : $(INSTALLDIR) -mkdir $(BINDIR) $(SHAREDIR) : $(INSTALLDIR) -mkdir $(SHAREDIR) $(INSTALLDIR) : -mkdir $(INSTALLDIR) #-------------------------------------------------- plotwish.exe : winmain.obj cgnstcl.obj hash.obj $(WINHTML_OBJ) $(LINK) $(LFLAGS) /nodefaultlib /subsystem:windows \ -out:$@ winmain.obj cgnstcl.obj hash.obj $(WINHTML_OBJ) \ $(CGNSLIB) $(BUILDLIBS) $(CLIBS) $(TKOGLLIB) $(TCLLIB) $(TKLIB) \ $(guilibs) $(ogllibs) $(WINHTML_LIB) winmain.obj : winmain.c $(CC) $(COPTS) $(WINHTML_OPT) -c winmain.c cgnstcl.obj : cgnstcl.c $(CC) $(COPTS) $(PLOTOPTS) -c cgnstcl.c #-------------------------------------------------- cgnstcl.dll : cgnstcl-dll.obj hash.obj cgnames.obj $(CGNSLIB) $(LINK) -dll -out:cgnstcl.dll cgnstcl-dll.obj \ hash.obj cgnames.obj $(CGNSLIB) $(CLIBS) $(TCLLIB) $(TKLIB) \ $(dlllibs) $(ogllibs) cgnstcl-dll.obj : cgnstcl.c $(CC) $(COPTS) $(PLOTOPTS) -DBUILD_DLL -Fo$@ -c cgnstcl.c #-------------------------------------------------- hash.obj : ..\common\hash.c ..\common\hash.h $(CC) $(COPTS) -Fohash.obj -c ..\common\hash.c #-------------------------------------------------- winhtml.obj : ..\common\winhtml.c $(CC) $(COPTS) $(WINHTML_INC) -Fowinhtml.obj -c ..\common\winhtml.c #-------------------------------------------------- .c.obj : $(CC) $(COPTS) -Fo$@ -c $< .obj.exe : $(LINK) $(LFLAGS) /out:$@ $< $(CGNSLIB) clean: -$(RM) *.obj -$(RM) *.lib -$(RM) *.exp -$(RM) *.exe -$(RM) *.pdb -$(RM) *.ilk -$(RM) *.dll -$(RM) *.bak CGNS-4.5.0/src/cgnstools/cgnsplot/cgnsplot-icon.xbm000066400000000000000000000016001474000356600221760ustar00rootroot00000000000000#define ploticon_width 32 #define ploticon_height 32 static unsigned char ploticon_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x80, 0x5f, 0x01, 0x00, 0xc0, 0xbf, 0x00, 0x00, 0xc0, 0x5f, 0x01, 0x00, 0xe0, 0xbf, 0x02, 0x00, 0xe0, 0x5f, 0x01, 0x00, 0xf0, 0xbf, 0x02, 0x00, 0xc0, 0x5f, 0x01, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; CGNS-4.5.0/src/cgnstools/cgnsplot/cgnsplot-mask.xbm000066400000000000000000000016001474000356600222010ustar00rootroot00000000000000#define plotmask_width 32 #define plotmask_height 32 static unsigned char plotmask_bits[] = { 0x10, 0x04, 0x41, 0x10, 0x10, 0x04, 0x41, 0x10, 0x10, 0x04, 0x41, 0x10, 0x10, 0x04, 0x51, 0x10, 0x10, 0x04, 0x59, 0x10, 0xff, 0xff, 0xff, 0xff, 0x10, 0x04, 0x7d, 0x10, 0x10, 0x04, 0x7d, 0x10, 0x10, 0x04, 0x7f, 0x10, 0x10, 0x04, 0xff, 0x10, 0x10, 0x04, 0xff, 0x10, 0xff, 0xff, 0xff, 0xff, 0x10, 0x84, 0xff, 0x11, 0x10, 0xc4, 0xff, 0x13, 0x10, 0xe4, 0xff, 0x13, 0x10, 0xe4, 0xff, 0x17, 0xff, 0xff, 0xff, 0xff, 0x10, 0xf4, 0xff, 0x1f, 0x08, 0xfa, 0xff, 0x27, 0x08, 0xf2, 0xff, 0x23, 0x04, 0xc2, 0xff, 0x21, 0xff, 0xff, 0xff, 0xff, 0x04, 0x01, 0x7d, 0x41, 0x02, 0x01, 0x11, 0x41, 0x02, 0x81, 0x00, 0x42, 0x01, 0x81, 0x00, 0x82, 0xff, 0xff, 0xff, 0xff, 0x80, 0x80, 0x00, 0x04, 0x80, 0x80, 0x00, 0x04, 0x80, 0x80, 0x00, 0x04, 0x40, 0x80, 0x00, 0x08, 0xff, 0xff, 0xff, 0xff}; CGNS-4.5.0/src/cgnstools/cgnsplot/cgnsplot.bat000066400000000000000000000015421474000356600212350ustar00rootroot00000000000000@echo off setlocal set dir=%~dps0 if exist %dir%cgconfig.bat ( call %dir%cgconfig.bat goto getwish ) if exist %dir%..\cgconfig.bat call %dir%..\cgconfig.bat :getwish if "%CG_BIN_DIR%" == "" set CG_BIN_DIR=%dir% if exist %dir%plotwish.exe ( set wish=%dir%plotwish.exe goto getscript ) if exist %dir%cgnstools\plotwish.exe ( set wish=%dir%cgnstools\plotwish.exe goto getscript ) echo plotwish.exe not found pause goto done :getscript if exist %dir%cgnsplot.tcl ( set script=%dir%cgnsplot.tcl goto run ) if not "%CG_LIB_DIR%" == "" ( if exist %CG_LIB_DIR%\cgnsplot.tcl ( set script=%CG_LIB_DIR%\cgnsplot.tcl goto run ) ) if exist %dir%..\share\cgnsplot.tcl ( set CG_LIB_DIR=%dir%..\share set script=%dir%..\share\cgnsplot.tcl goto run ) echo cgnsplot.tcl not found pause goto done :run start /b %wish% %script% %1 :done endlocal CGNS-4.5.0/src/cgnstools/cgnsplot/cgnsplot.desktop000077500000000000000000000002761474000356600221460ustar00rootroot00000000000000[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=Application Name=CGNSplot GenericName=CGNS plot Terminal=false Categories=Development; Exec="./cgnsplot" Icon=../share/cgnstools/cgnsplot.png CGNS-4.5.0/src/cgnstools/cgnsplot/cgnsplot.ico000066400000000000000000000020661474000356600212430ustar00rootroot00000000000000 è&(( @€€€€€€€€€€ÀÀÀ€€€ÿÿÿÿÿÿÿÿÿÿÿÿÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌîîîÎîîîîìîîîîÎîîîîîìîîîîìîîîîÎîîîîîìîîîîÎîîîìîîîîîîìîîîîÎîîîìîîîÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌìîîîÎîîîÎîîìîîîÎìîîîÎîîîÎîìîîìîîÎîîÎîîìîÎîîÎîîÎîîÎîîìá™îìîîÌÌÌÌÌÌÌÌ™ÌÌÌÎîÎîìîî™™ÎîììîÎîìîá™™™îÎìîìîìî™™™ìîîÎìîîÎá™™™ÎîÌÌÌÌÌÌÁ™™™ÌÌwÇwÇwÇw™™ÇwwÇwÇwÇw™™wÇwwÇwÇwÇwÁ™™wÇwwÇwÇwÇwÁ™™wÇwÌÌÌÌÌÌÌÌ™ÌÌÌwÇwÇwÇwÇ™wwÇwwÇwÇwÇwÇq™wwÇwwÇwÇwÇwÇq™wwÇwwÇwÇwÇwÇwwwÇwwÇwÇwÇwÇw|wwÇwÌÌÌÌÌÌÌÌÌÁÌÌÌÌÌwÇwÇwÇwÇwÁ|wwÇwwÇwÇwÇwÇwÇ|wwÇwwÇwÇwÇwÇwÇw|wwÇwwÇwÇwÇwÇwÇw|wwÇwwÇwÇwÇwÇwÇw|wwÇw( À€€€€€€€€€ÀÀÀ€€€ÿÿÿÿÿÿÿÿÿÿÿÿîìîîÎîìîîìîîÎîìîîìîîÎÎîÌÌÌÌÁ‘ÌÎîÎì‘ìÎîΙ‘ìîΙ‘ÌÌÌÁ™‘Ì|wÇÇ‘w|wÇÇ‘w|wÇÇq‘wÌÌÌÌÌ‘Ì|wÇÇ|w|wÇÇ|q|w|wÇÇ|w|w|wÇÇ|w|wCGNS-4.5.0/src/cgnstools/cgnsplot/cgnsplot.png000066400000000000000000000005751474000356600212600ustar00rootroot00000000000000‰PNG  IHDR szzôsBIT|dˆ4IDATX…ÝWí ¼ÞKÞL|3|²úñÕAæ/1Ù ×O•bŒ Þß㠣カ.Æÿ ˆÞ_'àèå@ó,$žûh]ªÈѪÞãà™ÞãëÚ.èMÇÉ{ NmCY§ ñ˜Ðô%àYÜ£_1ÔûË5Ôx~2ŠkaÐë} ?û2Ò¢`*š÷¥"ÜÎåWÝÀÀj/=kë¬sAð~R@ b±h0÷¼ð-Èk !&0WÃ\CHÙ"\Ó{ˆ> ½ÑÈò¿ˆpìÒßÙ6ÂvJÖ½^'xÊ‘¨Eˆ¶hh"‚l²—S΂LÉjçÂSî¿ìÌ 0ƒ•Om­°€öYa'0s+̽-jY›ú£ÔgönÒž?øg´­G÷è Ò‚Ë‹ð òƒüL’ùe©IEND®B`‚CGNS-4.5.0/src/cgnstools/cgnsplot/cgnsplot.sh000077500000000000000000000022721474000356600211050ustar00rootroot00000000000000#!/bin/sh # sh script to launch CGNS plot dir=`dirname $0` # source the setup script for d in $dir $dir/cgnstools $dir/.. ; do if test -f $d/cgconfig ; then . $d/cgconfig break fi done # get the plotwish executable plotwish="" for d in $CG_BIN_DIR $dir $dir/cgnstools $dir/cgnsplot \ /usr/local/bin /usr/local/bin/cgnstools ; do if test -x $d/plotwish ; then plotwish=$d/plotwish break fi if test -x $d/cgnswish/plotwish ; then plotwish=$d/cgnswish/plotwish break fi done if test -z "$plotwish" ; then echo "Error: plotwish executable not found" exit 1 fi # find the cgnsplot tcl script cgnsplot="" for d in $CG_LIB_DIR $dir $dir/cgnstools $dir/cgnsplot \ $dir/../share/cgnstools \ /usr/local/share /usr/local/share/cgnstools ; do if test -f $d/cgnsplot.tcl ; then cgnsplot=$d/cgnsplot.tcl break fi done if test -z "$cgnsplot" ; then echo "Error: cgnsplot.tcl script not found" exit 1 fi # check that display is set #if test -z "$DISPLAY" ; then # echo "Error: DISPLAY environment variable not set" # exit 1 #fi # execute if test "$#" = 0 ; then exec $plotwish $cgnsplot else exec $plotwish $cgnsplot "$@" fi CGNS-4.5.0/src/cgnstools/cgnsplot/cgnsplot.tcl000066400000000000000000001641421474000356600212570ustar00rootroot00000000000000#!/bin/sh # the next line restarts using wish \ exec plotwish -f "$0" "$@" proc error_exit {msg} { wm withdraw . tk_dialog .error Error $msg error 0 Exit exit 1 } if {[catch {package require Tk 8.0} msg]} { error_exit $msg } #---------- get platform set platform $tcl_platform(platform) if {$platform == "windows" && [info exists env(TERM)] && ($env(TERM) == "cygwin" || $env(TERM) == "xterm")} { set platform cygwin } #----- get startup directory and name set cmd_name [file tail $argv0] set cmd_dir [file dirname $argv0] if {![file exists $argv0] || [file isdirectory $argv0]} { if {$platform == "windows"} { set sep ";" } else { set sep ":" } foreach i [split $env(PATH) $sep] { if {$sep == ";"} { set i [join [split $i \\] /] } if {[file exists $i/$cmd_name] && ![file isdirectory $i/$cmd_name]} { set cmd_dir $i break; } } } set curdir [pwd] if ![catch {cd $cmd_dir}] { set cmd_dir [pwd] cd $curdir } if {$tcl_platform(platform) == "windows"} { set cmd_dir [file attributes $cmd_dir -shortname] } #----- set path to tcl scripts set auto_path "$cmd_dir $cmd_dir/../common $auto_path" if {[info exists env(TCL_PROC_DIR)]} { set auto_path "$env(TCL_PROC_DIR) $auto_path" } #----- initialize if {$platform == "windows"} { set vers [join [split $tcl_version .] {}] if {[info commands CGNSopen] == {}} { if {[catch {load cgnstcl$vers} msg]} { error_exit $msg } } catch {load tclreg$vers registry} } else { if {[info commands CGNSopen] == {}} { error_exit "need to run script with plotwish" } } if {[catch {package require Tkogl} msg]} { error_exit $msg } if [catch {config_defaults 1} msg] {error_exit $msg} array set ProgData { winwidth 700 winheight 500 seppos 0.25 sepwd 7 cgnsfile "" displaylist "" axislist "" planelist "" cutlist "" background {0.0 0.0 0.0} autocolor 1 showcolors 1 showlines 1 twosided 0 culling disable revnorm 0 axis 0 meshvis 1 meshmode 1 regvis 0 regmode 2 edgeangle 60 fov 30 np 0.025 fp 2.0 bases {} nzones 0 zones {} curbase "" curnode "" curdim 0 curclr "" curmode 0 cutplane "" cutcolor {0.7 0.7 0.4 0.5} cutmode 1 usecutclr 0 ignorevis 0 drawID "" dotrace 0 reg,file ".cgnstools" reg,base "HKEY_CURRENT_USER/Software/CGNS" reg,key "CGNSplot" reg,vals {cgnsfile background autocolor twosided culling \ axis edgeangle meshvis meshmode regvis regmode fov \ winwidth winheight seppos cutcolor usecutclr ignorevis \ showcolors showlines} } #----- read registry if {[tclreg_init -base $ProgData(reg,base) -fname $ProgData(reg,file)]} { foreach i $ProgData(reg,vals) { if {![catch {tclreg_get $ProgData(reg,key) $i} val] && $val != ""} { set ProgData($i) $val } } } #---------- main window wm title . "CGNSplot" wm protocol . WM_DELETE_WINDOW do_quit proc do_quit {} { global ProgData catch CGNSclose set ProgData(winwidth) [winfo width .main] set ProgData(winheight) [winfo height .main] foreach i $ProgData(reg,vals) { catch {tclreg_set $ProgData(reg,key) $i $ProgData($i)} } catch tclreg_close catch {WinHtml close} destroy . exit 0 } #----- menu menubar_create {File Options View Display Help} #----- file menu set m [menubar_get File] $m add command -label "Load CGNS..." -command load_cgns $m add separator $m add command -label "Quit" -command do_quit #----- options menu set m [menubar_get Options] $m add command -label "Set Defaults..." -command set_defaults $m add command -label "Set Perspective..." -command set_perspective #----- view menu set m [menubar_get View] $m add command -label "Open Level" -command tree_open $m add command -label "Close Level" -command tree_close $m add separator $m add command -label "Reset View" -command {reset_view; $OGLwin redraw} $m add command -label "Center View" -command Center #----- display menu set m [menubar_get Display] $m add checkbutton -label "Two Sided" -command set_twosided \ -variable ProgData(twosided) -onvalue 1 -offvalue 0 $m add checkbutton -label "Backface Culling" -command set_culling \ -variable ProgData(culling) -onvalue enable -offvalue disable #$m add checkbutton -label "Reverse Normals" -command set_normals \ # -variable ProgData(revnorm) -onvalue 1 -offvalue 0 $m add checkbutton -label "Display Axis" -command set_axis \ -variable ProgData(axis) -onvalue 1 -offvalue 0 if {[info commands OGLcutplane] != ""} { $m add command -label "Cutting Plane..." -command cutplane_control } proc set_twosided {} { global ProgData OGLwin if {$ProgData(twosided)} { .toolbar.but.b3.twosided configure -relief sunken set_balloon .toolbar.but.b3.twosided "Disable Two-Sided Lighting" } else { .toolbar.but.b3.twosided configure -relief raised set_balloon .toolbar.but.b3.twosided "Enable Two-Sided Lighting" } $OGLwin eval -lightmodel lightmodeltwoside $ProgData(twosided) $OGLwin redraw } proc set_culling {} { global ProgData OGLwin if {$ProgData(culling) == "enable"} { .toolbar.but.b3.culling configure -relief sunken set_balloon .toolbar.but.b3.culling "Disable Backface Culling" } else { .toolbar.but.b3.culling configure -relief raised set_balloon .toolbar.but.b3.culling "Enable Backface Culling" } $OGLwin eval -$ProgData(culling) cullface $OGLwin redraw } proc set_normals {} { global ProgData OGLwin if {$ProgData(revnorm)} { .toolbar.but.b3.revnorm configure -relief sunken set_balloon .toolbar.but.b3.revnorm "Default Face Normals" } else { .toolbar.but.b3.revnorm configure -relief raised set_balloon .toolbar.but.b3.revnorm "Reverse Face Normals" } } proc set_axis {} { global ProgData OGLwin if {$ProgData(axis)} { .toolbar.but.b3.axis configure -relief sunken set_balloon .toolbar.but.b3.axis "Disable Axis Display" } else { .toolbar.but.b3.axis configure -relief raised set_balloon .toolbar.but.b3.axis "Enable Axis Display" } OGLaxis $ProgData(axis) $OGLwin redraw } #----- help menu set m [menubar_get Help] $m add command -label "CGNSplot Help..." \ -command {help_show cgnstools/cgnsplot/index.html} $m add command -label "CGNS Help..." -command {help_show} $m add separator $m add command -label "Configure Help..." -command help_setup $m add separator $m add command -label "About..." -underline 0 -command do_about image create photo img_about -data {\ R0lGODlhIAAgALMAAAAA/wD//4QAAMbGxv8AAP//////////////////////////////////\ /////////ywAAAAAIAAgAAAEv3AMIGelEttbN8+fp3mkGGpj2plgawluiZ6XAJMooO98v9sC\ H881cwkINtyqyBocgaoOs3hE2qI0oqQKvMWas6o1eRKaxd2gT0sUj8my7MSdvo3AFfebfJ/m\ CYCAdTA5Zj+BgYM9AQEAjI6MjYx6e1CRko+RkJSVNpiYkJmTiIJ1mp+hnwE2iHWphmeJXUKi\ p5eSXEC2l6mqorO3r7e+tQK1tb3ExMmOsM7Ow8rSydHU09HD1tfYx9nYvc/hQhEAADs=} proc do_about {} { global ProgData dialog .about -1 -1 "About CGNSplot" \ "CGNSplot Version 3.2 Bruce Wedan leavingdust@gmail.com" img_about 0 Close } #---------- toolbar frame .toolbar pack .toolbar -side top -pady 2 -fill x set f [frame .toolbar.but] pack $f -side left #--- image create photo img_open -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQ4EMlJKwJvZcC7BxdnSV04nCgKjtR6vZgmZ49L\ bmlus7xV9j4QQPYRtWbI3RCXU10WgKaTVPQAexEAOw==} button $f.open -image img_open -takefocus 0 \ -command {load_cgns ""} pack $f.open -side left -padx 5 set_balloon $f.open "Open a CGNS File..." #--- image create photo img_colors -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwRFEMlJ63TYsc2ab1QiJku5KKhCPewDvMAhH+Fo\ nimVadwHTi0XbEazGI/IyohkSqkmy5tTl+F0PlSM1bdqwWKzLutLTB4jADs=} image create photo img_viewing -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQqEMlJqwT2uo0z6JkFht44fdSnVuipmiXpyUhL\ wiwMbA5onzzcj3bB0ToRADs=} set b [frame $f.b1] pack $b -side left -padx 5 button $b.colors -image img_colors -takefocus 0 \ -command set_defaults set_balloon $b.colors "Set Defaults..." button $b.viewing -image img_viewing -takefocus 0 \ -command set_perspective set_balloon $b.viewing "Set Perspective..." pack $b.colors $b.viewing -side left -padx 1 #--- image create photo img_expand -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQvEMlJq712DJzX5pP2VQBIWuWVUitBTCsMlMTz\ IrHl3jnYUy7J7Cep8UA7k3IpiQAAOw==} image create photo img_collapse -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQkEMlJq7046wrwGBQgXsMCTh35hRvbSqm1urJJ\ V98Jvzvv/5UIADs=} image create photo img_reset -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQiEMlJKwXYWqA17xXGjQgZguA3qWhbni58vaQY\ vzHb2XdvRQA7} image create photo img_center -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQmEMmJAL22Ypmp/dolduJYcqiXqiB5umcFwG9s\ YzOd07fZy7yfJAIAOw==} set b [frame $f.b2] pack $b -side left -padx 5 button $b.expand -image img_expand -takefocus 0 -command tree_open set_balloon $b.expand "Open One Level" button $b.collapse -image img_collapse -takefocus 0 -command tree_close set_balloon $b.collapse "Close One Level" button $b.reset -image img_reset -takefocus 0 \ -command {reset_view; $OGLwin redraw} set_balloon $b.reset "Reset View" button $b.center -image img_center -takefocus 0 \ -command Center set_balloon $b.center "Center View" pack $b.expand $b.collapse $b.reset $b.center -side left #--- image create photo img_twosided -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwRGEMlJKwLnUMZoBtSyPNwjWpJIMuaCbh2KTQvn\ Sgd4aak95S/OyyIc0nyyG6KIWOgwB9GoJP1ApavW4iMBKJnOV42hNDIpEQA7} image create photo img_culling -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQqEMlJq5UgX6oxuF0VhuCHfKR3YlM3spzZwpxI\ z/Vq56nc+zcRKlXaGC0RADs=} image create photo img_axis -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQwEEkJUJ04o5V6p9o2hJlAnteJLaOKKIqJujNt\ Z+ydY1UqwYKAMGAp/mIqgNKm9J0iADs=} image create photo img_revnorm -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQ5EMlJq6XsIsAn+1rnhdsEMMCVStzpiCwLODRD\ v2s634595zIeDVYK4iw600q1RGSYTc3l85SOrNgIADs=} image create photo img_cutting -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQwEMlJq5UEkFsBQB6HbGNpXp+UimDIErBJWjFL\ rSuH22DP+7wNbFYhCTEXI4b4m0QAADs=} set b [frame $f.b3] pack $b -side left -padx 5 button $b.twosided -image img_twosided -takefocus 0 \ -command toggle_twosided if {$ProgData(twosided)} { $b.twosided configure -relief sunken set_balloon $b.twosided "Disable Two-Sided Lighting" } else { set_balloon $b.twosided "Enable Two-Sided Lighting" } button $b.culling -image img_culling -takefocus 0 \ -command toggle_culling if {$ProgData(culling) == "enable"} { $b.culling configure -relief sunken set_balloon $b.culling "Disable Backface Culling" } else { set_balloon $b.culling "Enable Backface Culling" } button $b.revnorm -image img_revnorm -takefocus 0 \ -command toggle_normals if {$ProgData(revnorm)} { $b.revnorm configure -relief sunken set_balloon $b.revnorm "Default Face Normals" } else { set_balloon $b.revnorm "Reverse Face Normals" } button $b.axis -image img_axis -takefocus 0 \ -command toggle_axis if {$ProgData(axis)} { $b.axis configure -relief sunken set_balloon $b.axis "Disable Axis Display" } else { set_balloon $b.axis "Enable Axis Display" } #pack $b.twosided $b.culling $b.revnorm $b.axis -side left -padx 1 pack $b.twosided $b.culling $b.axis -side left -padx 1 if {[info commands OGLcutplane] != ""} { button $b.cutting -image img_cutting -takefocus 0 \ -command cutplane_control set_balloon $b.cutting "Cutting Plane..." pack $b.cutting -side left -padx 1 } proc toggle_twosided {} { global ProgData if {$ProgData(twosided)} { set ProgData(twosided) 0 } else { set ProgData(twosided) 1 } set_twosided } proc toggle_culling {} { global ProgData if {$ProgData(culling) == "enable"} { set ProgData(culling) disable } else { set ProgData(culling) enable } set_culling } proc toggle_normals {} { global ProgData if {$ProgData(revnorm)} { set ProgData(revnorm) 0 } else { set ProgData(revnorm) 1 } set_normals } proc toggle_axis {} { global ProgData if {$ProgData(axis)} { set ProgData(axis) 0 } else { set ProgData(axis) 1 } set_axis } #--- image create photo img_help -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQiEMlJq50kX5kJ1hvShd+4mSJ4qmTrXl28ehw7\ t+j75joVAQA7} button $f.help -image img_help -takefocus 0 \ -command {help_show cgnstools/cgnsplot/index.html} set_balloon $f.help "CGNSplot Help..." pack $f.help -side left -padx 5 frame .toolsep -bd 1 -height 2 -relief sunken pack .toolsep -side top -fill x #----- status bar set ProgData(status) "" label .status -textvariable ProgData(status) -relief sunken -anchor w pack .status -side bottom -fill x -padx 5 -pady 3 proc display_message {msg} { global ProgData set ProgData(status) $msg update idletasks } #---------- main window frame .main -width $ProgData(winwidth) -height $ProgData(winheight) pack .main -side top -fill both -expand 1 -padx 5 -pady 2 #--- window separator frame .main.sep -width 4 -bd 2 -relief raised -cursor sb_h_double_arrow bind .main.sep sep_begin_move proc sep_begin_move {} { set width [winfo width .main] set x [winfo rootx .main.sep] set y [winfo rooty .main.sep] set h [winfo height .main.sep] set xmin [expr [winfo rootx .main] + 100] set xmax [expr [winfo rootx .main] + $width - 100] set top [toplevel .main.move -borderwidth 1 \ -relief raised -cursor sb_h_double_arrow] wm overrideredirect $top 1 wm geom $top "4x$h+$x+$y" update idletasks grab set $top bind $top "sep_end_move $top $xmin $xmax %X" bind $top "sep_move $top $xmin $xmax %X $y" } proc sep_move {top xmin xmax x y} { if {$x < $xmin} { set x $xmin } elseif {$x > $xmax} { set x $xmax } wm geom $top "+$x+$y" } proc sep_end_move {top xmin xmax x} { global ProgData destroy $top if {$x < $xmin} { set x $xmin } elseif {$x > $xmax} { set x $xmax } set s [expr double($x - [winfo rootx .main]) / \ double([winfo width .main])] sep_locate $s } proc sep_locate {s} { global ProgData if [expr $s < 0.5] { place .main.sel -relx 0 -x 0 \ -relwidth $s -width -$ProgData(sepwd) \ -rely 0 -relheight 1 place .main.plot -relx $s -x $ProgData(sepwd) \ -relwidth [expr 1.0 - $s] -width -$ProgData(sepwd) \ -rely 0 -relheight 1 } else { place .main.plot -relx 0 -x 0 \ -relwidth $s -width -$ProgData(sepwd) \ -rely 0 -relheight 1 place .main.sel -relx $s -x $ProgData(sepwd) \ -relwidth [expr 1.0 - $s] -width -$ProgData(sepwd) \ -rely 0 -relheight 1 } place .main.sep -relx $s -x -2 -rely 0 -relheight 1 set ProgData(seppos) $s } frame .main.plot frame .main.sel sep_locate $ProgData(seppos) #----- OpenGL window set OGLwin .main.plot.gl if {[catch {OGLwin $OGLwin} msg]} { error_exit $msg } pack $OGLwin -side left -fill both -expand 1 #---------- selections # base selection set f [frame .main.sel.base] pack $f -side top -fill x -pady 5 label $f.lab -text Base pack $f.lab -side left set ProgData(baselist) [ComboboxCreate $f.cb -width 10 \ -edit 0 -state disabled -command set_base] pack $f.cb -side left -fill x -expand 1 # object tree image create photo box_empty -data { R0lGODlhDAAMALMAAAAAAMbGxv//////////////////////////////////////////////\ /////////yH5BAEAAAEALAAAAAAMAAwAAAQaEMhJZ7g4y8zD7tgHesB4iSDaqRyrlWYlSxEA\ Ow==} image create photo box_checked -data { R0lGODlhDAAMALMAAAAAAMbGxv//////////////////////////////////////////////\ /////////yH5BAEAAAEALAAAAAAMAAwAAAQjEMhJabj4CrmznkGHddJnBuUnokC2siOwpqJY\ vqTcelvlSxEAOw==} image create photo box_question -data { R0lGODlhDAAMALMAAIQAAMbGxv8AAP//////////////////////////////////////////\ /////////yH5BAEAAAEALAAAAAAMAAwAAAQjMMggap1TgL0FrsAEXJIWSqNXbiKJoePbqnIn\ i/Gtv7beSxEAOw==} set f [frame .main.sel.objs] pack $f -side top -fill both -expand 1 set ProgData(tree) $f.tree scrollbar $f.ys -orient vertical -command "$ProgData(tree) yview" \ -takefocus 0 -highlightthickness 0 pack $f.ys -side right -fill y scrollbar $f.xs -orient horizontal -command "$ProgData(tree) xview" \ -takefocus 0 -highlightthickness 0 pack $f.xs -side bottom -fill x TreeCreate $ProgData(tree) -width 150 -height 300 -relief sunken \ -bd 2 -highlightthickness 1 -yscrollcommand "$f.ys set" -takefocus 1 \ -xscrollcommand "$f.xs set" -font $Font(normal) -padx 4 \ -lines $ProgData(showlines) pack $ProgData(tree) -side left -fill both -expand 1 bind $ProgData(tree) <1> {tree_show %W %x %y} bind $ProgData(tree) {tree_info %W %x %y} bind $ProgData(tree) <3> {tree_menu %W %x %y} bind $ProgData(tree) {tree_at %W %x %y Toggle} bind $ProgData(tree) {tree_at %W %x %y Expand} bind $ProgData(tree) {tree_at %W %x %y Collapse} set ProgData(menu) [menu .nodemenu -tearoff 0] $ProgData(menu) add radiobutton -label "Outline" \ -variable ProgData(curmode) -value 1 -command update_mode $ProgData(menu) add radiobutton -label "Mesh" \ -variable ProgData(curmode) -value 2 -command update_mode $ProgData(menu) add radiobutton -label "Shaded" \ -variable ProgData(curmode) -value 3 -command update_mode $ProgData(menu) add separator $ProgData(menu) add command -label "Color..." \ -command "update_color $ProgData(tree)" $ProgData(menu) add command -label "AutoColor" \ -command "auto_color $ProgData(tree)" $ProgData(menu) add command -label "Info..." proc tree_show {w x y} { set value [TreeTypeAt $w $x $y] if {$value == ""} return set type [lindex $value 0] set node [lindex $value 1] if {$type == "image"} { toggle_visibility $node } else { if {$node != [TreeSelectionGet $w]} { set_node $node } } } proc tree_info {w x y} { set value [TreeTypeAt $w $x $y] if {$value == ""} return if {[lindex $value 0] == "text"} { show_info $w $x $y [lindex $value 1] } } proc tree_menu {w x y} { global ProgData set value [TreeTypeAt $w $x $y] if {$value == ""} return if {[lindex $value 0] == "image"} return set node [lindex $value 1] if {$node != [TreeSelectionGet $w]} { set_node $node } if {$ProgData(curdim) == 0} { set state disabled } else { set state normal } foreach n {0 1 2 4 5} { $ProgData(menu) entryconfigure $n -state $state } set cnt [llength [TreeGet $w $node -tag]] if {$cnt < 1 || $cnt > 2} { $ProgData(menu) entryconfigure 6 -state disabled } else { $ProgData(menu) entryconfigure 6 -state normal \ -command "show_info $w $x $y {$node}" } $ProgData(menu) post [expr [winfo rootx $ProgData(tree)] + $x] \ [expr [winfo rooty $ProgData(tree)] + $y] } proc tree_at {w x y mode} { set value [TreeTypeAt $w $x $y] if {$value == ""} return set type [lindex $value 0] set node [lindex $value 1] if {$type == "image"} { if {$mode == "Expand"} { set_visibility $node 1 1 if {$node != [TreeSelectionGet $w]} { set_node $node } } elseif {$mode == "Collapse"} { set_visibility $node 0 1 } else { return } update_node $node } else { if {$node != [TreeSelectionGet $w]} { set_node $node } Tree$mode $w $node } } proc tree_open {} { global ProgData catch {TreeOpenLevel $ProgData(tree) /} } proc tree_close {} { global ProgData catch {TreeCloseLevel $ProgData(tree) /} } # options frame .main.sel.opts pack .main.sel.opts -side top -fill x set f [frame .main.sel.opts.top] pack $f -side top -fill x radiobutton $f.o -text "Outline" -variable ProgData(curmode) -value 1 \ -command update_mode -state disabled pack $f.o -side left radiobutton $f.m -text "Mesh" -variable ProgData(curmode) -value 2 \ -command update_mode -state disabled pack $f.m -side right set f [frame .main.sel.opts.bot] pack $f -side top -fill x radiobutton $f.s -text "Shaded" -variable ProgData(curmode) -value 3 \ -command update_mode -state disabled pack $f.s -side left set ProgData(clrbut) [button $f.c -relief solid -text Color... \ -borderwidth 1 -command "update_color $f.c" -state disabled] pack $f.c -side right -padx 5 proc options_state {dim} { if {$dim} { set state normal } else { set state disabled } foreach i {top.o top.m bot.s} { .main.sel.opts.$i configure -state $state } } #----- help proc help_menu {} { if [help_valid] { menubar_state Help normal 0 menubar_state Help normal 1 .toolbar.but.help configure -state normal } else { menubar_state Help disabled 0 menubar_state Help disabled 1 .toolbar.but.help configure -state disabled } } help_init #----- set default colors and zone/region viewing proc set_defaults {{loc .}} { global ProgData Defaults OGLwin fgColor Font foreach i {showcolors showlines meshvis meshmode regvis regmode \ background autocolor} { set Defaults($i) $ProgData($i) } set w .defaults toplevel $w wm title $w "Defaults" wm transient $w . wm protocol $w WM_DELETE_WINDOW {set ProgData(done) 0} FrameCreate $w.tree -text "Display Tree" -font $Font(bold) -padx 0 -pady 0 pack $w.tree -side top -padx 5 -pady 2 -fill x -expand 1 set tree [FrameGet $w.tree] checkbutton $tree.colors -text "Show Colors" -onvalue 1 -offvalue 0 \ -variable Defaults(showcolors) -highlightthickness 0 checkbutton $tree.lines -text "Show Lines" -onvalue 1 -offvalue 0 \ -variable Defaults(showlines) -highlightthickness 0 pack $tree.colors $tree.lines -side left -expand 1 FrameCreate $w.zone -text "Volume Mesh" -font $Font(bold) -padx 0 -pady 0 pack $w.zone -side top -padx 5 -pady 2 -fill x -expand 1 set zone [FrameGet $w.zone] checkbutton $zone.vis -text "Visible as" -onvalue 1 -offvalue 0 \ -variable Defaults(meshvis) -highlightthickness 0 pack $zone.vis -side top -anchor w set f [frame $zone.mode] pack $f -side top -fill x -expand 1 radiobutton $f.o -text "Outline" -variable Defaults(meshmode) -value 1 \ -highlightthickness 0 radiobutton $f.m -text "Mesh" -variable Defaults(meshmode) -value 2 \ -highlightthickness 0 radiobutton $f.s -text "Shaded" -variable Defaults(meshmode) -value 3 \ -highlightthickness 0 pack $f.o $f.m $f.s -side left -expand 1 FrameCreate $w.reg -text Regions -font $Font(bold) -padx 0 -pady 0 pack $w.reg -side top -padx 5 -pady 2 -fill x -expand 1 set reg [FrameGet $w.reg] checkbutton $reg.vis -text "Visible as" -onvalue 1 -offvalue 0 \ -variable Defaults(regvis) -highlightthickness 0 pack $reg.vis -side top -anchor w set f [frame $reg.mode] pack $f -side top -fill x -expand 1 radiobutton $f.o -text "Outline" -variable Defaults(regmode) -value 1 \ -highlightthickness 0 radiobutton $f.m -text "Mesh" -variable Defaults(regmode) -value 2 \ -highlightthickness 0 radiobutton $f.s -text "Shaded" -variable Defaults(regmode) -value 3 \ -highlightthickness 0 pack $f.o $f.m $f.s -side left -expand 1 FrameCreate $w.colors -text Colors -font $Font(bold) pack $w.colors -side top -padx 5 -pady 2 -fill x -expand 1 set colors [FrameGet $w.colors] set f [frame $colors.bg] pack $f -side top -fill x -expand 1 label $f.lab -text "Background Color" pack $f.lab -side left button $f.but -text Select -relief solid -bd 1 \ -command "background_color $f.but" color_button $f.but $Defaults(background) pack $f.but -side right set auto [frame $colors.auto] pack $auto -side top -fill x -expand 1 label $auto.lab -text "Assign Color Based On" pack $auto.lab -side top -anchor w set f [frame $auto.mode] pack $f -side top -fill x -expand 1 radiobutton $f.z -text "Zone" -variable Defaults(autocolor) -value 0 \ -highlightthickness 0 radiobutton $f.r -text "Region" -variable Defaults(autocolor) -value 1 \ -highlightthickness 0 pack $f.z $f.r -side left -expand 1 set f [frame $w.but] pack $f -side top -padx 5 -pady 2 -fill x -expand 1 button $f.default -text Defaults -width 8 -underline 0 \ -command "default_values $w" button $f.accept -text Accept -width 8 -underline 0 \ -command {set ProgData(done) 1} button $f.cancel -text Cancel -width 8 -underline 0 \ -command {set ProgData(done) 0} pack $f.default $f.accept $f.cancel -side left -pady 5 bind $w "$f.default flash; default_values $w" bind $w "$f.accept flash; set ProgData(done) 1" bind $w "$f.cancel flash; set ProgData(done) 0" center_window $w $loc set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} tkwait visibility $w focus $w tkwait variable ProgData(done) catch {focus $oldFocus} destroy $w if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } if {$ProgData(done)} { foreach i {meshvis meshmode regvis regmode background autocolor} { set ProgData($i) $Defaults($i) } eval $OGLwin eval -clearcolor $ProgData(background) init_display Center if {$Defaults(showlines) != $ProgData(showlines)} { set ProgData(showlines) $Defaults(showlines) TreeConfig $ProgData(tree) -lines $ProgData(showlines) } if {$Defaults(showcolors) != $ProgData(showcolors)} { set ProgData(showcolors) $Defaults(showcolors) build_tree } } } proc default_values {w} { global Defaults array set Defaults { showcolors 1 showlines 1 meshvis 1 meshmode 1 regvis 0 regmode 2 autocolor 0 background {0.0 0.0 0.0} } set cf [FrameGet $w.colors] color_button $cf.bg.but $Defaults(background) } proc background_color {but} { global Defaults set clr [select_color $Defaults(background) "Background Color" $but] if {$clr != ""} { set Defaults(background) $clr color_button $but $clr } } proc color_button {but clr} { global fgColor bgColor if {$clr == ""} { $but configure -fg $fgColor(normal) -activeforeground $fgColor(active) \ -bg $bgColor(normal) -activebackground $bgColor(active) \ -state disabled } else { if {[color_gray $clr] > 0.5} { set fg black } else { set fg white } $but configure -fg $fg -activeforeground $fg \ -bg [color_value $clr] \ -activebackground [color_value [color_lighten $clr]] \ -state normal } } proc select_color {oldclr title {loc .}} { return [color_select .color $title $oldclr $loc] } #----- set perspective ----- set Perspective(fov) $ProgData(fov) set Perspective(fd) [expr 0.5 / tan(0.00872665 * $Perspective(fov))] set Perspective(np) [expr $Perspective(fd) * $ProgData(np)] set Perspective(fp) [expr $Perspective(fd) * $ProgData(fp)] set Perspective(ar) 1.0 set Viewpoint(x) 0 set Viewpoint(y) 0 set Viewpoint(z) $Perspective(fd) proc apply_perspective {what val} { global ProgData Perspective OGLwin Viewpoint set Perspective(fov) $ProgData(fov) set fd [expr 0.5 / tan(0.00872665 * $Perspective(fov))] set Viewpoint(z) [expr $fd * $Viewpoint(z) / $Perspective(fd)] set Perspective(fd) $fd if {[expr $ProgData(fp) <= $ProgData(np)]} { if {$what == "np"} { set ProgData(fp) [expr 0.01 * (100.0 * $ProgData(np) + 1.0)] } else { set ProgData(np) [expr $ProgData(fp) - 0.001] } } set Perspective(np) [expr $fd * $ProgData(np)] set Perspective(fp) [expr $fd * $ProgData(fp)] compute_viewport $OGLwin set_view $OGLwin } proc set_perspective {{loc .}} { global ProgData fgColor Font set w .perspective if [winfo exists $w] { wm deiconify $w return } toplevel $w wm title $w "Perspective" FrameCreate $w.opts -font $Font(bold) pack $w.opts -side top -padx 5 -pady 5 set opts [FrameGet $w.opts] set f [frame $opts.fov] pack $f -side top label $f.lab -width 18 -anchor w -text "Field of View" scale $f.scl -length 200 -from 5 -to 85 -variable ProgData(fov) \ -orient horizontal -command {apply_perspective fov} pack $f.lab $f.scl -side left set f [frame $opts.np] pack $f -side top label $f.lab -width 18 -anchor w -text "Near Clipping Plane" scale $f.scl -length 200 -from 0.001 -to 1 -resolution .001 \ -variable ProgData(np) -orient horizontal -command {apply_perspective np} pack $f.lab $f.scl -side left set f [frame $opts.fp] pack $f -side top label $f.lab -width 18 -anchor w -text "Far Clipping Plane" scale $f.scl -length 200 -from .01 -to 5 -resolution .01 \ -variable ProgData(fp) -orient horizontal -command {apply_perspective fp} pack $f.lab $f.scl -side left set f [frame $w.but] pack $f -side top -fill x -expand 1 button $f.default -text Defaults -width 8 -command perspective_defaults button $f.close -text Close -width 8 -command "destroy $w" pack $f.default $f.close -side left -pady 2 -expand 1 center_window $w $loc } proc perspective_defaults {} { global ProgData array set ProgData { fov 30 np 0.025 fp 2 } apply_perspective all 0 } #----- OGL window controls set ProgData(axislist) [OGLaxis $ProgData(axis)] $OGLwin main -clear colorbuffer depthbuffer -call $ProgData(axislist) if {[info commands OGLcutplane] != ""} { OGLcutconfig $ProgData(cutcolor) $ProgData(usecutclr) $ProgData(ignorevis) set ProgData(cutlist) [OGLcutplane] set ProgData(planelist) [OGLdrawplane] } eval $OGLwin eval \ -clearcolor $ProgData(background) \ -$ProgData(culling) cullface \ -matrixmode projection \ -loadidentity \ -perspective $Perspective(fov) $Perspective(ar) \ $Perspective(np) $Perspective(fp) \ -matrixmode modelview \ -loadidentity \ -light light0 position 0 1 5 0 \ -light light0 diffuse .8 .8 .8 \ -light light0 specular 1 1 1 \ -light light0 ambient .2 .2 .2 \ -lightmodel lightmodeltwoside $ProgData(twosided) \ -enable lighting -enable light0 \ -enable depthtest -enable normalize -shademodel flat set ViewMatrix [$OGLwin get modelviewmatrix] bind $OGLwin {compute_viewport %W} bind $OGLwin {set xlast %x ; set ylast %y} bind $OGLwin {Rotate %W %x %y} bind $OGLwin {Pan %W %x %y} bind $OGLwin {Zoom %W %x %y} bind $OGLwin {Zoom %W %x %y} bind $OGLwin {Pan %W %x %y} catch {bind . {WheelZoom %D}} bind . {Center} bind . {reset_view ; $OGLwin redraw} bind . toggle_twosided bind . toggle_culling bind . toggle_axis if {[info commands OGLcutplane] != ""} { bind . cutplane_control bind . {if [winfo exists .cutplane] draw_cut} } proc compute_viewport {w} { global ProgData Perspective set ProgData(width) [winfo width $w] set ProgData(height) [winfo height $w] set ProgData(scale) [expr 1.0 / double($ProgData(height))] set Perspective(ar) [expr double($ProgData(width)) / \ double($ProgData(height))] $w eval \ -matrixmode projection \ -loadidentity \ -perspective $Perspective(fov) $Perspective(ar) \ $Perspective(np) $Perspective(fp) \ -matrixmode modelview } proc set_view {w} { global Viewpoint ViewMatrix eval $w eval \ -loadidentity \ -lookat $Viewpoint(x) $Viewpoint(y) $Viewpoint(z) \ $Viewpoint(x) $Viewpoint(y) 0 0 1 0 \ -multmatrix $ViewMatrix $w redraw } proc Rotate {w x y} { global xlast ylast ViewMatrix Viewpoint Perspective set scl [expr $Viewpoint(z) / $Perspective(fd)] if {[expr $scl > 1.0]} { set dx [expr $x - $xlast] set dy [expr $y - $ylast] } else { if {[expr $scl < 0.1]} {set scl 0.1} set dx [expr $scl * ($x - $xlast)] set dy [expr $scl * ($y - $ylast)] } set xlast $x set ylast $y eval $w eval \ -loadidentity \ -rotate $dy 1 0 0 \ -rotate $dx 0 1 0 \ -multmatrix $ViewMatrix set ViewMatrix [$w get modelviewmatrix] set_view $w } proc Pan {w x y} { global xlast ylast Viewpoint Perspective ProgData set scl [expr $Viewpoint(z) / $Perspective(fd)] if {[expr $scl > 1.0]} { set scl $ProgData(scale) } else { if {[expr $scl < 0.1]} {set scl 0.1} set scl [expr $scl * $ProgData(scale)] } set Viewpoint(x) [expr $scl * ($xlast - $x) + $Viewpoint(x)] set Viewpoint(y) [expr $scl * ($y - $ylast) + $Viewpoint(y)] set xlast $x set ylast $y set_view $w } proc Zoom {w x y} { global xlast ylast Viewpoint set scl [expr 0.01 * $Viewpoint(z)] if {[expr $scl < 0.001]} {set scl 0.001} set Viewpoint(z) [expr $scl * ($ylast - $y) + $Viewpoint(z)] if {[expr $Viewpoint(z) < 0.001]} { set Viewpoint(z) 0.001 } set xlast $x set ylast $y set_view $w } proc WheelZoom {d} { global Viewpoint OGLwin set scl [expr 0.001 * $Viewpoint(z)] if {[expr $scl < 0.0001]} {set scl 0.0001} set Viewpoint(z) [expr $scl * $d + $Viewpoint(z)] if {[expr $Viewpoint(z) < 0.001]} { set Viewpoint(z) 0.001 } set_view $OGLwin } proc reset_clipping {} { global ProgData Perspective OGLwin array set ProgData { np 0.025 fp 2.0 } set Perspective(np) [expr $Perspective(fd) * $ProgData(np)] set Perspective(fp) [expr $Perspective(fd) * $ProgData(fp)] compute_viewport $OGLwin } proc Center {} { global ProgData Viewpoint ViewMatrix Perspective OGLwin set bounds [CGNSbounds 0 $ViewMatrix] set b [lindex $bounds 0] set xt [expr -0.5 * ([lindex $b 1] + [lindex $b 0])] set xd [expr double([lindex $b 1]) - double([lindex $b 0])] set b [lindex $bounds 1] set yt [expr -0.5 * ([lindex $b 1] + [lindex $b 0])] set yd [expr double([lindex $b 1]) - double([lindex $b 0])] set b [lindex $bounds 2] set zt [expr -0.5 * ([lindex $b 1] + [lindex $b 0])] set zd [expr double([lindex $b 1]) - double([lindex $b 0])] set dd [expr $xd * $xd + $yd * $yd + $zd * $zd] if {[expr $dd < 1.0e-15]} { set scl 1.0 } else { set scl [expr 1.0 / sqrt($dd)] } # reset_clipping eval $OGLwin eval \ -matrixmode modelview \ -loadidentity \ -scale $scl $scl $scl \ -translate $xt $yt $zt \ -multmatrix $ViewMatrix set ViewMatrix [$OGLwin get modelviewmatrix] set Viewpoint(x) 0 set Viewpoint(y) 0 set Viewpoint(z) $Perspective(fd) set_view $OGLwin } proc reset_view {} { global ProgData Viewpoint ViewMatrix Perspective OGLwin set bounds [CGNSbounds 0] set b [lindex $bounds 0] set xt [expr -0.5 * ([lindex $b 1] + [lindex $b 0])] set xd [expr double([lindex $b 1]) - double([lindex $b 0])] set b [lindex $bounds 1] set yt [expr -0.5 * ([lindex $b 1] + [lindex $b 0])] set yd [expr double([lindex $b 1]) - double([lindex $b 0])] set b [lindex $bounds 2] set zt [expr -0.5 * ([lindex $b 1] + [lindex $b 0])] set zd [expr double([lindex $b 1]) - double([lindex $b 0])] set dd [expr $xd * $xd + $yd * $yd + $zd * $zd] if {[expr $dd < 1.0e-15]} { set scl 1.0 } else { set scl [expr 1.0 / sqrt($dd)] } set Viewpoint(x) 0 set Viewpoint(y) 0 set Viewpoint(z) $Perspective(fd) reset_clipping $OGLwin eval \ -matrixmode modelview \ -loadidentity \ -scale $scl $scl $scl \ -translate $xt $yt $zt set ViewMatrix [$OGLwin get modelviewmatrix] eval $OGLwin eval \ -loadidentity \ -lookat $Viewpoint(x) $Viewpoint(y) $Viewpoint(z) \ $Viewpoint(x) $Viewpoint(y) 0 0 1 0 \ -multmatrix $ViewMatrix } proc init_data {} { global ProgData set ProgData(/,dim) 0 set ProgData(/,mode) 0 set ProgData(/,vis) 1 set ProgData(/,clr) "" set ProgData(/,msg) [CGNSsummary] set nz 0 foreach z $ProgData(zones) { set clr [OGLcolor $nz] set zone /$z set ProgData($zone,dim) 0 set ProgData($zone,vis) 1 set ProgData($zone,mode) 0 set ProgData($zone,clr) $clr set ProgData($zone,msg) [CGNSsummary $nz] set subdirs {} set nr 0 foreach r $ProgData($nz,regions) { set reg $zone/$r if [catch {CGNSregiondim $nz $nr} dim] { set msg $dim set dim 0 } else { set msg "" } if {$dim < 1} { set ProgData($reg,dim) 0 set ProgData($reg,vis) 0 set ProgData($reg,mode) 0 set ProgData($reg,clr) "" if {$msg == ""} { set ProgData($reg,msg) "couldn't process for exterior faces" } else { set ProgData($reg,msg) $msg } } else { set ProgData($reg,dim) $dim if {$nr == 0 || $dim == 3} { set ProgData($reg,vis) $ProgData(meshvis) set ProgData($reg,mode) $ProgData(meshmode) } else { set ProgData($reg,vis) $ProgData(regvis) set ProgData($reg,mode) $ProgData(regmode) } if {$ProgData(autocolor)} { set clr [OGLcolor [expr $nz + $nr]] } set ProgData($reg,clr) $clr set ProgData($reg,msg) [CGNSsummary $nz $nr] } set dir [file dirname $r] if {$dir != "" && $dir != "."} { if {[lsearch $subdirs $dir] < 0} { lappend subdirs $dir set ProgData($zone/$dir,dim) $ProgData($reg,dim) set ProgData($zone/$dir,vis) 1 set ProgData($zone/$dir,mode) $ProgData($reg,mode) set ProgData($zone/$dir,clr) $clr set ProgData($zone/$dir,msg) "" } else { if {$ProgData($zone/$dir,dim) < $ProgData($reg,dim)} { set ProgData($zone/$dir,dim) $ProgData($reg,dim) } if {$ProgData($zone/$dir,mode) != $ProgData($reg,mode)} { set ProgData($zone/$dir,mode) 0 } } } if {$nr == 0} { set ProgData($zone,dim) $ProgData($reg,dim) set ProgData($zone,mode) $ProgData($reg,mode) } else { if {$ProgData($zone,dim) < $ProgData($reg,dim)} { set ProgData($zone,dim) $ProgData($reg,dim) } if {$ProgData($zone,mode) != $ProgData($reg,mode)} { set ProgData($zone,mode) 0 } } incr nr } if {$nz == 0} { set ProgData(/,dim) $ProgData($zone,dim) set ProgData(/,mode) $ProgData($zone,mode) } else { if {$ProgData(/,dim) < $ProgData($zone,dim)} { set ProgData(/,dim) $ProgData($zone,dim) } if {$ProgData(/,mode) != $ProgData($zone,mode)} { set ProgData(/,mode) 0 } } incr nz } } proc init_display {} { global ProgData OGLwin if {$ProgData(displaylist) != ""} { $OGLwin deletelist $ProgData(displaylist) } if {$ProgData(nzones) < 1} { set ProgData(displaylist) "" $OGLwin main -clear colorbuffer depthbuffer -call $ProgData(axislist) } else { set calllist {} set nz 0 foreach z $ProgData(zones) { set nr 0 foreach r $ProgData($nz,regions) { if {$ProgData(/$z/$r,dim)} { set clr $ProgData(/$z/$r,clr) if {$ProgData(/$z/$r,vis)} { set dl [OGLregion $nz $nr $ProgData(/$z/$r,mode) $clr] } else { set dl [OGLregion $nz $nr 0 $clr] } lappend calllist -call $dl } incr nr } incr nz } if {$ProgData(cutlist) != ""} { lappend calllist -call $ProgData(cutlist) } if {$ProgData(planelist) != ""} { lappend calllist -call $ProgData(planelist) } set ProgData(displaylist) [eval $OGLwin newlist $calllist] $OGLwin main -clear colorbuffer depthbuffer \ -call $ProgData(axislist) -call $ProgData(displaylist) } OGLaxis $ProgData(axis) } proc cleanup_display {} { global ProgData OGLwin display_message "" if {$ProgData(cgnsfile) == ""} return catch CGNSclose close_cutplane if {$ProgData(displaylist) != ""} { $OGLwin deletelist $ProgData(displaylist) set ProgData(displaylist) "" } $OGLwin main -clear colorbuffer depthbuffer -call $ProgData(axislist) TreeDelete $ProgData(tree) / array set ProgData { bases {} nzones 0 zones {} curnode "" curdim 0 curclr "" curmode 0 } OGLaxis $ProgData(axis) $OGLwin redraw } #---------- set base proc build_tree {} { global ProgData set_node "" TreeDelete $ProgData(tree) / TreeInsert $ProgData(tree) / -text $ProgData(curbase) set nz 0 foreach z $ProgData(zones) { set zone /$z if {$ProgData($zone,dim) == 0} { set icon box_question set clr "" } else { if {$ProgData($zone,vis)} { set icon box_checked } else { set icon box_empty } if {$ProgData(showcolors)} { set clr [color_value $ProgData($zone,clr)] } else { set clr "" } } TreeInsert $ProgData(tree) $zone -tag $nz -icon $icon -iconbg $clr set nr 0 foreach r $ProgData($nz,regions) { set dir [file dirname $r] if {$dir != "" && $dir != "." && ![TreeExists $ProgData(tree) $zone/$dir]} { if {$ProgData($zone/$dir,dim) == 0} { set icon box_question set clr "" } else { if {$ProgData($zone/$dir,vis)} { set icon box_checked } else { set icon box_empty } if {$ProgData(showcolors)} { set clr [color_value $ProgData($zone/$dir,clr)] } else { set clr "" } } TreeInsert $ProgData(tree) $zone/$dir -icon $icon -iconbg $clr } set reg $zone/$r if {$ProgData($reg,dim) == 0} { set icon box_question set clr "" } else { if {$ProgData($reg,vis)} { set icon box_checked } else { set icon box_empty } if {$ProgData(showcolors)} { set clr [color_value $ProgData($reg,clr)] } else { set clr "" } } TreeInsert $ProgData(tree) $reg -tag "$nz $nr" -icon $icon -iconbg $clr incr nr } incr nz } } proc set_base {w nb} { global ProgData display_message "reading zone information..." if {[catch {CGNSbase $nb} zones]} { display_message $zones errormsg $zones return "" } set ProgData(zones) $zones set ProgData(nzones) [llength $zones] . configure -cursor watch update for {set nz 0} {$nz < $ProgData(nzones)} {incr nz} { display_message "reading zone [expr $nz + 1]..." if {[catch {CGNSzone $nz} regs]} { errormsg $regs set regs "" } set ProgData($nz,regions) $regs } set ProgData(curbase) [lindex $ProgData(bases) $nb] init_data display_message "building display lists..." init_display reset_view build_tree if [winfo exists .cutplane] { OGLcutplane 0 center_cutplane } . configure -cursor {} display_message "" return "" } proc show_info {w x y node} { global ProgData Font if {$node == ""} return if {$node == "/"} { catch CGNSgetbase msg } else { set tag [TreeGet $w $node -tag] if {[llength $tag] == 1} { catch {CGNSgetzone $tag} msg } elseif {[llength $tag] == 2} { catch {CGNSgetregion [lindex $tag 0] [lindex $tag 1]} msg } else { set msg "" } } if {$msg != ""} { incr x [winfo rootx $w] incr y [winfo rooty $w] popup_message $msg -parent $w -position "$x $y" \ -font $Font(fixed) -wrap 0 } } proc set_node {node} { global ProgData TreeSelectionSet $ProgData(tree) $node set ProgData(curnode) $node if {$node == "" || ![info exists ProgData($node,dim)]} { set ProgData(curdim) 0 set ProgData(curmode) 0 set ProgData(curclr) "" set msg "" } else { set ProgData(curdim) $ProgData($node,dim) set ProgData(curmode) $ProgData($node,mode) set ProgData(curclr) $ProgData($node,clr) set msg $ProgData($node,msg) } color_button $ProgData(clrbut) $ProgData(curclr) options_state $ProgData(curdim) display_message $msg } proc set_visibility {node vis all} { global ProgData if {$ProgData($node,dim) == 0} return if {$vis} { set ProgData($node,vis) 1 TreeSet $ProgData(tree) $node -icon box_checked } else { set ProgData($node,vis) 0 TreeSet $ProgData(tree) $node -icon box_empty } if {$all} { foreach c [TreeGet $ProgData(tree) $node -children] { set_visibility $node/$c $vis 1 } } } proc toggle_visibility {node {all 0}} { global ProgData if {$node == "" || ![info exists ProgData($node,dim)] || $ProgData($node,dim) == 0} return if {$ProgData($node,vis)} { set vis 0 } else { set vis 1 } set_visibility $node $vis $all update_node $node if {$vis && $node != [TreeSelectionGet $ProgData(tree)]} { set_node $node } } proc node_visible {node} { global ProgData if {$ProgData($node,vis) == 0} {return 0} set node [file dirname $node] while {$node != "" && $node != "." && $node != "/"} { if {$ProgData($node,vis) == 0} {return 0} set node [file dirname $node] } return 1 } proc update_children {node mode clr} { global ProgData if {$mode != ""} { set ProgData($node,mode) $mode } if {$clr != ""} { if {[llength $clr] == 1} { set ProgData($node,clr) [OGLcolor $clr] } else { set ProgData($node,clr) $clr } if {$ProgData(showcolors)} { TreeSet $ProgData(tree) $node -iconbg [color_value $ProgData($node,clr)] } } set children [TreeGet $ProgData(tree) $node -children] if {[llength $children] > 0} { if {$node == "/"} {set node ""} foreach c $children { update_children $node/$c $mode $clr if {[llength $clr] == 1} {incr clr} } } else { set tag [TreeGet $ProgData(tree) $node -tag] if {[llength $tag] == 2} { if [node_visible $node] { set mode $ProgData($node,mode) } else { set mode 0 } OGLregion [lindex $tag 0] [lindex $tag 1] $mode $ProgData($node,clr) } } } proc update_node {node {mode ""} {clr ""}} { global ProgData OGLwin if {$node == "" || $ProgData($node,dim) == 0} return update_children $node $mode $clr OGLaxis $ProgData(axis) $OGLwin redraw } proc parent_mode {node} { global ProgData if {$node == "" || $node == "."} return set mode "" set par $node if {$par == "/"} {set par ""} foreach c [TreeGet $ProgData(tree) $node -children] { if {$mode == ""} { set mode $ProgData($par/$c,mode) } else { if {$mode != $ProgData($par/$c,mode)} { set mode 0 break } } } if {$mode == ""} return set ProgData($node,mode) $mode if {$node != "/"} { parent_mode [file dirname $node] } } proc update_mode {} { global ProgData set node $ProgData(curnode) if {$node == "" || $ProgData($node,dim) == 0} return update_node $node $ProgData(curmode) if {$node != "/"} { parent_mode [file dirname $node] } } proc update_color {w} { global ProgData set node $ProgData(curnode) if {$node == "" || $ProgData($node,dim) == 0} return set newclr [select_color $ProgData(curclr) "Set Color" $w] if {$newclr != ""} { set ProgData(curclr) $newclr color_button $ProgData(clrbut) $newclr update_node $node "" $newclr } } proc auto_color {w} { global ProgData set node $ProgData(curnode) if {$node == "" || $ProgData($node,dim) == 0} return set clr [expr [llength [split $node /]] - 2] set newclr [OGLcolor $clr] set ProgData(curclr) $newclr color_button $ProgData(clrbut) $newclr update_node $node "" $clr } #---------- cutting plane proc normalize_cutplane {} { global ProgData set r 0.0 foreach i {x y z} { set r [expr $r + $ProgData(cut$i) * $ProgData(cut$i)] } if [expr $r == 0.0] { set r 1.0 } else { set r [expr sqrt($r)] } foreach i {x y z} { set ProgData(cut$i) [expr $ProgData(cut$i) / $r] } } proc reset_cutplane {} { global ProgData set bounds [CGNSbounds 0] array set ProgData { rotx 0 roty 0 rotz 0 lastx 0 lasty 0 lastz 0 } set n 0 set dist 0.0 set diag 0.0 foreach i {x y z} { set b [lindex $bounds $n] set r [expr [lindex $b 1] - [lindex $b 0]] set diag [expr $diag + $r * $r] set r [expr 0.5 * ([lindex $b 0] + [lindex $b 1])] set dist [expr $dist + $r * $ProgData(cut$i)] incr n } set ProgData(translate) [expr ($ProgData(cutd) - $dist) / sqrt($diag)] } proc draw_cut {{recompute 1}} { global ProgData OGLwin set ProgData(cutplane) \ [list $ProgData(cutx) $ProgData(cuty) $ProgData(cutz) $ProgData(cutd)] if {$recompute} { OGLcutplane $ProgData(cutmode) $ProgData(cutplane) } else { OGLcutplane $ProgData(cutmode) } if {$ProgData(cutmode)} OGLdrawplane $OGLwin redraw reset_cutplane } proc draw_cutplane {} { global ProgData OGLwin if {$ProgData(drawID) == ""} { set ProgData(drawID) [after idle draw_cutplane] return } set ProgData(drawID) "" set plane {} foreach i {x y z d} { if [catch {expr double($ProgData(cut$i))} val] return lappend plane $val } if [catch {OGLdrawplane $plane} msg] { OGLdrawplane } else { set msg "" } $OGLwin redraw display_message $msg } proc update_cutplane {data var op} { global ProgData if {$ProgData(dotrace)} draw_cutplane } proc center_cutplane {} { global ProgData OGLwin set ProgData(dotrace) 0 normalize_cutplane set bounds [CGNSbounds 0] set d 0.0 set n 0 foreach i {x y z} { set b [lindex $bounds $n] set r [expr 0.5 * ([lindex $b 0] + [lindex $b 1])] set d [expr $d + $r * $ProgData(cut$i)] incr n } set ProgData(cutd) [format "%g" $d] set ProgData(translate) 0 draw_cutplane set ProgData(dotrace) 1 } proc set_cutplane {dir} { global ProgData OGLwin set ProgData(dotrace) 0 set bounds [CGNSbounds 0] if {$dir == "x"} { array set ProgData { cutx 1 cuty 0 cutz 0 } set b [lindex $bounds 0] } elseif {$dir == "y"} { array set ProgData { cutx 0 cuty 1 cutz 0 } set b [lindex $bounds 1] } else { array set ProgData { cutx 0 cuty 0 cutz 1 } set b [lindex $bounds 2] } set ProgData(cutd) [format "%g" \ [expr 0.5 * ([lindex $b 0] + [lindex $b 1])]] draw_cutplane reset_cutplane set ProgData(dotrace) 1 } proc rotate_cutplane {axis amt} { global ProgData set ProgData(dotrace) 0 normalize_cutplane set bounds [CGNSbounds 0] set n 0 set d $ProgData(cutd) foreach i {x y z} { set b [lindex $bounds $n] set p$i [expr 0.5 * ([lindex $b 0] + [lindex $b 1])] set d [expr $d - [set p$i] * $ProgData(cut$i)] incr n } foreach i {x y z} { set r$i [expr [set p$i] + $d * $ProgData(cut$i)] } set ca [expr cos(0.0174533 * ($amt - $ProgData(last$axis)))] set sa [expr sin(0.0174533 * ($amt - $ProgData(last$axis)))] set ProgData(last$axis) $amt set x $ProgData(cutx) set y $ProgData(cuty) set z $ProgData(cutz) if {$axis == "x"} { set ProgData(cuty) [format "%g" [expr $ca * $y - $sa * $z]] set ProgData(cutz) [format "%g" [expr $ca * $z + $sa * $y]] } elseif {$axis == "y"} { set ProgData(cutx) [format "%g" [expr $ca * $x + $sa * $z]] set ProgData(cutz) [format "%g" [expr $ca * $z - $sa * $x]] } else { set ProgData(cutx) [format "%g" [expr $ca * $x - $sa * $y]] set ProgData(cuty) [format "%g" [expr $ca * $y + $sa * $x]] } set d 0.0 foreach i {x y z} { set d [expr $d + $ProgData(cut$i) * [set r$i]] } set ProgData(cutd) [format "%g" $d] draw_cutplane set ProgData(dotrace) 1 } proc translate_cutplane {amt} { global ProgData set ProgData(dotrace) 0 normalize_cutplane set bounds [CGNSbounds 0] set n 0 set dist 0.0 set diag 0.0 foreach i {x y z} { set b [lindex $bounds $n] set r [expr [lindex $b 1] - [lindex $b 0]] set diag [expr $diag + $r * $r] set r [expr 0.5 * ([lindex $b 0] + [lindex $b 1])] set dist [expr $dist + $r * $ProgData(cut$i)] incr n } set ProgData(cutd) [format "%g" [expr $dist + $amt * sqrt($diag)]] draw_cutplane set ProgData(dotrace) 1 } proc cutplane_color {but {trans ""}} { global ProgData if {$trans == ""} { set clr [select_color [lrange $ProgData(cutcolor) 0 2] "Select Color" $but] if {$clr == ""} return set trans [lindex $ProgData(cutcolor) 3] set ProgData(cutcolor) $clr lappend ProgData(cutcolor) $trans color_button $but $clr } else { set ProgData(cutcolor) [lreplace $ProgData(cutcolor) 3 3 $trans] } OGLcutconfig $ProgData(cutcolor) draw_cutplane } proc cutplane_config {recompute} { global ProgData OGLcutconfig $ProgData(cutcolor) $ProgData(usecutclr) $ProgData(ignorevis) draw_cut $recompute } proc cutplane_defaults {but} { global ProgData set ProgData(cutcolor) {0.7 0.7 0.4 0.5} set ProgData(transparency) 0.5 color_button $but $ProgData(cutcolor) set ProgData(cutmode) 1 set ProgData(usecutclr) 0 set ProgData(ignorevis) 0 OGLcutconfig $ProgData(cutcolor) 0 0 set_cutplane x } proc cutplane_control {} { global ProgData Font set w .cutplane if [winfo exists $w] { wm deiconify $w raise $w focus $w return } if {$ProgData(cutplane) == ""} { array set ProgData { cutx 1 cuty 0 cutz 0 } } else { set ProgData(cutx) [lindex $ProgData(cutplane) 0] set ProgData(cuty) [lindex $ProgData(cutplane) 1] set ProgData(cutz) [lindex $ProgData(cutplane) 2] } set ProgData(transparency) [lindex $ProgData(cutcolor) 3] toplevel $w wm title $w "Cutting Plane" wm protocol $w WM_DELETE_WINDOW close_cutplane FrameCreate $w.clr -text "Color" -font $Font(bold) -padx 0 -pady 0 pack $w.clr -side top -padx 5 -pady 2 -fill x -expand 1 set clr [FrameGet $w.clr] label $clr.lab -text Transparency pack $clr.lab -side left scale $clr.scl -length 50 -from 0 -to 1 -resolution 0.01 \ -orient horizontal -label "" -showvalue 0 -width 12 \ -highlightthickness 0 -variable ProgData(transparency) \ -command "cutplane_color $clr.but" pack $clr.scl -side left -fill x -expand 1 button $clr.but -text Select -relief solid -bd 1 \ -command "cutplane_color $clr.but" pack $clr.but -side right color_button $clr.but $ProgData(cutcolor) FrameCreate $w.pos -text "Cut Plane" -font $Font(bold) -padx 0 -pady 0 pack $w.pos -side top -padx 5 -pady 2 -fill x -expand 1 set pos [FrameGet $w.pos] foreach r {X Y Z} { set i [string tolower $r] set f [frame $pos.d$i] pack $f -side top -fill x label $f.lab -text "$r Direction" -width 10 -anchor w pack $f.lab -side left entry $f.ent -width 10 -textvariable ProgData(cut$i) pack $f.ent -side left -fill x -expand 1 -padx 2 button $f.but -text "$r Cut" -width 6 -command "set_cutplane $i" pack $f.but -side right set f [frame $pos.r$i] pack $f -side top -fill x label $f.lab -width 10 -text "$r Rotate" -anchor e pack $f.lab -side left scale $f.scl -length 50 -from -90 -to 90 -resolution 1 \ -orient horizontal -label "" -showvalue 0 -width 12 \ -highlightthickness 0 -variable ProgData(rot$i) \ -command "rotate_cutplane $i" pack $f.scl -side left -fill x -expand 1 } set f [frame $pos.dd] pack $f -side top -fill x label $f.lab -text "Offset" -width 10 -anchor w pack $f.lab -side left entry $f.ent -width 10 -textvariable ProgData(cutd) pack $f.ent -side left -fill x -expand 1 -padx 2 button $f.but -text Center -width 6 -command center_cutplane pack $f.but -side right set f [frame $pos.rd] pack $f -side top -fill x label $f.lab -width 10 -text "Translate" -anchor e pack $f.lab -side left scale $f.scl -length 50 -from -.5 -to 0.5 -resolution 0.001 \ -orient horizontal -label "" -showvalue 0 -width 12 \ -highlightthickness 0 -variable ProgData(translate) \ -command translate_cutplane pack $f.scl -side left -fill x -expand 1 FrameCreate $w.mode -text "Display" -font $Font(bold) -padx 0 -pady 0 pack $w.mode -side top -padx 5 -pady 2 -fill x -expand 1 set mode [FrameGet $w.mode] set f [frame $mode.d] pack $f -side top -fill x set n 0 foreach i {Off Planar Elements Shaded} { radiobutton $f.f$n -text $i -variable ProgData(cutmode) \ -value $n -command {draw_cut 0} pack $f.f$n -side left -expand 1 incr n } set f [frame $mode.b] pack $f -side top -fill x checkbutton $f.cc -text "Use Cutplane Color" \ -variable ProgData(usecutclr) -onvalue 1 -offvalue 0 \ -command {cutplane_config 0} checkbutton $f.iv -text "Ignore Region Visibility" \ -variable ProgData(ignorevis) -onvalue 1 -offvalue 0 \ -command {cutplane_config 1} pack $f.cc $f.iv -side left -expand 1 frame $w.but pack $w.but -side top -fill x -padx 5 -expand 1 button $w.but.r -text Compute -width 8 -default active \ -command draw_cut button $w.but.d -text Defaults -width 8 \ -command "cutplane_defaults $clr.but" button $w.but.c -text Close -width 8 -command close_cutplane pack $w.but.r $w.but.d $w.but.c -side left -expand 1 bind $w draw_cut center_cutplane reset_cutplane foreach i {x y z d} { trace variable ProgData(cut$i) w update_cutplane } set ProgData(dotrace) 1 } proc close_cutplane {} { global ProgData OGLwin if {[winfo exists .cutplane]} { set ProgData(dotrace) 1 foreach i {x y z d} { trace vdelete ProgData(cut$i) w update_cutplane } OGLcutplane 0 OGLdrawplane $OGLwin redraw destroy .cutplane } } #---------- set variable for plotting proc set_variable {w n} { global ProgData return "" } #---------- read cgns file set FileList { {{CGNS Files} {.cgns .cga .cgh .cgx}} {{All Files} {*}} } proc load_cgns {{filename ""}} { global ProgData FileList ModelData global Translate Scale if {$filename == ""} { set filename [FileOpen "Open CGNS File" \ $ProgData(cgnsfile) . $FileList] } if {$filename == ""} return cleanup_display display_message "reading base information..." . configure -cursor watch update set msg "" if {[catch {CGNSopen $filename} bases]} { set msg $bases } else { set msg "" } . configure -cursor {} if {$msg != ""} { display_message $msg errormsg $msg return } set ProgData(bases) $bases ComboboxConfig $ProgData(baselist) -values $bases -index 0 -state normal if {[llength $bases] < 2} { ComboboxConfig $ProgData(baselist) -state disabled } set_base $ProgData(baselist) 0 wm title . "CGNSplot : [file tail $filename]" set ProgData(cgnsfile) $filename } catch { config_icon . [list cgnsplot cgns] \ [list $cmd_dir $cmd_dir/images $cmd_dir/../common] } wm deiconify . if {$argc} { set file [lindex $argv [expr $argc - 1]] if {[string index $file 0] != "-" && [file exists $file]} { load_cgns $file } } CGNS-4.5.0/src/cgnstools/cgnsplot/cgnstcl.c000066400000000000000000005366711474000356600205350ustar00rootroot00000000000000#include #include #include #include #include #ifdef _WIN32 # define WIN32_LEAN_AND_MEAN # include #endif #include "gl_config.h" #include "tk.h" #include "cgnslib.h" #include "hash.h" #ifdef CG_BUILD_BASESCOPE typedef char char_66[66]; /* 32 + '/' + 32 + '\0' */ #else typedef char char_66[33]; /* 32 + '\0' (caller's malloc compat issues) */ #endif /* define this to exclude structured mesh boundaries */ /* imin, imax, jmin, jmax, kmin, kmax */ /*#define NO_MESH_BOUNDARIES*/ /* define this to disable a cutting plane */ /* the cutting plane requires more memory since all nodes and elements are saved */ /*#define NO_CUTTING_PLANE*/ /* this is the cosine of the angle between faces to define an interior edge */ /* it's set to 60 degrees - comment to remove interior edges */ #define EDGE_ANGLE 0.5 typedef float Node[3]; typedef struct { cgsize_t id; cgsize_t nodes[2]; } Edge; typedef struct { cgsize_t id; int flags; int nnodes; cgsize_t *nodes; float normal[3]; } Face; typedef struct { Face *face; cgsize_t num; int flags; } PolyFace; #ifndef NO_CUTTING_PLANE typedef struct { int id; cgsize_t nodes[3]; float ratio; } CutNode; typedef struct { cgsize_t nelems; cgsize_t *elems; cgsize_t nedges; Edge *edges; } CutData; typedef struct { float plane[4]; cgsize_t nelems; cgsize_t nedges; cgsize_t nnodes; Node *nodes; } CutPlane; static float cutcolor[4] = {(float)0.8, (float)0.4, (float)0.8, (float)0.5}; static int usecutclr = 0; static int ignorevis = 0; static CutPlane cutplane; static int CutDL = 0; static int PlaneDL = 0; #endif typedef struct { char name[33]; int type; int dim; cgsize_t data[10]; char_66 d_name; cgsize_t nedges; Edge *edges; cgsize_t nfaces; Face **faces; #ifndef NO_CUTTING_PLANE CGNS_ENUMT(ElementType_t) elemtype; cgsize_t nelems; cgsize_t *elems; cgsize_t *elem_offsets; int npoly; Face **poly; CutData cut; #endif float bbox[3][2]; int dlist; int mode; float color[4]; char errmsg[81]; } Regn; typedef struct { char name[33]; cgsize_t nnodes; Node *nodes; int nregs; Regn *regs; } Zone; static int cgnsfn = 0; static int cgnsbase = 0; static int cgnszone = 0; static int nbases = 0; static int nzones = 0; static Zone *zones; static int AxisDL = 0; static char BaseName[33]; static int CellDim, PhyDim; static Tcl_Interp *global_interp; enum { REG_MESH, REG_ELEM, REG_1TO1, REG_CONN, REG_HOLE, REG_BOCO, REG_BNDS }; /* mapping from elements to faces */ static int facenodes[22][5] = { /* tri */ {3, 0, 1, 2, 0}, /* quad */ {4, 0, 1, 2, 3}, /* tet */ {3, 0, 2, 1, 0}, {3, 0, 1, 3, 0}, {3, 1, 2, 3, 0}, {3, 2, 0, 3, 0}, /* pyramid */ {4, 0, 3, 2, 1}, {3, 0, 1, 4, 0}, {3, 1, 2, 4, 0}, {3, 2, 3, 4, 0}, {3, 3, 0, 4, 0}, /* wedge */ {4, 0, 1, 4, 3}, {4, 1, 2, 5, 4}, {4, 2, 0, 3, 5}, {3, 0, 2, 1, 0}, {3, 3, 4, 5, 0}, /* hex */ {4, 0, 3, 2, 1}, {4, 0, 1, 5, 4}, {4, 1, 2, 6, 5}, {4, 2, 3, 7, 6}, {4, 0, 4, 7, 3}, {4, 4, 5, 6, 7} }; /*=================================================================== * local routines *===================================================================*/ /*-------------------------------------------------------------------*/ static void FATAL (char *errmsg) { char cmd[129]; sprintf (cmd, "error_exit {%s}", errmsg); Tcl_Eval (global_interp, cmd); exit (1); } /*-------------------------------------------------------------------*/ static void *MALLOC (char *funcname, size_t bytes) { void *data = calloc (bytes, 1); if (NULL == data) { char msg[128]; if (funcname != NULL) sprintf (msg, "%s:malloc failed for %lu bytes", funcname, (unsigned long)bytes); else sprintf (msg, "malloc failed for %lu bytes", (unsigned long)bytes); FATAL (msg); } return data; } /*-------------------------------------------------------------------*/ static void *REALLOC (char *funcname, size_t bytes, void *old_data) { void *new_data; if (NULL == old_data) return MALLOC (funcname, bytes); new_data = realloc (old_data, bytes); if (NULL == new_data) { char msg[128]; if (funcname != NULL) sprintf (msg, "%s:realloc failed for %lu bytes", funcname, (unsigned long)bytes); else sprintf (msg, "realloc failed for %lu bytes", (unsigned long)bytes); FATAL (msg); } return new_data; } /*-------------------------------------------------------------------*/ static Face *new_face(char *funcname, int nnodes) { Face *f = (Face *) calloc (nnodes * sizeof(cgsize_t) + sizeof(Face), 1); if (f == NULL) { char msg[128]; if (funcname != NULL) sprintf (msg, "%s:malloc failed for face with %d nodes", funcname, nnodes); else sprintf (msg, "malloc failed for face with %d nodes", nnodes); FATAL (msg); } f->nnodes = nnodes; f->nodes = (cgsize_t *)(f + 1); return f; } /*-------------------------------------------------------------------*/ static Face *copy_face(char *funcname, Face *face) { int n; Face *f = new_face(funcname, face->nnodes); f->id = face->id; f->flags = face->flags; for (n = 0; n < face->nnodes; n++) f->nodes[n] = face->nodes[n]; for (n = 0; n < 3; n++) f->normal[n] = face->normal[n]; return f; } /*-------------------------------------------------------------------*/ static void zone_message (char *msg, char *name) { char cmd[129]; if (name != NULL) sprintf (cmd, "display_message {Zone %d : %s %s...}", cgnszone, msg, name); else sprintf (cmd, "display_message {Zone %d : %s...}", cgnszone, msg); Tcl_Eval (global_interp, cmd); } /*-------------------------------------------------------------------*/ static void free_all (void) { int nz, nr, nf; if (!nzones) return; for (nz = 0; nz < nzones; nz++) { for (nr = 0; nr < zones[nz].nregs; nr++) { if (zones[nz].regs[nr].dlist) glDeleteLists (zones[nz].regs[nr].dlist, 1); if (zones[nz].regs[nr].nedges) free (zones[nz].regs[nr].edges); if (zones[nz].regs[nr].nfaces) { for (nf = 0; nf < zones[nz].regs[nr].nfaces; nf++) { if (zones[nz].regs[nr].faces[nf]) free (zones[nz].regs[nr].faces[nf]); } free (zones[nz].regs[nr].faces); } #ifndef NO_CUTTING_PLANE if (zones[nz].regs[nr].nelems) free (zones[nz].regs[nr].elems); if (zones[nz].regs[nr].nelems && zones[nz].regs[nr].elem_offsets) free (zones[nz].regs[nr].elem_offsets); if (zones[nz].regs[nr].npoly) free (zones[nz].regs[nr].poly); if (zones[nz].regs[nr].cut.nelems) free (zones[nz].regs[nr].cut.elems); if (zones[nz].regs[nr].cut.nedges) free (zones[nz].regs[nr].cut.edges); #endif } if (zones[nz].nregs) free (zones[nz].regs); if (zones[nz].nnodes) free(zones[nz].nodes); } free (zones); nzones = 0; #ifndef NO_CUTTING_PLANE if (cutplane.nnodes) free (cutplane.nodes); cutplane.nelems = 0; cutplane.nedges = 0; cutplane.nnodes = 0; #endif } /*-------------------------------------------------------------------*/ static int compare_ints (const void *v1, const void *v2) { return (int)(*((cgsize_t *)v1) - *((cgsize_t *)v2)); } /*-------------------------------------------------------------------*/ static int find_int (cgsize_t value, cgsize_t nlist, cgsize_t *list) { cgsize_t lo = 0, hi = nlist - 1, mid; if (!nlist || value < list[0]) return 0; if (value == list[0]) return 1; if (!hi || value > list[hi]) return 0; if (value == list[hi]) return 1; while (lo <= hi) { mid = (lo + hi) >> 1; if (value == list[mid]) return 1; if (value < list[mid]) hi = mid - 1; else lo = mid + 1; } return 0; } /*==================================================================== * structured grid regions *====================================================================*/ #define NODE_INDEX(I,J,K) ((I)+dim[0]*((J)+dim[1]*(K))) /*-------------------------------------------------------------------*/ static int structured_range (Regn *reg, cgsize_t *dim, cgsize_t *ptrng, CGNS_ENUMT(GridLocation_t) location) { int n, i, j, nf; cgsize_t ii, jj, kk, nfaces, rng[3][2]; Face *f; static char *funcname = "structured_range"; if (location != CGNS_ENUMV(Vertex) && location != CGNS_ENUMV(IFaceCenter) && location != CGNS_ENUMV(JFaceCenter) && location != CGNS_ENUMV(KFaceCenter)) { i = j = 0; for (n = 0; n < CellDim; n++) { if (ptrng[n] == ptrng[n+CellDim] && (ptrng[n] == 1 || ptrng[n] == dim[n])) { if (ptrng[n] == 1) i++; else if (j) { j = 4; break; } else j = n + 1; } } if (!j && i == 1) { for (n = 0; n < CellDim; n++) { if (ptrng[n] == ptrng[n+CellDim] && ptrng[n] == 1) { j = n + 1; break; } } } if (j == 1) location = CGNS_ENUMV(IFaceCenter); else if (j == 2) location = CGNS_ENUMV(JFaceCenter); else if (j == 3) location = CGNS_ENUMV(KFaceCenter); else { strcpy (reg->errmsg, "unable to determine boundary - use [IJK]FaceCenter"); return 0; } } nfaces = 1; if (location == CGNS_ENUMV(Vertex)) { for (n = 0, i = 0; i < CellDim; i++) { if (ptrng[i] < 1 || ptrng[i] > dim[i]) return 0; if (ptrng[i] == ptrng[i+CellDim]) { if (n || (ptrng[i] != 1 && ptrng[i] != dim[i])) return 0; n = i + 1; rng[i][0] = rng[i][1] = ptrng[i] - 1; } else { if (ptrng[i] < ptrng[i+CellDim]) { rng[i][0] = ptrng[i] - 1; rng[i][1] = ptrng[i+CellDim] - 1; } else { rng[i][0] = ptrng[i+CellDim] - 1; rng[i][1] = ptrng[i] - 1; } nfaces *= (rng[i][1] - rng[i][0]); } } } else { if (location == CGNS_ENUMV(IFaceCenter)) n = 0; else if (location == CGNS_ENUMV(JFaceCenter)) n = 1; else n = 2; for (i = 0; i < CellDim; i++) { if (i == n) { if (ptrng[i] != ptrng[i+CellDim] || (ptrng[i] != 1 && ptrng[i] != dim[i])) return 0; rng[i][0] = rng[i][1] = ptrng[i] - 1; } else { if (ptrng[i] < ptrng[i+CellDim]) { rng[i][0] = ptrng[i] - 1; rng[i][1] = ptrng[i+CellDim]; } else { rng[i][0] = ptrng[i+CellDim] - 1; rng[i][1] = ptrng[i]; } if (rng[i][0] < 0 || rng[i][1] >= dim[i]) return 0; nfaces *= (rng[i][1] - rng[i][0]); } } n++; } if (!nfaces || n < 1 || n > CellDim) { strcpy (reg->errmsg, "couldn't find any exterior faces"); return 0; } if (CellDim == 2) { reg->nedges = nfaces; reg->edges = (Edge *) MALLOC (funcname, (size_t)nfaces * sizeof(Edge)); nf = 0; kk = 0; if (n == 1) { ii = rng[0][0]; for (jj = rng[1][0]; jj < rng[1][1]; jj++) { reg->edges[nf].nodes[0] = NODE_INDEX(ii, jj, kk); reg->edges[nf].nodes[1] = NODE_INDEX(ii, jj+1, kk); nf++; } } else { jj = rng[1][0]; for (ii = rng[0][0]; ii < rng[0][1]; ii++) { reg->edges[nf].nodes[0] = NODE_INDEX(ii, jj, kk); reg->edges[nf].nodes[1] = NODE_INDEX(ii+1, jj, kk); nf++; } } return 1; } reg->nfaces = nfaces; reg->faces = (Face **) MALLOC (funcname, (size_t)nfaces * sizeof(Face *)); for (nf = 0; nf < nfaces; nf++) reg->faces[nf] = new_face (funcname, 4); nf = 0; if (n == 1) { if ((ii = rng[0][0]) == 0) { for (kk = rng[2][0]; kk < rng[2][1]; kk++) { for (jj = rng[1][0]; jj < rng[1][1]; jj++) { f = reg->faces[nf++]; f->nodes[0] = NODE_INDEX (ii, jj, kk); f->nodes[1] = NODE_INDEX (ii, jj, kk+1); f->nodes[2] = NODE_INDEX (ii, jj+1, kk+1); f->nodes[3] = NODE_INDEX (ii, jj+1, kk); } } } else { for (kk = rng[2][0]; kk < rng[2][1]; kk++) { for (jj = rng[1][0]; jj < rng[1][1]; jj++) { f = reg->faces[nf++]; f->nodes[0] = NODE_INDEX (ii, jj, kk); f->nodes[1] = NODE_INDEX (ii, jj+1, kk); f->nodes[2] = NODE_INDEX (ii, jj+1, kk+1); f->nodes[3] = NODE_INDEX (ii, jj, kk+1); } } } } else if (n == 2) { if ((jj = rng[1][0]) == 0) { for (kk = rng[2][0]; kk < rng[2][1]; kk++) { for (ii = rng[0][0]; ii < rng[0][1]; ii++) { f = reg->faces[nf++]; f->nodes[0] = NODE_INDEX (ii, jj, kk); f->nodes[1] = NODE_INDEX (ii+1, jj, kk); f->nodes[2] = NODE_INDEX (ii+1, jj, kk+1); f->nodes[3] = NODE_INDEX (ii, jj, kk+1); } } } else { for (kk = rng[2][0]; kk < rng[2][1]; kk++) { for (ii = rng[0][0]; ii < rng[0][1]; ii++) { f = reg->faces[nf++]; f->nodes[0] = NODE_INDEX (ii, jj, kk); f->nodes[1] = NODE_INDEX (ii, jj, kk+1); f->nodes[2] = NODE_INDEX (ii+1, jj, kk+1); f->nodes[3] = NODE_INDEX (ii+1, jj, kk); } } } } else { if ((kk = rng[2][0]) == 0) { for (jj = rng[1][0]; jj < rng[1][1]; jj++) { for (ii = rng[0][0]; ii < rng[0][1]; ii++) { f = reg->faces[nf++]; f->nodes[0] = NODE_INDEX (ii, jj, kk); f->nodes[1] = NODE_INDEX (ii, jj+1, kk); f->nodes[2] = NODE_INDEX (ii+1, jj+1, kk); f->nodes[3] = NODE_INDEX (ii+1, jj, kk); } } } else { for (jj = rng[1][0]; jj < rng[1][1]; jj++) { for (ii = rng[0][0]; ii < rng[0][1]; ii++) { f = reg->faces[nf++]; f->nodes[0] = NODE_INDEX (ii, jj, kk); f->nodes[1] = NODE_INDEX (ii+1, jj, kk); f->nodes[2] = NODE_INDEX (ii+1, jj+1, kk); f->nodes[3] = NODE_INDEX (ii, jj+1, kk); } } } } return 2; } /*-------------------------------------------------------------------*/ static int structured_list (Regn *mesh, Regn *reg, cgsize_t *dim, cgsize_t npts, cgsize_t *pts, CGNS_ENUMT(GridLocation_t) location) { cgsize_t n, nn, nf, nfaces = 0, noff, nmax; Face **faces, *f; static char *funcname = "structured_list"; if (location != CGNS_ENUMV(Vertex) && location != CGNS_ENUMV(IFaceCenter) && location != CGNS_ENUMV(JFaceCenter) && location != CGNS_ENUMV(KFaceCenter)) { int i, j, k; cgsize_t rng[3][2]; for (i = 0; i < CellDim; i++) rng[i][0] = rng[i][1] = pts[i]; for (nf = 1; nf < npts; nf++) { nn = nf * CellDim; for (i = 0; i < CellDim; i++) { if (rng[i][0] > pts[nn+i]) rng[i][0] = pts[nn+i]; if (rng[i][1] < pts[nn+i]) rng[i][1] = pts[nn+i]; } } j = k = 0; for (i = 0; i < CellDim; i++) { if (rng[i][0] == rng[i][1] && (rng[i][0] == 1 || rng[i][0] == dim[i])) { if (rng[i][0] == 1) j++; else if (k) { k = 4; break; } else k = i + 1; } } if (!k && j == 1) { for (i = 0; i < CellDim; i++) { if (rng[i][0] == rng[i][1] && rng[i][0] == 1) { k = i + 1; break; } } } if (k == 1) location = CGNS_ENUMV(IFaceCenter); else if (k == 2) location = CGNS_ENUMV(JFaceCenter); else if (k == 3) location = CGNS_ENUMV(KFaceCenter); else { strcpy (reg->errmsg, "unable to determine boundary - use [IJK]FaceCenter"); return 0; } } nmax = npts; if (CellDim == 2) { cgsize_t ii, jj, n0, n1, ne; Edge *edges = (Edge *) MALLOC (funcname, (size_t)nmax * sizeof(Edge)); ne = 0; if (location == CGNS_ENUMV(Vertex)) { for (nn = 0, n = 0; n < npts; n++) { pts[n] = NODE_INDEX (pts[nn]-1, pts[nn+1]-1, 0); nn += 2; } for (n = 1; n < npts; n++) { if (pts[n] < pts[n-1]) { qsort (pts, (size_t)npts, sizeof(cgsize_t), compare_ints); break; } } ne = 0; jj = 0; for (ii = 1; ii < dim[0]; ii++) { n0 = NODE_INDEX(ii-1, jj, 0); n1 = NODE_INDEX(ii, jj, 0); if (find_int(n0, npts, pts) && find_int(n1, npts, pts)) { if (ne == nmax) { nmax += 100; edges = (Edge *) REALLOC (funcname, (size_t)nmax * sizeof(Edge), edges); } edges[ne].nodes[0] = n0; edges[ne].nodes[1] = n1; ne++; } } jj = dim[1] - 1; for (ii = 1; ii < dim[0]; ii++) { n0 = NODE_INDEX(ii-1, jj, 0); n1 = NODE_INDEX(ii, jj, 0); if (find_int(n0, npts, pts) && find_int(n1, npts, pts)) { if (ne == nmax) { nmax += 100; edges = (Edge *) REALLOC (funcname, (size_t)nmax * sizeof(Edge), edges); } edges[ne].nodes[0] = n0; edges[ne].nodes[1] = n1; ne++; } } ii = 0; for (jj = 1; jj < dim[1]; jj++) { n0 = NODE_INDEX(ii, jj-1, 0); n1 = NODE_INDEX(ii, jj, 0); if (find_int(n0, npts, pts) && find_int(n1, npts, pts)) { if (ne == nmax) { nmax += 100; edges = (Edge *) REALLOC (funcname, (size_t)nmax * sizeof(Edge), edges); } edges[ne].nodes[0] = n0; edges[ne].nodes[1] = n1; ne++; } } ii = dim[0] - 1; for (jj = 1; jj < dim[1]; jj++) { n0 = NODE_INDEX(ii, jj-1, 0); n1 = NODE_INDEX(ii, jj, 0); if (find_int(n0, npts, pts) && find_int(n1, npts, pts)) { if (ne == nmax) { nmax += 100; edges = (Edge *) REALLOC (funcname, (size_t)nmax * sizeof(Edge), edges); } edges[ne].nodes[0] = n0; edges[ne].nodes[1] = n1; ne++; } } } else if (location == CGNS_ENUMV(IFaceCenter)) { for (nn = 0, n = 0; n < npts; n++) { if ((pts[nn] == 1 || pts[nn] == dim[0]) && pts[nn+1] > 0 && pts[nn+1] < dim[1]) { ii = pts[nn] - 1; jj = pts[nn+1] - 1; n0 = NODE_INDEX(ii, jj, 0); n1 = NODE_INDEX(ii, jj+1, 0); edges[ne].nodes[0] = n0; edges[ne].nodes[1] = n1; ne++; } nn += 2; } } else if (location == CGNS_ENUMV(JFaceCenter)) { for (nn = 0, n = 0; n < npts; n++) { if ((pts[nn+1] == 1 || pts[nn+1] == dim[1]) && pts[nn] > 0 && pts[nn] < dim[0]) { ii = pts[nn] - 1; jj = pts[nn+1] - 1; n0 = NODE_INDEX(ii, jj, 0); n1 = NODE_INDEX(ii+1, jj, 0); edges[ne].nodes[0] = n0; edges[ne].nodes[1] = n1; ne++; } nn += 2; } } if (ne == 0) { free(edges); strcpy (reg->errmsg, "couldn't find any exterior edges"); return 0; } reg->nedges = ne; reg->edges = edges; return 1; } faces = (Face **) MALLOC (funcname, (size_t)nmax * sizeof(Face *)); if (location == CGNS_ENUMV(Vertex)) { for (nn = 0, n = 0; n < npts; n++) { pts[n] = NODE_INDEX (pts[nn]-1, pts[nn+1]-1, pts[nn+2]-1); nn += 3; } for (n = 1; n < npts; n++) { if (pts[n] < pts[n-1]) { qsort (pts, (size_t)npts, sizeof(cgsize_t), compare_ints); break; } } for (nf = 0; nf < mesh->nfaces; nf++) { f = mesh->faces[nf]; for (nn = 0; nn < f->nnodes; nn++) { if (!find_int (f->nodes[nn], npts, pts)) break; } if (nn == f->nnodes) { if (nfaces == nmax) { nmax += 100; faces = (Face **) REALLOC (funcname, (size_t)nmax * sizeof(Face *), faces); } faces[nfaces++] = copy_face (funcname, f); } } } else if (location == CGNS_ENUMV(IFaceCenter)) { for (n = 0; n < npts; n++) { nn = 3 * n; if ((pts[nn] == 1 || pts[nn] == dim[0]) && pts[nn+1] > 0 && pts[nn+1] < dim[1] && pts[nn+2] > 0 && pts[nn+2] < dim[2]) { nf = pts[nn+1]-1 + (pts[nn+2]-1) * (dim[1]-1); if (pts[nn] == dim[0]) nf += (dim[1]-1) * (dim[2]-1); faces[nfaces++] = copy_face (funcname, mesh->faces[nf]); } } } else if (location == CGNS_ENUMV(JFaceCenter)) { noff = 2 * (dim[1]-1) * (dim[2]-1); for (n = 0; n < npts; n++) { nn = 3 * n; if ((pts[nn+1] == 1 || pts[nn+1] == dim[1]) && pts[nn] > 0 && pts[nn] < dim[0] && pts[nn+2] > 0 && pts[nn+2] < dim[2]) { nf = noff + pts[nn]-1 + (pts[nn+2]-1) * (dim[0]-1); if (pts[nn+1] == dim[1]) nf += (dim[0]-1) * (dim[2]-1); faces[nfaces++] = copy_face (funcname, mesh->faces[nf]); } } } else { noff = 2 * ((dim[1]-1) * (dim[2]-1) + (dim[0]-1) * (dim[2]-1)); for (n = 0; n < npts; n++) { nn = 3 * n; if ((pts[nn+2] == 1 || pts[nn+2] == dim[2]) && pts[nn] > 0 && pts[nn] < dim[0] && pts[nn+1] > 0 && pts[nn+1] < dim[1]) { nf = noff + pts[nn]-1 + (pts[nn+1]-1) * (dim[0]-1); if (pts[nn+2] == dim[2]) nf += (dim[0]-1) * (dim[1]-1); faces[nfaces++] = copy_face (funcname, mesh->faces[nf]); } } } if (nfaces == 0) { free (faces); strcpy (reg->errmsg, "couldn't find any exterior faces"); return 0; } reg->nfaces = nfaces; reg->faces = faces; return 2; } /*-------------------------------------------------------------------*/ static int structured_zone (Tcl_Interp *interp, cgsize_t *dim) { char name[33]; char_66 d_name; int nints, nconns, nbocos, nholes, ii, nn, nr, nsets; cgsize_t i, j, k, n, ni, nj, nk, nf, ne, fn; cgsize_t npts, *pts, ndpts; cgsize_t range[6], d_range[6]; int transform[3]; CGNS_ENUMT(GridLocation_t) location; CGNS_ENUMT(GridConnectivityType_t) type; CGNS_ENUMT(PointSetType_t) ptype, d_ptype; CGNS_ENUMT(ZoneType_t) d_ztype; CGNS_ENUMT(DataType_t) datatype; CGNS_ENUMT(BCType_t) bctype; Face *f; Zone *z = &zones[cgnszone-1]; static char *funcname = "structured_zone"; zone_message ("finding exterior faces", NULL); if (cg_n1to1 (cgnsfn, cgnsbase, cgnszone, &nints) || cg_nconns (cgnsfn, cgnsbase, cgnszone, &nconns) || cg_nholes (cgnsfn, cgnsbase, cgnszone, &nholes) || cg_nbocos (cgnsfn, cgnsbase, cgnszone, &nbocos)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } z->nregs = nints + nconns + nholes + nbocos + 1; #ifndef NO_MESH_BOUNDARIES z->nregs += (2 * CellDim); #endif z->regs = (Regn *) MALLOC (funcname, z->nregs * sizeof(Regn)); ni = dim[0] - 1; nj = dim[1] - 1; nk = dim[2] - 1; nr = 1; /* mesh boundaries */ strcpy (z->regs[0].name, ""); z->regs[0].type = REG_MESH; for (n = 0; n < CellDim; n++) { z->regs[0].data[n] = dim[n]; range[n] = 1; range[n+CellDim] = dim[n]; } if (CellDim == 2) { z->regs[0].dim = 2; z->regs[0].nfaces = ni * nj; z->regs[0].faces = (Face **) MALLOC (funcname, (size_t)z->regs[0].nfaces * sizeof(Face *)); fn = 0; k = 0; for (j = 0; j < nj; j++) { for (i = 0; i < ni; i++) { f = z->regs[0].faces[fn++] = new_face (funcname, 4); f->nodes[0] = NODE_INDEX (i, j, k); f->nodes[1] = NODE_INDEX (i, j+1, k); f->nodes[2] = NODE_INDEX (i+1, j+1, k); f->nodes[3] = NODE_INDEX (i+1, j, k); } } #ifndef NO_CUTTING_PLANE nf = z->regs[0].nfaces; z->regs[0].elemtype = CGNS_ENUMV(QUAD_4); z->regs[0].nelems = nf; z->regs[0].elems = (cgsize_t *) MALLOC (funcname, (size_t)(4 * nf) * sizeof(cgsize_t)); for (n = 0, j = 0; j < nf; j++) { f = z->regs[0].faces[j]; for (i = 0; i < 4; i++) z->regs[0].elems[n++] = f->nodes[i]; } #endif #ifndef NO_MESH_BOUNDARIES strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 1; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 4; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[2] = 1; z->regs[nr].nedges = nj; z->regs[nr].edges = (Edge *) MALLOC (funcname, (size_t)nj * sizeof(Edge)); for (i = 0, j = 0; j < nj; j++) { z->regs[nr].edges[j].nodes[0] = NODE_INDEX(i, j, k); z->regs[nr].edges[j].nodes[1] = NODE_INDEX(i, j+1, k); } nr++; strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 1; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 4; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[0] = dim[0]; z->regs[nr].nedges = nj; z->regs[nr].edges = (Edge *) MALLOC (funcname, (size_t)nj * sizeof(Edge)); for (i = ni, j = 0; j < nj; j++) { z->regs[nr].edges[j].nodes[0] = NODE_INDEX(i, j, k); z->regs[nr].edges[j].nodes[1] = NODE_INDEX(i, j+1, k); } nr++; strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 1; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 4; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[3] = 1; z->regs[nr].nedges = ni; z->regs[nr].edges = (Edge *) MALLOC (funcname, (size_t)ni * sizeof(Edge)); for (j = 0, i = 0; i < ni; i++) { z->regs[nr].edges[i].nodes[0] = NODE_INDEX(i, j, k); z->regs[nr].edges[i].nodes[1] = NODE_INDEX(i+1, j, k); } nr++; strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 1; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 4; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[1] = dim[1]; z->regs[nr].nedges = ni; z->regs[nr].edges = (Edge *) MALLOC (funcname, (size_t)ni * sizeof(Edge)); for (j = nj, i = 0; i < ni; i++) { z->regs[nr].edges[i].nodes[0] = NODE_INDEX(i, j, k); z->regs[nr].edges[i].nodes[1] = NODE_INDEX(i+1, j, k); } nr++; #endif } else { z->regs[0].dim = 3; #ifndef NO_CUTTING_PLANE z->regs[0].elemtype = CGNS_ENUMV(HEXA_8); z->regs[0].nelems = ni * nj * nk; z->regs[0].elems = pts = (cgsize_t *) MALLOC (funcname, (size_t)(8 * z->regs[0].nelems) * sizeof(cgsize_t)); for (n = 0, k = 0; k < nk; k++) { for (j = 0; j < nj; j++) { for (i = 0; i < ni; i++) { pts[n++] = NODE_INDEX (i, j, k); pts[n++] = NODE_INDEX (i+1, j, k); pts[n++] = NODE_INDEX (i+1, j+1, k); pts[n++] = NODE_INDEX (i, j+1, k); pts[n++] = NODE_INDEX (i, j, k+1); pts[n++] = NODE_INDEX (i+1, j, k+1); pts[n++] = NODE_INDEX (i+1, j+1, k+1); pts[n++] = NODE_INDEX (i, j+1, k+1); } } } #endif z->regs[0].nfaces = 2 * (nj * nk + ni * nk + ni * nj); z->regs[0].faces = (Face **) MALLOC (funcname, (size_t)z->regs[0].nfaces * sizeof(Face *)); fn = 0; for (i = 0, k = 0; k < nk; k++) { for (j = 0; j < nj; j++) { f = z->regs[0].faces[fn++] = new_face (funcname, 4); f->nodes[0] = NODE_INDEX (i, j, k); f->nodes[1] = NODE_INDEX (i, j, k+1); f->nodes[2] = NODE_INDEX (i, j+1, k+1); f->nodes[3] = NODE_INDEX (i, j+1, k); } } for (i = ni, k = 0; k < nk; k++) { for (j = 0; j < nj; j++) { f = z->regs[0].faces[fn++] = new_face (funcname, 4); f->nodes[0] = NODE_INDEX (i, j, k); f->nodes[1] = NODE_INDEX (i, j+1, k); f->nodes[2] = NODE_INDEX (i, j+1, k+1); f->nodes[3] = NODE_INDEX (i, j, k+1); } } for (j = 0, k = 0; k < nk; k++) { for (i = 0; i < ni; i++) { f = z->regs[0].faces[fn++] = new_face (funcname, 4); f->nodes[0] = NODE_INDEX (i, j, k); f->nodes[1] = NODE_INDEX (i+1, j, k); f->nodes[2] = NODE_INDEX (i+1, j, k+1); f->nodes[3] = NODE_INDEX (i, j, k+1); } } for (j = nj, k = 0; k < nk; k++) { for (i = 0; i < ni; i++) { f = z->regs[0].faces[fn++] = new_face (funcname, 4); f->nodes[0] = NODE_INDEX (i, j, k); f->nodes[1] = NODE_INDEX (i, j, k+1); f->nodes[2] = NODE_INDEX (i+1, j, k+1); f->nodes[3] = NODE_INDEX (i+1, j, k); } } for (k = 0, j = 0; j < nj; j++) { for (i = 0; i < ni; i++) { f = z->regs[0].faces[fn++] = new_face (funcname, 4); f->nodes[0] = NODE_INDEX (i, j, k); f->nodes[1] = NODE_INDEX (i, j+1, k); f->nodes[2] = NODE_INDEX (i+1, j+1, k); f->nodes[3] = NODE_INDEX (i+1, j, k); } } for (k = nk, j = 0; j < nj; j++) { for (i = 0; i < ni; i++) { f = z->regs[0].faces[fn++] = new_face (funcname, 4); f->nodes[0] = NODE_INDEX (i, j, k); f->nodes[1] = NODE_INDEX (i+1, j, k); f->nodes[2] = NODE_INDEX (i+1, j+1, k); f->nodes[3] = NODE_INDEX (i, j+1, k); } } #ifndef NO_MESH_BOUNDARIES fn = 0; nf = nj * nk; strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 2; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 6; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[3] = 1; z->regs[nr].nfaces = nf; z->regs[nr].faces = (Face **) MALLOC (funcname, (size_t)nf * sizeof(Face *)); for (n = 0; n < nf; n++) z->regs[nr].faces[n] = copy_face (funcname, z->regs->faces[fn++]); nr++; strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 2; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 6; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[0] = dim[0]; z->regs[nr].nfaces = nf; z->regs[nr].faces = (Face **) MALLOC (funcname, (size_t)nf * sizeof(Face *)); for (n = 0; n < nf; n++) z->regs[nr].faces[n] = copy_face (funcname, z->regs->faces[fn++]); nr++; nf = ni * nk; strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 2; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 6; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[4] = 1; z->regs[nr].nfaces = nf; z->regs[nr].faces = (Face **) MALLOC (funcname, (size_t)nf * sizeof(Face *)); for (n = 0; n < nf; n++) z->regs[nr].faces[n] = copy_face (funcname, z->regs->faces[fn++]); nr++; strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 2; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 6; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[1] = dim[1]; z->regs[nr].nfaces = nf; z->regs[nr].faces = (Face **) MALLOC (funcname, (size_t)nf * sizeof(Face *)); for (n = 0; n < nf; n++) z->regs[nr].faces[n] = copy_face (funcname, z->regs->faces[fn++]); nr++; nf = ni * nj; strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 2; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 6; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[5] = 1; z->regs[nr].nfaces = nf; z->regs[nr].faces = (Face **) MALLOC (funcname, (size_t)nf * sizeof(Face *)); for (n = 0; n < nf; n++) z->regs[nr].faces[n] = copy_face (funcname, z->regs->faces[fn++]); nr++; strcpy (z->regs[nr].name, ""); z->regs[nr].dim = 2; z->regs[nr].type = REG_BNDS; for (nn = 0; nn < 6; nn++) z->regs[nr].data[nn] = range[nn]; z->regs[nr].data[2] = dim[2]; z->regs[nr].nfaces = nf; z->regs[nr].faces = (Face **) MALLOC (funcname, (size_t)nf * sizeof(Face *)); for (n = 0; n < nf; n++) z->regs[nr].faces[n] = copy_face (funcname, z->regs->faces[fn++]); nr++; #endif } /* 1 to 1 interfaces */ for (nn = 1; nn <= nints; nn++) { if (cg_1to1_read (cgnsfn, cgnsbase, cgnszone, nn, name, d_name, range, d_range, transform)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } strcpy (z->regs[nr].name, name); z->regs[nr].type = REG_1TO1; z->regs[nr].data[0] = 2 * CellDim; for (ii = 0; ii < 2*CellDim; ii++) z->regs[nr].data[ii+1] = range[ii]; strcpy (z->regs[nr].d_name, d_name); k = structured_range (&z->regs[nr], dim, range, CGNS_ENUMV(Vertex)); z->regs[nr].dim = k; nr++; } /* general connectivities */ for (nn = 1; nn <= nconns; nn++) { if (cg_conn_info (cgnsfn, cgnsbase, cgnszone, nn, name, &location, &type, &ptype, &npts, d_name, &d_ztype, &d_ptype, &datatype, &ndpts)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } pts = (cgsize_t *) MALLOC (funcname, (size_t)(3 * npts) * sizeof(cgsize_t)); if (cg_conn_read_short (cgnsfn, cgnsbase, cgnszone, nn, pts)) { free (pts); Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } strcpy (z->regs[nr].name, name); z->regs[nr].type = REG_CONN; z->regs[nr].data[0] = type; z->regs[nr].data[1] = location; z->regs[nr].data[2] = ptype; z->regs[nr].data[3] = npts; if (ptype == CGNS_ENUMV(PointRange)) { z->regs[nr].data[3] = 2 * CellDim; for (ii = 0; ii < 2*CellDim; ii++) z->regs[nr].data[ii+4] = pts[ii]; } strcpy (z->regs[nr].d_name, d_name); if (type == CGNS_ENUMV(Abutting1to1) || type == CGNS_ENUMV(Abutting)) { if (ptype == CGNS_ENUMV(PointRange)) k = structured_range (&z->regs[nr], dim, pts, location); else if (ptype == CGNS_ENUMV(PointList)) k = structured_list (z->regs, &z->regs[nr], dim, npts, pts, location); else { k = 0; strcpy (z->regs[nr].errmsg, "invalid point set type"); } } else if (type == CGNS_ENUMV(Overset)) { k = 0; strcpy (z->regs[nr].errmsg, "Overset connectivity not implemented"); } else { k = 0; strcpy (z->regs[nr].errmsg, "invalid connectivity type"); } z->regs[nr].dim = k; free (pts); nr++; } /* holes */ for (nn = 1; nn <= nholes; nn++) { if (cg_hole_info (cgnsfn, cgnsbase, cgnszone, nn, name, &location, &ptype, &nsets, &npts)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } pts = (cgsize_t *) MALLOC (funcname, (size_t)(3 * npts * nsets) * sizeof(cgsize_t)); if (cg_hole_read (cgnsfn, cgnsbase, cgnszone, nn, pts)) { free (pts); Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } strcpy (z->regs[nr].name, name); z->regs[nr].type = REG_HOLE; z->regs[nr].data[0] = nsets; z->regs[nr].data[1] = location; z->regs[nr].data[2] = ptype; z->regs[nr].data[3] = npts; if (ptype == CGNS_ENUMV(PointRange)) { z->regs[nr].data[3] = 2 * CellDim; for (ii = 0; ii < 2*CellDim; ii++) z->regs[nr].data[ii+4] = pts[ii]; z->regs[nr].dim = structured_range (&z->regs[nr], dim, pts, location); if (z->regs[nr].dim && nsets > 1) { Edge *edges = z->regs[nr].edges; Face **faces = z->regs[nr].faces; ne = z->regs[nr].nedges; nf = z->regs[nr].nfaces; for (ii = 1; ii < nsets; ii++) { z->regs[nr].nedges = z->regs[nr].nfaces = 0; k = structured_range (&z->regs[nr], dim, &pts[ii*2*CellDim], location); if (k && z->regs[nr].nedges) { edges = (Edge *) REALLOC (funcname, (ne + z->regs[nr].nedges) * sizeof(Edge), edges); for (i = 0; i < z->regs[nr].nedges; i++) { edges[ne].nodes[0] = z->regs[nr].edges[i].nodes[0]; edges[ne].nodes[1] = z->regs[nr].edges[i].nodes[1]; ne++; } free(z->regs[nr].edges); } if (k && z->regs[nr].nfaces) { faces = (Face **) REALLOC (funcname, (nf + z->regs[nr].nfaces) * sizeof(Face *), faces); for (i = 0; i < z->regs[nr].nfaces; i++) faces[nf++] = z->regs[nr].faces[i]; free(z->regs[nr].faces); } } z->regs[nr].nedges = ne; z->regs[nr].edges = edges; z->regs[nr].nfaces = nf; z->regs[nr].faces = faces; } } else if (ptype == CGNS_ENUMV(PointList)) { z->regs[nr].dim = structured_list (z->regs, &z->regs[nr], dim, npts, pts, location); } else { strcpy (z->regs[nr].errmsg, "invalid Point Set Type"); } free(pts); nr++; } /* boundary conditions */ for (nn = 1; nn <= nbocos; nn++) { if (cg_boco_info (cgnsfn, cgnsbase, cgnszone, nn, name, &bctype, &ptype, &npts, transform, &j, &datatype, &ii) || cg_boco_gridlocation_read(cgnsfn, cgnsbase, cgnszone, nn, &location)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } pts = (cgsize_t *) MALLOC (funcname, (size_t)(3 * npts) * sizeof(cgsize_t)); if (cg_boco_read (cgnsfn, cgnsbase, cgnszone, nn, pts, 0)) { free (pts); Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } strcpy (z->regs[nr].name, name); z->regs[nr].type = REG_BOCO; z->regs[nr].data[0] = bctype; z->regs[nr].data[1] = location; z->regs[nr].data[2] = ptype; z->regs[nr].data[3] = i; if (ptype == CGNS_ENUMV(PointRange) || ptype == CGNS_ENUMV(ElementRange)) { z->regs[nr].data[3] = 2 * CellDim; for (ii = 0; ii < 2*CellDim; ii++) z->regs[nr].data[ii+4] = pts[ii]; } if (ptype == CGNS_ENUMV(PointRange) || ptype == CGNS_ENUMV(ElementRange)) k = structured_range (&z->regs[nr], dim, pts, location); else if (ptype == CGNS_ENUMV(PointList) || ptype == CGNS_ENUMV(ElementList)) k = structured_list (z->regs, &z->regs[nr], dim, npts, pts, location); else { k = 0; strcpy (z->regs[nr].errmsg, "invalid point set type"); } z->regs[nr].dim = k; free (pts); nr++; } z->nregs = nr; #ifndef NO_CUTTING_PLANE for (nr = 0; nr < z->nregs; nr++) { if (z->regs[nr].dim == 2 && z->regs[nr].nfaces) { nf = z->regs[nr].nfaces; z->regs[nr].elemtype = CGNS_ENUMV(QUAD_4); z->regs[nr].nelems = nf; z->regs[nr].elems = (cgsize_t *) MALLOC (funcname, (size_t)(4 * nf) * sizeof(cgsize_t)); for (n = 0, j = 0; j < nf; j++, f++) { f = z->regs[nr].faces[j]; for (ii = 0; ii < 4; ii++) z->regs[nr].elems[n++] = f->nodes[ii]; } } } #endif return 0; } /*==================================================================== * unstructured grid regions *====================================================================*/ static int max_face_nodes = 0; static cgsize_t *sort_face_nodes = NULL; /*-------------------------------------------------------------------*/ static int compare_faces (void *v1, void *v2) { Face *f1 = (Face *)v1; Face *f2 = (Face *)v2; int i, k; cgsize_t id, nn, *n1, *n2; if (f1->nnodes != f2->nnodes) return (f1->nnodes - f2->nnodes); if (f1->nnodes > max_face_nodes) { max_face_nodes += 10; sort_face_nodes = (cgsize_t *) REALLOC ("compare_faces", 2 * max_face_nodes * sizeof(cgsize_t), sort_face_nodes); } n1 = sort_face_nodes; n2 = sort_face_nodes + max_face_nodes; for (i = 0; i < f1->nnodes; i++) { id = f1->nodes[i]; for (k = 0; k < i; k++) { if (n1[k] > id) { nn = n1[k]; n1[k] = id; id = nn; } } n1[i] = id; } for (i = 0; i < f2->nnodes; i++) { id = f2->nodes[i]; for (k = 0; k < i; k++) { if (n2[k] > id) { nn = n2[k]; n2[k] = id; id = nn; } } n2[i] = id; } for (i = 0; i < f1->nnodes; i++) { if (n1[i] != n2[i]) return (int)(n1[i] - n2[i]); } return 0; } /*-------------------------------------------------------------------*/ static size_t hash_face (void *v) { Face *f = (Face *)v; int n; size_t hash = 0; for (n = 0; n < f->nnodes; n++) hash += (size_t)f->nodes[n]; return hash; } /*-------------------------------------------------------------------*/ static size_t get_faces (void *vf, void *vr) { Face *f = (Face *)vf; Regn *r = (Regn *)vr; r->faces[r->nfaces] = f; (r->nfaces)++; return 1; } /*-------------------------------------------------------------------*/ static int compare_poly (void *v1, void *v2) { PolyFace *p1 = (PolyFace *)v1; PolyFace *p2 = (PolyFace *)v2; return compare_faces(p1->face, p2->face); } /*-------------------------------------------------------------------*/ static size_t hash_poly (void *v) { PolyFace *p = (PolyFace *)v; return hash_face(p->face); } /*-------------------------------------------------------------------*/ static cgsize_t nPolyFaces; static size_t poly_faces (void *vp, void *vl) { PolyFace *pf = (PolyFace *)vp; PolyFace **pl = (PolyFace **)vl; pl[nPolyFaces++] = pf; return 1; } /*-------------------------------------------------------------------*/ static int poly_sort (const void *v1, const void *v2) { const PolyFace **p1 = (const PolyFace **)v1; const PolyFace **p2 = (const PolyFace **)v2; return (int)((*p1)->num - (*p2)->num); } /*-------------------------------------------------------------------*/ static Face *find_face (Zone *z, cgsize_t fnum) { int nr; cgsize_t nf; for (nr = 0; nr < z->nregs; nr++) { if (z->regs[nr].type == REG_ELEM && z->regs[nr].dim == 2 && z->regs[nr].data[1] <= fnum && z->regs[nr].data[2] >= fnum) { nf = fnum - z->regs[nr].data[1]; return z->regs[nr].faces[nf]; } } return NULL; } /*-------------------------------------------------------------------*/ static int element_dimension (CGNS_ENUMT(ElementType_t) elemtype) { switch (elemtype) { case CGNS_ENUMV(NODE): return 0; case CGNS_ENUMV(BAR_2): case CGNS_ENUMV(BAR_3): case CGNS_ENUMV(BAR_4): case CGNS_ENUMV(BAR_5): return 1; case CGNS_ENUMV(TRI_3): case CGNS_ENUMV(TRI_6): case CGNS_ENUMV(TRI_9): case CGNS_ENUMV(TRI_10): case CGNS_ENUMV(TRI_12): case CGNS_ENUMV(TRI_15): case CGNS_ENUMV(QUAD_4): case CGNS_ENUMV(QUAD_8): case CGNS_ENUMV(QUAD_9): case CGNS_ENUMV(QUAD_12): case CGNS_ENUMV(QUAD_16): case CGNS_ENUMV(QUAD_P4_16): case CGNS_ENUMV(QUAD_25): case CGNS_ENUMV(NGON_n): return 2; case CGNS_ENUMV(TETRA_4): case CGNS_ENUMV(TETRA_10): case CGNS_ENUMV(TETRA_16): case CGNS_ENUMV(TETRA_20): case CGNS_ENUMV(TETRA_22): case CGNS_ENUMV(TETRA_34): case CGNS_ENUMV(TETRA_35): case CGNS_ENUMV(PYRA_5): case CGNS_ENUMV(PYRA_13): case CGNS_ENUMV(PYRA_14): case CGNS_ENUMV(PYRA_21): case CGNS_ENUMV(PYRA_29): case CGNS_ENUMV(PYRA_30): case CGNS_ENUMV(PYRA_P4_29): case CGNS_ENUMV(PYRA_50): case CGNS_ENUMV(PYRA_55): case CGNS_ENUMV(PENTA_6): case CGNS_ENUMV(PENTA_15): case CGNS_ENUMV(PENTA_18): case CGNS_ENUMV(PENTA_24): case CGNS_ENUMV(PENTA_38): case CGNS_ENUMV(PENTA_40): case CGNS_ENUMV(PENTA_33): case CGNS_ENUMV(PENTA_66): case CGNS_ENUMV(PENTA_75): case CGNS_ENUMV(HEXA_8): case CGNS_ENUMV(HEXA_20): case CGNS_ENUMV(HEXA_27): case CGNS_ENUMV(HEXA_32): case CGNS_ENUMV(HEXA_56): case CGNS_ENUMV(HEXA_64): case CGNS_ENUMV(HEXA_44): case CGNS_ENUMV(HEXA_98): case CGNS_ENUMV(HEXA_125): case CGNS_ENUMV(NFACE_n): return 3; default: break; } return -1; } /*-------------------------------------------------------------------*/ static void edge_elements (Regn *r, cgsize_t *conn) { int ip; cgsize_t istart, n, ne, nelems; istart = r->data[1]; nelems = r->data[2] - istart + 1; cg_npe ((CGNS_ENUMT(ElementType_t))r->data[0], &ip); r->nedges = nelems; r->edges = (Edge *) MALLOC ("edge_elements", nelems * sizeof(Edge)); for (n = 0, ne = 0; ne < nelems; ne++) { r->edges[ne].id = istart + ne; r->edges[ne].nodes[0] = conn[n] - 1; r->edges[ne].nodes[1] = conn[n+1] - 1; n += ip; } } /*-------------------------------------------------------------------*/ static void face_elements (Regn *r, cgsize_t *conn, cgsize_t *conn_offsets) { int i, ip; cgsize_t ne, nn, istart, nelems; cgsize_t rind0, rind1; CGNS_ENUMT(ElementType_t) elemtype, type; static char *funcname = "face_elements"; elemtype = type = (CGNS_ENUMT(ElementType_t))r->data[0]; istart = r->data[1]; nelems = r->data[2] - istart + 1; rind0 = r->data[3]; rind1 = nelems - r->data[4]; r->nfaces = nelems; r->faces = (Face **) MALLOC (funcname, nelems * sizeof(Face *)); for (nn = 0, ne = 0; ne < nelems; ne++) { if (elemtype == CGNS_ENUMV(MIXED)) type = (CGNS_ENUMT(ElementType_t))conn[nn++]; switch (type) { case CGNS_ENUMV(TRI_3): case CGNS_ENUMV(TRI_6): case CGNS_ENUMV(TRI_9): case CGNS_ENUMV(TRI_10): case CGNS_ENUMV(TRI_12): case CGNS_ENUMV(TRI_15): ip = 3; break; case CGNS_ENUMV(QUAD_4): case CGNS_ENUMV(QUAD_8): case CGNS_ENUMV(QUAD_9): case CGNS_ENUMV(QUAD_12): case CGNS_ENUMV(QUAD_16): case CGNS_ENUMV(QUAD_P4_16): case CGNS_ENUMV(QUAD_25): ip = 4; break; case CGNS_ENUMV(NGON_n): ip = (int)(conn_offsets[ne+1]-conn_offsets[ne]); break; default: if (type < CGNS_ENUMV(NODE) || type >= NofValidElementTypes) FATAL ("face_elements:unknown element type"); ip = 0; break; } if (ip) { r->faces[ne] = new_face (funcname, ip); r->faces[ne]->id = istart + ne; for (i = 0; i < ip; i++) r->faces[ne]->nodes[i] = conn[nn+i] - 1; if (ne < rind0 || ne >= rind1) r->faces[ne]->flags = 1; } else { r->faces[ne] = NULL; } if (type == CGNS_ENUMV(NGON_n)) nn += ip; else { cg_npe (type, &i); nn += i; } } } /*-------------------------------------------------------------------*/ static void exterior_faces (Zone *z, Regn *r, cgsize_t *conn, cgsize_t *conn_offsets) { int i, j, nf, ip, flag; cgsize_t ne, nn, istart, nelems; cgsize_t rind0, rind1; CGNS_ENUMT(ElementType_t) elemtype; HASH *facehash; Face *face, *pf; static char *funcname = "exterior_faces"; elemtype = (CGNS_ENUMT(ElementType_t))r->data[0]; istart = r->data[1]; nelems = r->data[2] - istart + 1; rind0 = r->data[3]; rind1 = nelems - r->data[4]; facehash = HashCreate (nelems > 1024 ? (size_t)nelems / 3 : 127, compare_faces, hash_face); if (NULL == facehash) FATAL ("exterior_faces:face hash table creation failed"); if (elemtype == CGNS_ENUMV(NFACE_n)) { for (ne = 0; ne < nelems; ne++) { flag = (ne < rind0 || ne >= rind1) ? 1 : 0; for (j = conn_offsets[ne]; j < conn_offsets[ne+1]; j++) { face = find_face (z, abs(conn[j])); if (face != NULL) { pf = (Face *) HashFind (facehash, face); if (NULL == pf) { pf = copy_face (funcname, face); pf->id = 0; pf->flags = flag; (void) HashAdd (facehash, pf); } else if (flag == pf->flags) { HashDelete (facehash, pf); free (pf); } else { pf->flags = 0; } } } } } else { CGNS_ENUMT(ElementType_t) type = elemtype; face = new_face(funcname, 4); for (nn = 0, ne = 0; ne < nelems; ne++) { flag = (ne < rind0 || ne >= rind1) ? 1 : 0; if (elemtype == CGNS_ENUMV(MIXED)) type = (CGNS_ENUMT(ElementType_t))conn[nn++]; switch (type) { case CGNS_ENUMV(TETRA_4): case CGNS_ENUMV(TETRA_10): case CGNS_ENUMV(TETRA_16): case CGNS_ENUMV(TETRA_20): case CGNS_ENUMV(TETRA_22): case CGNS_ENUMV(TETRA_34): case CGNS_ENUMV(TETRA_35): ip = 2; nf = 4; break; case CGNS_ENUMV(PYRA_5): case CGNS_ENUMV(PYRA_13): case CGNS_ENUMV(PYRA_14): case CGNS_ENUMV(PYRA_21): case CGNS_ENUMV(PYRA_29): case CGNS_ENUMV(PYRA_30): case CGNS_ENUMV(PYRA_P4_29): case CGNS_ENUMV(PYRA_50): case CGNS_ENUMV(PYRA_55): ip = 6; nf = 5; break; case CGNS_ENUMV(PENTA_6): case CGNS_ENUMV(PENTA_15): case CGNS_ENUMV(PENTA_18): case CGNS_ENUMV(PENTA_24): case CGNS_ENUMV(PENTA_38): case CGNS_ENUMV(PENTA_40): case CGNS_ENUMV(PENTA_33): case CGNS_ENUMV(PENTA_66): case CGNS_ENUMV(PENTA_75): ip = 11; nf = 5; break; case CGNS_ENUMV(HEXA_8): case CGNS_ENUMV(HEXA_20): case CGNS_ENUMV(HEXA_27): case CGNS_ENUMV(HEXA_32): case CGNS_ENUMV(HEXA_56): case CGNS_ENUMV(HEXA_64): case CGNS_ENUMV(HEXA_44): case CGNS_ENUMV(HEXA_98): case CGNS_ENUMV(HEXA_125): ip = 16; nf = 6; break; default: if (type < CGNS_ENUMV(NODE) || type >= NofValidElementTypes) FATAL ("exterior_faces:unknown element type"); ip = 0; nf = 0; break; } for (j = 0; j < nf; j++) { face->nnodes = facenodes[ip+j][0]; for (i = 0; i < face->nnodes; i++) face->nodes[i] = conn[nn + facenodes[ip+j][i+1]] - 1; pf = (Face *) HashFind (facehash, face); if (NULL == pf) { pf = copy_face (funcname, face); pf->id = 0; pf->flags = flag; (void) HashAdd (facehash, pf); } else if (flag == pf->flags) { HashDelete (facehash, pf); free (pf); } else { pf->flags = 0; } } cg_npe (type, &j); nn += j; } free(face); } r->nfaces = 0; ne = (cgsize_t) HashSize (facehash); if (ne) { r->faces = (Face **) MALLOC (funcname, ne * sizeof(Face *)); HashList (facehash, get_faces, r); } else { strcpy (r->errmsg, "couldn't find any exterior faces"); } HashDestroy (facehash, NULL); } /*-------------------------------------------------------------------*/ static void polyhedral_faces (Zone *z, Regn *r, cgsize_t *conn, cgsize_t *conn_offsets) { int j, nf, flag; cgsize_t ne, nn, istart, nelems, nfaces, id; cgsize_t rind0, rind1; HASH *facehash; Face *face; PolyFace poly, *pf, **polylist; static char *funcname = "polyhedral_faces"; istart = r->data[1]; nelems = r->data[2] - istart + 1; rind0 = r->data[3]; rind1 = nelems - r->data[4]; facehash = HashCreate (nelems > 1024 ? (size_t)nelems / 3 : 127, compare_poly, hash_poly); if (NULL == facehash) FATAL ("polyhedral_faces:face hash table creation failed"); nfaces = 0; for (nn = 0, ne = 0; ne < nelems; ne++) { flag = (ne < rind0 || ne >= rind1) ? 1 : 0; for (j = conn_offsets[ne]; j < conn_offsets[ne+1]; j++) { id = conn[j]; face = find_face (z, abs(id)); poly.face = face; pf = (PolyFace *) HashFind (facehash, &poly); if (NULL == pf) { pf = (PolyFace *)MALLOC(funcname, sizeof(PolyFace)); pf->face = face; pf->num = ++nfaces; pf->flags = flag; (void) HashAdd (facehash, pf); } else { if ((pf->flags & 1) != flag) pf->flags &= ~1; pf->flags |= 2; } conn[j] = id < 0 ? -(pf->num) : pf->num; } } nfaces = (cgsize_t) HashSize (facehash); polylist = (PolyFace **) MALLOC (funcname, nfaces * sizeof(PolyFace *)); nPolyFaces = 0; HashList (facehash, poly_faces, polylist); HashDestroy (facehash, NULL); qsort(polylist, nfaces, sizeof(PolyFace *), poly_sort); for (nn = 0, ne = 0; ne < nfaces; ne++) { if ((polylist[ne]->flags & 2) == 0) nn++; } r->nfaces = nn; r->faces = (Face **) MALLOC (funcname, nn * sizeof(Face *)); for (nn = 0, ne = 0; ne < nfaces; ne++) { if ((polylist[ne]->flags & 2) == 0) { r->faces[nn] = copy_face(funcname, polylist[ne]->face); r->faces[nn]->id = 0; r->faces[nn]->flags = (polylist[ne]->flags & 1); nn++; } } r->npoly = nfaces; r->poly = (Face **) MALLOC (funcname, nfaces * sizeof(Face *)); for (nn = 0; nn < nfaces; nn++) { face = polylist[nn]->face; face->flags |= (polylist[nn]->flags & 2); r->poly[nn] = face; free(polylist[nn]); } free(polylist); r->elemtype = CGNS_ENUMV(NFACE_n); r->nelems = nelems; r->elems = conn; r->elem_offsets = conn_offsets; } /*-------------------------------------------------------------------*/ static int sort_elemsets(const void *v1, const void *v2) { return (((Regn *)v2)->dim - ((Regn *)v1)->dim); } /*-------------------------------------------------------------------*/ static cgsize_t unstructured_region (int nregs, Regn *regs, Regn *r, CGNS_ENUMT(PointSetType_t) ptype, cgsize_t nlist, cgsize_t *list) { int nr, nn; cgsize_t nf, nfaces, maxfaces; Face **faces, *f; static char *funcname = "unstructured_region"; if (ptype == CGNS_ENUMV(PointList) || ptype == CGNS_ENUMV(ElementList)) { for (nf = 1; nf < nlist; nf++) { if (list[nf] < list[nf-1]) { qsort (list, (size_t)nlist, sizeof(cgsize_t), compare_ints); break; } } maxfaces = nlist; } else if (ptype == CGNS_ENUMV(PointRange) || ptype == CGNS_ENUMV(ElementRange)) { if (list[0] > list[1]) { nf = list[0]; list[0] = list[1]; list[1] = nf; } maxfaces = list[1] - list[0] + 1; } else { strcpy (r->errmsg, "invalid point set type"); maxfaces = 0; } if (maxfaces < 1) return 0; faces = (Face **)MALLOC(funcname, (size_t)maxfaces * sizeof(Face *)); nfaces = 0; for (nr = 0; nr < nregs; nr++) { if (!regs[nr].nfaces) continue; for (nf = 0; nf < regs[nr].nfaces; nf++) { f = regs[nr].faces[nf]; switch (ptype) { case CGNS_ENUMV(PointList): if (f->id) continue; for (nn = 0; nn < f->nnodes; nn++) { if (!find_int (f->nodes[nn]+1, nlist, list)) break; } if (nn == f->nnodes) break; continue; case CGNS_ENUMV(PointRange): if (f->id) continue; for (nn = 0; nn < f->nnodes; nn++) { if (f->nodes[nn]+1 < list[0] || f->nodes[nn]+1 > list[1]) break; } if (nn == f->nnodes) break; continue; case CGNS_ENUMV(ElementList): if (f->id && find_int (f->id, nlist, list)) break; continue; case CGNS_ENUMV(ElementRange): if (f->id >= list[0] && f->id <= list[1]) break; continue; default: continue; } if (nfaces == maxfaces) { maxfaces += 100; faces = (Face **) REALLOC (funcname, (size_t)maxfaces * sizeof(Face *), faces); } faces[nfaces++] = f; } } if (nfaces) { r->nfaces = nfaces; r->faces = (Face **)MALLOC(funcname, (size_t)nfaces * sizeof(Face *)); for (nf = 0; nf < nfaces; nf++) r->faces[nf] = copy_face(funcname, faces[nf]); } else strcpy (r->errmsg, "couldn't find any exterior faces"); free (faces); return nfaces; } /*-------------------------------------------------------------------*/ static int unstructured_zone (Tcl_Interp *interp) { int i, ns, nb, ip, nr, haspoly, nsets; int nsect, nints, nconns, nholes, nbocos, nrmlindex[3]; int transform[3], rind[2]; cgsize_t is, ie, np, n, ne, nf; cgsize_t nelem, elemsize, *conn, *conn_offsets; cgsize_t range[6], d_range[6]; CGNS_ENUMT(GridLocation_t) location; CGNS_ENUMT(GridConnectivityType_t) type; CGNS_ENUMT(PointSetType_t) ptype, d_ptype; CGNS_ENUMT(ZoneType_t) d_ztype; CGNS_ENUMT(DataType_t) datatype; CGNS_ENUMT(BCType_t) bctype; CGNS_ENUMT(ElementType_t) elemtype; char name[33]; char_66 d_name; Zone *z = &zones[cgnszone-1]; static char *funcname = "unstructured_zone"; static char *dspmsg = "finding exterior faces for"; if (cg_nsections (cgnsfn, cgnsbase, cgnszone, &nsect) || cg_n1to1 (cgnsfn, cgnsbase, cgnszone, &nints) || cg_nconns (cgnsfn, cgnsbase, cgnszone, &nconns) || cg_nholes (cgnsfn, cgnsbase, cgnszone, &nholes) || cg_nbocos (cgnsfn, cgnsbase, cgnszone, &nbocos)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } z->nregs = nsect + nints + nconns + nholes + nbocos; z->regs = (Regn *) MALLOC (funcname, z->nregs * sizeof(Regn)); /* element sets */ haspoly = 0; for (nr = 0, ns = 1; ns <= nsect; ns++, nr++) { if (cg_section_read (cgnsfn, cgnsbase, cgnszone, ns, name, &elemtype, &is, &ie, &nb, &ip) || cg_ElementDataSize (cgnsfn, cgnsbase, cgnszone, ns, &elemsize)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } zone_message (dspmsg, name); strcpy (z->regs[nr].name, name); z->regs[nr].type = REG_ELEM; z->regs[nr].data[0] = elemtype; z->regs[nr].data[1] = is; z->regs[nr].data[2] = ie; if (cg_goto (cgnsfn, cgnsbase, "Zone_t", cgnszone, "Elements_t", ns, "end") || cg_rind_read (rind)) { rind[0] = rind[1] = 0; } z->regs[nr].data[3] = rind[0]; z->regs[nr].data[4] = rind[1]; if (elemtype < CGNS_ENUMV(BAR_2) || elemtype >= NofValidElementTypes) { strcpy (z->regs[nr].errmsg, "invalid element type"); continue; } /* do this after reading all the sections */ if (elemtype == CGNS_ENUMV(NFACE_n)) { z->regs[nr].dim = 3; haspoly++; continue; } nelem = ie - is + 1; conn = (cgsize_t *) MALLOC (funcname, (size_t)elemsize * sizeof(cgsize_t)); conn_offsets = NULL; if (elemtype == CGNS_ENUMV(MIXED) || elemtype == CGNS_ENUMV(NGON_n) ) { conn_offsets = (cgsize_t *) MALLOC (funcname, (size_t) (nelem+1)*sizeof(cgsize_t)); if (cg_poly_elements_read (cgnsfn, cgnsbase, cgnszone, ns, conn, conn_offsets, 0)) { free (conn); if (conn_offsets) { free(conn_offsets); } Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } } else { if (cg_elements_read (cgnsfn, cgnsbase, cgnszone, ns, conn, 0)) { free (conn); Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } } /* check element indices */ if (elemtype == CGNS_ENUMV(MIXED)) { int dim; CGNS_ENUMT(ElementType_t) type; z->regs[nr].dim = -1; for (n = 0, ne = 0; ne < nelem; ne++) { type = (CGNS_ENUMT(ElementType_t))conn[n++]; if (cg_npe (type, &ip) || ip <= 0) { strcpy(z->regs[nr].errmsg, "unhandled element type found in MIXED"); break; } for (i = 0; i < ip; i++) { if (conn[n] < 1 || conn[n] > z->nnodes) { strcpy(z->regs[nr].errmsg, "invalid element index"); break; } n++; } if (i < ip) break; dim = element_dimension(type); if (z->regs[nr].dim < dim) z->regs[nr].dim = dim; } } else if (elemtype == CGNS_ENUMV(NGON_n)) { z->regs[nr].dim = 2; for (ne = 0; ne < nelem; ne++) { ip = (int) conn_offsets[ne+1]; for (n = conn_offsets[ne]; n < conn_offsets[ne+1]; n++) { if (conn[n] < 1 || conn[n] > z->nnodes) { strcpy(z->regs[nr].errmsg, "invalid element index"); break; } } if (n < ip) break; } } else { z->regs[nr].dim = element_dimension(elemtype); cg_npe (elemtype, &ip); for (n = 0, ne = 0; ne < nelem; ne++) { for (i = 0; i < ip; i++) { if (conn[n] < 1 || conn[n] > z->nnodes) { strcpy(z->regs[nr].errmsg, "invalid element index"); break; } n++; } if (i < ip) break; } } if (ne == nelem && z->regs[nr].dim > 0) { if (z->regs[nr].dim == 1) edge_elements(&z->regs[nr], conn); else if (z->regs[nr].dim == 2) face_elements (&z->regs[nr], conn, conn_offsets); else exterior_faces (z, &z->regs[nr], conn, conn_offsets); #ifndef NO_CUTTING_PLANE if (z->regs[nr].dim > 1) { z->regs[nr].elemtype = elemtype; z->regs[nr].nelems = nelem; z->regs[nr].elems = conn; z->regs[nr].elem_offsets = conn_offsets; /* fix element indexing */ cg_npe (elemtype, &ip); for (n = 0, ne = 0; ne < nelem; ne++) { if (elemtype == CGNS_ENUMT(MIXED)) { nb = (int)conn[n++]; cg_npe ((CGNS_ENUMT(ElementType_t))nb, &ip); } else if (elemtype == CGNS_ENUMT(NGON_n)) { ip = (int)(conn_offsets[ne+1] - conn_offsets[ne]); } for (i = 0; i < ip; i++) { (conn[n])--; n++; } } } else #endif free (conn); } } /* process NFACE_n sections */ if (haspoly) { for (ns = 0; ns < nsect; ns++) { if (z->regs[ns].data[0] != CGNS_ENUMV(NFACE_n)) continue; zone_message (dspmsg, z->regs[ns].name); nelem = z->regs[ns].data[2] - z->regs[ns].data[1] + 1; cg_ElementDataSize (cgnsfn, cgnsbase, cgnszone, ns+1, &elemsize); conn = (cgsize_t *) MALLOC (funcname, (size_t)elemsize * sizeof(cgsize_t)); conn_offsets = (cgsize_t *) MALLOC (funcname, (size_t) (nelem+1)*sizeof(cgsize_t)); if (cg_poly_elements_read (cgnsfn, cgnsbase, cgnszone, ns+1, conn, conn_offsets, 0)) { free (conn); free(conn_offsets); Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } /* check element indices */ for (n = 0, ne = 0; ne < nelem; ne++) { ip = (int) conn_offsets[ne+1]; for (n = conn_offsets[ne]; n < conn_offsets[ne+1]; n++) { if (NULL == find_face(z, abs(conn[n]))) { strcpy(z->regs[nr].errmsg, "invalid face index"); break; } } if (n < ip) break; } if (ne == nelem) { #ifndef NO_CUTTING_PLANE polyhedral_faces (z, &z->regs[ns], conn, conn_offsets); #else exterior_faces (z, &z->regs[ns], conn, conn_offsets); free (conn); #endif } } } qsort(z->regs, nr, sizeof(Regn), sort_elemsets); /* 1to1 connectivities */ for (ns = 1; ns <= nints; ns++) { if (cg_1to1_read (cgnsfn, cgnsbase, cgnszone, ns, name, d_name, range, d_range, transform)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } zone_message (dspmsg, name); strcpy (z->regs[nr].name, name); z->regs[nr].type = REG_1TO1; z->regs[nr].data[0] = 2; z->regs[nr].data[1] = range[0]; z->regs[nr].data[2] = range[1]; strcpy (z->regs[nr].d_name, d_name); if (unstructured_region (nsect, z->regs, &z->regs[nr], CGNS_ENUMV(PointRange), 2, range)) z->regs[nr].dim = 2; nr++; } /* general connectivities */ for (ns = 1; ns <= nconns; ns++) { if (cg_conn_info (cgnsfn, cgnsbase, cgnszone, ns, name, &location, &type, &ptype, &np, d_name, &d_ztype, &d_ptype, &datatype, &ie)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } zone_message (dspmsg, name); conn = (cgsize_t *) MALLOC (funcname, (size_t)np * sizeof(cgsize_t)); if (cg_conn_read_short (cgnsfn, cgnsbase, cgnszone, ns, conn)) { free (conn); Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } strcpy (z->regs[nr].name, name); z->regs[nr].type = REG_CONN; z->regs[nr].data[0] = type; z->regs[nr].data[1] = location; z->regs[nr].data[2] = ptype; z->regs[nr].data[3] = np; if (ptype == CGNS_ENUMT(PointRange)) { z->regs[nr].data[4] = conn[0]; z->regs[nr].data[5] = conn[1]; } strcpy (z->regs[nr].d_name, d_name); if (type != CGNS_ENUMV(Abutting) && type != CGNS_ENUMV(Abutting1to1)) { strcpy(z->regs[nr].errmsg, "can only handle Abutting or Abutting1to1 currently"); } else if (ptype != CGNS_ENUMV(PointList) && ptype != CGNS_ENUMV(PointRange)) { strcpy(z->regs[nr].errmsg, "point set type not PointList or PointRange"); } else if (location != CGNS_ENUMV(Vertex) && location != CGNS_ENUMV(CellCenter) && location != CGNS_ENUMV(FaceCenter)) { strcpy(z->regs[nr].errmsg, "location not Vertex, CellCenter or FaceCenter"); } else { if (location != CGNS_ENUMV(Vertex)) { ptype = (ptype == CGNS_ENUMV(PointRange) ? CGNS_ENUMV(ElementRange) : CGNS_ENUMV(ElementList)); } if (unstructured_region (nsect, z->regs, &z->regs[nr], ptype, np, conn)) z->regs[nr].dim = 2; } free (conn); nr++; } /* holes */ for (ns = 1; ns <= nholes; ns++) { if (cg_hole_info (cgnsfn, cgnsbase, cgnszone, ns, name, &location, &ptype, &nsets, &np)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } conn = (cgsize_t *) MALLOC (funcname, (size_t)(3 * np * nsets) * sizeof(cgsize_t)); if (cg_hole_read (cgnsfn, cgnsbase, cgnszone, ns, conn)) { free (conn); Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } strcpy (z->regs[nr].name, name); z->regs[nr].type = REG_HOLE; z->regs[nr].data[0] = nsets; z->regs[nr].data[1] = location; z->regs[nr].data[2] = ptype; z->regs[nr].data[3] = np; if (ptype == CGNS_ENUMV(PointRange)) { z->regs[nr].data[4] = conn[0]; z->regs[nr].data[5] = conn[1]; } else if (ptype != CGNS_ENUMV(PointList)) { strcpy(z->regs[nr].errmsg, "point set type not PointList or PointRange"); } else { if (location == CGNS_ENUMV(Vertex)) { d_ptype = ptype; } else { d_ptype = (ptype == CGNS_ENUMV(PointRange) ? CGNS_ENUMV(ElementRange) : CGNS_ENUMV(ElementList)); } if (unstructured_region (nsect, z->regs, &z->regs[nr], d_ptype, np, conn)) z->regs[nr].dim = 2; if (z->regs[nr].dim && nsets > 1 && ptype == CGNS_ENUMV(PointRange)) { Edge *edges = z->regs[nr].edges; Face **faces = z->regs[nr].faces; ne = z->regs[nr].nedges; nf = z->regs[nr].nfaces; for (ip = 1; ip < nsets; ip++) { z->regs[nr].nedges = z->regs[nr].nfaces = 0; is = unstructured_region (nsect, z->regs, &z->regs[nr], d_ptype, np, &conn[ip*2]); if (is && z->regs[nr].nedges) { edges = (Edge *) REALLOC (funcname, (ne + z->regs[nr].nedges) * sizeof(Edge), edges); for (i = 0; i < z->regs[nr].nedges; i++) { edges[ne].nodes[0] = z->regs[nr].edges[i].nodes[0]; edges[ne].nodes[1] = z->regs[nr].edges[i].nodes[1]; ne++; } free(z->regs[nr].edges); } if (is && z->regs[nr].nfaces) { faces = (Face **) REALLOC (funcname, (nf + z->regs[nr].nfaces) * sizeof(Face *), faces); for (i = 0; i < z->regs[nr].nfaces; i++) faces[nf++] = z->regs[nr].faces[i]; free(z->regs[nr].faces); } } z->regs[nr].nedges = ne; z->regs[nr].edges = edges; z->regs[nr].nfaces = nf; z->regs[nr].faces = faces; } } free (conn); nr++; } /* boundary conditions */ for (ns = 1; ns <= nbocos; ns++) { if (cg_boco_info (cgnsfn, cgnsbase, cgnszone, ns, name, &bctype, &ptype, &np, nrmlindex, &is, &datatype, &nb) || cg_boco_gridlocation_read (cgnsfn, cgnsbase, cgnszone, ns, &location)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } zone_message (dspmsg, name); conn = (cgsize_t *) MALLOC (funcname, (size_t)np * sizeof(cgsize_t)); if (cg_boco_read (cgnsfn, cgnsbase, cgnszone, ns, conn, 0)) { free (conn); Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return 1; } strcpy (z->regs[nr].name, name); z->regs[nr].type = REG_BOCO; z->regs[nr].data[0] = bctype; z->regs[nr].data[1] = location; z->regs[nr].data[2] = ptype; z->regs[nr].data[3] = np; if (ptype == CGNS_ENUMV(PointRange) || ptype == CGNS_ENUMV(ElementRange)) { z->regs[nr].data[4] = conn[0]; z->regs[nr].data[5] = conn[1]; } if ((ptype == CGNS_ENUMV(PointRange) || ptype == CGNS_ENUMV(PointList)) && (location == CGNS_ENUMV(FaceCenter) || location == CGNS_ENUMV(CellCenter))) { ptype = (ptype == CGNS_ENUMV(PointRange) ? CGNS_ENUMV(ElementRange) : CGNS_ENUMV(ElementList)); } if (unstructured_region (nsect, z->regs, &z->regs[nr], ptype, np, conn)) z->regs[nr].dim = 2; free (conn); nr++; } z->nregs = nr; return 0; } /*==================================================================== * find region edges *====================================================================*/ /*-------------------------------------------------------------------*/ static int compare_edges (void *v1, void *v2) { Edge *e1 = (Edge *)v1; Edge *e2 = (Edge *)v2; if (e1->nodes[0] < e1->nodes[1]) { if (e2->nodes[0] < e2->nodes[1]) return (int)(e1->nodes[0] - e2->nodes[0]); return (int)(e1->nodes[0] - e2->nodes[1]); } if (e2->nodes[0] < e2->nodes[1]) return (int)(e1->nodes[1] - e2->nodes[0]); return (int)(e1->nodes[1] - e2->nodes[1]); } /*-------------------------------------------------------------------*/ static size_t hash_edge (void *v) { Edge *e = (Edge *)v; return ((size_t)(e->nodes[0] + e->nodes[1])); } /*-------------------------------------------------------------------*/ static size_t get_edges (void *ve, void *vr) { Edge *e = (Edge *)ve; Regn *r = (Regn *)vr; r->edges[r->nedges].nodes[0] = e->nodes[0]; r->edges[r->nedges].nodes[1] = e->nodes[1]; (r->nedges)++; return 1; } /*-------------------------------------------------------------------*/ static void extract_edges (Regn *r) { int i, k; cgsize_t j, n; size_t ne; Face *f; Edge edge, *ep; HASH *edgehash; float dot; static char *funcname = "extract_edges"; if (!r->nfaces) return; edgehash = HashCreate ((size_t)r->nfaces, compare_edges, hash_edge); if (NULL == edgehash) FATAL ("edge hash table creation failed"); for (j = 0; j < r->nfaces; j++) { f = r->faces[j]; if (f->flags) continue; for (i = 0, k = f->nnodes-1; i < f->nnodes; k = i++) { if (f->nodes[i] == f->nodes[k]) continue; if (f->nodes[i] < f->nodes[k]) { edge.nodes[0] = f->nodes[i]; edge.nodes[1] = f->nodes[k]; } else { edge.nodes[0] = f->nodes[k]; edge.nodes[1] = f->nodes[i]; } ep = (Edge *) HashFind (edgehash, &edge); if (NULL == ep) { ep = (Edge *) MALLOC (funcname, sizeof(Edge)); ep->nodes[0] = edge.nodes[0]; ep->nodes[1] = edge.nodes[1]; ep->id = j; (void) HashAdd (edgehash, ep); } else { n = ep->id; dot = r->faces[n]->normal[0] * f->normal[0] + r->faces[n]->normal[1] * f->normal[1] + r->faces[n]->normal[2] * f->normal[2]; if (dot > EDGE_ANGLE) { HashDelete (edgehash, ep); free (ep); } } } } ne = HashSize (edgehash); if (ne) { r->nedges = 0; r->edges = (Edge *) MALLOC (funcname, ne * sizeof(Edge)); HashList (edgehash, get_edges, r); } HashDestroy (edgehash, NULL); } /*=================================================================== * region manipulation *===================================================================*/ /*-------------------------------------------------------------------*/ static float *compute_normal (Node n0, Node n1, Node n2, Node n3) { int j; double xn, yn, zn, sn; double d1[3], d2[3]; static float norm[3]; /* triangle */ if (NULL == n3) { for (j = 0; j < 3; j++) { d1[j] = n1[j] - n0[j]; d2[j] = n2[j] - n0[j]; } sn = 0.5; } /* quadrilateral */ else { for (j = 0; j < 3; j++) { d1[j] = n2[j] - n0[j]; d2[j] = n3[j] - n1[j]; } sn = 1.0; } xn = sn * (d1[1] * d2[2] - d2[1] * d1[2]); yn = sn * (d1[2] * d2[0] - d2[2] * d1[0]); zn = sn * (d1[0] * d2[1] - d2[0] * d1[1]); sn = sqrt (xn * xn + yn * yn + zn * zn); if (sn == 0.0) sn = 1.0; norm[0] = (float)(xn / sn); norm[1] = (float)(yn / sn); norm[2] = (float)(zn / sn); return norm; } /*-------------------------------------------------------------------*/ static float *face_normal (Zone *z, int nnodes, cgsize_t *nodes) { int i, n; float *n0, *n1, *n2, *n3; float *norm, sn; static float sum[3]; if (nnodes < 3) { for (i = 0; i < 3; i++) sum[i] = 0.0; return sum; } if (nnodes <= 4) { n0 = z->nodes[nodes[0]]; n1 = z->nodes[nodes[1]]; n2 = z->nodes[nodes[2]]; n3 = nnodes == 4 ? z->nodes[nodes[3]] : NULL; return compute_normal(n0, n1, n2, n3); } for (i = 0; i < 3; i++) sum[i] = 0.0; n0 = z->nodes[nodes[0]]; n1 = z->nodes[nodes[1]]; for (n = 2; n < nnodes; n++) { n2 = z->nodes[nodes[n]]; norm = compute_normal(n0, n1, n2, NULL); for (i = 0; i < 3; i++) sum[i] += norm[i]; n1 = n2; } sn = (float)sqrt(sum[0]*sum[0] + sum[1]*sum[1] + sum[2]*sum[2]); if (sn == 0.0) sn = 1.0; for (i = 0; i < 3; i++) sum[i] /= sn; return sum; } /*-------------------------------------------------------------------*/ static void region_normals (Zone *z, Regn *r) { int i, n; Face *f; float *norm; for (n = 0; n < r->nfaces; n++) { f = r->faces[n]; norm = face_normal(z, f->nnodes, f->nodes); for (i = 0; i < 3; i++) f->normal[i] = norm[i]; } } /*-------------------------------------------------------------------*/ static void bounding_box (Zone *z, Regn *r) { int i, j, n; if (r->nfaces) { Face *f = r->faces[0]; for (j = 0; j < 3; j++) r->bbox[j][0] = r->bbox[j][1] = z->nodes[f->nodes[0]][j]; for (n = 0; n < r->nfaces; n++) { f = r->faces[n]; for (i = 0; i < f->nnodes; i++) { for (j = 0; j < 3; j++) { if (r->bbox[j][0] > z->nodes[f->nodes[i]][j]) r->bbox[j][0] = z->nodes[f->nodes[i]][j]; if (r->bbox[j][1] < z->nodes[f->nodes[i]][j]) r->bbox[j][1] = z->nodes[f->nodes[i]][j]; } } } } else if (r->nedges) { Edge *e = r->edges; for (j = 0; j < 3; j++) r->bbox[j][0] = r->bbox[j][1] = z->nodes[e->nodes[0]][j]; for (n = 0; n < r->nedges; n++, e++) { for (i = 0; i < 2; i++) { for (j = 0; j < 3; j++) { if (r->bbox[j][0] > z->nodes[e->nodes[i]][j]) r->bbox[j][0] = z->nodes[e->nodes[i]][j]; if (r->bbox[j][1] < z->nodes[e->nodes[i]][j]) r->bbox[j][1] = z->nodes[e->nodes[i]][j]; } } } } else { for (j = 0; j < 3; j++) r->bbox[j][0] = r->bbox[j][1] = 0.0; } } /*-------------------------------------------------------------------*/ static void get_bounds (int all, float bbox[3][2]) { int nz, nr, n, first = 1; for (nz = 0; nz < nzones; nz++) { for (nr = 0; nr < zones[nz].nregs; nr++) { if (zones[nz].regs[nr].nfaces && (all || zones[nz].regs[nr].mode)) { if (first) { for (n = 0; n < 3; n++) { bbox[n][0] = zones[nz].regs[nr].bbox[n][0]; bbox[n][1] = zones[nz].regs[nr].bbox[n][1]; } first = 0; } else { for (n = 0; n < 3; n++) { if (bbox[n][0] > zones[nz].regs[nr].bbox[n][0]) bbox[n][0] = zones[nz].regs[nr].bbox[n][0]; if (bbox[n][1] < zones[nz].regs[nr].bbox[n][1]) bbox[n][1] = zones[nz].regs[nr].bbox[n][1]; } } } } } if (first) { for (n = 0; n < 3; n++) { bbox[n][0] = 0.0; bbox[n][1] = 1.0; } } } /*-------------------------------------------------------------------*/ static void draw_outlines (Zone *z, Regn *r) { glDisable (GL_LIGHTING); glShadeModel (GL_FLAT); glBegin (GL_LINES); if (r->nedges) { int ne; for (ne = 0; ne < r->nedges; ne++) { glVertex3fv (z->nodes[r->edges[ne].nodes[0]]); glVertex3fv (z->nodes[r->edges[ne].nodes[1]]); } } else { glVertex3f (r->bbox[0][0], r->bbox[1][0], r->bbox[2][0]); glVertex3f (r->bbox[0][1], r->bbox[1][0], r->bbox[2][0]); glVertex3f (r->bbox[0][1], r->bbox[1][0], r->bbox[2][0]); glVertex3f (r->bbox[0][1], r->bbox[1][1], r->bbox[2][0]); glVertex3f (r->bbox[0][1], r->bbox[1][1], r->bbox[2][0]); glVertex3f (r->bbox[0][0], r->bbox[1][1], r->bbox[2][0]); glVertex3f (r->bbox[0][0], r->bbox[1][1], r->bbox[2][0]); glVertex3f (r->bbox[0][0], r->bbox[1][0], r->bbox[2][0]); glVertex3f (r->bbox[0][0], r->bbox[1][0], r->bbox[2][1]); glVertex3f (r->bbox[0][1], r->bbox[1][0], r->bbox[2][1]); glVertex3f (r->bbox[0][1], r->bbox[1][0], r->bbox[2][1]); glVertex3f (r->bbox[0][1], r->bbox[1][1], r->bbox[2][1]); glVertex3f (r->bbox[0][1], r->bbox[1][1], r->bbox[2][1]); glVertex3f (r->bbox[0][0], r->bbox[1][1], r->bbox[2][1]); glVertex3f (r->bbox[0][0], r->bbox[1][1], r->bbox[2][1]); glVertex3f (r->bbox[0][0], r->bbox[1][0], r->bbox[2][1]); glVertex3f (r->bbox[0][0], r->bbox[1][0], r->bbox[2][0]); glVertex3f (r->bbox[0][0], r->bbox[1][0], r->bbox[2][1]); glVertex3f (r->bbox[0][1], r->bbox[1][0], r->bbox[2][0]); glVertex3f (r->bbox[0][1], r->bbox[1][0], r->bbox[2][1]); glVertex3f (r->bbox[0][1], r->bbox[1][1], r->bbox[2][0]); glVertex3f (r->bbox[0][1], r->bbox[1][1], r->bbox[2][1]); glVertex3f (r->bbox[0][0], r->bbox[1][1], r->bbox[2][0]); glVertex3f (r->bbox[0][0], r->bbox[1][1], r->bbox[2][1]); } glEnd (); } /*-------------------------------------------------------------------*/ static void draw_mesh (Zone *z, Regn *r) { int nf, nn; Face *f; glEnable (GL_LIGHTING); glShadeModel (GL_FLAT); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); for (nf = 0; nf < r->nfaces; nf++) { f = r->faces[nf]; if (f->flags || f->nnodes < 2) continue; if (f->nnodes == 2) glBegin (GL_LINES); else if (f->nnodes == 3) glBegin (GL_TRIANGLES); else if (f->nnodes == 4) glBegin (GL_QUADS); else glBegin (GL_POLYGON); glNormal3fv (f->normal); for (nn = 0; nn < f->nnodes; nn++) glVertex3fv (z->nodes[f->nodes[nn]]); glEnd (); } } /*-------------------------------------------------------------------*/ static void draw_shaded (Zone *z, Regn *r) { int nf, nn; Face *f; glEnable (GL_LIGHTING); glShadeModel (GL_FLAT); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); for (nf = 0; nf < r->nfaces; nf++) { f = r->faces[nf]; if (f->flags || f->nnodes < 3) continue; if (f->nnodes == 3) glBegin (GL_TRIANGLES); else if (f->nnodes == 4) glBegin (GL_QUADS); else glBegin (GL_POLYGON); glNormal3fv (f->normal); for (nn = 0; nn < f->nnodes; nn++) glVertex3fv (z->nodes[f->nodes[nn]]); glEnd (); } } /*=================================================================== * tcl interface *===================================================================*/ /*---------- CGNSopen ---------------------------------------------- * open a CGNS file - return bases *------------------------------------------------------------------*/ static int CGNSopen (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int fn, nb, idum; static char buff[33]; if (argc != 2) { Tcl_SetResult (interp, "usage: CGNSopen filename", TCL_STATIC); return TCL_ERROR; } Tcl_ResetResult (interp); if (cgnsfn) { cg_close (cgnsfn); cgnsfn = 0; } if (cg_open (argv[1], CG_MODE_READ, &fn)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } if (cg_nbases (fn, &nb)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); cg_close (fn); return TCL_ERROR; } if (nb < 1) { Tcl_SetResult (interp, "no bases defined", TCL_STATIC); cg_close (fn); return TCL_ERROR; } nbases = nb; for (nb = 1; nb <= nbases; nb++) { if (cg_base_read (fn, nb, buff, &idum, &idum)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); cg_close (fn); return TCL_ERROR; } Tcl_AppendElement (interp, buff); } cgnsfn = fn; return TCL_OK; } /*---------- CGNSclose --------------------------------------------- * close the open CGNS file *------------------------------------------------------------------*/ static int CGNSclose (ClientData data, Tcl_Interp *interp, int argc, char **argv) { if (cgnsfn && cg_close (cgnsfn)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } cgnsfn = 0; free_all (); Tcl_ResetResult (interp); return TCL_OK; } /*---------- CGNSbase ---------------------------------------------- * set the CGNS base - return zones *------------------------------------------------------------------*/ static int CGNSbase (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int base, nz; cgsize_t sizes[9]; char buff[33]; if (!cgnsfn) { Tcl_SetResult (interp, "CGNS file not open", TCL_STATIC); return TCL_ERROR; } if (argc != 2) { Tcl_SetResult (interp, "usage: CGNSbase basenum", TCL_STATIC); return TCL_ERROR; } base = atoi (argv[1]) + 1; if (base < 1 || base > nbases) { Tcl_SetResult (interp, "base number out of range", TCL_STATIC); return TCL_ERROR; } Tcl_ResetResult (interp); cgnsbase = base; if (cg_base_read (cgnsfn, cgnsbase, BaseName, &CellDim, &PhyDim) || cg_nzones (cgnsfn, cgnsbase, &nz)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } free_all (); if (CellDim < 2 || CellDim > 3 || PhyDim < 2 || PhyDim > 3) { Tcl_SetResult (interp, "CellDim and Phydim not 2 or 3", TCL_STATIC); return TCL_ERROR; } nzones = nz; zones = (Zone *) MALLOC ("CGNSbase", nzones * sizeof(Zone)); for (nz = 1; nz <= nzones; nz++) { if (cg_zone_read (cgnsfn, cgnsbase, nz, buff, sizes)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } strcpy (zones[nz-1].name, buff); Tcl_AppendElement (interp, buff); } return TCL_OK; } /*---------- CGNSzone ---------------------------------------------- * set the CGNS zone - return regions *------------------------------------------------------------------*/ static int CGNSzone (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int i, j, zone, nr, ncoords; cgsize_t sizes[9], rng[2][3], n, nnodes; int rind[6]; CGNS_ENUMT(DataType_t) datatype; CGNS_ENUMT(ZoneType_t) zonetype; Node *nodes; float *xyz; double rad, theta, phi; char buff[65], coordtype[4]; Zone *z; #ifdef NO_CUTTING_PLANE int *tag, nf, nn; #endif static char *funcname = "CGNSzone"; if (!cgnsfn) { Tcl_SetResult (interp, "CGNS file not open", TCL_STATIC); return TCL_ERROR; } if (argc != 2) { Tcl_SetResult (interp, "usage: CGNSzone zonenum", TCL_STATIC); return TCL_ERROR; } zone = atoi (argv[1]) + 1; if (zone < 1 || zone > nzones) { Tcl_SetResult (interp, "zone number out of range", TCL_STATIC); return TCL_ERROR; } if (cg_zone_read (cgnsfn, cgnsbase, zone, buff, sizes) || cg_zone_type (cgnsfn, cgnsbase, zone, &zonetype)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } if (zonetype == CGNS_ENUMV(Structured)) { for (i = 0; i < CellDim; i++) { if (sizes[i] < 2) { Tcl_SetResult (interp, "zone dimension < 2", TCL_STATIC); return TCL_ERROR; } } } else if (zonetype != CGNS_ENUMV(Unstructured)) { Tcl_SetResult (interp, "invalid zone type", TCL_STATIC); return TCL_ERROR; } cgnszone = zone; z = &zones[zone-1]; /* get number of coordinates */ if (cg_ncoords (cgnsfn, cgnsbase, cgnszone, &ncoords)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } if (ncoords < PhyDim) { Tcl_SetResult (interp, "less than PhyDim coordinates", TCL_STATIC); return TCL_ERROR; } /* check for rind */ if (cg_goto (cgnsfn, cgnsbase, "Zone_t", zone, "GridCoordinates_t", 1, "end")) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } if ((i = cg_rind_read (rind)) != CG_OK) { if (i != CG_NODE_NOT_FOUND) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } for (i = 0; i < 6; i++) rind[i] = 0; } /* get grid coordinate range */ if (zonetype == CGNS_ENUMV(Structured)) { for (i = 0; i < 3; i++) { rng[0][i] = 1; rng[1][i] = 1; } nnodes = 1; for (i = 0; i < CellDim; i++) { rng[0][i] = rind[2*i] + 1; rng[1][i] = rind[2*i] + sizes[i]; nnodes *= sizes[i]; } } else { nnodes = sizes[0] + rind[0] + rind[1]; rng[0][0] = 1; rng[1][0] = nnodes; } /* read the nodes */ strcpy (coordtype, " "); zone_message ("reading coordinates", NULL); xyz = (float *) MALLOC (funcname, (size_t)nnodes * sizeof(float)); nodes = (Node *) MALLOC (funcname, (size_t)nnodes * sizeof(Node)); for (i = 1; i <= ncoords; i++) { if (cg_coord_info (cgnsfn, cgnsbase, cgnszone, i, &datatype, buff) || cg_coord_read (cgnsfn, cgnsbase, cgnszone, buff, CGNS_ENUMV(RealSingle), rng[0], rng[1], xyz)) { free (xyz); free (nodes); Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } if (0 == strcmp (buff, "CoordinateX") || 0 == strcmp (buff, "CoordinateR")) j = 0; else if (0 == strcmp (buff, "CoordinateY") || 0 == strcmp (buff, "CoordinateTheta")) j = 1; else if (0 == strcmp (buff, "CoordinateZ") || 0 == strcmp (buff, "CoordinatePhi")) j = 2; else continue; if (coordtype[j] == ' ' || strchr ("XYZ", buff[10]) != NULL) coordtype[j] = buff[10]; for (n = 0; n < nnodes; n++) nodes[n][j] = xyz[n]; } free (xyz); if (0 == strncmp (coordtype, "RTZ", PhyDim)) { for (n = 0; n < nnodes; n++) { rad = nodes[n][0]; theta = nodes[n][1]; nodes[n][0] = (float)(rad * cos (theta)); nodes[n][1] = (float)(rad * sin (theta)); } } else if (0 == strcmp (coordtype, "RTP")) { for (n = 0; n < nnodes; n++) { rad = nodes[n][0]; theta = nodes[n][1]; phi = nodes[n][2]; nodes[n][0] = (float)(rad * sin (theta) * cos (phi)); nodes[n][1] = (float)(rad * sin (theta) * sin (phi)); nodes[n][2] = (float)(rad * cos (theta)); } } else if (strncmp (coordtype, "XYZ", PhyDim)) { free (nodes); Tcl_SetResult (interp, "unknown coordinate system", TCL_STATIC); return TCL_ERROR; } z->nnodes = nnodes; z->nodes = nodes; /* build regions */ if (zonetype == CGNS_ENUMV(Structured)) { if (structured_zone (interp, sizes)) return TCL_ERROR; } else { if (unstructured_zone (interp)) return TCL_ERROR; } #ifdef NO_CUTTING_PLANE tag = (int *) MALLOC (funcname, nnodes * sizeof(int)); for (n = 0; n < nnodes; n++) tag[n] = -1; /* tag nodes which are actually used */ for (nn = 0, nr = 0; nr < z->nregs; nr++) { for (nf = 0; nf < z->regs[nr].nfaces; nf++) { for (n = 0; n < z->regs[nr].faces[nf]->nnodes; n++) { i = z->regs[nr].faces[nf]->nodes[n]; if (tag[i] < 0) tag[i] = nn++; } } } nodes = (Node *) MALLOC (funcname, nn * sizeof(Node)); for (n = 0; n < nnodes; n++) { if (tag[n] >= 0) { j = tag[n]; for (i = 0; i < 3; i++) nodes[j][i] = z->nodes[n][i]; } } free(z->nodes); z->nodes = nodes; z->nnodes = nn; /* re-index region faces */ for (nr = 0; nr < z->nregs; nr++) { for (nf = 0; nf < z->regs[nr].nfaces; nf++) { for (n = 0; n < z->regs[nr].faces[nf]->nnodes; n++) { i = z->regs[nr].faces[nf]->nodes[n]; z->regs[nr].faces[nf]->nodes[n] = tag[i]; } } } free(tag); #endif /* find region bounding box, edges and normals */ zone_message ("finding normals and edges", NULL); for (nr = 0; nr < z->nregs; nr++) { if (z->regs[nr].nfaces) { bounding_box (z, &z->regs[nr]); region_normals (z, &z->regs[nr]); extract_edges (&z->regs[nr]); } } Tcl_ResetResult (interp); for (nr = 0; nr < z->nregs; nr++) { switch (z->regs[nr].type) { case REG_MESH: strcpy(buff, z->regs[nr].name); break; case REG_ELEM: sprintf(buff, "/%s", z->regs[nr].name); break; case REG_1TO1: sprintf(buff, "<1to1 Connections>/%s", z->regs[nr].name); break; case REG_CONN: sprintf(buff, "/%s", z->regs[nr].name); break; case REG_HOLE: sprintf(buff, "/%s", z->regs[nr].name); break; case REG_BOCO: sprintf(buff, "/%s", z->regs[nr].name); break; case REG_BNDS: sprintf(buff, "/%s", z->regs[nr].name); break; } Tcl_AppendElement (interp, buff); } return TCL_OK; } /*---------- CGNSsummary ------------------------------------------- * return info summary string *------------------------------------------------------------------*/ static int CGNSsummary (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n, nz; char *p, buff[128]; Regn *r; if (!cgnsfn) { Tcl_SetResult (interp, "CGNS file not open", TCL_STATIC); return TCL_ERROR; } if (argc < 1 || argc > 3) { Tcl_SetResult (interp, "usage: CGNSsummary [zone [reg]]", TCL_STATIC); return TCL_ERROR; } Tcl_ResetResult (interp); if (argc == 1) { sprintf (buff, "Physical Dim = %d, Cell Dim = %d", PhyDim, CellDim); Tcl_AppendResult (interp, buff, NULL); return TCL_OK; } nz = atoi (argv[1]); if (nz < 0 || nz >= nzones) { Tcl_SetResult (interp, "zone number out of range", TCL_STATIC); return TCL_ERROR; } if (argc == 2) { cgsize_t sizes[9]; CGNS_ENUMT(ZoneType_t) zonetype; if (cg_zone_read (cgnsfn, cgnsbase, nz+1, buff, sizes) || cg_zone_type (cgnsfn, cgnsbase, nz+1, &zonetype)) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } Tcl_AppendResult (interp, cg_ZoneTypeName(zonetype), " Zone : ", NULL); if (zonetype == CGNS_ENUMV(Unstructured)) { sprintf (buff, "%ld vertices, %ld elements", (long)sizes[0], (long)sizes[1]); Tcl_AppendResult (interp, buff, NULL); } else { sprintf (buff, "%ld", (long)sizes[0]); for (n = 1; n < CellDim; n++) { p = buff + strlen(buff); sprintf (p, " x %ld", (long)sizes[n]); } Tcl_AppendResult (interp, buff, " vertices", NULL); } return TCL_OK; } n = atoi (argv[2]); if (n < 0 || n >= zones[nz].nregs) { Tcl_SetResult (interp, "region number out of range", TCL_STATIC); return TCL_ERROR; } r = &zones[nz].regs[n]; switch (r->type) { case REG_MESH: if (CellDim == 2) { sprintf (buff, "%ld x %ld", (long)r->data[0], (long)r->data[1]); } else { sprintf (buff, "%ld x %ld x %ld", (long)r->data[0], (long)r->data[1], (long)r->data[2]); } Tcl_AppendResult (interp, "Structured Mesh : ", buff, " vertices", NULL); break; case REG_ELEM: sprintf (buff, "%ld", (long)(r->data[2] - r->data[1] + 1)); Tcl_AppendResult (interp, cg_ElementTypeName(r->data[0]), " Element Set : ", buff, " elements", NULL); break; case REG_1TO1: if (r->data[0] == 2) sprintf (buff, "%ld", (long)(r->data[2] - r->data[1] + 1)); else if (CellDim == 2) { sprintf (buff, "%ld x %ld", (long)(r->data[3] - r->data[1] + 1), (long)(r->data[4] - r->data[2] + 1)); } else { sprintf (buff, "%ld x %ld x %ld", (long)(r->data[4] - r->data[1] + 1), (long)(r->data[5] - r->data[2] + 1), (long)(r->data[6] - r->data[3] + 1)); } Tcl_AppendResult (interp, "1to1 Connection : PointRange ", buff, " -> ", r->d_name, NULL); break; case REG_CONN: if (r->data[2] == CGNS_ENUMV(PointList) || r->data[2] == CGNS_ENUMV(ElementList)) sprintf (buff, " %ld", (long)r->data[3]); else if (r->data[3] == 2) sprintf (buff, " %ld", (long)(r->data[5] - r->data[4] + 1)); else if (CellDim == 2) { sprintf (buff, " %ld x %ld", (long)(r->data[6] - r->data[4] + 1), (long)(r->data[7] - r->data[5] + 1)); } else { sprintf (buff, " %ld x %ld x %ld", (long)(r->data[7] - r->data[4] + 1), (long)(r->data[8] - r->data[5] + 1), (long)(r->data[9] - r->data[6] + 1)); } Tcl_AppendResult (interp, cg_GridConnectivityTypeName(r->data[0]), " Connection : ", cg_PointSetTypeName(r->data[2]), buff, " -> ", r->d_name, NULL); break; case REG_HOLE: if (r->data[2] == CGNS_ENUMV(PointList) || r->data[2] == CGNS_ENUMV(ElementList)) sprintf (buff, " %ld", (long)r->data[3]); else if (r->data[3] == 2) sprintf (buff, " %ld", (long)(r->data[5] - r->data[4] + 1)); else if (CellDim == 2) { sprintf (buff, " %ld x %ld", (long)(r->data[6] - r->data[4] + 1), (long)(r->data[7] - r->data[5] + 1)); } else { sprintf (buff, " %ld x %ld x %ld", (long)(r->data[7] - r->data[4] + 1), (long)(r->data[8] - r->data[5] + 1), (long)(r->data[9] - r->data[6] + 1)); } Tcl_AppendResult (interp, "Overset Hole : ", cg_PointSetTypeName(r->data[2]), buff, NULL); break; case REG_BOCO: if (r->data[2] == CGNS_ENUMV(PointList) || r->data[2] == CGNS_ENUMV(ElementList)) sprintf (buff, " %ld", (long)r->data[3]); else if (r->data[3] == 2) sprintf (buff, " %ld", (long)(r->data[5] - r->data[4] + 1)); else if (CellDim == 2) { sprintf (buff, " %ld x %ld", (long)(r->data[6] - r->data[4] + 1), (long)(r->data[7] - r->data[5] + 1)); } else { sprintf (buff, " %ld x %ld x %ld", (long)(r->data[7] - r->data[4] + 1), (long)(r->data[8] - r->data[5] + 1), (long)(r->data[9] - r->data[6] + 1)); } Tcl_AppendResult (interp, cg_BCTypeName(r->data[0]), " Boundary Condition : ", cg_PointSetTypeName(r->data[2]), buff, NULL); break; case REG_BNDS: if (CellDim == 2) { sprintf (buff, "%ld x %ld", (long)(r->data[2] - r->data[0] + 1), (long)(r->data[3] - r->data[1] + 1)); } else { sprintf (buff, "%ld x %ld x %ld", (long)(r->data[3] - r->data[0] + 1), (long)(r->data[4] - r->data[1] + 1), (long)(r->data[5] - r->data[2] + 1)); } Tcl_AppendResult (interp, "Mesh Boundary : ", buff, " vertices", NULL); break; } return TCL_OK; } /*---------- CGNSgetbase ------------------------------------------- * get base properties *------------------------------------------------------------------*/ static int CGNSgetbase (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char cd[16], pd[16], nz[16]; if (!cgnsfn) { Tcl_SetResult (interp, "CGNS file not open", TCL_STATIC); return TCL_ERROR; } if (argc != 1) { Tcl_SetResult (interp, "usage: CGNSgetbase", TCL_STATIC); return TCL_ERROR; } Tcl_ResetResult (interp); sprintf (pd, "%d", PhyDim); sprintf (cd, "%d", CellDim); sprintf (nz, "%d", nzones); Tcl_AppendResult (interp, "Base Name : ", BaseName, "\nPhysical Dim: ", pd, "\nCell Dim : ", cd, "\nNumber Zones: ", nz, NULL); return TCL_OK; } /*---------- CGNSgetzone ------------------------------------------- * get zone properties *------------------------------------------------------------------*/ static int CGNSgetzone (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n, ndim, zone, cnts[4]; cgsize_t sizes[9]; CGNS_ENUMT(ZoneType_t) zonetype; char *p, buff[65]; static char *cntname[] = { "Element Sections", "1to1 Connections", "General Connections", "Boundary Conditions" }; if (!cgnsfn) { Tcl_SetResult (interp, "CGNS file not open", TCL_STATIC); return TCL_ERROR; } if (argc != 2) { Tcl_SetResult (interp, "usage: CGNSgetzone zonenum", TCL_STATIC); return TCL_ERROR; } zone = atoi (argv[1]) + 1; if (zone < 1 || zone > nzones) { Tcl_SetResult (interp, "zone number out of range", TCL_STATIC); return TCL_ERROR; } if (cg_zone_read (cgnsfn, cgnsbase, zone, buff, sizes) || cg_zone_type (cgnsfn, cgnsbase, zone, &zonetype) || cg_nsections (cgnsfn, cgnsbase, zone, &cnts[0]) || cg_n1to1 (cgnsfn, cgnsbase, zone, &cnts[1]) || cg_nconns (cgnsfn, cgnsbase, zone, &cnts[2]) || cg_nbocos (cgnsfn, cgnsbase, zone, &cnts[3])) { Tcl_SetResult (interp, (char *)cg_get_error(), TCL_STATIC); return TCL_ERROR; } Tcl_ResetResult (interp); Tcl_AppendResult (interp, "Zone Name : ", buff, "\nType of Zone : ", cg_ZoneTypeName(zonetype), "\nVertex Dimensions : ", NULL); ndim = zonetype == CGNS_ENUMV(Unstructured) ? 1 : CellDim; sprintf (buff, "%ld", (long)sizes[0]); for (n = 1; n < ndim; n++) { p = buff + strlen(buff); sprintf (p, " x %ld", (long)sizes[n]); } Tcl_AppendResult (interp, buff, "\nCell Dimensions : ", NULL); sprintf (buff, "%ld", (long)sizes[ndim]); for (n = 1; n < ndim; n++) { p = buff + strlen(buff); sprintf (p, " x %ld", (long)sizes[n+CellDim]); } Tcl_AppendResult (interp, buff, NULL); for (n = 0; n < 4; n++) { sprintf (buff, "\n%-19s: %d", cntname[n], cnts[n]); Tcl_AppendResult (interp, buff, NULL); } return TCL_OK; } /*---------- CGNSgetregion ----------------------------------------- * get region properties *------------------------------------------------------------------*/ static int CGNSgetregion (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n; char buff[128]; Zone *z; Regn *r; if (!cgnsfn) { Tcl_SetResult (interp, "CGNS file not open", TCL_STATIC); return TCL_ERROR; } if (argc != 3) { Tcl_SetResult (interp, "usage: CGNSgetregion zone reg", TCL_STATIC); return TCL_ERROR; } n = atoi (argv[1]); if (n < 0 || n >= nzones) { Tcl_SetResult (interp, "zone number out of range", TCL_STATIC); return TCL_ERROR; } z = &zones[n]; n = atoi (argv[2]); if (n < 0 || n >= z->nregs) { Tcl_SetResult (interp, "region number out of range", TCL_STATIC); return TCL_ERROR; } r = &z->regs[n]; Tcl_ResetResult (interp); switch (r->type) { case REG_MESH: if (CellDim == 2) { sprintf (buff, "%ld x %ld", (long)r->data[0], (long)r->data[1]); } else { sprintf (buff, "%ld x %ld x %ld", (long)r->data[0], (long)r->data[1], (long)r->data[2]); } Tcl_AppendResult (interp, "Region Name : ", r->name, "\nType of Region : Structured Mesh", "\nMesh Dimensions: ", buff, NULL); break; case REG_ELEM: sprintf (buff, "%ld -> %ld", (long)r->data[1], (long)r->data[2]); Tcl_AppendResult (interp, "Region Name : ", r->name, "\nType of Region : Element Set", "\nElement Set Type: ", cg_ElementTypeName(r->data[0]), "\nElement Range : ", buff, NULL); if (r->data[3] || r->data[4]) { sprintf (buff, "%ld %ld", (long)r->data[3], (long)r->data[4]); Tcl_AppendResult (interp, "\nRind Elements : ", buff, NULL); } break; case REG_1TO1: Tcl_AppendResult (interp, "Region Name : ", r->name, "\nType of Region: 1to1 Connectivity", "\nPoint Set Type: PointRange", NULL); if (r->data[0] == 2) { sprintf (buff, "%ld -> %ld", (long)r->data[1], (long)r->data[2]); Tcl_AppendResult (interp, "\nIndex Range : ", buff, NULL); } else { sprintf (buff, "%ld -> %ld", (long)r->data[1], (long)r->data[1+CellDim]); Tcl_AppendResult (interp, "\nI Index Range : ", buff, NULL); sprintf (buff, "%ld -> %ld", (long)r->data[2], (long)r->data[2+CellDim]); Tcl_AppendResult (interp, "\nJ Index Range : ", buff, NULL); if (CellDim == 3) { sprintf (buff, "%ld -> %ld", (long)r->data[3], (long)r->data[6]); Tcl_AppendResult (interp, "\nK Index Range : ", buff, NULL); } } Tcl_AppendResult (interp, "\nDonor Zone : ", r->d_name, NULL); break; case REG_CONN: Tcl_AppendResult (interp, "Region Name : ", r->name, "\nType of Region : General Connectivity", "\nConnectivity Type: ", cg_GridConnectivityTypeName(r->data[0]), "\nGrid Location : ", cg_GridLocationName(r->data[1]), "\nPoint Set Type : ", cg_PointSetTypeName(r->data[2]), NULL); if (r->data[2] == CGNS_ENUMV(PointList) || r->data[2] == CGNS_ENUMV(ElementList)) { sprintf (buff, "%ld", (long)r->data[3]); Tcl_AppendResult (interp, "\nNumber of Points : ", buff, NULL); } else if (r->data[3] == 2) { sprintf (buff, "%ld -> %ld", (long)r->data[4], (long)r->data[5]); Tcl_AppendResult (interp, "\nIndex Range : ", buff, NULL); } else { sprintf (buff, "%ld -> %ld", (long)r->data[4], (long)r->data[4+CellDim]); Tcl_AppendResult (interp, "\nI Index Range : ", buff, NULL); sprintf (buff, "%ld -> %ld", (long)r->data[5], (long)r->data[5+CellDim]); Tcl_AppendResult (interp, "\nJ Index Range : ", buff, NULL); if (CellDim == 3) { sprintf (buff, "%ld -> %ld", (long)r->data[6], (long)r->data[9]); Tcl_AppendResult (interp, "\nK Index Range : ", buff, NULL); } } Tcl_AppendResult (interp, "\nDonor Zone : ", r->d_name, NULL); break; case REG_HOLE: sprintf(buff, "%ld", (long)r->data[0]); Tcl_AppendResult (interp, "Region Name : ", r->name, "\nType of Region : Overset Hole", "\nNumber Sets : ", buff, "\nGrid Location : ", cg_GridLocationName(r->data[1]), "\nPoint Set Type : ", cg_PointSetTypeName(r->data[2]), NULL); if (r->data[2] == CGNS_ENUMV(PointList) || r->data[2] == CGNS_ENUMV(ElementList)) { sprintf (buff, "%ld", (long)r->data[3]); Tcl_AppendResult (interp, "\nNumber of Points : ", buff, NULL); } else if (r->data[3] == 2) { sprintf (buff, "%ld -> %ld", (long)r->data[4], (long)r->data[5]); Tcl_AppendResult (interp, "\nIndex Range : ", buff, NULL); } else { sprintf (buff, "%ld -> %ld", (long)r->data[4], (long)r->data[4+CellDim]); Tcl_AppendResult (interp, "\nI Index Range : ", buff, NULL); sprintf (buff, "%ld -> %ld", (long)r->data[5], (long)r->data[5+CellDim]); Tcl_AppendResult (interp, "\nJ Index Range : ", buff, NULL); if (CellDim == 3) { sprintf (buff, "%ld -> %ld", (long)r->data[6], (long)r->data[9]); Tcl_AppendResult (interp, "\nK Index Range : ", buff, NULL); } } break; case REG_BOCO: Tcl_AppendResult (interp, "Region Name : ", r->name, "\nType of Region : Boundary Condition", "\nType of BC : ", cg_BCTypeName(r->data[0]), "\nGrid Location : ", cg_GridLocationName(r->data[1]), "\nPoint Set Type : ", cg_PointSetTypeName(r->data[2]), NULL); if (r->data[2] == CGNS_ENUMV(PointList) || r->data[2] == CGNS_ENUMV(ElementList)) { sprintf (buff, "%ld", (long)r->data[3]); Tcl_AppendResult (interp, "\nNumber of Points: ", buff, NULL); } else if (r->data[3] == 2) { sprintf (buff, "%ld -> %ld", (long)r->data[4], (long)r->data[5]); Tcl_AppendResult (interp, "\nIndex Range : ", buff, NULL); } else { sprintf (buff, "%ld -> %ld", (long)r->data[4], (long)r->data[4+CellDim]); Tcl_AppendResult (interp, "\nI Index Range : ", buff, NULL); sprintf (buff, "%ld -> %ld", (long)r->data[5], (long)r->data[5+CellDim]); Tcl_AppendResult (interp, "\nJ Index Range : ", buff, NULL); if (CellDim == 3) { sprintf (buff, "%ld -> %ld", (long)r->data[6], (long)r->data[9]); Tcl_AppendResult (interp, "\nK Index Range : ", buff, NULL); } } break; case REG_BNDS: strcpy (buff, r->name); Tcl_AppendResult (interp, "Region Name : ", r->name, "\nType of Region: Mesh Boundary", NULL); sprintf (buff, "%ld -> %ld", (long)r->data[0], (long)r->data[CellDim]); Tcl_AppendResult (interp, "\nI Index Range : ", buff, NULL); sprintf (buff, "%ld -> %ld", (long)r->data[1], (long)r->data[1+CellDim]); Tcl_AppendResult (interp, "\nJ Index Range : ", buff, NULL); if (CellDim == 3) { sprintf (buff, "%ld -> %ld", (long)r->data[2], (long)r->data[5]); Tcl_AppendResult (interp, "\nK Index Range : ", buff, NULL); } break; } return TCL_OK; } /*---------- CGNSregiondim ----------------------------------------- * return dimension of a region *------------------------------------------------------------------*/ static int CGNSregiondim (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n; char buff[16]; Zone *z; if (!cgnsfn) { Tcl_SetResult (interp, "CGNS file not open", TCL_STATIC); return TCL_ERROR; } if (argc != 3) { Tcl_SetResult (interp, "usage: CGNSregtype zone reg", TCL_STATIC); return TCL_ERROR; } n = atoi (argv[1]); if (n < 0 || n >= nzones) { Tcl_SetResult (interp, "zone number out of range", TCL_STATIC); return TCL_ERROR; } z = &zones[n]; n = atoi (argv[2]); if (n < 0 || n >= z->nregs) { Tcl_SetResult (interp, "region number out of range", TCL_STATIC); return TCL_ERROR; } Tcl_ResetResult (interp); if (!z->regs[n].dim) { if (*(z->regs[n].errmsg)) Tcl_SetResult (interp, z->regs[n].errmsg, TCL_STATIC); return TCL_ERROR; } sprintf (buff, "%d", z->regs[n].dim); Tcl_AppendResult (interp, buff, NULL); return TCL_OK; } /*---------- CGNSbounds -------------------------------------------- * get bounding box *------------------------------------------------------------------*/ static void transform_bounds (float m[16], float bb[3][2]) { int i, j; float x, y, z, bbox[3][2]; x = m[0] * bb[0][0] + m[4] * bb[1][0] + m[8] * bb[2][0] + m[12]; y = m[1] * bb[0][0] + m[5] * bb[1][0] + m[9] * bb[2][0] + m[13]; z = m[2] * bb[0][0] + m[6] * bb[1][0] + m[10] * bb[2][0] + m[14]; bbox[0][0] = bbox[0][1] = x; bbox[1][0] = bbox[1][1] = y; bbox[2][0] = bbox[2][1] = z; x = m[0] * bb[0][1] + m[4] * bb[1][0] + m[8] * bb[2][0] + m[12]; y = m[1] * bb[0][1] + m[5] * bb[1][0] + m[9] * bb[2][0] + m[13]; z = m[2] * bb[0][1] + m[6] * bb[1][0] + m[10] * bb[2][0] + m[14]; if (bbox[0][0] > x) bbox[0][0] = x; if (bbox[0][1] < x) bbox[0][1] = x; if (bbox[1][0] > y) bbox[1][0] = y; if (bbox[1][1] < y) bbox[1][1] = y; if (bbox[2][0] > z) bbox[2][0] = z; if (bbox[2][1] < z) bbox[2][1] = z; x = m[0] * bb[0][0] + m[4] * bb[1][1] + m[8] * bb[2][0] + m[12]; y = m[1] * bb[0][0] + m[5] * bb[1][1] + m[9] * bb[2][0] + m[13]; z = m[2] * bb[0][0] + m[6] * bb[1][1] + m[10] * bb[2][0] + m[14]; if (bbox[0][0] > x) bbox[0][0] = x; if (bbox[0][1] < x) bbox[0][1] = x; if (bbox[1][0] > y) bbox[1][0] = y; if (bbox[1][1] < y) bbox[1][1] = y; if (bbox[2][0] > z) bbox[2][0] = z; if (bbox[2][1] < z) bbox[2][1] = z; x = m[0] * bb[0][1] + m[4] * bb[1][1] + m[8] * bb[2][0] + m[12]; y = m[1] * bb[0][1] + m[5] * bb[1][1] + m[9] * bb[2][0] + m[13]; z = m[2] * bb[0][1] + m[6] * bb[1][1] + m[10] * bb[2][0] + m[14]; if (bbox[0][0] > x) bbox[0][0] = x; if (bbox[0][1] < x) bbox[0][1] = x; if (bbox[1][0] > y) bbox[1][0] = y; if (bbox[1][1] < y) bbox[1][1] = y; if (bbox[2][0] > z) bbox[2][0] = z; if (bbox[2][1] < z) bbox[2][1] = z; x = m[0] * bb[0][0] + m[4] * bb[1][0] + m[8] * bb[2][1] + m[12]; y = m[1] * bb[0][0] + m[5] * bb[1][0] + m[9] * bb[2][1] + m[13]; z = m[2] * bb[0][0] + m[6] * bb[1][0] + m[10] * bb[2][1] + m[14]; if (bbox[0][0] > x) bbox[0][0] = x; if (bbox[0][1] < x) bbox[0][1] = x; if (bbox[1][0] > y) bbox[1][0] = y; if (bbox[1][1] < y) bbox[1][1] = y; if (bbox[2][0] > z) bbox[2][0] = z; if (bbox[2][1] < z) bbox[2][1] = z; x = m[0] * bb[0][1] + m[4] * bb[1][0] + m[8] * bb[2][1] + m[12]; y = m[1] * bb[0][1] + m[5] * bb[1][0] + m[9] * bb[2][1] + m[13]; z = m[2] * bb[0][1] + m[6] * bb[1][0] + m[10] * bb[2][1] + m[14]; if (bbox[0][0] > x) bbox[0][0] = x; if (bbox[0][1] < x) bbox[0][1] = x; if (bbox[1][0] > y) bbox[1][0] = y; if (bbox[1][1] < y) bbox[1][1] = y; if (bbox[2][0] > z) bbox[2][0] = z; if (bbox[2][1] < z) bbox[2][1] = z; x = m[0] * bb[0][0] + m[4] * bb[1][1] + m[8] * bb[2][1] + m[12]; y = m[1] * bb[0][0] + m[5] * bb[1][1] + m[9] * bb[2][1] + m[13]; z = m[2] * bb[0][0] + m[6] * bb[1][1] + m[10] * bb[2][1] + m[14]; if (bbox[0][0] > x) bbox[0][0] = x; if (bbox[0][1] < x) bbox[0][1] = x; if (bbox[1][0] > y) bbox[1][0] = y; if (bbox[1][1] < y) bbox[1][1] = y; if (bbox[2][0] > z) bbox[2][0] = z; if (bbox[2][1] < z) bbox[2][1] = z; x = m[0] * bb[0][1] + m[4] * bb[1][1] + m[8] * bb[2][1] + m[12]; y = m[1] * bb[0][1] + m[5] * bb[1][1] + m[9] * bb[2][1] + m[13]; z = m[2] * bb[0][1] + m[6] * bb[1][1] + m[10] * bb[2][1] + m[14]; if (bbox[0][0] > x) bbox[0][0] = x; if (bbox[0][1] < x) bbox[0][1] = x; if (bbox[1][0] > y) bbox[1][0] = y; if (bbox[1][1] < y) bbox[1][1] = y; if (bbox[2][0] > z) bbox[2][0] = z; if (bbox[2][1] < z) bbox[2][1] = z; for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) bb[i][j] = bbox[i][j]; } /*-------------------------------------------------------------------*/ static int CGNSbounds (ClientData data, Tcl_Interp *interp, int argc, char **argv) { float bbox[3][2], matrix[16]; int n, all = 0; CONST char **args; char sbb[65]; if (argc > 1) all = atoi(argv[1]); get_bounds (all, bbox); if (argc > 2) { if (TCL_OK != Tcl_SplitList (interp, argv[2], &n, &args)) return TCL_ERROR; for (n = 0; n < 16; n++) matrix[n] = (float) atof (args[n]); Tcl_Free ((char *)args); transform_bounds (matrix, bbox); } Tcl_ResetResult (interp); for (n = 0; n < 3; n++) { sprintf (sbb, "%f %f", bbox[n][0], bbox[n][1]); Tcl_AppendElement (interp, sbb); } return TCL_OK; } /*---------- OGLregion --------------------------------------------- * create OGL display list for region *------------------------------------------------------------------*/ static int OGLregion (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int zone, regn, nc; CONST char **args; Zone *z; Regn *r; static char slist[17]; if (argc != 5) { Tcl_SetResult (interp, "usage: OGLregion zone region mode color", TCL_STATIC); return TCL_ERROR; } zone = atoi (argv[1]); if (zone < 0 || zone >= nzones) { Tcl_SetResult (interp, "zone number out of range", TCL_STATIC); return TCL_ERROR; } z = &zones[zone]; regn = atoi (argv[2]); if (regn < 0 || regn >= z->nregs) { Tcl_SetResult (interp, "region number out of range", TCL_STATIC); return TCL_ERROR; } r = &z->regs[regn]; if (r->nfaces || r->nedges) { r->mode = atoi (argv[3]); if (TCL_OK != Tcl_SplitList (interp, argv[4], &nc, &args)) return TCL_ERROR; if (nc != 3) { Tcl_Free ((char *)args); Tcl_SetResult (interp, "invalid color", TCL_STATIC); return TCL_ERROR; } for (nc = 0; nc < 3; nc++) r->color[nc] = (float)atof (args[nc]); r->color[3] = 1.0; Tcl_Free ((char *)args); if (!r->dlist) r->dlist = glGenLists (1); glNewList (r->dlist, GL_COMPILE); glColor3fv (r->color); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, r->color); if (r->nfaces) { switch (r->mode) { case 1: draw_outlines (z, r); break; case 2: draw_mesh (z, r); break; case 3: draw_shaded (z, r); break; default: r->mode = 0; break; } } else if (r->mode < 1 || r->mode > 3) { r->mode = 0; } else { draw_outlines (z, r); } glEndList (); } sprintf (slist, "%d", r->dlist); Tcl_SetResult (interp, slist, TCL_STATIC); return TCL_OK; } /*---------- OGLaxis ----------------------------------------------- * create OGL display list for axis *------------------------------------------------------------------*/ #define CHAR_W 8 #define CHAR_H 13 static GLubyte x_raster[] = { 0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3 }; static GLubyte y_raster[] = { 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3 }; static GLubyte z_raster[] = { 0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff }; /*-------------------------------------------------------------------*/ static int OGLaxis (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int vis; float bbox[3][2]; static char slist[17]; if (argc < 2 || argc > 3) { Tcl_SetResult (interp, "usage: OGLaxis visible [bounds]", TCL_STATIC); return TCL_ERROR; } vis = atoi (argv[1]); if (!AxisDL) AxisDL = glGenLists (1); glNewList (AxisDL, GL_COMPILE); if (vis) { if (argc == 3) { int nb, n = 0; CONST char **args; if (TCL_OK != Tcl_SplitList (interp, argv[2], &nb, &args)) return TCL_ERROR; if (nb == 3) { for (n = 0; n < nb; n++) { if (sscanf (args[n], "%f %f", &bbox[n][0], &bbox[n][1]) != 2) break; } } Tcl_Free ((char *)args); if (n != 3) { Tcl_SetResult (interp, "invalid bounding box", TCL_STATIC); return TCL_ERROR; } } else get_bounds (0, bbox); glLineWidth (3.0); glDisable (GL_LIGHTING); glShadeModel (GL_FLAT); glBegin (GL_LINES); glColor3f (1.0, 0.0, 0.0); glVertex3f (bbox[0][0], bbox[1][0], bbox[2][0]); glVertex3f (bbox[0][1], bbox[1][0], bbox[2][0]); glColor3f (1.0, 1.0, 0.0); glVertex3f (bbox[0][0], bbox[1][0], bbox[2][0]); glVertex3f (bbox[0][0], bbox[1][1], bbox[2][0]); glColor3f (0.0, 1.0, 0.0); glVertex3f (bbox[0][0], bbox[1][0], bbox[2][0]); glVertex3f (bbox[0][0], bbox[1][0], bbox[2][1]); glEnd (); glLineWidth (1.0); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glColor3f (1.0, 0.0, 0.0); glRasterPos3f (bbox[0][1], bbox[1][0], bbox[2][0]); glBitmap (CHAR_W, CHAR_H, -0.5 * (float)CHAR_W, 0.5 * (float)CHAR_H, 0.0, 0.0, x_raster); glColor3f (1.0, 1.0, 0.0); glRasterPos3f (bbox[0][0], bbox[1][1], bbox[2][0]); glBitmap (CHAR_W, CHAR_H, -0.5 * (float)CHAR_W, 0.5 * (float)CHAR_H, 0.0, 0.0, y_raster); glColor3f (0.0, 1.0, 0.0); glRasterPos3f (bbox[0][0], bbox[1][0], bbox[2][1]); glBitmap (CHAR_W, CHAR_H, -0.5 * (float)CHAR_W, 0.5 * (float)CHAR_H, 0.0, 0.0, z_raster); } glEndList (); sprintf (slist, "%d", AxisDL); Tcl_SetResult (interp, slist, TCL_STATIC); return TCL_OK; } /*-------------------------------------------------------------------*/ static int OGLcolor (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int index, i, j; double r, g, b; double h, v, s; static char color[256]; static double huemap[12] = {0,1,2,3,4,5,0.5,1.25,2.65,3.4,4.5,5.5}; if (argc != 2) { Tcl_SetResult (interp, "usage: OGLcolor index", TCL_STATIC); return TCL_ERROR; } index = abs(atoi(argv[1])) % 132; h = huemap[index % 12]; i = (int)h; h -= (double)i; j = index / 12; if ((j % 2) == 0) { v = 1.0; s = 1.0 - sqrt((double)j / 22.0); } else { v = 1.0 - sqrt((double)j / 44.0); s = 1.0; } r = g = b = 0.0; switch (i) { case 6: h = 0.0; /* FALLTHRU */ case 0: r = v; g = v * (1.0 - (s * (1.0 - h))); b = v * (1.0 - s); break; case 1: r = v * (1.0 - (s * h)); g = v; b = v * (1.0 - s); break; case 2: r = v * (1.0 - s); g = v; b = v * (1.0 - (s * (1.0 - h))); break; case 3: r = v * (1.0 - s); g = v * (1.0 - (s * h)); b = v; break; case 4: r = v * (1.0 - (s * (1.0 - h))); g = v * (1.0 - s); b = v; break; case 5: r = v; g = v * (1.0 - s); b = v * (1.0 - (s * h)); break; } if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0; if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0; if (b < 0.0) b = 0.0; if (b > 1.0) b = 1.0; sprintf(color, "%g %g %g", r, g, b); Tcl_SetResult (interp, color, TCL_STATIC); return TCL_OK; } /*============================================================== * cutting plane routines *==============================================================*/ #ifndef NO_CUTTING_PLANE /*------------------------------------------------------------------*/ static void init_cutplane (float plane[4]) { int nz, nr; for (nz = 0; nz < nzones; nz++) { for (nr = 0; nr < zones[nz].nregs; nr++) { if (zones[nz].regs[nr].cut.nelems) { free (zones[nz].regs[nr].cut.elems); zones[nz].regs[nr].cut.nelems = 0; } if (zones[nz].regs[nr].cut.nedges) { free (zones[nz].regs[nr].cut.edges); zones[nz].regs[nr].cut.nedges = 0; } } } if (cutplane.nnodes) free (cutplane.nodes); cutplane.nelems = 0; cutplane.nedges = 0; cutplane.nnodes = 0; for (nr = 0; nr < 4; nr++) cutplane.plane[nr] = plane[nr]; } /*------------------------------------------------------------------*/ static int classify_element (Zone *z, int nnodes, cgsize_t *nodeid) { int n, index = 0; int mask = (1 << (nnodes - 1)) - 1; float *node; double s; for (n = 0; n < nnodes; n++) { node = z->nodes[nodeid[n]]; s = node[0] * cutplane.plane[0] + node[1] * cutplane.plane[1] + node[2] * cutplane.plane[2] - cutplane.plane[3]; if (s >= 0.0) index |= (1 << n); } if (index > mask) index ^= ((mask << 1) | 1); return index; } /*------------------------------------------------------------------*/ static int classify_polygon (Zone *z, int nnodes, cgsize_t *nodeid) { int n, start, diff; float *node; double s; node = z->nodes[nodeid[0]]; s = node[0] * cutplane.plane[0] + node[1] * cutplane.plane[1] + node[2] * cutplane.plane[2] - cutplane.plane[3]; start = s >= 0.0 ? 1 : -1; for (n = 1; n < nnodes; n++) { node = z->nodes[nodeid[n]]; s = node[0] * cutplane.plane[0] + node[1] * cutplane.plane[1] + node[2] * cutplane.plane[2] - cutplane.plane[3]; diff = start * (s >= 0.0 ? 1 : -1); if (diff < 0) return 1; } return 0; } /*------------------------------------------------------------------*/ static cgsize_t find_elements () { #define ELEM_INC 50 int nz, nnodes, nn, nr, nf; cgsize_t n, ne, maxelems, nelems, *elems; CGNS_ENUMT(ElementType_t) type; Zone *z; Regn *r; Face *f; for (nz = 0; nz < nzones; nz++) { z = &zones[nz]; for (nr = 0; nr < z->nregs; nr++) { r = &z->regs[nr]; if (r->dim < 2 || (r->mode == 0 && !ignorevis)) continue; type = r->elemtype; cg_npe(type, &nnodes); maxelems = nelems = 0; elems = NULL; if (type == CGNS_ENUMV(NGON_n)) { for (n = 0, ne = 0; ne < r->nelems; ne++) { nn = r->elem_offsets[ne+1] - r->elem_offsets[ne]; if (nn > 2 && classify_polygon(z, nn, &r->elems[n])) { if (nelems >= maxelems) { maxelems += ELEM_INC; elems = (cgsize_t *) REALLOC ("find_elements", (size_t)maxelems * sizeof(cgsize_t), elems); } elems[nelems++] = ne; } n += nn; } } else if (type == CGNS_ENUMV(NFACE_n)) { for (n = 0, ne = 0; ne < r->nelems; ne++) { nf = r->elem_offsets[ne+1] - r->elem_offsets[ne]; for (nn = 0; nn < nf; nn++) { f = r->poly[abs(r->elems[n+nn])-1]; if (f->nnodes > 2 && classify_polygon(z, f->nnodes, f->nodes)) { if (nelems >= maxelems) { maxelems += ELEM_INC; elems = (cgsize_t *) REALLOC ("find_elements", (size_t)maxelems * sizeof(cgsize_t), elems); } elems[nelems++] = ne; break; } } n += nf; } } else { for (n = 0, ne = 0; ne < r->nelems; ne++) { if (r->elemtype == CGNS_ENUMV(MIXED)) { type = (CGNS_ENUMT(ElementType_t))r->elems[n++]; cg_npe(type, &nnodes); } switch (type) { case CGNS_ENUMV(TRI_3): case CGNS_ENUMV(TRI_6): case CGNS_ENUMV(TRI_9): case CGNS_ENUMV(TRI_10): case CGNS_ENUMV(TRI_12): case CGNS_ENUMV(TRI_15): nn = 3; break; case CGNS_ENUMV(QUAD_4): case CGNS_ENUMV(QUAD_8): case CGNS_ENUMV(QUAD_9): case CGNS_ENUMV(QUAD_12): case CGNS_ENUMV(QUAD_16): case CGNS_ENUMV(QUAD_P4_16): case CGNS_ENUMV(QUAD_25): case CGNS_ENUMV(TETRA_4): case CGNS_ENUMV(TETRA_10): case CGNS_ENUMV(TETRA_16): case CGNS_ENUMV(TETRA_20): case CGNS_ENUMV(TETRA_22): case CGNS_ENUMV(TETRA_34): case CGNS_ENUMV(TETRA_35): nn = 4; break; case CGNS_ENUMV(PYRA_5): case CGNS_ENUMV(PYRA_13): case CGNS_ENUMV(PYRA_14): case CGNS_ENUMV(PYRA_21): case CGNS_ENUMV(PYRA_29): case CGNS_ENUMV(PYRA_30): case CGNS_ENUMV(PYRA_P4_29): case CGNS_ENUMV(PYRA_50): case CGNS_ENUMV(PYRA_55): nn = 5; break; case CGNS_ENUMV(PENTA_6): case CGNS_ENUMV(PENTA_15): case CGNS_ENUMV(PENTA_18): case CGNS_ENUMV(PENTA_24): case CGNS_ENUMV(PENTA_38): case CGNS_ENUMV(PENTA_40): case CGNS_ENUMV(PENTA_33): case CGNS_ENUMV(PENTA_66): case CGNS_ENUMV(PENTA_75): nn = 6; break; case CGNS_ENUMV(HEXA_8): case CGNS_ENUMV(HEXA_20): case CGNS_ENUMV(HEXA_27): case CGNS_ENUMV(HEXA_32): case CGNS_ENUMV(HEXA_56): case CGNS_ENUMV(HEXA_64): case CGNS_ENUMV(HEXA_44): case CGNS_ENUMV(HEXA_98): case CGNS_ENUMV(HEXA_125): nn = 8; break; default: nn = 0; break; } if (nn && classify_element(z, nn, &r->elems[n])) { if (nelems >= maxelems) { maxelems += ELEM_INC; elems = (cgsize_t *) REALLOC ("find_elements", (size_t)maxelems * sizeof(cgsize_t), elems); } if (r->elemtype == CGNS_ENUMV(MIXED)) elems[nelems] = n - 1; else elems[nelems] = n; nelems++; } n += nnodes; } } r->cut.nelems = nelems; r->cut.elems = elems; cutplane.nelems += nelems; } } return cutplane.nelems; } /*-------------------------------------------------------------------*/ static int compare_cut_node (void *v1, void *v2) { int i; CutNode *c1 = (CutNode *)v1; CutNode *c2 = (CutNode *)v2; for (i = 0; i < 3; i++) { if (c1->nodes[i] != c2->nodes[i]) return (int)(c1->nodes[i] - c2->nodes[i]); } return 0; } /*-------------------------------------------------------------------*/ static size_t hash_cut_node (void *v) { CutNode *c = (CutNode *)v; return ((size_t)(c->nodes[0] + c->nodes[1] + c->nodes[2])); } /*-------------------------------------------------------------------*/ static void get_cut_node (void *v) { int i; CutNode *c = (CutNode *)v; Zone *z = &zones[c->nodes[0]]; float *n, *n1, *n2; n = cutplane.nodes[c->id]; n1 = z->nodes[c->nodes[1]]; n2 = z->nodes[c->nodes[2]]; for (i = 0; i < 3; i++) n[i] = n1[i] + c->ratio * (n2[i] - n1[i]); free (c); } /*-------------------------------------------------------------------*/ static size_t get_cut_edge (void *ve, void *vc) { Edge *e = (Edge *)ve; CutData *c = (CutData *)vc; c->edges[c->nedges].nodes[0] = e->nodes[0]; c->edges[c->nedges].nodes[1] = e->nodes[1]; (c->nedges)++; return 1; } /*----- tri elements -----*/ #define TRI_SIZE 3 #define TRI_EDGES 3 static int triCuts[TRI_SIZE+1][4] = { {0}, {2,0,2, 0}, {2,0,1, 0}, {2,1,2, 0} }; static int triEdges[TRI_EDGES][2] = { {0,1}, {1,2}, {2,0} }; /*----- quad elements -----*/ #define QUAD_SIZE 7 #define QUAD_EDGES 4 static int quadCuts[QUAD_SIZE+1][4] = { {0}, {2,0,3, 0}, {2,0,1, 0}, {2,1,3, 0}, {2,1,2, 0}, {2,0,3, 0}, {2,0,2, 0}, {2,2,3, 0} }; static int quadEdges[QUAD_EDGES][2] = { {0,1}, {1,2}, {2,3}, {3,0} }; /*----- tet elements -----*/ #define TET_SIZE 7 #define TET_EDGES 6 static int tetCuts[TET_SIZE+1][6] = { {0}, {3,0,3,2, 0}, {3,0,1,4, 0}, {4,1,4,3,2, 0}, {3,1,2,5, 0}, {4,0,3,5,1, 0}, {4,0,2,5,4, 0}, {3,3,5,4, 0} }; static int tetEdges[TET_EDGES][2] = { {0,1}, {1,2}, {2,0}, {0,3}, {1,3}, {2,3} }; /*----- pyramid elements -----*/ #define PYR_SIZE 15 #define PYR_EDGES 8 static int pyrCuts[PYR_SIZE+1][9] = { {0}, {3,0,4,3, 0}, {3,0,1,5, 0}, {4,1,5,4,3, 0}, {3,1,2,6, 0}, {3,0,4,3, 3,1,2,6, 0}, {4,0,2,6,5, 0}, {5,3,2,6,5,4, 0}, {3,2,3,7, 0}, {4,0,4,7,2, 0}, {3,2,3,7, 3,0,1,5, 0}, {5,1,5,4,7,2, 0}, {4,1,3,7,6, 0}, {5,0,4,7,6,1, 0}, {5,0,3,7,6,5, 0}, {4,4,7,6,5, 0}, }; static int pyrEdges[PYR_EDGES][2] = { {0,1}, {1,2}, {2,3}, {3,0}, {0,4}, {1,4}, {2,4}, {3,4} }; /*----- wedge elements -----*/ #define WDG_SIZE 31 #define WDG_EDGES 9 static int wdgCuts[WDG_SIZE+1][10] = { {0}, {3,0,3,2, 0}, {3,0,1,4, 0}, {4,1,4,3,2, 0}, {3,1,2,5, 0}, {4,0,3,5,1, 0}, {4,0,2,5,4, 0}, {3,3,5,4, 0}, {3,3,6,8, 0}, {4,0,6,8,2, 0}, {3,3,6,8, 3,0,1,4, 0}, {5,1,4,6,8,2, 0}, {3,3,6,8, 3,1,2,5, 0}, {5,0,6,8,5,1, 0}, {3,3,6,8, 4,0,2,5,4, 0}, {4,4,6,8,5, 0}, {3,4,7,6, 0}, {3,4,7,6, 3,0,3,2, 0}, {4,0,1,7,6, 0}, {5,1,7,6,3,2, 0}, {3,4,7,6, 3,1,2,5, 0}, {3,4,7,6, 4,0,3,5,1, 0}, {5,0,2,5,7,6, 0}, {4,3,5,7,6, 0}, {4,3,4,7,8, 0}, {5,0,4,7,8,2, 0}, {5,0,1,7,8,3, 0}, {4,1,7,8,2, 0}, {4,3,4,7,8, 3,1,2,5, 0}, {3,0,4,1, 3,5,7,8, 0}, {3,0,2,3, 3,5,7,8, 0}, {3,5,7,8, 0} }; static int wdgEdges[WDG_EDGES][2] = { {0,1}, {1,2}, {2,0}, {0,3}, {1,4}, {2,5}, {3,4}, {4,5}, {5,3} }; /*----- hex elements -----*/ #define HEX_SIZE 127 #define HEX_EDGES 12 static int hexCuts[HEX_SIZE+1][17] = { {0}, {3,3,0,4, 0}, {3,0,1,5, 0}, {4,3,1,5,4, 0}, {3,1,2,6, 0}, {3,3,0,4, 3,1,2,6, 0}, {4,0,2,6,5, 0}, {5,3,2,6,5,4, 0}, {3,3,7,2, 0}, {4,0,4,7,2, 0}, {3,0,1,5, 3,3,7,2, 0}, {5,4,7,2,1,5, 0}, {4,3,7,6,1, 0}, {5,0,4,7,6,1, 0}, {5,0,3,7,6,5, 0}, {4,7,6,5,4, 0}, {3,4,11,8, 0}, {4,0,8,11,3, 0}, {3,0,1,5, 3,4,11,8, 0}, {5,3,11,8,5,1, 0}, {3,1,2,6, 3,4,11,8, 0}, {4,0,8,11,3, 3,1,2,6, 0}, {4,0,2,6,5, 3,4,11,8, 0}, {6,3,2,6,5,8,11, 0}, {3,3,7,2, 3,4,11,8, 0}, {5,0,2,7,11,8, 0}, {3,0,1,5, 3,3,7,2, 3,4,11,8, 0}, {6,2,1,5,8,11,7, 0}, {4,3,7,6,1, 3,4,11,8, 0}, {6,0,8,11,7,6,1, 0}, {5,0,3,7,6,5, 3,4,11,8, 0}, {5,11,7,6,5,8, 0}, {3,8,9,5, 0}, {3,8,9,5, 3,3,0,4, 0}, {4,0,8,9,1, 0}, {5,4,3,1,9,8, 0}, {3,8,9,5, 3,1,2,6, 0}, {3,1,9,5, 3,3,0,4, 3,1,2,6, 0}, {5,0,2,6,9,8, 0}, {6,3,2,6,9,8,4, 0}, {3,8,9,5, 3,3,7,2, 0}, {4,0,4,7,2, 3,8,9,5, 0}, {4,0,8,9,1, 3,3,7,2, 0}, {6,4,7,2,1,9,8, 0}, {4,3,7,6,1, 3,8,9,5, 0}, {5,7,6,1,0,4, 3,8,9,5, 0}, {6,0,3,7,6,9,8, 0}, {5,4,7,6,9,8, 0}, {4,4,11,9,5, 0}, {5,0,3,11,9,5, 0}, {5,0,4,11,9,1, 0}, {4,3,1,9,11, 0}, {4,4,11,9,5, 3,1,2,6, 0}, {6,0,3,11,9,6,2, 0}, {6,0,2,6,9,11,4, 0}, {5,3,2,6,9,11, 0}, {4,4,11,9,5, 3,3,7,2, 0}, {6,0,2,7,11,9,5, 0}, {5,11,9,1,0,4, 3,3,7,2, 0}, {5,11,7,2,1,9, 0}, {4,3,7,6,1, 4,4,11,9,5, 0}, {4,11,7,6,9, 3,0,1,5, 0}, {4,11,7,6,9, 3,3,0,4, 0}, {4,11,7,6,9, 0}, {3,9,10,6, 0}, {3,9,10,6, 3,3,0,4, 0}, {3,9,10,6, 3,0,1,5, 0}, {4,4,3,1,5, 3,9,10,6, 0}, {4,2,1,9,10, 0}, {4,2,1,9,10, 3,3,0,4, 0}, {5,0,2,10,9,5, 0}, {6,3,2,10,9,5,4, 0}, {3,3,7,2, 3,9,10,6, 0}, {4,7,2,0,4, 3,9,10,6, 0}, {3,0,1,5, 3,2,3,7, 3,9,10,6, 0}, {4,4,7,10,9, 4,1,2,6,5, 0}, {5,3,7,10,9,1, 0}, {6,4,7,10,9,1,0, 0}, {6,3,7,10,9,5,0, 0}, {5,4,7,10,9,5, 0}, {3,4,11,8, 3,9,10,6, 0}, {4,0,8,11,3, 3,9,10,6, 0}, {3,0,1,5, 3,4,11,8, 3,9,10,6, 0}, {5,3,11,10,6,1, 3,1,9,5, 0}, {4,1,2,10,9, 3,4,11,8, 0}, {4,3,11,10,2, 4,0,8,9,1, 0}, {5,4,11,10,2,0, 3,8,9,5, 0}, {4,3,11,10,2, 3,8,9,5, 0}, {3,3,7,2, 3,9,10,6, 3,4,11,8, 0}, {5,0,2,6,9,8, 3,11,7,10, 0}, {3,0,4,3, 3,11,7,10, 3,1,2,6, 3,8,9,5, 0}, {3,1,9,5, 3,11,7,10, 3,1,2,6, 0}, {5,3,1,9,8,4, 3,11,7,10, 0}, {4,0,8,9,1, 3,11,7,10, 0}, {3,11,7,10, 3,8,9,5, 3,3,0,4, 0}, {3,11,7,10, 3,8,9,5, 0}, {4,8,10,6,5, 0}, {4,8,10,6,5, 3,3,0,4, 0}, {5,0,8,10,6,1, 0}, {6,3,4,8,10,6,1, 0}, {5,10,2,1,5,8, 0}, {5,3,2,10,8,4, 3,0,1,5, 0}, {4,0,8,10,2, 0}, {5,3,2,10,8,4, 0}, {4,8,10,6,5, 3,3,7,2, 0}, {4,4,7,10,8, 4,0,2,6,5, 0}, {5,3,7,10,8,0, 3,1,2,6, 0}, {4,4,7,10,8, 3,1,2,6, 0}, {6,3,7,10,8,5,1, 0}, {4,4,7,10,8, 3,0,1,5, 0}, {5,3,7,10,8,0, 0}, {4,4,7,10,8, 0}, {5,4,11,10,6,5, 0}, {6,0,3,11,10,6,5, 0}, {6,4,11,10,6,1,0, 0}, {5,3,11,10,6,1, 0}, {6,4,11,10,2,1,5, 0}, {4,3,11,10,2, 3,0,1,5, 0}, {5,4,11,10,2,0, 0}, {4,11,10,2,3, 0}, {5,3,2,6,5,4, 3,11,7,10, 0}, {4,0,2,6,5, 3,11,7,10, 0}, {3,3,0,4, 3,1,2,6, 3,11,7,10, 0}, {3,1,2,6, 3,11,7,10, 0}, {4,4,3,1,5, 3,11,7,10, 0}, {3,0,1,5, 3,11,7,10, 0}, {3,11,7,10, 3,3,0,4, 0}, {3,11,7,10, 0} }; static int hexEdges[HEX_EDGES][2] = { {0,1}, {1,2}, {2,3}, {3,0}, {0,4}, {1,5}, {2,6}, {3,7}, {4,5}, {5,6}, {6,7}, {7,4} }; static int n_cut_nodes; static HASH *cut_hash; /*------------------------------------------------------------------*/ static void intersect_polygon (int zonenum, int nnodes, cgsize_t *nodeid, HASH *edgehash) { int i, n, nn, i1, i2; cgsize_t id = -1; float *node; double s1, s2; CutNode cnode, *cn; Edge edge, *ep; Zone *z = &zones[zonenum]; static char *funcname = "intersect_polygon"; if (nnodes < 3) return; node = z->nodes[nodeid[0]]; for (s1 = 0.0, i = 0; i < 3; i++) s1 += (node[i] * cutplane.plane[i]); i1 = (s1 - cutplane.plane[3]) >= 0.0 ? 1 : -1; for (n = 1; n <= nnodes; n++) { nn = n % nnodes; node = z->nodes[nodeid[nn]]; for (s2 = 0.0, i = 0; i < 3; i++) s2 += (node[i] * cutplane.plane[i]); i2 = (s2 - cutplane.plane[3]) >= 0.0 ? 1 : -1; if (i1 * i2 < 0) { cnode.nodes[0] = zonenum; if (nodeid[n-1] < nodeid[nn]) { cnode.nodes[1] = nodeid[n-1]; cnode.nodes[2] = nodeid[nn]; if (s1 == s2) cnode.ratio = 0.0; else cnode.ratio = (float)((cutplane.plane[3] - s1) / (s2 - s1)); } else { cnode.nodes[1] = nodeid[nn]; cnode.nodes[2] = nodeid[n-1]; if (s1 == s2) cnode.ratio = 0.0; else cnode.ratio = (float)((cutplane.plane[3] - s2) / (s1 - s2)); } cn = (CutNode *) HashFind (cut_hash, &cnode); if (cn == NULL) { cn = (CutNode *) MALLOC (funcname, sizeof(CutNode)); for (i = 0; i < 3; i++) cn->nodes[i] = cnode.nodes[i]; cn->id = n_cut_nodes++; cn->ratio = cnode.ratio; (void) HashAdd (cut_hash, cn); } if (id >= 0) { edge.nodes[0] = id; edge.nodes[1] = cn->id; ep = (Edge *) HashFind (edgehash, &edge); if (NULL == ep) { ep = (Edge *) MALLOC (funcname, sizeof(Edge)); ep->nodes[0] = edge.nodes[0]; ep->nodes[1] = edge.nodes[1]; (void) HashAdd (edgehash, ep); } } id = cn->id; } s1 = s2; i1 = i2; } } /*------------------------------------------------------------------*/ static void intersect_element (int zonenum, CGNS_ENUMT(ElementType_t) elemtype, cgsize_t *nodeid, HASH *edgehash) { int i, n, index, nn, nc, *cuts; int edgemap[HEX_EDGES][2], ids[7]; cgsize_t swap; double s1, s2; float *node; CutNode cnode, *cn; Edge edge, *ep; Zone *z = &zones[zonenum]; static char *funcname = "intersect_element"; /* get intersection lookup table */ switch (elemtype) { case CGNS_ENUMV(TRI_3): case CGNS_ENUMV(TRI_6): case CGNS_ENUMV(TRI_9): case CGNS_ENUMV(TRI_10): case CGNS_ENUMV(TRI_12): case CGNS_ENUMV(TRI_15): index = classify_element(z, 3, nodeid); if (index < 1 || index > TRI_SIZE) return; cuts = triCuts[index]; for (n = 0; n < TRI_EDGES; n++) { edgemap[n][0] = triEdges[n][0]; edgemap[n][1] = triEdges[n][1]; } break; case CGNS_ENUMV(QUAD_4): case CGNS_ENUMV(QUAD_8): case CGNS_ENUMV(QUAD_9): case CGNS_ENUMV(QUAD_12): case CGNS_ENUMV(QUAD_16): case CGNS_ENUMV(QUAD_P4_16): case CGNS_ENUMV(QUAD_25): index = classify_element(z, 4, nodeid); if (index < 1 || index > QUAD_SIZE) return; cuts = quadCuts[index]; for (n = 0; n < QUAD_EDGES; n++) { edgemap[n][0] = quadEdges[n][0]; edgemap[n][1] = quadEdges[n][1]; } break; case CGNS_ENUMV(TETRA_4): case CGNS_ENUMV(TETRA_10): case CGNS_ENUMV(TETRA_16): case CGNS_ENUMV(TETRA_20): case CGNS_ENUMV(TETRA_22): case CGNS_ENUMV(TETRA_34): case CGNS_ENUMV(TETRA_35): index = classify_element(z, 4, nodeid); if (index < 1 || index > TET_SIZE) return; cuts = tetCuts[index]; for (n = 0; n < TET_EDGES; n++) { edgemap[n][0] = tetEdges[n][0]; edgemap[n][1] = tetEdges[n][1]; } break; case CGNS_ENUMV(PYRA_5): case CGNS_ENUMV(PYRA_13): case CGNS_ENUMV(PYRA_14): case CGNS_ENUMV(PYRA_21): case CGNS_ENUMV(PYRA_29): case CGNS_ENUMV(PYRA_30): case CGNS_ENUMV(PYRA_P4_29): case CGNS_ENUMV(PYRA_50): case CGNS_ENUMV(PYRA_55): index = classify_element(z, 5, nodeid); if (index < 1 || index > PYR_SIZE) return; cuts = pyrCuts[index]; for (n = 0; n < PYR_EDGES; n++) { edgemap[n][0] = pyrEdges[n][0]; edgemap[n][1] = pyrEdges[n][1]; } break; case CGNS_ENUMV(PENTA_6): case CGNS_ENUMV(PENTA_15): case CGNS_ENUMV(PENTA_18): case CGNS_ENUMV(PENTA_24): case CGNS_ENUMV(PENTA_38): case CGNS_ENUMV(PENTA_40): case CGNS_ENUMV(PENTA_33): case CGNS_ENUMV(PENTA_66): case CGNS_ENUMV(PENTA_75): index = classify_element(z, 6, nodeid); if (index < 1 || index > WDG_SIZE) return; cuts = wdgCuts[index]; for (n = 0; n < WDG_EDGES; n++) { edgemap[n][0] = wdgEdges[n][0]; edgemap[n][1] = wdgEdges[n][1]; } break; case CGNS_ENUMV(HEXA_8): case CGNS_ENUMV(HEXA_20): case CGNS_ENUMV(HEXA_27): case CGNS_ENUMV(HEXA_32): case CGNS_ENUMV(HEXA_56): case CGNS_ENUMV(HEXA_64): case CGNS_ENUMV(HEXA_44): case CGNS_ENUMV(HEXA_98): case CGNS_ENUMV(HEXA_125): index = classify_element(z, 8, nodeid); if (index < 1 || index > HEX_SIZE) return; cuts = hexCuts[index]; for (n = 0; n < HEX_EDGES; n++) { edgemap[n][0] = hexEdges[n][0]; edgemap[n][1] = hexEdges[n][1]; } break; default: return; } /* get the edge intersections */ for (nc = 0; cuts[nc];) { nn = cuts[nc]; for (n = 1; n <= nn; n++) { /* get edge nodes */ cnode.nodes[0] = zonenum; cnode.nodes[1] = nodeid[edgemap[cuts[nc+n]][0]]; cnode.nodes[2] = nodeid[edgemap[cuts[nc+n]][1]]; if (cnode.nodes[2] < cnode.nodes[1]) { swap = cnode.nodes[1]; cnode.nodes[1] = cnode.nodes[2]; cnode.nodes[2] = swap; } cn = (CutNode *) HashFind (cut_hash, &cnode); /* add node to hash table if not there */ if (NULL == cn) { cn = (CutNode *) MALLOC (funcname, sizeof(CutNode)); cn->id = n_cut_nodes++; for (i = 0; i < 3; i++) cn->nodes[i] = cnode.nodes[i]; node = z->nodes[cn->nodes[1]]; for (s1 = 0.0, i = 0; i < 3; i++) s1 += (node[i] * cutplane.plane[i]); node = z->nodes[cn->nodes[2]]; for (s2 = 0.0, i = 0; i < 3; i++) s2 += (node[i] * cutplane.plane[i]); if (s1 == s2) cn->ratio = 0.0; else cn->ratio = (float)((cutplane.plane[3] - s1) / (s2 - s1)); (void) HashAdd (cut_hash, cn); } ids[n-1] = cn->id; } ids[nn] = ids[0]; /* add cutplane edge */ for (n = 0; n < nn; n++) { edge.nodes[0] = ids[n]; edge.nodes[1] = ids[n+1]; ep = (Edge *) HashFind (edgehash, &edge); if (NULL == ep) { ep = (Edge *) MALLOC (funcname, sizeof(Edge)); ep->nodes[0] = edge.nodes[0]; ep->nodes[1] = edge.nodes[1]; (void) HashAdd (edgehash, ep); } } /* next cut */ nc += (nn + 1); } } /*------------------------------------------------------------------*/ static cgsize_t find_intersects () { int nz, nr, nf, nfaces, nnodes; cgsize_t n, ne; size_t nn; CGNS_ENUMT(ElementType_t) type; Face *f; Regn *r; HASH *edgehash; static char *funcname = "find_intersects"; /* create hash table to store nodes at edge intersections */ n_cut_nodes = 0; nn = (size_t)cutplane.nelems; cut_hash = HashCreate (nn > 1024 ? nn / 3 : 127, compare_cut_node, hash_cut_node); cutplane.nedges = 0; for (nz = 0; nz < nzones; nz++) { for (nr = 0; nr < zones[nz].nregs; nr++) { r = &zones[nz].regs[nr]; if (r->cut.nelems == 0) continue; type = r->elemtype; nn = (size_t)r->cut.nelems; edgehash = HashCreate (nn > 1024 ? nn / 3: 127, compare_edges, hash_edge); for (n = 0, ne = 0; ne < r->cut.nelems; ne++) { n = r->cut.elems[ne]; if (r->elemtype == CGNS_ENUMV(NGON_n)) { nnodes = r->elem_offsets[n+1]-r->elem_offsets[n]; intersect_polygon(nz, nnodes, &r->elems[r->elem_offsets[n]], edgehash); } else if (r->elemtype == CGNS_ENUMV(NFACE_n)) { nfaces = r->elem_offsets[n+1]-r->elem_offsets[n]; for (nf = 0; nf < nfaces; nf++) { f = r->poly[abs(r->elems[r->elem_offsets[n]+nf])-1]; intersect_polygon(nz, f->nnodes, f->nodes, edgehash); } } else { cg_npe(type, &nnodes); if (r->elemtype == CGNS_ENUMV(MIXED)) { type = (CGNS_ENUMT(ElementType_t))r->elems[n++]; cg_npe(type, &nnodes); } intersect_element (nz, type, &r->elems[n], edgehash); } } r->cut.nedges = 0; nn = HashSize (edgehash); if (nn) { r->cut.edges = (Edge *) MALLOC (funcname, nn * sizeof(Edge)); HashList (edgehash, get_cut_edge, &r->cut); } HashDestroy (edgehash, NULL); cutplane.nedges += r->cut.nedges; } } nn = HashSize (cut_hash); cutplane.nnodes = (cgsize_t)nn; cutplane.nodes = (Node *) MALLOC (funcname, nn * sizeof(Node)); HashDestroy (cut_hash, get_cut_node); return cutplane.nelems; } /*------------------------------------------------------------------*/ static void draw_edges () { int nz, nr; cgsize_t ne, nn; Zone *z; Regn *r; glDisable(GL_LIGHTING); glShadeModel(GL_FLAT); glBegin(GL_LINES); glColor3fv(cutcolor); for (nz = 0; nz < nzones; nz++) { z = &zones[nz]; for (nr = 0; nr < z->nregs; nr++) { r = &z->regs[nr]; if (r->cut.nedges == 0) continue; if (!usecutclr) glColor3fv(r->color); for (ne = 0; ne < r->cut.nedges; ne++) { nn = r->cut.edges[ne].nodes[0]; glVertex3fv(cutplane.nodes[nn]); nn = r->cut.edges[ne].nodes[1]; glVertex3fv(cutplane.nodes[nn]); } } } glEnd(); } /*------------------------------------------------------------------*/ static void draw_elements (int mode) { int nz, nr, i, j; int ip, nf, nnodes; cgsize_t n, ne, nn; float *nodes[4], norm[3]; CGNS_ENUMT(ElementType_t) type; Zone *z; Regn *r; Face *f; glEnable(GL_LIGHTING); glShadeModel(GL_FLAT); glPolygonMode(GL_FRONT_AND_BACK, mode); glColor3fv(cutcolor); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, cutcolor); for (nz = 0; nz < nzones; nz++) { z = &zones[nz]; for (nr = 0; nr < z->nregs; nr++) { r = &z->regs[nr]; if (r->cut.nelems == 0) continue; type = r->elemtype; if (!usecutclr) { glColor3fv(r->color); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, r->color); } if (type == CGNS_ENUMV(NGON_n)) { for (ne = 0; ne < r->cut.nelems; ne++) { nn = r->cut.elems[ne]; nnodes = r->elem_offsets[nn+1]- r->elem_offsets[nn]; if (nnodes < 3) continue; if (nnodes == 3) glBegin(GL_TRIANGLES); else if (nnodes == 4) glBegin(GL_QUADS); else glBegin(GL_POLYGON); glNormal3fv(face_normal(z, nnodes, &r->elems[r->elem_offsets[nn]])); for (i = r->elem_offsets[nn]; i < r->elem_offsets[nn+1]; i++) glVertex3fv(z->nodes[r->elems[i]]); glEnd(); } } else if (type == CGNS_ENUMV(NFACE_n)) { for (ne = 0; ne < r->cut.nelems; ne++) { nn = r->cut.elems[ne]; nf = r->elem_offsets[nn+1]- r->elem_offsets[nn]; for (j = 0; j < nf; j++) { f = r->poly[abs(r->elems[r->elem_offsets[nn]+j])-1]; if (f->nnodes < 3) continue; if (f->nnodes == 3) glBegin(GL_TRIANGLES); else if (f->nnodes == 4) glBegin(GL_QUADS); else glBegin(GL_POLYGON); if (r->elems[r->elem_offsets[nn]+j] < 0) { for (i = 0; i < 3; i++) norm[i] = -f->normal[i]; } else { for (i = 0; i < 3; i++) norm[i] = f->normal[i]; } glNormal3fv(norm); for (i = 0; i < f->nnodes; i++) glVertex3fv(z->nodes[f->nodes[i]]); glEnd(); } } } else { for (ne = 0; ne < r->cut.nelems; ne++) { n = r->cut.elems[ne]; if (r->elemtype == CGNS_ENUMV(MIXED)) type = (CGNS_ENUMT(ElementType_t))r->elems[n++]; switch (type) { case CGNS_ENUMV(TRI_3): case CGNS_ENUMV(TRI_6): case CGNS_ENUMV(TRI_9): case CGNS_ENUMV(TRI_10): case CGNS_ENUMV(TRI_12): case CGNS_ENUMV(TRI_15): ip = 0; nf = 1; break; case CGNS_ENUMV(QUAD_4): case CGNS_ENUMV(QUAD_8): case CGNS_ENUMV(QUAD_9): case CGNS_ENUMV(QUAD_12): case CGNS_ENUMV(QUAD_16): case CGNS_ENUMV(QUAD_P4_16): case CGNS_ENUMV(QUAD_25): ip = 1; nf = 1; break; case CGNS_ENUMV(TETRA_4): case CGNS_ENUMV(TETRA_10): case CGNS_ENUMV(TETRA_16): case CGNS_ENUMV(TETRA_20): case CGNS_ENUMV(TETRA_22): case CGNS_ENUMV(TETRA_34): case CGNS_ENUMV(TETRA_35): ip = 2; nf = 4; break; case CGNS_ENUMV(PYRA_5): case CGNS_ENUMV(PYRA_13): case CGNS_ENUMV(PYRA_14): case CGNS_ENUMV(PYRA_21): case CGNS_ENUMV(PYRA_29): case CGNS_ENUMV(PYRA_30): case CGNS_ENUMV(PYRA_P4_29): case CGNS_ENUMV(PYRA_50): case CGNS_ENUMV(PYRA_55): ip = 6; nf = 5; break; case CGNS_ENUMV(PENTA_6): case CGNS_ENUMV(PENTA_15): case CGNS_ENUMV(PENTA_18): case CGNS_ENUMV(PENTA_24): case CGNS_ENUMV(PENTA_38): case CGNS_ENUMV(PENTA_40): case CGNS_ENUMV(PENTA_33): case CGNS_ENUMV(PENTA_66): case CGNS_ENUMV(PENTA_75): ip = 11; nf = 5; break; case CGNS_ENUMV(HEXA_8): case CGNS_ENUMV(HEXA_20): case CGNS_ENUMV(HEXA_27): case CGNS_ENUMV(HEXA_32): case CGNS_ENUMV(HEXA_56): case CGNS_ENUMV(HEXA_64): case CGNS_ENUMV(HEXA_44): case CGNS_ENUMV(HEXA_98): case CGNS_ENUMV(HEXA_125): ip = 16; nf = 6; break; default: ip = 0; nf = 0; break; } for (j = 0; j < nf; j++) { nnodes = facenodes[ip+j][0]; for (i = 0; i < nnodes; i++) { nn = r->elems[n+facenodes[ip+j][i+1]]; nodes[i] = z->nodes[nn]; } if (nnodes == 4) { glBegin(GL_QUADS); glNormal3fv(compute_normal(nodes[0], nodes[1], nodes[2], nodes[3])); } else { glBegin(GL_TRIANGLES); glNormal3fv(compute_normal(nodes[0], nodes[1], nodes[2], NULL)); } for (i = 0; i < nnodes; i++) glVertex3fv(nodes[i]); glEnd(); } } } } } } /*---------- OGLcutplane ------------------------------------------- * create OGL display list for a cutting plane *------------------------------------------------------------------*/ static int OGLcutplane (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int mode; float plane[4]; static char slist[33]; if (argc < 1 || argc > 3) { Tcl_SetResult (interp, "usage: OGLcutplane [mode] [plane]", TCL_STATIC); return TCL_ERROR; } /* create and return displaylist flag */ if (argc == 1) { if (!CutDL) CutDL = glGenLists (1); sprintf (slist, "%d", CutDL); Tcl_SetResult (interp, slist, TCL_STATIC); return TCL_OK; } mode = atoi(argv[1]); if (argc == 3) { int np; CONST char **args; if (TCL_OK != Tcl_SplitList (interp, argv[2], &np, &args)) return TCL_ERROR; if (np != 4) { Tcl_Free ((char *)args); Tcl_SetResult (interp, "invalid plane", TCL_STATIC); return TCL_ERROR; } for (np = 0; np < 4; np++) plane[np] = (float) atof (args[np]); Tcl_Free ((char *)args); init_cutplane(plane); find_elements(); } if (!CutDL) CutDL = glGenLists (1); glNewList (CutDL, GL_COMPILE); if (mode && cutplane.nelems) { if (mode == 1) { if (cutplane.nedges == 0) find_intersects(); draw_edges (); } else { draw_elements (mode > 2 ? GL_FILL : GL_LINE); } } glEndList (); sprintf (slist, "%ld %ld", (long)cutplane.nelems, (long)cutplane.nedges); Tcl_SetResult (interp, slist, TCL_STATIC); return TCL_OK; } /*---------- OGLdrawplane ------------------------------------------ * draw the cutting plane *------------------------------------------------------------------*/ static int OGLdrawplane (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n, np, i, j, k, index, n0, n1; CONST char **args; float plane[4], bbox[3][2], s[8], ds; float node[8][3], pnode[6][3]; static char slist[17]; if (argc < 1 || argc > 2) { Tcl_SetResult (interp, "usage: OGLdrawplane [plane]", TCL_STATIC); return TCL_ERROR; } if (!PlaneDL) PlaneDL = glGenLists (1); if (argc == 1) { glNewList (PlaneDL, GL_COMPILE); glEndList (); sprintf (slist, "%d", PlaneDL); Tcl_SetResult (interp, slist, TCL_STATIC); return TCL_OK; } if (TCL_OK != Tcl_SplitList (interp, argv[1], &np, &args)) return TCL_ERROR; if (np != 4) { Tcl_Free ((char *)args); Tcl_SetResult (interp, "invalid plane", TCL_STATIC); return TCL_ERROR; } for (n = 0; n < np; n++) plane[n] = (float) atof (args[n]); Tcl_Free ((char *)args); get_bounds (ignorevis, bbox); index = n = 0; for (k = 0; k < 2; k++) { for (j = 0; j < 2; j++) { for (i = 0; i < 2; i++) { node[n][0] = bbox[0][(i+j)%2]; node[n][1] = bbox[1][j]; node[n][2] = bbox[2][k]; s[n] = node[n][0] * plane[0] + node[n][1] * plane[1] + node[n][2] * plane[2]; if (s[n] >= plane[3]) index |= (1 << n); n++; } } } if (index > 0x7f) index ^= 0xff; if (index < 1 || index > HEX_SIZE) { Tcl_SetResult (interp, "plane doesn't intersect", TCL_STATIC); return TCL_ERROR; } np = hexCuts[index][0]; for (n = 0; n < np; n++) { j = hexCuts[index][n+1]; n0 = hexEdges[j][0]; n1 = hexEdges[j][1]; ds = s[n1] - s[n0]; if (ds != 0.0) ds = (plane[3] - s[n0]) / ds; for (i = 0; i < 3; i++) pnode[n][i] = node[n0][i] + ds * (node[n1][i] - node[n0][i]); } glNewList (PlaneDL, GL_COMPILE); glEnable(GL_BLEND); glDepthMask(GL_FALSE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_LIGHTING); glShadeModel(GL_FLAT); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glColor4fv(cutcolor); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, cutcolor); glBegin(GL_TRIANGLE_FAN); glNormal3fv(plane); for (n = 0; n < np; n++) glVertex3fv(pnode[n]); glEnd(); glDepthMask(GL_TRUE); glDisable(GL_BLEND); glEnable(GL_LIGHTING); glEndList (); sprintf (slist, "%d", PlaneDL); Tcl_SetResult (interp, slist, TCL_STATIC); return TCL_OK; } /*---------- OGLcutconfig ------------------------------------------ * set the cutting plane color and operation *------------------------------------------------------------------*/ static int OGLcutconfig (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n, np; CONST char **args; if (argc < 2 || argc > 4) { Tcl_SetResult (interp, "usage: OGLcutconfig color [usecutclr] [ignorevis]", TCL_STATIC); return TCL_ERROR; } if (TCL_OK != Tcl_SplitList (interp, argv[1], &np, &args)) return TCL_ERROR; if (np < 3 || np > 4) { Tcl_Free ((char *)args); Tcl_SetResult (interp, "invalid color", TCL_STATIC); return TCL_ERROR; } for (n = 0; n < np; n++) cutcolor[n] = (float) atof (args[n]); Tcl_Free ((char *)args); if (argc > 2) { usecutclr = atoi (argv[2]); if (argc > 3) ignorevis = atoi (argv[3]); } return TCL_OK; } #endif /*---------- Cgnstcl_Init -------------------------------------- * Initialize and create the commands *--------------------------------------------------------------*/ #if defined(_WIN32) && defined(BUILD_DLL) __declspec(dllexport) #endif int Cgnstcl_Init(Tcl_Interp *interp) { global_interp = interp; Tcl_CreateCommand (interp, "CGNSopen", (Tcl_CmdProc *)CGNSopen, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSclose", (Tcl_CmdProc *)CGNSclose, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSbase", (Tcl_CmdProc *)CGNSbase, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSzone", (Tcl_CmdProc *)CGNSzone, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSsummary", (Tcl_CmdProc *)CGNSsummary, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSgetbase", (Tcl_CmdProc *)CGNSgetbase, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSgetzone", (Tcl_CmdProc *)CGNSgetzone, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSgetregion", (Tcl_CmdProc *)CGNSgetregion, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSregiondim", (Tcl_CmdProc *)CGNSregiondim, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSbounds", (Tcl_CmdProc *)CGNSbounds, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "OGLregion", (Tcl_CmdProc *)OGLregion, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "OGLaxis", (Tcl_CmdProc *)OGLaxis, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "OGLcolor", (Tcl_CmdProc *)OGLcolor, (ClientData)0, (Tcl_CmdDeleteProc *)0); #ifndef NO_CUTTING_PLANE Tcl_CreateCommand (interp, "OGLcutplane", (Tcl_CmdProc *)OGLcutplane, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "OGLdrawplane", (Tcl_CmdProc *)OGLdrawplane, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "OGLcutconfig", (Tcl_CmdProc *)OGLcutconfig, (ClientData)0, (Tcl_CmdDeleteProc *)0); #endif return TCL_OK; } CGNS-4.5.0/src/cgnstools/cgnsplot/plotwish.c000066400000000000000000000056141474000356600207350ustar00rootroot00000000000000/* * tkAppInit.c -- * * Provides a default version of the Tcl_AppInit procedure for * use in wish and similar Tk-based applications. * * Copyright (c) 1993 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #include "tk.h" #include "locale.h" extern int Cgnstcl_Init _ANSI_ARGS_((Tcl_Interp *interp)); extern int Tkogl_Init _ANSI_ARGS_((Tcl_Interp *interp)); /* *---------------------------------------------------------------------- * * main -- * * This is the main program for the application. * * Results: * None: Tk_Main never returns here, so this procedure never * returns either. * * Side effects: * Whatever the application does. * *---------------------------------------------------------------------- */ int main(argc, argv) int argc; /* Number of command-line arguments. */ char **argv; /* Values of command-line arguments. */ { Tk_Main(argc, argv, Tcl_AppInit); return 0; /* Needed only to prevent compiler warning. */ } /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in the interp's result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(interp) Tcl_Interp *interp; /* Interpreter for application. */ { if (Tcl_Init(interp) == TCL_ERROR) { return TCL_ERROR; } if (Tk_Init(interp) == TCL_ERROR) { return TCL_ERROR; } Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit); /* * Call the init procedures for included packages. Each call should * look like this: * * if (Mod_Init(interp) == TCL_ERROR) { * return TCL_ERROR; * } * * where "Mod" is the name of the module. */ if (Cgnstcl_Init(interp) == TCL_ERROR) return TCL_ERROR; if (Tkogl_Init(interp) == TCL_ERROR) return TCL_ERROR; /* * Call Tcl_CreateCommand for application-specific commands, if * they weren't already created by the init procedures called above. */ /* * Specify a user-specific startup file to invoke if the application * is run interactively. Typically the startup file is "~/.apprc" * where "app" is the name of the application. If this line is deleted * then no user-specific startup file will be run under any conditions. */ Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); return TCL_OK; } CGNS-4.5.0/src/cgnstools/cgnsplot/winmain.c000066400000000000000000000205471474000356600205300ustar00rootroot00000000000000/* * winMain.c -- * * Main entry point for wish and other Tk-based applications. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright (c) 1998-1999 by Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN #include #include "tkWinInt.h" #include #include extern int Cgnstcl_Init _ANSI_ARGS_((Tcl_Interp *interp)); extern int Tkogl_Init _ANSI_ARGS_((Tcl_Interp *interp)); #ifdef USE_HTMLHELP extern int WinHtml_Init _ANSI_ARGS_((Tcl_Interp *interp)); #endif /* * Forward declarations for procedures defined later in this file: */ static void setargv _ANSI_ARGS_((int *argcPtr, char ***argvPtr)); static void WishPanic _ANSI_ARGS_(TCL_VARARGS(char *,format)); static int Proc_LoadIcon _ANSI_ARGS_((ClientData data, Tcl_Interp *interp, int argc, char **argv)); static HINSTANCE myInstance; /* *---------------------------------------------------------------------- * * WinMain -- * * Main entry point from Windows. * * Results: * Returns false if initialization fails, otherwise it never * returns. * * Side effects: * Just about anything, since from here we call arbitrary Tcl code. * *---------------------------------------------------------------------- */ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { char **argv; int argc; char buffer[MAX_PATH+1]; char *p; Tcl_SetPanicProc((Tcl_PanicProc *)WishPanic); /* * Increase the application queue size from default value of 8. * At the default value, cross application SendMessage of WM_KILLFOCUS * will fail because the handler will not be able to do a PostMessage! * This is only needed for Windows 3.x, since NT dynamically expands * the queue. */ SetMessageQueue(64); /* * Set up the default locale to be standard "C" locale so parsing * is performed correctly. */ setlocale(LC_ALL, "C"); setargv(&argc, &argv); /* * Replace argv[0] with full pathname of executable, and forward * slashes substituted for backslashes. */ GetModuleFileName(NULL, buffer, sizeof(buffer)); argv[0] = buffer; for (p = buffer; *p != '\0'; p++) { if (*p == '\\') { *p = '/'; } } myInstance = hInstance; Tk_Main(argc, argv, Tcl_AppInit); return 1; } /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in the interp's result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(Tcl_Interp *interp) { if (Tcl_Init(interp) == TCL_ERROR) { goto error; } if (Tk_Init(interp) == TCL_ERROR) { goto error; } Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit); if (Cgnstcl_Init(interp) == TCL_ERROR) goto error; if (Tkogl_Init(interp) == TCL_ERROR) goto error; #ifdef USE_HTMLHELP if (WinHtml_Init(interp) == TCL_ERROR) goto error; #endif Tcl_CreateCommand (interp, "LoadIcon", (Tcl_CmdProc *)Proc_LoadIcon, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_SetVar(interp, "tcl_rcFileName", "~/wishrc.tcl", TCL_GLOBAL_ONLY); return TCL_OK; error: MessageBeep(MB_ICONEXCLAMATION); MessageBox(NULL, Tcl_GetStringResult(interp), "Error in Wish", MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); ExitProcess(1); /* we won't reach this, but we need the return */ return TCL_ERROR; } /* *---------------------------------------------------------------------- * * WishPanic -- * * Display a message and exit. * * Results: * None. * * Side effects: * Exits the program. * *---------------------------------------------------------------------- */ void WishPanic TCL_VARARGS_DEF(char *,arg1) { va_list argList; char buf[1024]; char *format; format = TCL_VARARGS_START(char *,arg1,argList); vsprintf(buf, format, argList); MessageBeep(MB_ICONEXCLAMATION); MessageBox(NULL, buf, "Fatal Error in Wish", MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); #ifdef _MSC_VER DebugBreak(); #endif ExitProcess(1); } /* *------------------------------------------------------------------------- * * setargv -- * * Parse the Windows command line string into argc/argv. Done here * because we don't trust the builtin argument parser in crt0. * Windows applications are responsible for breaking their command * line into arguments. * * 2N backslashes + quote -> N backslashes + begin quoted string * 2N + 1 backslashes + quote -> literal * N backslashes + non-quote -> literal * quote + quote in a quoted string -> single quote * quote + quote not in quoted string -> empty string * quote -> begin quoted string * * Results: * Fills argcPtr with the number of arguments and argvPtr with the * array of arguments. * * Side effects: * Memory allocated. * *-------------------------------------------------------------------------- */ static void setargv(int *argcPtr, char ***argvPtr) { char *cmdLine, *p, *arg, *argSpace; char **argv; int argc, size, inquote, copy, slashes; cmdLine = GetCommandLine(); /* INTL: BUG */ /* * Precompute an overly pessimistic guess at the number of arguments * in the command line by counting non-space spans. */ size = 2; for (p = cmdLine; *p != '\0'; p++) { if ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */ size++; while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */ p++; } if (*p == '\0') { break; } } } argSpace = (char *) Tcl_Alloc( (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1)); argv = (char **) argSpace; argSpace += size * sizeof(char *); size--; p = cmdLine; for (argc = 0; argc < size; argc++) { argv[argc] = arg = argSpace; while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */ p++; } if (*p == '\0') { break; } inquote = 0; slashes = 0; while (1) { copy = 1; while (*p == '\\') { slashes++; p++; } if (*p == '"') { if ((slashes & 1) == 0) { copy = 0; if ((inquote) && (p[1] == '"')) { p++; copy = 1; } else { inquote = !inquote; } } slashes >>= 1; } while (slashes) { *arg = '\\'; arg++; slashes--; } if ((*p == '\0') || (!inquote && ((*p == ' ') || (*p == '\t')))) { /* INTL: ISO space. */ break; } if (copy != 0) { *arg = *p; arg++; } p++; } *arg = '\0'; argSpace = arg + 1; } argv[argc] = NULL; *argcPtr = argc; *argvPtr = argv; } /*---------------------------------------------------------------------- * set the toplevel window icon *----------------------------------------------------------------------*/ typedef struct TkWmInfo { TkWindow *winPtr; HWND hwnd; } WmInfo; static int Proc_LoadIcon(ClientData data, Tcl_Interp *interp, int argc, char **argv) { TkWindow *winPtr; HANDLE hIcon; HWND hwnd = NULL; if (2 != argc) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " iconname\"", (char *) NULL); return TCL_ERROR; } winPtr = (TkWindow *) Tk_MainWindow (interp); if (NULL != winPtr && NULL != winPtr->wmInfoPtr) hwnd = winPtr->wmInfoPtr->hwnd; if (!hwnd) { Tcl_SetResult (interp, "toplevel window has not been created/mapped", TCL_STATIC); return TCL_ERROR; } if (argv[1][0] == '@') hIcon = LoadImage (NULL, &argv[1][1], IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE); else hIcon = (HANDLE) LoadIcon (myInstance, argv[1]); if (!hIcon) { Tcl_SetResult (interp, "icon not found", TCL_STATIC); return TCL_ERROR; } SetClassLongPtr (hwnd, GCLP_HICON, (LONG_PTR)hIcon); Tcl_ResetResult (interp); return TCL_OK; } CGNS-4.5.0/src/cgnstools/cgnsview/000077500000000000000000000000001474000356600167065ustar00rootroot00000000000000CGNS-4.5.0/src/cgnstools/cgnsview/CMakeLists.txt000066400000000000000000000045031474000356600214500ustar00rootroot00000000000000############# # cgnsview # ############# # Define source files if (WIN32) if (HTML_HELP_INCLUDE_PATH AND HTML_HELP_LIBRARY) set(cgnsview_FILES cgiotcl.c winmain.c ../common/winhtml.c) else () set(cgnsview_FILES cgiotcl.c winmain.c) endif () else () set(cgnsview_FILES cgiowish.c cgiotcl.c) endif () # Define target add_executable(cgiowish ${cgnsview_FILES}) target_include_directories(cgiowish PRIVATE ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR}) target_include_directories(cgiowish PRIVATE ../common) target_include_directories(cgiowish PRIVATE ../..) if(CGNS_USE_SHARED) set(CGNSVIEW_LK_LIBS cgns_shared) else() set(CGNSVIEW_LK_LIBS cgns_static) endif() if (CGNS_ENABLE_HDF5 AND HDF5_LIBRARY) list(APPEND CGNSVIEW_LK_LIBS ${HDF5_LIBRARY}) if(HDF5_NEED_ZLIB AND ZLIB_LIBRARY) list(APPEND CGNSVIEW_LK_LIBS ${ZLIB_LIBRARY}) endif() if(HDF5_NEED_SZIP AND SZIP_LIBRARY) list(APPEND CGNSVIEW_LK_LIBS ${SZIP_LIBRARY}) endif() if(HDF5_NEED_MPI AND MPI_LIBS) list(APPEND CGNSVIEW_LK_LIBS ${MPI_LIBS}) endif() endif () list(APPEND CGNSVIEW_LK_LIBS ${TCL_LIBRARY} ${TK_LIBRARY}) if (WIN32) if (HTML_HELP_INCLUDE_PATH AND HTML_HELP_LIBRARY) add_definitions(-DUSE_HTMLHELP) target_include_directories(cgiowish PRIVATE ${HTML_HELP_INCLUDE_PATH}) list(APPEND CGNSVIEW_LK_LIBS ${HTML_HELP_LIBRARY}) endif () else () target_include_directories(cgiowish PRIVATE ${X11_X11_INCLUDE_PATH}) list(APPEND CGNSVIEW_LK_LIBS ${X11_X11_LIB} m) endif () target_link_libraries(cgiowish PRIVATE ${CGNSVIEW_LK_LIBS}) if (WIN32) set_target_properties(cgiowish PROPERTIES LINK_FLAGS /subsystem:windows) endif () if (WIN32) install(TARGETS cgiowish RUNTIME DESTINATION bin) install(PROGRAMS cgnsview.bat cgnsnodes.bat DESTINATION bin) install(FILES cgnsview.tcl cgns.tcl cgnsnodes.tcl export.tcl import.tcl tools.tcl DESTINATION share) else () install(TARGETS cgiowish RUNTIME DESTINATION bin/cgnstools) install(PROGRAMS cgnsview.sh DESTINATION bin RENAME cgnsview) install(PROGRAMS cgnsview.desktop DESTINATION bin) install(PROGRAMS cgnsnodes.sh DESTINATION bin RENAME cgnsnodes) install(PROGRAMS cgnsnodes.desktop DESTINATION bin) install(FILES cgnsview.tcl cgns.tcl cgnsnodes.tcl export.tcl import.tcl tools.tcl DESTINATION share/cgnstools) endif () CGNS-4.5.0/src/cgnstools/cgnsview/Makefile.unix000066400000000000000000000061131474000356600213310ustar00rootroot00000000000000# Makefile for adfviewer include ../make.defs COPTS = $(CFLAGS) -I$(CGNSDIR) $(TKINCS) LDLIST = $(CGNSLIB) $(BUILDLIBS) $(TKLIBS) $(X11LIBS) $(CLIBS) #-------------------------------------------------- all : cgiowish$(EXE) cgiowish$(EXE) : cgiowish.$(O) cgiotcl.$(O) $(CGNSLIB) $(CC) $(LDFLAGS) -o $@ cgiowish.$(O) cgiotcl.$(O) $(LDLIST) $(STRIP) $@ cgiowish.$(O) : cgiowish.c cgiotcl.$(O) : cgiotcl.c #--------------------------------------------------------------- TCLSCRIPTS = \ cgnsview.tcl \ balloon.tcl \ cgns.tcl \ cgnsnodes.tcl \ combobox.tcl \ config.tcl \ dialog.tcl \ editfile.tcl \ export.tcl \ filesel.tcl \ findfile.tcl \ frame.tcl \ help.tcl \ import.tcl \ menubar.tcl \ tclreg.tcl \ tkdir.tcl \ tools.tcl \ tree.tcl \ units.tcl \ tclIndex ICONS = cgns.ico cgns.png cgns-icon.xbm cgns-mask.xbm install : install-dirs install-prog install-wish install-script install-dirs : @for d in \ $(BIN_INSTALL_DIR) \ $(EXE_INSTALL_DIR) \ $(WSH_INSTALL_DIR) \ $(LIB_INSTALL_DIR) ; do \ if [ ! -d $$d ] ; then \ echo "Making directory $$d"; \ mkdir -p $$d; \ chmod 755 $$d; \ fi; \ done; install-prog : $(ALL) @echo "installing shell scripts to $(BIN_INSTALL_DIR)" @$(INSTALL_PROG) cgnsview.sh $(BIN_INSTALL_DIR)/cgnsview @$(INSTALL_PROG) cgnsview.desktop $(BIN_INSTALL_DIR)/ @chmod +x $(BIN_INSTALL_DIR)/cgnsview $(BIN_INSTALL_DIR)/cgnsview.desktop @$(INSTALL_PROG) cgnsnodes.sh $(BIN_INSTALL_DIR)/cgnsnodes @$(INSTALL_PROG) cgnsnodes.desktop $(BIN_INSTALL_DIR)/ @chmod +x $(BIN_INSTALL_DIR)/cgnsnodes $(BIN_INSTALL_DIR)/cgnsnodes.desktop @if [ ! -f $(EXE_INSTALL_DIR)/cgconfig ] ; then \ echo "installing configuration file to $(EXE_INSTALL_DIR)"; \ $(INSTALL_DATA) ../cgconfig $(EXE_INSTALL_DIR)/cgconfig; \ fi; install-wish : cgiowish$(EXE) @echo "installing cgiowish executable to $(WSH_INSTALL_DIR)" @$(INSTALL_PROG) cgiowish$(EXE) $(WSH_INSTALL_DIR) install-script : @echo "installing tcl scripts to $(LIB_INSTALL_DIR)" @for i in *.tcl ; do \ $(INSTALL_DATA) $$i $(LIB_INSTALL_DIR); \ done; @for i in ../common/*.tcl ; do \ $(INSTALL_DATA) $$i $(LIB_INSTALL_DIR); \ done; @$(INSTALL_DATA) ../common/tclIndex $(LIB_INSTALL_DIR) @echo "installing icons to $(LIB_INSTALL_DIR)" @for i in $(ICONS) ; do \ $(INSTALL_DATA) ../common/$$i $(LIB_INSTALL_DIR); \ done; uninstall : @echo "uninstalling executables" @for i in cgnsview cgnsnodes ; do \ if [ -f $(BIN_INSTALL_DIR)/$$i ] ; then \ /bin/rm -f $(BIN_INSTALL_DIR)/$$i; \ fi; \ done; @if [ -f $(WSH_INSTALL_DIR)/cgiowish$(EXE) ] ; then \ /bin/rm -f $(WSH_INSTALL_DIR)/cgiowish$(EXE); \ fi; @echo "uninstalling tcl scripts" @for i in $(TCLSCRIPTS) ; do \ if [ -f $(LIB_INSTALL_DIR)/$$i ] ; then \ /bin/rm -f $(LIB_INSTALL_DIR)/$$i; \ fi; \ done; @echo "uninstalling icons" @for i in $(ICONS) ; do \ if [ -f $(LIB_INSTALL_DIR)/$$i ] ; then \ /bin/rm -f $(LIB_INSTALL_DIR)/$$i; \ fi; \ done; #--------------------------------------------------------------- .c.$(O) : $(CC) $(COPTS) -c $< clean: $(RM) *.$(O) *~ *.bak cgiowish$(EXE) CGNS-4.5.0/src/cgnstools/cgnsview/Makefile.win000066400000000000000000000034321474000356600211440ustar00rootroot00000000000000include ..\make.win COPTS = $(CFLAGS) -I$(CGNSDIR) $(TCLINC) #-------------------------------------------------- all : cgiowish.exe dll : cgiotcl.dll #-------------------------------------------------- cgiowish.exe : winmain.obj cgiotcl.obj $(WINHTML_OBJ) $(LINK) $(LFLAGS) /nodefaultlib /subsystem:windows \ -out:$@ winmain.obj cgiotcl.obj $(WINHTML_OBJ) \ $(CGNSLIB) $(CLIBS) $(BUILDLIBS) $(TCLLIB) $(TKLIB) \ $(guilibs) $(WINHTML_LIB) winmain.obj : winmain.c $(CC) $(COPTS) $(WINHTML_OPT) -c winmain.c cgiotcl.obj : cgiotcl.c $(CC) $(COPTS) -c cgiotcl.c #-------------------------------------------------- cgiotcl.dll : cgiotcl-dll.obj $(CGNSLIB) $(LINK) -dll -out:cgiotcl.dll cgiotcl-dll.obj \ $(CGNSLIB) $(CLIBS) $(TCLLIB) $(TKLIB) $(dlllibs) cgiotcl-dll.obj : cgiotcl.c $(CC) $(COPTS) -DBUILD_DLL -Fo$@ -c cgiotcl.c #-------------------------------------------------- winhtml.obj : ..\common\winhtml.c $(CC) $(COPTS) $(WINHTML_INC) -Fowinhtml.obj -c ..\common\winhtml.c #--------------------------------------------------------------- install : cgiowish.exe $(BINDIR) $(SHAREDIR) -$(INSTALL) cgiowish.exe $(BINDIR) -$(INSTALL) cgnsview.bat $(BINDIR) -$(INSTALL) cgnsnodes.bat $(BINDIR) -$(INSTALL) *.tcl $(SHAREDIR) -$(INSTALL) *.ico $(SHAREDIR) -$(INSTALL) ..\common\tclIndex $(SHAREDIR) -$(INSTALL) ..\common\*.tcl $(SHAREDIR) -$(INSTALL) ..\common\*.ico $(SHAREDIR) $(BINDIR) : $(INSTALLDIR) -mkdir $(BINDIR) $(SHAREDIR) : $(INSTALLDIR) -mkdir $(SHAREDIR) $(INSTALLDIR) : -mkdir $(INSTALLDIR) #-------------------------------------------------- .c.obj : $(CC) $(COPTS) -Fo$@ -c $< .obj.exe : $(LINK) $(LFLAGS) /out:$@ $< $(CGNSLIB) $(BUILDLIBS) clean: -$(RM) *.obj -$(RM) *.lib -$(RM) *.exp -$(RM) *.pdb -$(RM) *.ilk -$(RM) *.exe -$(RM) *.dll -$(RM) *.bak CGNS-4.5.0/src/cgnstools/cgnsview/cgiotcl.c000066400000000000000000002121001474000356600204720ustar00rootroot00000000000000#include #include #include #include #include "tk.h" #include "cgns_io.h" #include "cgnslib.h" /* only needed for CGNS_VERSION */ #ifndef CGNSTYPES_H # define cgsize_t int # define cglong_t long # define cgulong_t unsigned long #endif #ifndef CONST # define CONST #endif /* these are the data types as used in CGIO */ #define I4 int #define U4 unsigned int #define I8 cglong_t #define U8 cgulong_t #define R4 float #define R8 double #define X4 float #define X8 double #define C1 char #define B1 unsigned char enum DataTags { MTdata = 0, I4data, I8data, U4data, U8data, R4data, R8data, X4data, X8data, C1data, B1data, LKdata }; static struct DataType { char *name; int type; int bytes; int size; } DataList[] = { {"MT", MTdata, 0, 0}, {"I4", I4data, 4, sizeof(I4)}, {"I8", I8data, 8, sizeof(I8)}, {"U4", U4data, 4, sizeof(U4)}, {"U8", U8data, 8, sizeof(U8)}, {"R4", R4data, 4, sizeof(R4)}, {"R8", R8data, 8, sizeof(R8)}, {"X4", X4data, 8, sizeof(X4)*2}, {"X8", X8data, 16, sizeof(X8)*2}, {"C1", C1data, 1, 1}, {"B1", B1data, 1, 1}, {"LK", LKdata, 0, 0} }; #define NumDataTypes (sizeof(DataList)/sizeof(struct DataType)) static int cgioNum = 0; static double RootID = 0.0; /*=================================================================== * local routines *===================================================================*/ /*---------- get_error ---------------------------------------------- * save error message *-------------------------------------------------------------------*/ static int get_error (Tcl_Interp *interp, char *funcname) { char errmsg[CGIO_MAX_ERROR_LENGTH+1]; cgio_error_message (errmsg); Tcl_AppendResult (interp, /*funcname, ":",*/ errmsg, NULL); return TCL_ERROR; } /*---------- get_node ---------------------------------------------- * get the node ID for a node *------------------------------------------------------------------*/ static int get_node (Tcl_Interp *interp, char *nodename, double *nodeid) { if (!*nodename || 0 == strcmp (nodename, "/")) *nodeid = RootID; else { if (cgio_get_node_id (cgioNum, RootID, nodename, nodeid)) return (get_error (interp, "cgio_get_node_id")); } return TCL_OK; } /*---------- get_parent ---------------------------------------------- * get the parent node ID for a node *------------------------------------------------------------------*/ static char *get_parent (Tcl_Interp *interp, char *nodename, double *nodeid) { char *node; if (!*nodename || 0 == strcmp (nodename, "/") || NULL == (node = strrchr (nodename, '/'))) { Tcl_AppendResult (interp, "node does not have a parent", NULL); return NULL; } if (node == nodename) *nodeid = RootID; else { *node = 0; if (cgio_get_node_id (cgioNum, RootID, nodename, nodeid)) { get_error (interp, "cgio_get_node_id"); return NULL; } *node = '/'; } return (++node); } /*---------- data_size --------------------------------------------- * return number of data values for a node *------------------------------------------------------------------*/ static cgsize_t data_size (Tcl_Interp *interp, double nodeid) { int n, ndim; cgsize_t np, dims[CGIO_MAX_DIMENSIONS]; if (cgio_get_dimensions (cgioNum, nodeid, &ndim, dims)) { get_error (interp, "cgio_get_dimensions"); return -1; } if (ndim == 0) return 0; for (np = 1, n = 0; n < ndim; n++) np *= dims[n]; return np; } /*---------- data_type --------------------------------------------- * return number of data values for a node *------------------------------------------------------------------*/ static struct DataType * data_type (Tcl_Interp *interp, double nodeid) { int n; char type[CGIO_MAX_DATATYPE_LENGTH+1]; if (cgio_get_data_type (cgioNum, nodeid, type)) { get_error (interp, "cgio_get_data_type"); return NULL; } for (n = 0; n < CGIO_MAX_DATATYPE_LENGTH && type[n]; n++) { if (islower (type[n])) type[n] = toupper (type[n]); } for (n = 0; n < NumDataTypes; n++) { if (0 == strncmp (type, DataList[n].name, 2)) return (&DataList[n]); } Tcl_AppendResult (interp, "unrecognized data type:", type, NULL); return NULL; } /*---------- convert_C1 -------------------------------------------- * convert data from C1 *------------------------------------------------------------------*/ static char *convert_C1 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; C1 *d = (C1 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == C1data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case I4data: { I4 *i = (I4 *)newdata; for (n = 0; n < np; n++) *i++ = (I4)*d++; break; } case U4data: { U4 *u = (U4 *)newdata; for (n = 0; n < np; n++) *u++ = (U4)*d++; break; } case I8data: { I8 *i = (I8 *)newdata; for (n = 0; n < np; n++) *i++ = (I8)*d++; break; } case U8data: { U8 *u = (U8 *)newdata; for (n = 0; n < np; n++) *u++ = (U8)*d++; break; } case R4data: { R4 *r = (R4 *)newdata; for (n = 0; n < np; n++) *r++ = (R4)*d++; break; } case R8data: { R8 *r = (R8 *)newdata; for (n = 0; n < np; n++) *r++ = (R8)*d++; break; } case X4data: { X4 *x = (X4 *)newdata; for (n = 0; n < np; n++) { *x++ = (X4)*d++; *x++ = 0.0; } break; } case X8data: { X8 *x = (X8 *)newdata; for (n = 0; n < np; n++) { *x++ = (X8)*d++; *x++ = 0.0; } break; } case B1data: { B1 *b = (B1 *)newdata; for (n = 0; n < np; n++) *b++ = (B1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*---------- convert_B1 -------------------------------------------- * convert data from B1 *------------------------------------------------------------------*/ static char *convert_B1 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; B1 *d = (B1 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == B1data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case I4data: { I4 *i = (I4 *)newdata; for (n = 0; n < np; n++) *i++ = (I4)*d++; break; } case U4data: { U4 *u = (U4 *)newdata; for (n = 0; n < np; n++) *u++ = (U4)*d++; break; } case I8data: { I8 *i = (I8 *)newdata; for (n = 0; n < np; n++) *i++ = (I8)*d++; break; } case U8data: { U8 *u = (U8 *)newdata; for (n = 0; n < np; n++) *u++ = (U8)*d++; break; } case R4data: { R4 *r = (R4 *)newdata; for (n = 0; n < np; n++) *r++ = (R4)*d++; break; } case R8data: { R8 *r = (R8 *)newdata; for (n = 0; n < np; n++) *r++ = (R8)*d++; break; } case X4data: { X4 *x = (X4 *)newdata; for (n = 0; n < np; n++) { *x++ = (X4)*d++; *x++ = 0.0; } break; } case X8data: { X8 *x = (X8 *)newdata; for (n = 0; n < np; n++) { *x++ = (X8)*d++; *x++ = 0.0; } break; } case C1data: { C1 *c = (C1 *)newdata; for (n = 0; n < np; n++) *c++ = (C1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*---------- convert_I4 -------------------------------------------- * convert data from I4 *------------------------------------------------------------------*/ static char *convert_I4 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; I4 *d = (I4 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == I4data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case U4data: { U4 *u = (U4 *)newdata; for (n = 0; n < np; n++) *u++ = (U4)*d++; break; } case I8data: { I8 *i = (I8 *)newdata; for (n = 0; n < np; n++) *i++ = (I8)*d++; break; } case U8data: { U8 *u = (U8 *)newdata; for (n = 0; n < np; n++) *u++ = (U8)*d++; break; } case R4data: { R4 *r = (R4 *)newdata; for (n = 0; n < np; n++) *r++ = (R4)*d++; break; } case R8data: { R8 *r = (R8 *)newdata; for (n = 0; n < np; n++) *r++ = (R8)*d++; break; } case X4data: { X4 *x = (X4 *)newdata; for (n = 0; n < np; n++) { *x++ = (X4)*d++; *x++ = 0.0; } break; } case X8data: { X8 *x = (X8 *)newdata; for (n = 0; n < np; n++) { *x++ = (X8)*d++; *x++ = 0.0; } break; } case C1data: { C1 *c = (C1 *)newdata; for (n = 0; n < np; n++) *c++ = (C1)*d++; break; } case B1data: { B1 *b = (B1 *)newdata; for (n = 0; n < np; n++) *b++ = (B1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*---------- convert_U4 -------------------------------------------- * convert data from U4 *------------------------------------------------------------------*/ static char *convert_U4 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; U4 *d = (U4 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == U4data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case I4data: { I4 *i = (I4 *)newdata; for (n = 0; n < np; n++) *i++ = (I4)*d++; break; } case I8data: { I8 *i = (I8 *)newdata; for (n = 0; n < np; n++) *i++ = (I8)*d++; break; } case U8data: { U8 *u = (U8 *)newdata; for (n = 0; n < np; n++) *u++ = (U8)*d++; break; } case R4data: { R4 *r = (R4 *)newdata; for (n = 0; n < np; n++) *r++ = (R4)*d++; break; } case R8data: { R8 *r = (R8 *)newdata; for (n = 0; n < np; n++) *r++ = (R8)*d++; break; } case X4data: { X4 *x = (X4 *)newdata; for (n = 0; n < np; n++) { *x++ = (X4)*d++; *x++ = 0.0; } break; } case X8data: { X8 *x = (X8 *)newdata; for (n = 0; n < np; n++) { *x++ = (X8)*d++; *x++ = 0.0; } break; } case C1data: { C1 *c = (C1 *)newdata; for (n = 0; n < np; n++) *c++ = (C1)*d++; break; } case B1data: { B1 *b = (B1 *)newdata; for (n = 0; n < np; n++) *b++ = (B1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*---------- convert_I8 -------------------------------------------- * convert data from I8 *------------------------------------------------------------------*/ static char *convert_I8 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; I8 *d = (I8 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == I8data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case I4data: { I4 *i = (I4 *)newdata; for (n = 0; n < np; n++) *i++ = (I4)*d++; break; } case U4data: { U4 *u = (U4 *)newdata; for (n = 0; n < np; n++) *u++ = (U4)*d++; break; } case U8data: { U8 *u = (U8 *)newdata; for (n = 0; n < np; n++) *u++ = (U8)*d++; break; } case R4data: { R4 *r = (R4 *)newdata; for (n = 0; n < np; n++) *r++ = (R4)*d++; break; } case R8data: { R8 *r = (R8 *)newdata; for (n = 0; n < np; n++) *r++ = (R8)*d++; break; } case X4data: { X4 *x = (X4 *)newdata; for (n = 0; n < np; n++) { *x++ = (X4)*d++; *x++ = 0.0; } break; } case X8data: { X8 *x = (X8 *)newdata; for (n = 0; n < np; n++) { *x++ = (X8)*d++; *x++ = 0.0; } break; } case C1data: { C1 *c = (C1 *)newdata; for (n = 0; n < np; n++) *c++ = (C1)*d++; break; } case B1data: { B1 *b = (B1 *)newdata; for (n = 0; n < np; n++) *b++ = (B1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*---------- convert_U8 -------------------------------------------- * convert data from U8 *------------------------------------------------------------------*/ static char *convert_U8 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; U8 *d = (U8 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == U8data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case I4data: { I4 *i = (I4 *)newdata; for (n = 0; n < np; n++) *i++ = (I4)*d++; break; } case U4data: { U4 *u = (U4 *)newdata; for (n = 0; n < np; n++) *u++ = (U4)*d++; break; } case I8data: { I8 *i = (I8 *)newdata; for (n = 0; n < np; n++) *i++ = (I8)*d++; break; } case R4data: { R4 *r = (R4 *)newdata; for (n = 0; n < np; n++) *r++ = (R4)*d++; break; } case R8data: { R8 *r = (R8 *)newdata; for (n = 0; n < np; n++) *r++ = (R8)*d++; break; } case X4data: { X4 *x = (X4 *)newdata; for (n = 0; n < np; n++) { *x++ = (X4)*d++; *x++ = 0.0; } break; } case X8data: { X8 *x = (X8 *)newdata; for (n = 0; n < np; n++) { *x++ = (X8)*d++; *x++ = 0.0; } break; } case C1data: { C1 *c = (C1 *)newdata; for (n = 0; n < np; n++) *c++ = (C1)*d++; break; } case B1data: { B1 *b = (B1 *)newdata; for (n = 0; n < np; n++) *b++ = (B1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*---------- convert_R4 -------------------------------------------- * convert data from R4 *------------------------------------------------------------------*/ static char *convert_R4 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; R4 *d = (R4 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == R4data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case I4data: { I4 *i = (I4 *)newdata; for (n = 0; n < np; n++) *i++ = (I4)*d++; break; } case U4data: { U4 *u = (U4 *)newdata; for (n = 0; n < np; n++) *u++ = (U4)*d++; break; } case I8data: { I8 *i = (I8 *)newdata; for (n = 0; n < np; n++) *i++ = (I8)*d++; break; } case U8data: { U8 *u = (U8 *)newdata; for (n = 0; n < np; n++) *u++ = (U8)*d++; break; } case R8data: { R8 *r = (R8 *)newdata; for (n = 0; n < np; n++) *r++ = (R8)*d++; break; } case X4data: { X4 *x = (X4 *)newdata; for (n = 0; n < np; n++) { *x++ = (X4)*d++; *x++ = 0.0; } break; } case X8data: { X8 *x = (X8 *)newdata; for (n = 0; n < np; n++) { *x++ = (X8)*d++; *x++ = 0.0; } break; } case C1data: { C1 *c = (C1 *)newdata; for (n = 0; n < np; n++) *c++ = (C1)*d++; break; } case B1data: { B1 *b = (B1 *)newdata; for (n = 0; n < np; n++) *b++ = (B1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*---------- convert_R8 -------------------------------------------- * convert data from R8 *------------------------------------------------------------------*/ static char *convert_R8 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; R8 *d = (R8 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == R8data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case I4data: { I4 *i = (I4 *)newdata; for (n = 0; n < np; n++) *i++ = (I4)*d++; break; } case U4data: { U4 *u = (U4 *)newdata; for (n = 0; n < np; n++) *u++ = (U4)*d++; break; } case I8data: { I8 *i = (I8 *)newdata; for (n = 0; n < np; n++) *i++ = (I8)*d++; break; } case U8data: { U8 *u = (U8 *)newdata; for (n = 0; n < np; n++) *u++ = (U8)*d++; break; } case R4data: { R4 *r = (R4 *)newdata; for (n = 0; n < np; n++) *r++ = (R4)*d++; break; } case X4data: { X4 *x = (X4 *)newdata; for (n = 0; n < np; n++) { *x++ = (X4)*d++; *x++ = 0.0; } break; } case X8data: { X8 *x = (X8 *)newdata; for (n = 0; n < np; n++) { *x++ = (X8)*d++; *x++ = 0.0; } break; } case C1data: { C1 *c = (C1 *)newdata; for (n = 0; n < np; n++) *c++ = (C1)*d++; break; } case B1data: { B1 *b = (B1 *)newdata; for (n = 0; n < np; n++) *b++ = (B1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*---------- convert_X4 -------------------------------------------- * convert data from X4 *------------------------------------------------------------------*/ static char *convert_X4 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; X4 *d = (X4 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == X4data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case I4data: { I4 *i = (I4 *)newdata; for (n = 0; n < np; n++, d++) *i++ = (I4)*d++; break; } case U4data: { U4 *u = (U4 *)newdata; for (n = 0; n < np; n++, d++) *u++ = (U4)*d++; break; } case I8data: { I8 *i = (I8 *)newdata; for (n = 0; n < np; n++, d++) *i++ = (I8)*d++; break; } case U8data: { U8 *u = (U8 *)newdata; for (n = 0; n < np; n++, d++) *u++ = (U8)*d++; break; } case R4data: { R4 *r = (R4 *)newdata; for (n = 0; n < np; n++, d++) *r++ = (R4)*d++; break; } case R8data: { R8 *r = (R8 *)newdata; for (n = 0; n < np; n++, d++) *r++ = (R8)*d++; break; } case X8data: { X8 *x = (X8 *)newdata; for (n = 0; n < np; n++) { *x++ = (X8)*d++; *x++ = (X8)*d++; } break; } case C1data: { C1 *c = (C1 *)newdata; for (n = 0; n < np; n++, d++) *c++ = (C1)*d++; break; } case B1data: { B1 *b = (B1 *)newdata; for (n = 0; n < np; n++, d++) *b++ = (B1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*---------- convert_X8 -------------------------------------------- * convert data from C1 *------------------------------------------------------------------*/ static char *convert_X8 (size_t np, char *olddata, struct DataType *dtnew) { size_t n; X8 *d = (X8 *)olddata; char *newdata; if (np < 1 || dtnew->size == 0) return NULL; if (dtnew->type == X8data) return olddata; newdata = (char *) calloc (np, dtnew->size); if (NULL == newdata) return NULL; switch (dtnew->type) { case I4data: { I4 *i = (I4 *)newdata; for (n = 0; n < np; n++, d++) *i++ = (I4)*d++; break; } case U4data: { U4 *u = (U4 *)newdata; for (n = 0; n < np; n++, d++) *u++ = (U4)*d++; break; } case I8data: { I8 *i = (I8 *)newdata; for (n = 0; n < np; n++, d++) *i++ = (I8)*d++; break; } case U8data: { U8 *u = (U8 *)newdata; for (n = 0; n < np; n++, d++) *u++ = (U8)*d++; break; } case R4data: { R4 *r = (R4 *)newdata; for (n = 0; n < np; n++, d++) *r++ = (R4)*d++; break; } case R8data: { R8 *r = (R8 *)newdata; for (n = 0; n < np; n++, d++) *r++ = (R8)*d++; break; } case X4data: { X4 *x = (X4 *)newdata; for (n = 0; n < np; n++) { *x++ = (X4)*d++; *x++ = (X4)*d++; } break; } case C1data: { C1 *c = (C1 *)newdata; for (n = 0; n < np; n++, d++) *c++ = (C1)*d++; break; } case B1data: { B1 *b = (B1 *)newdata; for (n = 0; n < np; n++, d++) *b++ = (B1)*d++; break; } default: free (newdata); newdata = NULL; break; } return newdata; } /*=================================================================== * tcl routines *===================================================================*/ /*---------- CGNSversion ----------------------------------------------- * get CGNS library version *----------------------------------------------------------------------*/ static int CGNSversion (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char version[33]; Tcl_ResetResult (interp); if (argc != 1) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], "\"", NULL); return TCL_ERROR; } sprintf (version, "%g", CGNS_DOTVERS); Tcl_AppendResult (interp, version, NULL); return TCL_OK; } /*---------- CGNSfile -------------------------------------------------- * detect file type *----------------------------------------------------------------------*/ static int CGNSfile (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int file_type; Tcl_ResetResult (interp); if (argc != 2) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " filename\"", NULL); return TCL_ERROR; } if (cgio_check_file (argv[1], &file_type)) return (get_error (interp, "cgio_check_file")); if (file_type == CGIO_FILE_ADF) Tcl_SetResult (interp, "adf", TCL_STATIC); else if (file_type == CGIO_FILE_HDF5) Tcl_SetResult (interp, "hdf5", TCL_STATIC); else { Tcl_SetResult (interp, "unknown file type", TCL_STATIC); return TCL_ERROR; } return TCL_OK; } /*---------- CGIOsupported ---------------------------------------------- * get supported file types *----------------------------------------------------------------------*/ static int CGIOsupported (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int type = CGIO_FILE_NONE; Tcl_ResetResult (interp); if (argc < 1 || argc > 2) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " ?type?\"", NULL); return TCL_ERROR; } if (argc == 2) { switch (argv[1][0]) { case 'a': case 'A': type = CGIO_FILE_ADF; break; case 'h': case 'H': type = CGIO_FILE_HDF5; break; default: Tcl_SetResult (interp, "unknown file type", TCL_STATIC); return TCL_ERROR; } } if ((type == CGIO_FILE_NONE || type == CGIO_FILE_ADF) && cgio_is_supported (CGIO_FILE_ADF) == 0) Tcl_AppendElement (interp, "adf"); if ((type == CGIO_FILE_NONE || type == CGIO_FILE_HDF5) && cgio_is_supported (CGIO_FILE_HDF5) == 0) Tcl_AppendElement (interp, "hdf5"); return TCL_OK; } /*---------- CGIOversion ------------------------------------------------ * get CGIO library version *----------------------------------------------------------------------*/ static int CGIOversion (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char version[CGIO_MAX_VERSION_LENGTH+1]; Tcl_ResetResult (interp); if (argc != 1) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], "\"", NULL); return TCL_ERROR; } if (cgioNum > 0) { if (cgio_library_version (cgioNum, version)) return (get_error (interp, "cgio_library_version")); Tcl_AppendResult (interp, version, NULL); } return TCL_OK; } /*---------- CGIOopen --------------------------------------------------- * open CGIO database *----------------------------------------------------------------------*/ static int CGIOopen (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int mode, type, cgio_num; char rootname[CGIO_MAX_NAME_LENGTH+1]; double root_id; Tcl_ResetResult (interp); if (argc < 2 || argc > 4) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " filename ?mode? ?type?\"", NULL); return TCL_ERROR; } if (cgioNum != 0) { cgio_close_file (cgioNum); cgioNum = 0; } mode = CGIO_MODE_READ; type = CGIO_FILE_NONE; if (argc > 2) { switch (argv[2][0]) { case 'r': case 'R': mode = CGIO_MODE_READ; break; case 'w': case 'W': case 'n': case 'N': mode = CGIO_MODE_WRITE; break; case 'm': case 'M': case 'a': case 'A': case 'o': case 'O': mode = CGIO_MODE_MODIFY; break; default: Tcl_SetResult (interp, "unknown file mode", TCL_STATIC); return TCL_ERROR; } if (argc > 3) { switch (argv[3][0]) { case 'a': case 'A': type = CGIO_FILE_ADF; break; case 'h': case 'H': type = CGIO_FILE_HDF5; break; default: Tcl_SetResult (interp, "unknown file type", TCL_STATIC); return TCL_ERROR; } } } if (cgio_open_file (argv[1], mode, type, &cgio_num)) return (get_error (interp, "cgio_open_file")); if (cgio_get_root_id (cgio_num, &root_id)) return (get_error (interp, "cgio_get_root_id")); if (cgio_get_name (cgio_num, root_id, rootname)) return (get_error (interp, "cgio_get_name")); cgioNum = cgio_num; RootID = root_id; Tcl_AppendResult (interp, rootname, NULL); return TCL_OK; } /*---------- CGIOsave --------------------------------------------------- * save CGIO database *----------------------------------------------------------------------*/ static int CGIOsave (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int err, type, cgio_num; Tcl_ResetResult (interp); if (argc != 3) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " filename type\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } switch (argv[2][0]) { case 'a': case 'A': type = CGIO_FILE_ADF; break; case 'h': case 'H': type = CGIO_FILE_HDF5; break; default: Tcl_SetResult (interp, "unknown file type", TCL_STATIC); return TCL_ERROR; } if (cgio_open_file (argv[1], CGIO_MODE_WRITE, type, &cgio_num)) return (get_error (interp, "cgio_open_file")); err = cgio_copy_file (cgioNum, cgio_num, 1); cgio_close_file (cgio_num); if (err) return (get_error (interp, "cgio_copy_file")); return TCL_OK; } /*---------- CGIOclose -------------------------------------------------- * close CGIO database file *----------------------------------------------------------------------*/ static int CGIOclose (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int err; Tcl_ResetResult (interp); if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } err = cgio_close_file (cgioNum); cgioNum = 0; if (err) return (get_error (interp, "cgio_close_file")); return TCL_OK; } /*---------- CGIOcompress ----------------------------------------------- * remove empty space from CGIO database file *----------------------------------------------------------------------*/ static int CGIOcompress (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int err; Tcl_ResetResult (interp); if (argc != 2) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " filename\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } err = cgio_compress_file (cgioNum, argv[1]); if (err) return (get_error (interp, "cgio_compress_file")); return TCL_OK; } /*---------- CGIOnode --------------------------------------------------- * get type of node *----------------------------------------------------------------------*/ static int CGIOnode (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int len; double node_id; Tcl_ResetResult (interp); if (argc != 2) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (0 == strcmp (argv[1], "/")) { Tcl_SetResult (interp, "root", TCL_STATIC); return TCL_OK; } if (cgio_get_node_id (cgioNum, RootID, argv[1], &node_id) == 0) { if (cgio_is_link (cgioNum, node_id, &len) == 0 && len > 0) Tcl_SetResult (interp, "link", TCL_STATIC); else Tcl_SetResult (interp, "node", TCL_STATIC); } return TCL_OK; } /*---------- CGIOname --------------------------------------------------- * get/set name for a node *----------------------------------------------------------------------*/ static int CGIOname (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char name[CGIO_MAX_NAME_LENGTH+1]; double parent_id, node_id; Tcl_ResetResult (interp); if (argc < 2 || argc > 3) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node ?newname?\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; if (argc == 3) { if (NULL == get_parent (interp, argv[1], &parent_id)) return TCL_ERROR; if (cgio_set_name (cgioNum, parent_id, node_id, argv[2])) return (get_error (interp, "cgio_set_name")); } if (cgio_get_name (cgioNum, node_id, name)) return (get_error (interp, "cgio_get_name")); Tcl_AppendResult (interp, name, NULL); return TCL_OK; } /*---------- CGIOlabel -------------------------------------------------- * get/set label for a node *----------------------------------------------------------------------*/ static int CGIOlabel (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char label[CGIO_MAX_LABEL_LENGTH+1]; double node_id; Tcl_ResetResult (interp); if (argc < 2 || argc > 3) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node ?newlabel?\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; if (argc == 3) { if (cgio_set_label (cgioNum, node_id, argv[2])) return (get_error (interp, "cgio_set_label")); } if (cgio_get_label (cgioNum, node_id, label)) return (get_error (interp, "cgio_get_label")); Tcl_AppendResult (interp, label, NULL); return TCL_OK; } /*---------- CGIOtype --------------------------------------------------- * get data type for a node *----------------------------------------------------------------------*/ static int CGIOtype (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n, ndim, err; cgsize_t np, dims[CGIO_MAX_DIMENSIONS]; char type[CGIO_MAX_DATATYPE_LENGTH+1]; double node_id; struct DataType *dtnew, *dtold; char *olddata, *newdata; Tcl_ResetResult (interp); if (argc == 1) { for (ndim = 0; ndim < NumDataTypes; ndim++) Tcl_AppendElement (interp, DataList[ndim].name); return TCL_OK; } if (argc > 3) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node ?newtype?\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; if (argc > 2) { /* get new data type */ strncpy (type, argv[2], CGIO_MAX_DATATYPE_LENGTH); type[CGIO_MAX_DATATYPE_LENGTH] = 0; for (n = 0; n < CGIO_MAX_DATATYPE_LENGTH && type[n]; n++) { if (islower (type[n])) type[n] = toupper (type[n]); } dtnew = NULL; for (n = 0; n < NumDataTypes; n++) { if (0 == strncmp (type, DataList[n].name, 2)) { dtnew = &DataList[n]; break; } } if (NULL == dtnew) { Tcl_AppendResult (interp, "unrecognized data type", NULL); return TCL_ERROR; } /* get old data type */ dtold = data_type (interp, node_id); if (NULL == dtold) return TCL_ERROR; /* convert the data */ if (dtnew->type != dtold->type) { /* get current data size */ np = 0; if (cgio_get_dimensions (cgioNum, node_id, &ndim, dims)) return (get_error (interp, "cgio_get_dimensions")); if (ndim > 0) { for (np = 1, n = 0; n < ndim; n++) np *= dims[n]; } newdata = NULL; if (np > 0 && dtold->size > 0) { olddata = (char *) malloc ((size_t)(np * dtold->size)); if (NULL == olddata) { Tcl_AppendResult (interp, "malloc failed for data", NULL); return TCL_ERROR; } if (cgio_read_all_data_type (cgioNum, node_id, dtold->name, olddata)) { free (olddata); return (get_error (interp, "cgio_read_all_data")); } switch (dtold->type) { case C1data: newdata = convert_C1 ((size_t)np, olddata, dtnew); break; case B1data: newdata = convert_B1 ((size_t)np, olddata, dtnew); break; case I4data: newdata = convert_I4 ((size_t)np, olddata, dtnew); break; case U4data: newdata = convert_U4 ((size_t)np, olddata, dtnew); break; case I8data: newdata = convert_I8 ((size_t)np, olddata, dtnew); break; case U8data: newdata = convert_U8 ((size_t)np, olddata, dtnew); break; case R4data: newdata = convert_R4 ((size_t)np, olddata, dtnew); break; case R8data: newdata = convert_R8 ((size_t)np, olddata, dtnew); break; case X4data: newdata = convert_X4 ((size_t)np, olddata, dtnew); break; case X8data: newdata = convert_X8 ((size_t)np, olddata, dtnew); break; } if (newdata != olddata) free (olddata); } /* rewrite the data */ if (NULL == newdata) ndim = 0; if (cgio_set_dimensions (cgioNum, node_id, dtnew->name, ndim, dims)) return (get_error (interp, "cgio_set_dimensions")); if (NULL != newdata) { err = cgio_write_all_data (cgioNum, node_id, newdata); free (newdata); if (err) return (get_error (interp, "cgio_write_all_data")); } } } if (cgio_get_data_type (cgioNum, node_id, type)) return (get_error (interp, "cgio_get_data_type")); Tcl_AppendResult (interp, type, NULL); return TCL_OK; } /*---------- CGIOdimensions --------------------------------------------- * get/set data dimensions for a node *----------------------------------------------------------------------*/ static int CGIOdimensions (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n; int ndim; cgsize_t dims[CGIO_MAX_DIMENSIONS]; double node_id; CONST char **args; char str[65]; Tcl_ResetResult (interp); if (argc < 2 || argc > 3) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node ?newdimensions?\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; if (argc > 2) { if (cgio_get_data_type (cgioNum, node_id, str)) return (get_error (interp, "cgio_get_data_type")); if (TCL_OK != Tcl_SplitList (interp, argv[2], &ndim, &args)) return TCL_ERROR; if (ndim > CGIO_MAX_DIMENSIONS) { Tcl_Free ((char *)args); Tcl_AppendResult (interp, "invalid number of dimensions", NULL); return TCL_ERROR; } if (ndim) { for (n = 0; n < ndim; n++) dims[n] = atoi (args[n]); Tcl_Free ((char *)args); } if (cgio_set_dimensions (cgioNum, node_id, str, ndim, dims)) return (get_error (interp, "cgio_set_dimensions")); } if (cgio_get_dimensions (cgioNum, node_id, &ndim, dims)) return (get_error (interp, "cgio_get_dimensions")); if (ndim > 0) { for (n = 0; n < ndim; n++) { sprintf (str, "%ld", (long)dims[n]); Tcl_AppendElement (interp, str); } } return TCL_OK; } /*---------- CGIOsize --------------------------------------------------- * get number of bytes of data for a node *----------------------------------------------------------------------*/ static int CGIOsize (ClientData data, Tcl_Interp *interp, int argc, char **argv) { cgsize_t np; char str[65]; double node_id; struct DataType *type; Tcl_ResetResult (interp); if (argc != 2) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; np = data_size (interp, node_id); if (np == -1) return TCL_ERROR; type = data_type (interp, node_id); if (NULL == type) return TCL_ERROR; sprintf (str, "%u", (unsigned)np * (unsigned)type->bytes); Tcl_AppendResult (interp, str, NULL); return TCL_OK; } /*---------- CGIOread --------------------------------------------------- * read node data *----------------------------------------------------------------------*/ static int CGIOread (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n; cgsize_t np; char *values, str[65]; double node_id; struct DataType *dt; Tcl_ResetResult (interp); if (argc < 2 || argc > 14) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node ?range1 range2 ...?\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; np = data_size (interp, node_id); if (np == -1) return TCL_ERROR; dt = data_type (interp, node_id); if (NULL == dt) return TCL_ERROR; if (np == 0 || dt->size == 0) return TCL_OK; values = (char *) malloc ((unsigned)np * (unsigned)dt->size + 1); if (NULL == values) { Tcl_AppendResult (interp, "malloc failed for data", NULL); return TCL_ERROR; } if (cgio_read_all_data_type (cgioNum, node_id, dt->name, values)) { free (values); return (get_error (interp, "cgio_read_all_data_type")); } if (dt->type == C1data) { values[np] = 0; Tcl_AppendResult (interp, values, NULL); } else if (dt->type == B1data) { B1 *u = (B1 *)values; for (n = 0; n < np; n++, u++) { sprintf (str, "%d", (int)*u); Tcl_AppendElement (interp, str); } } else if (dt->type == I4data) { I4 *i = (I4 *)values; for (n = 0; n < np; n++, i++) { sprintf (str, "%d", *i); Tcl_AppendElement (interp, str); } } else if (dt->type == U4data) { U4 *u = (U4 *)values; for (n = 0; n < np; n++, u++) { sprintf (str, "%u", *u); Tcl_AppendElement (interp, str); } } else if (dt->type == I8data) { I8 *i = (I8 *)values; for (n = 0; n < np; n++, i++) { sprintf (str, "%ld", *i); Tcl_AppendElement (interp, str); } } else if (dt->type == U8data) { U8 *u = (U8 *)values; for (n = 0; n < np; n++, u++) { sprintf (str, "%lu", *u); Tcl_AppendElement (interp, str); } } else if (dt->type == R4data) { R4 *r = (R4 *)values; for (n = 0; n < np; n++, r++) { sprintf (str, "%g", *r); Tcl_AppendElement (interp, str); } } else if (dt->type == R8data) { R8 *r = (R8 *)values; for (n = 0; n < np; n++, r++) { sprintf (str, "%g", *r); Tcl_AppendElement (interp, str); } } else if (dt->type == X4data) { X4 *r = (X4 *)values; for (n = 0; n < np; n++, r++) { sprintf (str, "%g %g", *r, *(r+1)); Tcl_AppendElement (interp, str); r++; } } else if (dt->type == X8data) { X8 *r = (X8 *)values; for (n = 0; n < np; n++, r++) { sprintf (str, "%g %g", *r, *(r+1)); Tcl_AppendElement (interp, str); r++; } } else { free (values); Tcl_AppendResult (interp, "internal error - should not happen", NULL); return TCL_ERROR; } free (values); return TCL_OK; } /*---------- CGIOwrite -------------------------------------------------- * write node data *----------------------------------------------------------------------*/ static int CGIOwrite (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n, nv, ns; int ndim; cgsize_t np, dims[CGIO_MAX_DIMENSIONS]; double node_id; CONST char **args; char *values, type[CGIO_MAX_DATATYPE_LENGTH+1]; struct DataType *dt = NULL; Tcl_ResetResult (interp); if (argc < 3 || argc > 5) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node type ?dimensions? ?data?\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } /* get node ID for node */ if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; /* get data type */ strncpy (type, argv[2], CGIO_MAX_DATATYPE_LENGTH); type[CGIO_MAX_DATATYPE_LENGTH] = 0; for (n = 0; n < CGIO_MAX_DATATYPE_LENGTH && type[n]; n++) { if (islower (type[n])) type[n] = toupper (type[n]); } for (n = 0; n < NumDataTypes; n++) { if (0 == strncmp (type, DataList[n].name, 2)) { dt = &DataList[n]; break; } } if (dt == NULL) { Tcl_AppendResult (interp, "data type not recognized", NULL); return TCL_ERROR; } /* get dimensions */ ndim = 0; args = NULL; if (argc > 3 && TCL_OK != Tcl_SplitList (interp, argv[3], &ndim, &args)) return TCL_ERROR; if (ndim == 0) { if (cgio_set_dimensions (cgioNum, node_id, dt->name, ndim, dims)) return (get_error (interp, "cgio_set_dimensions")); return TCL_OK; } if (ndim > CGIO_MAX_DIMENSIONS) { Tcl_Free ((char *)args); Tcl_AppendResult (interp, "invalid number of dimensions", NULL); return TCL_ERROR; } for (n = 0; n < ndim; n++) dims[n] = (cgsize_t) atol (args[n]); Tcl_Free ((char *)args); for (np = 1, n = 0; n < ndim; n++) { if (dims[n] < 1) { Tcl_AppendResult (interp, "invalid dimension", NULL); return TCL_ERROR; } np *= dims[n]; } /* create data array */ if (NULL == (values = (char *) calloc ((size_t)np, dt->size))) { Tcl_AppendResult (interp, "malloc failed for data", NULL); return TCL_ERROR; } /* get data */ if (argc > 4) { if (dt->type == C1data && ndim == 1) { strncpy (values, argv[4], (size_t)np); for (ns = (int)strlen(argv[4]); ns < np; ns++) values[ns] = ' '; } else { if (TCL_OK != Tcl_SplitList (interp, argv[4], &nv, &args)) { free (values); return TCL_ERROR; } if (nv) { if (dt->type == C1data) np /= dims[0]; if (np > nv) np = nv; if (dt->type == C1data) { char *p = values; for (n = 0; n < np; n++) { strncpy (p, args[n], (size_t)dims[0]); for (ns = (int)strlen(args[n]); ns < dims[0]; ns++) p[ns] = ' '; p += dims[0]; } } else if (dt->type == B1data) { B1 *u = (B1 *)values; for (n = 0; n < np; n++, u++) *u = (B1) atoi (args[n]); } else if (dt->type == I4data) { I4 *i = (I4 *)values; for (n = 0; n < np; n++, i++) *i = (I4) atoi (args[n]); } else if (dt->type == U4data) { U4 *u = (U4 *)values; for (n = 0; n < np; n++, u++) *u = (U4) atoi (args[n]); } else if (dt->type == I8data) { I8 *i = (I8 *)values; for (n = 0; n < np; n++, i++) *i = (I8) atol (args[n]); } else if (dt->type == U8data) { U8 *u = (U8 *)values; for (n = 0; n < np; n++, u++) *u = (U8) atol (args[n]); } else if (dt->type == R4data) { R4 *r = (R4 *)values; for (n = 0; n < np; n++, r++) *r = (R4) atof (args[n]); } else if (dt->type == R8data) { R8 *r = (R8 *)values; for (n = 0; n < np; n++, r++) *r = (R8) atof (args[n]); } else if (dt->type == X4data) { float fr, fi; X4 *r = (X4 *)values; for (n = 0; n < np; n++, r++) { if (2 != sscanf (args[n], "%f %f", &fr, &fi)) { fr = (float) atof (args[n]); fi = 0.0; } *r = (R4) fr; *++r = (R4) fi; } } else if (dt->type == X8data) { double dr, di; X8 *r = (X8 *)values; for (n = 0; n < np; n++, r++) { if (2 != sscanf (args[n], "%lf %lf", &dr, &di)) { dr = atof (args[n]); di = 0.0; } *r = (X8) dr; *++r = (X8) di; } } else { Tcl_Free ((char *)args); free (values); Tcl_AppendResult (interp, "internal error - should not happen", NULL); return TCL_ERROR; } Tcl_Free ((char *)args); } } } if (cgio_set_dimensions (cgioNum, node_id, dt->name, ndim, dims)) { free (values); return (get_error (interp, "cgio_set_dimensions")); } n = cgio_write_all_data (cgioNum, node_id, values); free (values); if (n) return (get_error (interp, "cgio_write_all_data")); return TCL_OK; } /*---------- CGIOlink --------------------------------------------------- * create/retrieve link of a node *----------------------------------------------------------------------*/ static int CGIOlink (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int file_len, name_len; char *node, *name_in_file, *file_name; double parent_id, node_id; Tcl_ResetResult (interp); if (argc < 2 || argc > 4) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node ?linknode? ?linkfile?\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (argc > 2) { if (NULL == (node = get_parent (interp, argv[1], &parent_id))) return TCL_ERROR; name_in_file = argv[2]; if (argc > 3) file_name = argv[3]; else file_name = NULL; if (cgio_create_link (cgioNum, parent_id, node, file_name, name_in_file, &node_id)) return (get_error (interp, "cgio_create_link")); } else { if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; } if (cgio_is_link (cgioNum, node_id, &name_len)) return (get_error (interp, "cgio_is_link")); if (name_len > 0) { if (cgio_link_size (cgioNum, node_id, &file_len, &name_len)) return (get_error (interp, "cgio_link_size")); file_name = (char *) malloc (file_len + name_len + 2); if (NULL == file_name) { Tcl_AppendResult (interp, "malloc failed for link", NULL); return TCL_ERROR; } name_in_file = file_name + file_len + 1; if (cgio_get_link (cgioNum, node_id, file_name, name_in_file)) { free (file_name); return (get_error (interp, "cgio_get_link")); } Tcl_AppendElement (interp, name_in_file); Tcl_AppendElement (interp, file_name); free (file_name); } return TCL_OK; } /*---------- CGIOchildren ----------------------------------------------- * retrieve children of a node *----------------------------------------------------------------------*/ static int CGIOchildren (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n, nchildren, len; char name[CGIO_MAX_NAME_LENGTH+1]; double node_id, *ids; Tcl_ResetResult (interp); if (2 != argc) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; if (cgio_number_children (cgioNum, node_id, &nchildren)) return (get_error (interp, "cgio_number_children")); if (nchildren < 1) return TCL_OK; ids = (double *) malloc (nchildren * sizeof(double)); if (NULL == ids) { Tcl_AppendResult (interp, "malloc failed for IDs", NULL); return TCL_ERROR; } if (cgio_children_ids (cgioNum, node_id, 1, nchildren, &len, ids)) { free (ids); Tcl_ResetResult (interp); return (get_error (interp, "cgio_children_ids")); } for (n = 0; n < nchildren; n++) { if (cgio_get_name (cgioNum, ids[n], name)) { free (ids); Tcl_ResetResult (interp); return (get_error (interp, "cgio_get_name")); } Tcl_AppendElement (interp, name); } free (ids); return TCL_OK; } /*---------- CGIOnumchild ----------------------------------------------- * returns number of children for a node *----------------------------------------------------------------------*/ static int CGIOnumchild (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int nchildren; double node_id; char buf[33]; Tcl_ResetResult (interp); if (2 != argc) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; if (cgio_number_children (cgioNum, node_id, &nchildren)) return (get_error (interp, "cgio_number_children")); sprintf (buf, "%d", nchildren); Tcl_AppendResult (interp, buf, NULL); return TCL_OK; } /*---------- CGIOchildname ---------------------------------------------- * retrieve child name for child index *----------------------------------------------------------------------*/ static int CGIOchildname (ClientData data, Tcl_Interp *interp, int argc, char **argv) { int len; char name[CGIO_MAX_NAME_LENGTH+1]; double node_id; Tcl_ResetResult (interp); if (3 != argc) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node childnum\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (get_node (interp, argv[1], &node_id)) return TCL_ERROR; if (cgio_children_names (cgioNum, node_id, atoi(argv[2]), 1, CGIO_MAX_NAME_LENGTH+1, &len, name)) return (get_error (interp, "cgio_children_names")); Tcl_AppendResult (interp, name, NULL); return TCL_OK; } /*---------- CGIOcreate ------------------------------------------------- * create a new node *----------------------------------------------------------------------*/ static int CGIOcreate (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char *node, label[CGIO_MAX_LABEL_LENGTH+1]; double parent_id, node_id; Tcl_ResetResult (interp); if (argc < 2 || argc > 3) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node ?label?\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (NULL == (node = get_parent (interp, argv[1], &parent_id))) return TCL_ERROR; if (cgio_create_node (cgioNum, parent_id, node, &node_id)) return (get_error (interp, "cgio_create_node")); if (argc > 2) { if (cgio_set_label (cgioNum, node_id, argv[2])) return (get_error (interp, "cgio_set_label")); } if (cgio_get_label (cgioNum, node_id, label)) return (get_error (interp, "cgio_get_label")); Tcl_AppendResult (interp, label, NULL); return TCL_OK; } /*---------- CGIOdelete ------------------------------------------------- * delete a node *----------------------------------------------------------------------*/ static int CGIOdelete (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char *node; double parent_id, node_id; Tcl_ResetResult (interp); if (argc != 2) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (NULL == (node = get_parent (interp, argv[1], &parent_id))) return TCL_ERROR; if (cgio_get_node_id (cgioNum, parent_id, node, &node_id)) return (get_error (interp, "cgio_get_node_id")); if (cgio_delete_node (cgioNum, parent_id, node_id)) return (get_error (interp, "cgio_delete_node")); return TCL_OK; } /*---------- CGIOmove --------------------------------------------------- * move a node *----------------------------------------------------------------------*/ static int CGIOmove (ClientData data, Tcl_Interp *interp, int argc, char **argv) { char *node; double parent_id, node_id, new_parent_id; Tcl_ResetResult (interp); if (argc != 3) { Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " node parent\"", NULL); return TCL_ERROR; } if (cgioNum == 0) { Tcl_AppendResult (interp, "no database is open", NULL); return TCL_ERROR; } if (NULL == (node = get_parent (interp, argv[1], &parent_id))) return TCL_ERROR; if (cgio_get_node_id (cgioNum, parent_id, node, &node_id)) return (get_error (interp, "cgio_get_node_id")); if (get_node (interp, argv[2], &new_parent_id)) return TCL_ERROR; if (cgio_move_node (cgioNum, parent_id, node_id, new_parent_id)) return (get_error (interp, "cgio_move_node")); return TCL_OK; } #ifdef SINGLE_COMMAND /*---------- CGIOcommand ---------------------------------------- * process CGIO command *--------------------------------------------------------------*/ static int CGIOcommand (ClientData data, Tcl_Interp *interp, int argc, char **argv) { static char usg_msg[] = "CGIO version\n" "CGIO supported ?type?\n" "CGIO open filename ?status? ?format?\n" "CGIO save filename format\n" "CGIO compress filename\n" "CGIO close\n" "CGIO node node\n" "CGIO name node ?newname?\n" "CGIO label node ?newlabel?\n" "CGIO type node ?newtype?\n" "CGIO dimensions node ?newdimensions?\n" "CGIO size node\n" "CGIO read node ?range1 range2 ...?\n" "CGIO write node type dimensions data\n" "CGIO link node ?linknode? ?linkfile?\n" "CGIO children node\n" "CGIO numchild node\n" "CGIO childname node childnum\n" "CGIO create node ?label?\n" "CGIO delete node\n" "CGIO move node newparent\n"; if (argc < 2) { Tcl_SetResult (interp, usg_msg, TCL_STATIC); return TCL_ERROR; } if (0 == strcmp (argv[1], "version")) return CGIOversion (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "supported")) return CGIOsupported (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "open")) return CGIOopen (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "save")) return CGIOsave (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "close")) return CGIOclose (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "compress")) return CGIOcompress (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "node")) return CGIOnode (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "name")) return CGIOname (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "label")) return CGIOlabel (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "type")) return CGIOtype (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "dimensions")) return CGIOdimensions (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "size")) return CGIOsize (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "read")) return CGIOread (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "write")) return CGIOwrite (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "link")) return CGIOlink (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "children")) return CGIOchildren (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "numchild")) return CGIOnumchild (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "childname")) return CGIOchildname (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "create")) return CGIOcreate (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "delete")) return CGIOdelete (data, interp, argc-1, argv+1); if (0 == strcmp (argv[1], "move")) return CGIOmove (data, interp, argc-1, argv+1); Tcl_SetResult (interp, usg_msg, TCL_STATIC); return TCL_ERROR; } #endif /*---------- CGIOtcl_Init --------------------------------------- * Initialize and create the commands *--------------------------------------------------------------*/ #if defined(_WIN32) && defined(BUILD_DLL) __declspec(dllexport) #endif int CGIOtcl_Init(Tcl_Interp *interp) { #ifdef SINGLE_COMMAND Tcl_CreateCommand (interp, "CGIO", (Tcl_CmdProc *)CGIOcommand, (ClientData)0, (Tcl_CmdDeleteProc *)0); #else Tcl_CreateCommand (interp, "CGIOversion", (Tcl_CmdProc *)CGIOversion, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOsupported", (Tcl_CmdProc *)CGIOsupported, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOopen", (Tcl_CmdProc *)CGIOopen, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOsave", (Tcl_CmdProc *)CGIOsave, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOclose", (Tcl_CmdProc *)CGIOclose, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOcompress", (Tcl_CmdProc *)CGIOcompress, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOnode", (Tcl_CmdProc *)CGIOnode, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOname", (Tcl_CmdProc *)CGIOname, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOlabel", (Tcl_CmdProc *)CGIOlabel, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOtype", (Tcl_CmdProc *)CGIOtype, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOdimensions", (Tcl_CmdProc *)CGIOdimensions, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOsize", (Tcl_CmdProc *)CGIOsize, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOread", (Tcl_CmdProc *)CGIOread, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOwrite", (Tcl_CmdProc *)CGIOwrite, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOlink", (Tcl_CmdProc *)CGIOlink, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOchildren", (Tcl_CmdProc *)CGIOchildren, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOnumchild", (Tcl_CmdProc *)CGIOnumchild, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOchildname", (Tcl_CmdProc *)CGIOchildname, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOcreate", (Tcl_CmdProc *)CGIOcreate, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOdelete", (Tcl_CmdProc *)CGIOdelete, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGIOmove", (Tcl_CmdProc *)CGIOmove, (ClientData)0, (Tcl_CmdDeleteProc *)0); #endif Tcl_CreateCommand (interp, "CGNSversion", (Tcl_CmdProc *)CGNSversion, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_CreateCommand (interp, "CGNSfile", (Tcl_CmdProc *)CGNSfile, (ClientData)0, (Tcl_CmdDeleteProc *)0); return TCL_OK; } CGNS-4.5.0/src/cgnstools/cgnsview/cgiowish.c000066400000000000000000000100401474000356600206610ustar00rootroot00000000000000/* * tkAppInit.c -- * * Provides a default version of the Tcl_AppInit procedure for * use in wish and similar Tk-based applications. * * Copyright (c) 1993 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #include "tk.h" #include "locale.h" #ifdef TK_TEST extern int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp)); extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp)); #endif /* TK_TEST */ extern int CGIOtcl_Init _ANSI_ARGS_((Tcl_Interp *interp)); /* *---------------------------------------------------------------------- * * main -- * * This is the main program for the application. * * Results: * None: Tk_Main never returns here, so this procedure never * returns either. * * Side effects: * Whatever the application does. * *---------------------------------------------------------------------- */ int main(argc, argv) int argc; /* Number of command-line arguments. */ char **argv; /* Values of command-line arguments. */ { /* * The following #if block allows you to change the AppInit * function by using a #define of TCL_LOCAL_APPINIT instead * of rewriting this entire file. The #if checks for that * #define and uses Tcl_AppInit if it doesn't exist. */ #ifndef TK_LOCAL_APPINIT #define TK_LOCAL_APPINIT Tcl_AppInit #endif extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp)); /* * The following #if block allows you to change how Tcl finds the startup * script, prime the library or encoding paths, fiddle with the argv, * etc., without needing to rewrite Tk_Main() */ #ifdef TK_LOCAL_MAIN_HOOK extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); TK_LOCAL_MAIN_HOOK(&argc, &argv); #endif Tk_Main(argc, argv, TK_LOCAL_APPINIT); return 0; /* Needed only to prevent compiler warning. */ } /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in the interp's result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(interp) Tcl_Interp *interp; /* Interpreter for application. */ { if (Tcl_Init(interp) == TCL_ERROR) { return TCL_ERROR; } if (Tk_Init(interp) == TCL_ERROR) { return TCL_ERROR; } Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit); #ifdef TK_TEST if (Tcltest_Init(interp) == TCL_ERROR) { return TCL_ERROR; } Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init, (Tcl_PackageInitProc *) NULL); if (Tktest_Init(interp) == TCL_ERROR) { return TCL_ERROR; } Tcl_StaticPackage(interp, "Tktest", Tktest_Init, (Tcl_PackageInitProc *) NULL); #endif /* TK_TEST */ /* * Call the init procedures for included packages. Each call should * look like this: * * if (Mod_Init(interp) == TCL_ERROR) { * return TCL_ERROR; * } * * where "Mod" is the name of the module. */ if (CGIOtcl_Init(interp) == TCL_ERROR) return TCL_ERROR; /* * Call Tcl_CreateCommand for application-specific commands, if * they weren't already created by the init procedures called above. */ /* * Specify a user-specific startup file to invoke if the application * is run interactively. Typically the startup file is "~/.apprc" * where "app" is the name of the application. If this line is deleted * then no user-specific startup file will be run under any conditions. */ Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); return TCL_OK; } CGNS-4.5.0/src/cgnstools/cgnsview/cgns.tcl000066400000000000000000002255321474000356600203550ustar00rootroot00000000000000 array set CGNSnodes { AdditionalExponents {1 AdditionalExponents_t R4 3 0} AdditionalFamilyName {0 AdditionalFamilyName_t C1 {} 1} AdditionalUnits {1 AdditionalUnits_t C1 {32 3} 0} ArbitraryGridMotion {0 ArbitraryGridMotion_t C1 {} 1} ArbitraryGridMotionPointers {1 DataArray_t C1 32 0} Area {1 Area_t MT {} 0} AreaType {1 AreaType_t C1 {} 0} AverageInterface {1 AverageInterface_t MT {} 0} AverageInterfaceType {1 AverageInterfaceType_t C1 {} 0} Axisymmetry {1 Axisymmetry_t MT {} 0} AxisymmetryAngle {1 DataArray_t R4 1 0} AxisymmetryAxisVector {1 DataArray_t R4 2 0} AxisymmetryReferencePoint {1 DataArray_t R4 2 0} BaseIterativeData {0 BaseIterativeData_t I4 1 0} BC {0 BC_t C1 {} 1} BCData {0 BCData_t MT {} 0} BCDataSet {0 BCDataSet_t C1 {} 1} BCProperty {1 BCProperty_t MT {} 0} BCRegionName {1 Descriptor_t C1 {} 1} CellListDonor {1 IndexArray_t I4 {} 0} CGNSBase {0 CGNSBase_t I4 2 1} CGNSLibraryVersion {1 CGNSLibraryVersion_t R4 1 0} ChemicalKineticsModel {1 ChemicalKineticsModel_t C1 {} 0} ConvergenceDataArray {1 DataArray_t R4 {} 1} CoordinateNames {1 DataArray_t C1 {32 2} 0} CoordinateData {0 DataArray_t R4 {} 1} DataArray {0 DataArray_t {} {} 1} DataClass {1 DataClass_t C1 {} 0} DataConversion {1 DataConversion_t R4 2 0} Descriptor {0 Descriptor_t C1 {} 1} DiffusionModel {1 \"int[1+...+IndexDimension]\" I4 {} 0} DimensionalExponents {1 DimensionalExponents_t R4 5 0} DimensionalUnits {1 DimensionalUnits_t C1 {32 5} 0} DirichletData {1 BCData_t MT {} 0} DiscreteData {0 DiscreteData_t MT {} 1} DiscreteDataArray {0 DataArray_t R4 {} 1} ElementConnectivity {1 DataArray_t I4 {} 0} ElementList {1 IndexArray_t I4 {} 0} ElementRange {1 IndexRange_t I4 {} 0} Elements {0 Elements_t I4 2 1} EMConductivityModel {1 EMConductivityModel_t C1 {} 0} EMElectricFieldModel {1 EMElectricFieldModel_t C1 {} 0} EMMagneticFieldModel {1 EMMagneticFieldModel_t C1 {} 0} EquationDimension {1 \"int\" I4 1 0} Family {0 Family_t MT {} 1} FamilyBC {1 FamilyBC_t C1 {} 0} FamilyBCDataSet {0 FamilyBCDataSet_t C1 {} 1} FamilyName {1 FamilyName_t C1 {} 0} FamilyNameReference {0 FamilyName_t C1 {} 0} FamilyPointers {1 DataArray_t C1 32 0} FlowEquationSet {1 FlowEquationSet_t MT {} 0} FlowSolution {0 FlowSolution_t MT {} 1} FlowSolutionPointers {1 DataArray_t C1 32 0} GasModel {1 GasModel_t C1 {} 0} GeometryEntity {0 GeometryEntity_t MT {} 1} GeometryFile {1 GeometryFile_t C1 {} 0} GeometryFormat {1 GeometryFormat_t C1 {} 0} GeometryReference {0 GeometryReference_t MT {} 1} GlobalConvergenceHistory {1 ConvergenceHistory_t I4 1 0} GoverningEquations {1 GoverningEquations_t C1 {} 0} Gravity {1 Gravity_t MT {} 0} GravityVector {1 DataArray_t R4 3 0} GridConnectivity {0 GridConnectivity_t C1 {} 1} GridConnectivity1to1 {0 GridConnectivity1to1_t C1 {} 1} GridConnectivityProperty {1 GridConnectivityProperty_t MT {} 0} GridConnectivityRegionName {1 Descriptor_t C1 {} 1} GridConnectivityType {1 GridConnectivityType_t C1 {} 0} GridCoordinates {0 GridCoordinates_t MT {} 1} GridCoordinatesPointers {1 DataArray_t C1 32 0} GridLocation {1 GridLocation_t C1 {} 0} GridVelocity {0 DataArray_t R4 {} 1} IndexArray {0 IndexArray_t I4 {} 0} IndexRange {0 IndexRange_t I4 {} 0} IntegralData {0 IntegralData_t MT {} 1} IntegralDataValue {0 DataArray_t R4 1 1} InterpolantsDonor {1 DataArray_t R4 {} 0} InwardNormalIndex {1 \"int[IndexDimension]\" I4 {} 0} InwardNormalList {1 IndexArray_t R4 {} 0} IterationValues {1 DataArray_t I4 {} 0} NeumannData {1 BCData_t MT {} 0} NormDefinitions {1 Descriptor_t C1 {} 0} NumberOfFamilies {1 DataArray_t I4 {} 0} NumberOfZones {1 DataArray_t I4 {} 0} Ordinal {1 Ordinal_t I4 1 0} OriginLocation {1 DataArray_t R4 {3 2} 0} OversetHoles {0 OversetHoles_t MT {} 1} ParentData {1 DataArray_t I4 {} 0} ParentElements {1 DataArray_t I4 {} 0} ParentElementsPosition {1 DataArray_t I4 {} 0} Periodic {1 Periodic_t MT {} 0} PointList {1 IndexArray_t I4 {} 0} PointListDonor {1 IndexArray_t I4 {} 0} PointRange {1 IndexRange_t I4 {} 0} PointRangeDonor {1 IndexRange_t I4 {} 0} ReferenceState {1 ReferenceState_t MT {} 0} ReferenceStateDescription {1 Descriptor_t C1 {} 0} ReferenceStateValue {0 DataArray_t R4 1 1} RegionName {1 DataArray_t C1 32 0} RigidGridMotion {0 RigidGridMotion_t C1 {} 1} RigidGridMotionPointers {1 DataArray_t C1 32 0} RigidRotationAngle {1 DataArray_t R4 3 0} RigidRotationRate {1 DataArray_t R4 3 0} RigidVelocity {1 DataArray_t R4 3 0} Rind {1 Rind_t I4 {} 0} RotatingCoordinates {1 RotatingCoordinates_t MT {} 0} RotationAngle {1 DataArray_t R4 3 0} RotationCenter {1 DataArray_t R4 3 0} RotationRateVector {1 DataArray_t R4 3 0} SimulationType {1 SimulationType_t C1 {} 0} SolutionData {0 DataArray_t R4 {} 1} SurfaceArea {1 DataArray_t R4 1 0} ThermalConductivityModel {1 ThermalConductivityModel_t C1 {} 0} ThermalRelaxationModel {1 ThermalRelaxationModel_t C1 {} 0} TimeValues {1 DataArray_t R4 {} 0} Transform {1 \"int[IndexDimension]\" I4 {} 0} Translation {1 DataArray_t R4 3 0} TurbulenceClosure {1 TurbulenceClosure_t C1 {} 0} TurbulenceModel {1 TurbulenceModel_t C1 {} 0} UserDefinedData {0 UserDefinedData_t MT {} 1} ViscosityModel {1 ViscosityModel_t C1 {} 0} WallFunction {1 WallFunction_t MT {} 0} WallFunctionType {1 WallFunctionType_t C1 {} 0} Zone {0 Zone_t I4 {} 1} ZoneBC {1 ZoneBC_t MT {} 0} ZoneConvergenceHistory {1 ConvergenceHistory_t I4 1 0} ZoneGridConnectivity {1 ZoneGridConnectivity_t MT {} 0} ZoneGridConnectivityPointers {1 DataArray_t C1 32 0} ZoneIterativeData {0 ZoneIterativeData_t MT {} 0} ZonePointers {1 DataArray_t C1 32 0} ZoneSubRegion {0 ZoneSubRegion_t I4 {} 1} ZoneSubRegionPointers {1 DataArray_t C1 32 0} ZoneType {1 ZoneType_t C1 {} 0} } array set CGNSnodeChildren { / {CGNSBase CGNSLibraryVersion} ArbitraryGridMotion_t {DataClass Descriptor DimensionalUnits \ GridLocation GridVelocity Rind UserDefinedData} Area_t {AreaType Descriptor RegionName SurfaceArea UserDefinedData} AverageInterface_t {AverageInterfaceType Descriptor UserDefinedData} Axisymmetry_t {AxisymmetryAngle AxisymmetryAxisVector \ AxisymmetryReferencePoint CoordinateNames DataClass \ Descriptor DimensionalUnits UserDefinedData} BaseIterativeData_t {DataArray DataClass Descriptor DimensionalUnits \ FamilyPointers IterationValues NumberOfFamilies NumberOfZones \ TimeValues UserDefinedData ZonePointers} BC_t {BCDataSet BCProperty DataClass Descriptor DimensionalUnits \ ElementList ElementRange FamilyName GridLocation InwardNormalIndex \ InwardNormalList Ordinal PointList PointRange \ ReferenceState UserDefinedData} BCData_t {DataArray DataClass Descriptor DimensionalUnits UserDefinedData} BCDataSet_t {DataClass Descriptor DimensionalUnits DirichletData \ NeumannData ReferenceState UserDefinedData} BCProperty_t {Area Descriptor UserDefinedData WallFunction} CGNSBase_t {Axisymmetry BaseIterativeData DataClass Descriptor \ DimensionalUnits Family FlowEquationSet GlobalConvergenceHistory \ Gravity IntegralData ReferenceState RotatingCoordinates \ SimulationType UserDefinedData Zone} ChemicalKineticsModel_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} ConvergenceHistory_t {ConvergenceDataArray DataClass Descriptor \ DimensionalUnits NormDefinitions UserDefinedData} DataArray_t {DataConversion DataClass Descriptor \ DimensionalExponents DimensionalUnits} DiscreteData_t {DataClass Descriptor DimensionalUnits \ DiscreteDataArray GridLocation Rind UserDefinedData} Elements_t {Descriptor ElementConnectivity ElementRange \ ParentData Rind UserDefinedData} Family_t {Descriptor FamilyBC GeometryReference Ordinal UserDefinedData} FamilyBCDataSet_t {DataClass Descriptor DimensionalUnits DirichletData \ NeumannData ReferenceState UserDefinedData} FlowEquationSet_t {ChemicalKineticsModel DataClass Descriptor \ DimensionalUnits EquationDimension GasModel GoverningEquations \ ThermalConductivityModel ThermalRelaxationModel TurbulenceClosure \ TurbulenceModel UserDefinedData ViscosityModel} FlowSolution_t {DataClass Descriptor DimensionalUnits \ GridLocation Rind SolutionData UserDefinedData} GasModel_t {DataArray DataClass Descriptor DimensionalUnits \ UserDefinedData} GeometryReference_t {Descriptor GeometryEntity GeometryFile \ GeometryFormat UserDefinedData} GoverningEquations_t {Descriptor DiffusionModel UserDefinedData} Gravity_t {DataClass Descriptor DimensionalUnits \ GravityVector UserDefinedData} GridConnectivity_t {CellListDonor Descriptor GridConnectivityProperty \ GridConnectivityType GridLocation InterpolantsDonor Ordinal \ PointList PointListDonor PointRange UserDefinedData} GridConnectivity1to1_t {Descriptor Ordinal PointRange PointRangeDonor \ Transform UserDefinedData} GridConnectivityProperty_t {AverageInterface Descriptor Periodic \ UserDefinedData} GridCoordinates_t {CoordinateData DataClass Descriptor DimensionalUnits \ Rind UserDefinedData} IntegralData_t {DataClass Descriptor DimensionalUnits \ IntegralDataValue UserDefinedData} OversetHoles_t {Descriptor GridLocation PointList PointRange \ UserDefinedData} Periodic_t {DataClass Descriptor DimensionalUnits RotationAngle \ RotationCenter Translation UserDefinedData} ReferenceState_t {DataClass Descriptor DimensionalUnits \ ReferenceStateDescription ReferenceStateValue UserDefinedData} RigidGridMotion_t {DataArray DataClass Descriptor DimensionalUnits \ OriginLocation RigidRotationAngle RigidRotationRate \ RigidVelocity UserDefinedData} RotatingCoordinates_t {DataClass Descriptor DimensionalUnits \ RotationCenter RotationRateVector UserDefinedData} ThermalConductivityModel_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} ThermalRelaxationModel_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} TurbulenceClosure_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} TurbulenceModel_t {DataArray DataClass Descriptor DiffusionModel \ DimensionalUnits UserDefinedData} UserDefinedData_t {DataArray DataClass Descriptor DimensionalUnits} ViscosityModel_t {DataArray DataClass Descriptor DimensionalUnits \ UserDefinedData} WallFunction_t {Descriptor UserDefinedData WallFunctionType} Zone_t {ArbitraryGridMotion DataClass Descriptor DiscreteData \ DimensionalUnits Elements FamilyName FlowEquationSet FlowSolution \ GridCoordinates IntegralData Ordinal ReferenceState RigidGridMotion \ RotatingCoordinates UserDefinedData ZoneBC ZoneConvergenceHistory \ ZoneGridConnectivity ZoneIterativeData ZoneType} ZoneBC_t {BC DataClass Descriptor DimensionalUnits ReferenceState \ UserDefinedData} ZoneGridConnectivity_t {Descriptor GridConnectivity \ GridConnectivity1to1 OversetHoles UserDefinedData} ZoneIterativeData_t {ArbitraryGridMotionPointers DataArray DataClass \ Descriptor DimensionalUnits FlowSolutionPointers \ GridCoordinatesPointers RigidGridMotionPointers UserDefinedData} ZoneSubRegion_t {BCRegionName DataArray DataClass DimensionalUnits \ Descriptor FamilyName GridConnectivityRegionName GridLocation \ PointList PointRange Rind UserDefinedData} } array set CGNSdataValues { AdditionalUnits_t {\ {Null UserDefined Ampere Abampere Statampere Edison auCurrent} \ {Null UserDefined Mole Entities StandardCubicFoot StandardCubicMeter} \ {Null UserDefined Candela Candle Carcel Hefner Violle}} AngleUnits_t {Null UserDefined Degree Radian} ArbitraryGridMotion_t {Null UserDefined NonDeformingGrid DeformingGrid} AreaType_t {Null UserDefined BleedArea CaptureArea} AverageInterfaceType_t {Null UserDefined AverageAll AverageCircumferential \ AverageRadial AverageI AverageJ AverageK} BC_t {Null UserDefined BCAxisymmetricWedge BCDegenerateLine \ BCDegeneratePoint BCDirichlet BCExtrapolate BCFarfield BCGeneral \ BCInflow BCInflowSubsonic BCInflowSupersonic BCNeumann BCOutflow \ BCOutflowSubsonic BCOutflowSupersonic BCSymmetryPlane BCSymmetryPolar \ BCTunnelInflow BCTunnelOutflow BCWall BCWallInviscid BCWallViscous \ BCWallViscousHeatFlux BCWallViscousIsothermal FamilySpecified} BCData_t {Null UserDefined Dirichlet Neumann} BCDataSet_t {Null UserDefined BCAxisymmetricWedge BCDegenerateLine \ BCDegeneratePoint BCDirichlet BCExtrapolate BCGeneral \ BCInflowSubsonic BCInflowSupersonic BCNeumann \ BCOutflowSubsonic BCOutflowSupersonic BCSymmetryPlane BCSymmetryPolar \ BCTunnelInflow BCTunnelOutflow BCWall BCWallInviscid BCWallViscous \ BCWallViscousHeatFlux BCWallViscousIsothermal FamilySpecified} ChemicalKineticsModel_t {Null UserDefined Frozen ChemicalEquilibCurveFit \ ChemicalEquilibMinimization ChemicalNonequilib} DataClass_t {Null UserDefined Dimensional NormalizedByDimensional \ NormalizedByUnknownDimensional NondimensionalParameter \ DimensionlessConstant} DimensionalUnits_t {\ {Null UserDefined Kilogram Gram Slug PoundMass} \ {Null UserDefined Meter Centimeter Millimeter Foot Inch} \ {Null UserDefined Second} \ {Null UserDefined Kelvin Celsius Rankine Fahrenheit} \ {Null UserDefined Radian Degree}} EMConductivityModel_t {Null UserDefined Constant Frozen \ Equilibrium_LinRessler Chemistry_LinRessler} EMElectricFieldModel_t {Null UserDefined Voltage Interpolated \ Constant Frozen} EMMagneticFieldModel_t {Null UserDefined Interpolated \ Constant Frozen} FamilyBC_t {Null UserDefined BCAxisymmetricWedge BCDegenerateLine \ BCDegeneratePoint BCDirichlet BCExtrapolate BCFarfield BCGeneral \ BCInflow BCInflowSubsonic BCInflowSupersonic BCNeumann BCOutflow \ BCOutflowSubsonic BCOutflowSupersonic BCSymmetryPlane BCSymmetryPolar \ BCTunnelInflow BCTunnelOutflow BCWall BCWallInviscid BCWallViscous \ BCWallViscousHeatFlux BCWallViscousIsothermal FamilySpecified} FamilyBCDataSet_t {Null UserDefined BCAxisymmetricWedge BCDegenerateLine \ BCDegeneratePoint BCDirichlet BCExtrapolate BCGeneral \ BCInflowSubsonic BCInflowSupersonic BCNeumann \ BCOutflowSubsonic BCOutflowSupersonic BCSymmetryPlane BCSymmetryPolar \ BCTunnelInflow BCTunnelOutflow BCWall BCWallInviscid BCWallViscous \ BCWallViscousHeatFlux BCWallViscousIsothermal} GasModel_t {Null UserDefined Ideal VanderWaals CaloricallyPerfect \ ThermallyPerfect ConstantDensity RedlichKwong} GoverningEquations_t {Null UserDefined FullPotential Euler NSLaminar \ NSTurbulent NSLaminarIncompressible NSTurbulentIncompressible} GridConnectivityType_t {Null UserDefined Overset Abutting Abutting1to1} GridLocation_t {Null UserDefined Vertex CellCenter FaceCenter \ IFaceCenter JFaceCenter KFaceCenter EdgeCenter} LengthUnits_t {Null UserDefined Meter Centimeter Millimeter Foot Inch} MassUnits_t {Null UserDefined Kilogram Gram Slug PoundMass} RigidGridMotion_t {Null UserDefined ConstantRate VariableRate} SimulationType_t {Null UserDefined TimeAccurate NonTimeAccurate} TemperatureUnits_t {Null UserDefined Kelvin Celsius Rankine Fahrenheit} ThermalConductivityModel_t {Null UserDefined PowerLaw SutherlandLaw \ ConstantPrandtl} ThermalRelaxationModel_t {Null UserDefined Frozen ThermalEquilib \ ThermalNonequilib} TimeUnits_t {Null UserDefined Second} TurbulenceClosure_t {Null UserDefined EddyViscosity ReynoldsStress \ ReynoldsStressAlgebraic} TurbulenceModel_t {Null UserDefined \ Algebraic_BaldwinLomax Algebraic_CebeciSmith \ HalfEquation_JohnsonKing OneEquation_BaldwinBarth \ OneEquation_SpalartAllmaras TwoEquation_JonesLaunder \ TwoEquation_MenterSST TwoEquation_Wilcox} ViscosityModel_t {Null UserDefined Constant PowerLaw SutherlandLaw} WallFunctionType_t {Null UserDefined Generic} ZoneType_t {Null UserDefined Structured Unstructured} DataType_t {Null UserDefined Integer RealSingle RealDouble Character} ElementType_t {Null UserDefined NODE BAR_2 BAR_3 TRI_3 TRI_6 QUAD_4 \ QUAD_8 QUAD_9 TETRA_4 TETRA_10 PYRA_5 PYRA_14 PENTA_6 PENTA_15 \ PENTA_18 HEXA_8 HEXA_20 HEXA_27 MIXED NGON_n} PointSet_t {Null UserDefined PointList PointListDonor PointRange \ PointRangeDonor ElementRange ElementList CellListDonor} } array set CGNSnodeDesc { AdditionalExponents_t {AdditionalExponents AdditionalExponents_t {0,1} \ {R4 or R8} 1 3 {ElectricCurrentExponent, SubstanceAmountExponent,\ LuminousIntensityExponent}} AdditionalFamilyName_t {{user defined} AdditionalFamilyName_t {0,N} \ C1 1 {length of string} {name of family}} AdditionalUnits_t {AdditionalUnits AdditionalUnits_t {0,1} C1 2 {32,3} \ {For ElectricCurrent, one of: Null, UserDefined, Ampere, Abampere,\ Statampere, Edison, auCurrent For SubstanceAmount, one of: Null, UserDefined, Mole, Entities,\ StandardCubicFoot, StandardCubicMeter For LuminousIntensity, one of: Null, UserDefined, Candela, Candle,\ Carcel, Hefner, Violle}} ArbitraryGridMotion_t {{user defined} ArbitraryGridMotion_t {0,N} C1 1 \ {length of string} {one of: Null, UserDefined, NonDeformingGrid,\ or DeformingGrid}} ArbitraryGridMotionPointers {ArbitraryGridMotionPointers DataArray_t {0,1} \ C1 2 {32,NumberOfSteps} {pointers to ArbitraryGridMotion_t nodes}} Area_t {Area Area_t {0,1} MT {} {} {}} AreaType_t {AreaType AreaType_t 1 C1 1 {length of string} {one of:\ Null, UserDefined, BleedArea, or CaptureArea}} AverageInterface_t {AverageInterface AverageInterface_t {0,1} MT {} {} {}} AverageInterfaceType_t {AverageInterfaceType AverageInterfaceType_t 1 \ C1 1 {length of string} {one of: Null, UserDefined, AverageAll,\ AverageCircumferential, AverageRadial, AverageI, AverageJ or AverageK}} Axisymmetry_t {Axisymmetry Axisymmetry_t {0,1} MT {} {} {}} AxisymmetryAngle {AxisymmetryAngle DataArray_t {0,1} R4 1 1 \ {circumferential extent}} AxisymmetryAxisVector {AxisymmetryAxisVector DataArray_t 1 R4 1 2 \ {direction cosines of rotation axis}} AxisymmetryReferencePoint {AxisymmetryReferencePoint DataArray_t 1 R4 1 2 \ {origin for defining rotation axis}} BaseIterativeData_t {{user defined} BaseIterativeData_t {0,1} I4 1 1 \ {NumberOfSteps}} BC_t {{user defined} BC_t {0,N} C1 1 {length of string} \ {one of: Null, UserDefined, BCAxisymmetricWedge, BCDegenerateLine,\ BCDegeneratePoint, BCDirichlet, BCExtrapolate, BCFarfield, BCGeneral,\ BCInflow, BCInflowSubsonic, BCInflowSupersonic, BCNeumann,\ BCOutflow, BCOutflowSubsonic, BCOutflowSupersonic,\ BCSymmetryPlane, BCSymmetryPolar, BCTunnelInflow,\ BCTunnelOutflow, BCWall, BCWallInviscid, BCWallViscous,\ BCWallViscousHeatFlux, BCWallViscousIsothermal or FamilySpecified}} BCData_t {{user defined} BCData_t {0,1} MT {} {} {}} BCDataSet_t {{user defined} BCDataSet_t {0,N} C1 1 {length of string} \ {BCTypeSimple value, one of: Null, UserDefined, BCAxisymmetricWedge,\ BCDegenerateLine, BCDegeneratePoint, BCDirichlet, BCExtrapolate,\ BCGeneral, BCInflowSubsonic, BCInflowSupersonic, BCNeumann,\ BCOutflowSubsonic, BCOutflowSupersonic, BCSymmetryPlane,\ BCSymmetryPolar, BCTunnelInflow, BCTunnelOutflow, BCWall,\ BCWallInviscid, BCWallViscous, BCWallViscousHeatFlux,\ BCWallViscousIsothermal or FamilySpecified}} BCProperty_t {BCProperty BCProperty_t {0,1} MT {} {} {}} BCRegionName {BCRegionName Descriptor_t {0,1} C1 1 \ {length of string} {name of a ZoneBC node}} CellListDonor {CellListDonor IndexArray_t {0,1} I4 2 \ {IndexDimension of donor,ListLength} \ {list of indices for cells on adjoining patch}} CGNSBase_t {{user defined} CGNSBase_t {0,N} I4 1 2 \ {CellDimension, PhysicalDimension}} CGNSLibraryVersion_t {CGNSLibraryVersion CGNSLibraryVersion_t 1 R4 1 1 \ {CGNS Mid-Level Library version number}} ChemicalKineticsModel_t {ChemicalKineticsModel ChemicalKineticsModel_t \ {0,1} C1 1 {length of string} {one of: Null, UserDefined, Frozen,\ ChemicalEquilibCurveFit, ChemicalEquilibMinimization,\ or ChemicalNonequilib}} ConvergenceDataArray {{user defined} DataArray_t {0,N} {C1,I4,R4 or R8} \ 1 NumIterations {convergence data}} ConvergenceHistory_t {{user defined} ConvergenceHistory_t {0,1} I4 1 1 \ {number of iterations}} CoordinateNames {CoordinateNames DataArray_t {0,1} C1 2 {32,2} \ {dataname identifiers for coordinates}} CoordinateData {{user defined} DataArray_t {0,N} {R4 or R8} 1 \ NumberOfVertices {coordinate component array. Data-name identifiers\ for coordinates are: CoordinateX, CoordinateY, CoordinateZ,\ CoordinateR, CoordinateTheta, CoordinatePhi, CoordinateXi,\ CoordinateEta, CoordinateZeta, CoordinateNormal and\ CoordinateTangential}} DataArray_t {{user defined} DataArray_t {0,N} {C1,I4,R4 or R8} \ {context dependent} {context dependent} {data values}} DataClass_t {DataClass DataClass_t {0,1} C1 1 {length of string} \ {one of: Null, UserDefined, Dimensional, NormalizedByDimensional,\ NormalizedByUnknownDimensional, NondimensionalParameter or\ DimensionlessConstant}} DataConversion_t {DataConversion DataConversion_t {0,1} {R4 or R8} 1 2 \ {ConversionScale, ConversionOffset}} Descriptor_t {{user defined} Descriptor_t {0,N} C1 1 {length of string} \ {description string}} DimensionalExponents_t {DimensionalExponents DimensionalExponents_t {0,1} \ {R4 or R8} 1 5 {MassExponent, LengthExponent, TimeExponent,\ TemperatureExponent, AngleExponent}} DimensionalUnits_t {DimensionalUnits DimensionalUnits_t {0,1} C1 2 {32,5} \ {For mass, one of: Null, UserDefined, Kilogram, Gram, Slug, PoundMass For length, one of: Null, UserDefined, Meter, Centimeter, Millimeter, Foot, Inch For time, one of: Null, UserDefined, Second For temperature, one of: Null, UserDefined, Kelvin, Celsius, Rankine, Fahrenheit For angles, one of: Null, UserDefined, Degree, Radian}} DirichletData {DirichletData BCData_t {0,1} MT {} {} {}} DiscreteData_t {{user defined} DiscreteData_t {0,N} MT {} {} {}} DiscreteDataArray {{user defined} DataArray_t {0,N} {C1,I4,R4 or R8} \ IndexDimension {number of vertices or cells} {additional solution data\ not normally part of the flow solution}} ElementConnectivity {ElementConnectivity DataArray_t 1 I4 1 \ {ElementDataSize} {element connectivity table}} ElementList {ElementList IndexArray_t {0,1} I4 2 \ {IndexDimension,ListLength} {list of indices for cells}} ElementRange {ElementRange IndexRange_t 1 I4 1 2 {begin and end indices}} Elements_t {{user defined} Elements_t {0,N} I4 1 2 \ {ElementType, ElementSizeBoundary element types are: 0:Null, 1:UserDefined, 2:NODE, 3:BAR_2, 4:BAR_3,\ 5:TRI_3, 6:TRI_6, 7:QUAD_4, 8:QUAD_8, 9:QUAD_9, 10:TETRA_4, 11:TETRA_10,\ 12:PYRA_5, 13:PYRA_14, 14:PENTA_6, 15:PENTA_15, 16:PENTA_18, 17:HEXA_8,\ 18:HEXA_20, 19:HEXA_27, 20:MIXED, 21+:NGON_n}} EMConductivityModel_t {EMConductivityModel EMConductivityModel_t \ {0,1} C1 1 {length of string} {one of: Null, UserDefined, Constant,\ Frozen, Equilibrium_LinRessler or Chemistry_LinRessler}} EMElectricFieldModel_t {EMElectricFieldModel EMElectricFieldModel_t \ {0,1} C1 1 {length of string} {one of: Null, UserDefined, Voltage,\ Interpolated, Constant or Frozen}} EMMagneticFieldModel_t {EMMagneticFieldModel EMMagneticFieldModel_t \ {0,1} C1 1 {length of string} {one of: Null, UserDefined, Interpolated,\ Constant or Frozen}} EquationDimension {EquationDimension \"int\" {0,1} I4 1 1 \ {EquationDimension value}} Family_t {{user defined} Family_t {0,N} MT {} {} {}} FamilyBC_t {FamilyBC FamilyBC_t {0,1} C1 1 {length of string} \ {one of: Null, UserDefined, BCAxisymmetricWedge, BCDegenerateLine,\ BCDegeneratePoint, BCDirichlet, BCExtrapolate, BCFarfield, BCGeneral,\ BCInflow, BCInflowSubsonic, BCInflowSupersonic, BCNeumann,\ BCOutflow, BCOutflowSubsonic, BCOutflowSupersonic,\ BCSymmetryPlane, BCSymmetryPolar, BCTunnelInflow,\ BCTunnelOutflow, BCWall, BCWallInviscid, BCWallViscous,\ BCWallViscousHeatFlux, BCWallViscousIsothermal or FamilySpecified}} FamilyBCDataSet_t {{user defined} FamilyBCDataSet_t {0,N} C1 1 {length of string} \ {BCTypeSimple value, one of: Null, UserDefined, BCAxisymmetricWedge,\ BCDegenerateLine, BCDegeneratePoint, BCDirichlet, BCExtrapolate,\ BCGeneral, BCInflowSubsonic, BCInflowSupersonic, BCNeumann,\ BCOutflowSubsonic, BCOutflowSupersonic, BCSymmetryPlane,\ BCSymmetryPolar, BCTunnelInflow, BCTunnelOutflow, BCWall,\ BCWallInviscid, BCWallViscous, BCWallViscousHeatFlux,\ BCWallViscousIsothermal}} FamilyName_t {FamilyName FamilyName_t {0,1} C1 1 {length of string} \ {name of CFD family}} FamilyNameReference {{FamilyParent or user defined} FamilyName_t {0,N} \ C1 1 {length of string} {name of family}} FamilyPointers {FamilyPointers DataArray_t {0,1} C1 3 \ {32,MaxNumberOfZones,NumberOfSteps} {pointers to Family_t nodes}} FlowEquationSet_t {FlowEquationSet FlowEquationSet_t {0,1} MT {} {} {}} FlowSolution_t {{user defined} FlowSolution_t {0,N} MT {} {} {}} FlowSolutionPointers {FlowSolutionPointers DataArray_t {0,1} C1 2 \ {32,NumberOfSteps} {pointers to FlowSolution_t nodes}} GasModel_t {GasModel GasModel_t {0,1} C1 1 {length of string} \ {one of: Null, UserDefined, Ideal, VanderWaals, CaloricallyPerfect,\ ThermallyPerfect, ConstantDensity, or RedlichKwong}} GeometryEntity_t {{user defined} GeometryEntity_t {0,N} MT {} {} {}} GeometryFile_t {GeometryFile GeometryFile_t 1 C1 1 {length of string} \ {name of the geometry file}} GeometryFormat_t {GeometryFormat GeometryFormat_t 1 C1 1 {length of string} \ {name of the geometry format}} GeometryReference_t {{user defined} GeometryReference_t {0,N} MT {} {} {}} GlobalConvergenceHistory {GlobalConvergenceHistory ConvergenceHistory_t \ {0,1} I4 1 1 {number of iterations}} GoverningEquations_t {GoverningEquations GoverningEquations_t {0,1} \ C1 1 {length of string} {one of: Null, UserDefined, FullPotential,\ Euler, NSLaminar, NSTurbulent, NSLaminarIncompressible\ or NSTurbulentIncompressible}} Gravity_t {Gravity Gravity_t {0,1} MT {} {} {}} GravityVector {GravityVector DataArray_t 1 {R4 or R8} 1 PhysicalDimension \ {components of the gravity vector}} GridConnectivity_t {{user defined} GridConnectivity_t {0,N} C1 1 \ {length of string} {ZoneDonorName}} GridConnectivity1to1_t {{user defined} GridConnectivity1to1_t {0,N} C1 1 \ {length of string} {ZoneDonorName}} GridConnectivityProperty_t {GridConnectivityProperty \ GridConnectivityProperty_t {0,1} MT {} {} {}} GridConnectivityRegionName {GridConnectivityRegionName Descriptor_t {0,1} \ C1 1 {length of string} {name of a ZoneGridConnectivity node}} GridConnectivityType_t {GridConnectivityType GridConnectivityType_t {0,1} \ C1 1 {length of string} {one of: Null, UserDefined, Overset,\ Abutting, or Abutting1to1}} GridCoordinates_t {{user defined} GridCoordinates_t {0,N} MT {} {} {}} GridCoordinatesPointers {GridCoordinatesPointers DataArray_t {0,1} \ C1 2 {32,NumberOfSteps} {pointers to GridCoordinates_t nodes}} GridLocation_t {GridLocation GridLocation_t {0,1} C1 1 {length of string} \ {one of: Null, UserDefined, Vertex, CellCenter, FaceCenter,\ IFaceCenter, JFaceCenter, KFaceCenter or EdgeCenter}} GridVelocity {{user defined} DataArray_t {0,N} {R4 or R8} 1 \ NumberOfVertices {component of grid velocity. Data-name identifiers\ are: GridVelocityX, GridVelocityY, GridVelocityZ, GridVelocityR,\ GridVelocityTheta, GridVelocityPhi, GridVelocityXi,\ GridVelocityEta and GridVelocityZeta}} IndexArray_t {{user defined} IndexArray_t {0,1} I4 2 \ {IndexDimension,number of items in the list} {Index coordinates of\ each point or element in the list}} IndexRange_t {{user defined} IndexRange_t {0,1} I4 2 {IndexDimension,2} \ {first indices, last indices}} \"int\" {{user defined} \"int\" {0,1} I4 1 1 {an integer value}} \"int[IndexDimension]\" {{user defined} \"int[IndexDimension]\" \ {0,1} I4 1 IndexDimension {array of integer values}} \"int[2*IndexDimension]\" {{user defined} \"int[2*IndexDimension]\" \ {0,1} I4 1 {2*IndexDimension} {array of integer values}} \"int[1+...+IndexDimension]\" {{user defined} \"int[1+...+IndexDimension]\" \ {0,1} I4 1 {1 + ... + IndexDimension} {array of integer values}} IntegralData_t {{user defined} IntegralData_t {0,N} MT {} {} {}} IntegralDataValue {{user defined} DataArray_t {0,N} {C1,I4,R4 or R8} \ 1 1 {integral data value}} InterpolantsDonor {InterpolantsDonor DataArray_t {0,1} {R4 or R8} 2 \ {CellDimension,PointListSize} {interpolants for each node}} InwardNormalIndex {InwardNormalIndex \"int[IndexDimension]\" {0,1} I4 \ 1 IndexDimension {index of inward normal}} InwardNormalList {InwardNormalList IndexArray_t {0,1} {R4 or R8} 2 \ {PhysicalDimension,number of items in the list} {physical-space\ normal vectors at each point or element in the list}} IterationValues {IterationValues DataArray_t {0,1} I4 1 NumberOfSteps \ {array of iteration values}} NeumannData {NeumannData BCData_t {0,1} MT {} {} {}} NormDefinitions {NormDefinitions Descriptor_t {0,1} C1 1 \ {length of string} {description of convergence information}} NumberOfFamilies {NumberOfFamilies DataArray_t {0,1} I4 1 NumberOfSteps \ {array of number of families involved in each time step}} NumberOfZones {NumberOfZones DataArray_t {0,1} I4 1 NumberOfSteps \ {array of number of zones involved in each time step}} Ordinal_t {Ordinal Ordinal_t {0,1} I4 1 1 \ {user-defined ordinal number (an integer)}} OriginLocation {OriginLocation DataArray_t 1 R4 2 {PhysicalDimension,2} \ {coordinates of origin before and after motion}} OversetHoles_t {{user defined} OversetHoles_t {0,N} MT {} {} {}} ParentData {ParentData DataArray_t {0,1} I4 2 {ElementSize,4} \ {Parent1[ElementSize], Parent2[ElementSize], SideOfParent1[ElementSize],\ SideOfParent2[ElementSize]}} ParentElements {ParentElements DataArray_t {0,1} I4 2 {ElementSize,2} \ {Parent1[ElementSize], Parent2[ElementSize]}} ParentElementsPosition {ParentElementsPosition DataArray_t {0,1} I4 2 \ {ElementSize,2} {SideOfParent1[ElementSize], SideOfParent2[ElementSize]}} Periodic_t {Periodic Periodic_t {0,1} MT {} {} {}} PointList {PointList IndexArray_t {0,1} I4 2 {IndexDimension,ListLength} \ {list of indices for vertices or cells}} PointListDonor {PointListDonor IndexArray_t {0,1} I4 2 \ {IndexDimension of donor,ListLength} \ {list of indices for vertices or cells on adjoining patch}} PointRange {PointRange IndexRange_t {0,1} I4 2 {IndexDimension,2} \ {begin[IndexDimension], end[IndexDimension]}} PointRangeDonor {PointRangeDonor IndexRange_t {0,1} I4 2 \ {IndexDimension of donor,2} \ {begin[IndexDimension], end[IndexDimension] for adjoining patch}} ReferenceState_t {ReferenceState ReferenceState_t {0,1} MT {} {} {}} ReferenceStateDescription {ReferenceStateDescription Descriptor_t {0,1} \ C1 1 {length of string} {reference state description}} ReferenceStateValue {{user defined} DataArray_t {0,N} {C1,I4,R4 or R8} \ 1 1 {reference state quantity}} RegionName {RegionName DataArray_t 1 C1 1 32 {name of region}} RigidGridMotion_t {{user defined} RigidGridMotion_t {0,N} C1 1 \ {length of string} {one of: Null, UserDefined, ConstantRate\ or VariableRate}} RigidGridMotionPointers {RigidGridMotionPointers DataArray_t {0,1} C1 2 \ {32,NumberOfSteps} {pointers to RigidGridMotion_t nodes}} RigidRotationAngle {RigidRotationAngle DataArray_t {0,1} {R4 or R8} \ 1 PhysicalDimension {rotation angles about each axis of the\ translated coordinate system}} RigidRotationRate {RigidRotationRate DataArray_t {0,1} {R4 or R8} \ 1 PhysicalDimension {rotation rate vector about each axis of the\ translated coordinate system}} RigidVelocity {RigidVelocity DataArray_t {0,1} {R4 or R8} \ 1 PhysicalDimension {grid velocity vector of the origin translation}} Rind_t {Rind Rind_t {0,1} I4 1 {2*IndexDimension} \ {number of planes of extra data in low i, high i, low j, high j, etc.}} RotatingCoordinates_t {RotatingCoordinates RotatingCoordinates_t {0,1} \ MT {} {} {}} RotationAngle {RotationAngle DataArray_t 1 {R4 or R8} 1 \ PhysicalDimension {defines angle from current interface to\ the connecting interface}} RotationCenter {RotationCenter DataArray_t 1 {R4 or R8} 1 \ PhysicalDimension {coordinates of center of rotation}} RotationRateVector {RotationRateVector DataArray_t 1 R4 1 PhysicalDimension \ {components of the angular velocity about the center of rotation}} SimulationType_t {SimulationType SimulationType_t {0,1} C1 1 \ {length of string} {one of: Null, UserDefined, TimeAccurate\ or NonTimeAccurate}} SolutionData {{user defined} DataArray_t {0,N} {C1,I4,R4 or R8} \ IndexDimension {number of vertices or cells} {solution data.\ See the documentation for a list of data-name identifiers}} SurfaceArea {SurfaceArea DataArray_t 1 R4 1 1 {size of area}} ThermalConductivityModel_t {ThermalConductivityModel \ ThermalConductivityModel_t {0,1} C1 1 {length of string} \ {one of: Null, UserDefined, PowerLaw, SutherlandLaw or ConstantPrandtl}} ThermalRelaxationModel_t {ThermalRelaxationModel \ ThermalRelaxationModel_t {0,1} C1 1 {length of string} \ {one of: Null, UserDefined, Frozen, ThermalEquilib or ThermalNonequilib}} TimeValues {TimeValues DataArray_t {0,1} {R4 or R8} 1 NumberOfSteps \ {array of iteration time values}} Transform {Transform \"int[IndexDimension]\" {0,1} I4 1 IndexDimension \ {shorthand for the connectivity transformation matrix}} Translation {Translation DataArray_t 1 {R4 or R8} 1 \ PhysicalDimension {defines translation from current interface to\ the connecting interface}} TurbulenceClosure_t {TurbulenceClosure TurbulenceClosure_t {0,1} C1 1 \ {length of string} {one of: Null, UserDefined, EddyViscosity,\ ReynoldsStress or ReynoldsStressAlgebraic}} TurbulenceModel_t {TurbulenceModel TurbulenceModel_t {0,1} C1 1 \ {length of string} {one of: Null, UserDefined,\ Algebraic_BaldwinLomax, Algebraic_CebeciSmith,\ HalfEquation_JohnsonKing, OneEquation_BaldwinBarth,\ OneEquation_SpalartAllmaras, TwoEquation_JonesLaunder,\ TwoEquation_MenterSST or TwoEquation_Wilcox}} UserDefinedData_t {{user defined} UserDefinedData_t {0,N} MT {} {} {}} ViscosityModel_t {ViscosityModel ViscosityModel_t {0,1} C1 1 \ {length of string} {one of: Null, UserDefined, Constant,\ PowerLaw or SutherlandLaw}} WallFunction_t {WallFunction WallFunction_t {0,1} MT {} {} {}} WallFunctionType_t {WallFunctionType WallFunctionType_t 1 C1 1 \ {length of string} {one of: Null, UserDefined, or Generic}} Zone_t {{user defined} Zone_t {0,N} I4 2 {IndexDimension,3} \ {VertexSize[IndexDimension], CellSize[IndexDimension],\ VertexSizeBoundary[IndexDimension]}} ZoneBC_t {ZoneBC ZoneBC_t {0,1} MT {} {} {}} ZoneConvergenceHistory {ZoneConvergenceHistory ConvergenceHistory_t \ {0,1} I4 1 1 {number of iterations}} ZoneGridConnectivity_t {ZoneGridConnectivity ZoneGridConnectivity_t \ {0,1} MT {} {} {}} ZoneGridConnectivityPointers {ZoneGridConnectivityPointers DataArray_t \ {0,1} C1 2 {32,NumberOfSteps} \ {pointers to ZoneGridConnectivity_t nodes}} ZoneIterativeData_t {{user defined} ZoneIterativeData_t {0,1} MT {} {} {}} ZonePointers {ZonePointers DataArray_t {0,1} C1 3 \ {32,MaxNumberOfZones,NumberOfSteps} {pointers to Zone_t nodes}} ZoneSubRegion_t {{user defined} ZoneSubRegion_t {0,N} I4 1 \ RegionCellDimension {region dimension}} ZoneSubRegionPointers {ZoneSubRegionPointers DataArray_t \ {0,1} C1 2 {32,NumberOfSteps} \ {pointers to ZoneSubRegion_t nodes}} ZoneType_t {ZoneType ZoneType_t 1 C1 1 {length of string} \ {one of: Null, UserDefined, Structured or Unstructured}} DataType_t {{} DataType_t {} C1 1 {length of string} \ {one of: Null, UserDefined, Integer, RealSingle, RealDouble\ or Character}} ElementType_t {{} ElementType_t {} C1 1 {length of string} \ {one of: Null, UserDefined, NODE, BAR_2, BAR_3, TRI_3, TRI_6, QUAD_4,\ QUAD_8, QUAD_9, TETRA_4, TETRA_10, PYRA_5, PYRA_14, PENTA_6, PENTA_15,\ PENTA_18, HEXA_8, HEXA_20, HEXA_27, MIXED, or NGON_n}} PointSet_t {{} PointSet_t {} C1 1 {length of string} \ {one of: Null, UserDefined, PointList, PointListDonor, PointRange,\ PointRangeDonor, ElementRange, ElementList, or CellListDonor}} } array set CGNSnodeRef { AdditionalExponents_t {{build DimensionalExponents} \ {physical dimensionalexponents}} AdditionalFamilyName_t {{} {families familyname}} AdditionalUnits_t {{build DimensionalUnits} {physical dimensionalunits}} ArbitraryGridMotion_t {{timedep ArbitraryGridMotion} {timedep arbitrary}} ArbitraryGridMotionPointers {} Area_t {{bc Area} {bc bcproperty}} AreaType_t {} AverageInterface_t {{cnct AverageInterface} {connectivity connproperty}} AverageInterfaceType_t {} Axisymmetry_t {{gridflow Axisymmetry} {grid axisymmetry}} AxisymmetryAngle {{} {physical dataarray}} AxisymmetryAxisVector {} AxisymmetryReferencePoint {} BaseIterativeData_t {{timedep BaseIterativeData} {timedep biter}} BC_t {{bc BC} {bc bc}} BCData_t {{bc BCData} {bc bcdata}} BCDataSet_t {{bc BCDataSet} {bc bcdataset}} BCProperty_t {{bc BCProperty} {bc bcproperty}} BCType_t {{bc BCType} {}} CellListDonor {} CGNSBase_t {{cgnsbase CGNSBase} {structural base}} CGNSLibraryVersion_t {{cgnsbase CGNSLibraryVersion} {open}} ChemicalKineticsModel_t {{floweqn ChemicalKineticsModel} \ {equation auxiliary}} ConvergenceHistory_t {{misc ConvergenceHistory} {auxiliary convergence}} CoordinateNames {{} {physical dataarray}} CoordinateData {{dataname dataname_grid} {grid gridcoordinates}} DataArray_t {{data DataArray} {physical dataarray}} DataClass_t {{build DataClass} {physical dataclass}} DataConversion_t {{data DataConversion} {physical dataconversion}} Descriptor_t {{build Descriptor} {descriptor descriptor}} DiffusionModel {{floweqn DiffusionModel} {equation governingequations}} DimensionalExponents_t {{build DimensionalExponents} \ {physical dimensionalexponents}} DimensionalUnits_t {{build DimensionalUnits} {physical dimensionalunits}} DiscreteData_t {{misc DiscreteData} {solution discretedata}} ElementConnectivity {{gridflow ElementConnectivity} {}} ElementList {} ElementRange {} Elements_t {{gridflow Elements} {grid elements}} EMConductivityModel_t {{floweqn EMConductivityModel} \ {equation auxiliary}} EMElectricFieldModel_t {{floweqn EMElectricFieldModel} \ {equation auxiliary}} EMMagneticFieldModel_t {{floweqn EMMagneticFieldModel} \ {equation auxiliary}} EquationDimension {} Family_t {{misc Family} {families family}} FamilyBC_t {{misc FamilyBC} {families familybc}} FamilyBCDataSet_t {{bc BCDataSet} {bc bcdataset}} FamilyName_t {{} {families familyname}} FamilyNameReference {{} {families familyname}} FamilyPointers {{} {physical dataarray}} FlowEquationSet_t {{floweqn FlowEquationSet} {equation flowequationset}} FlowSolution_t {{gridflow FlowSolution} {solution flowsolution}} FlowSolutionPointers {} GasModel_t {{floweqn GasModel} {equation auxiliary}} GeometryEntity_t {{} {families geometry}} GeometryFile_t {} GeometryFormat_t {} GeometryReference_t {{misc GeometryReference} {families geometry}} GoverningEquations_t {{floweqn GoverningEquations} \ {equation governingequations}} Gravity_t {{misc Gravity} {auxiliary gravity}} GravityVector {} GridConnectivity_t {{cnct GridConnectivity} {connectivity general}} GridConnectivity1to1_t {{cnct GridConnectivity1to1} {connectivity 1to1}} GridConnectivityProperty_t {{cnct GridConnectivityProperty} \ {connectivity connproperty}} GridConnectivityType_t {} GridCoordinates_t {{gridflow GridCoordinates} {grid gridcoordinates}} GridCoordinatesPointers {} GridLocation_t {{build GridLocation} {location gridlocation}} GridVelocity {} IndexArray_t {{build IndexArray} {}} IndexRange_t {{build IndexRange} {}} IntegralData_t {{misc IntegralData} {auxiliary integral}} InterpolantsDonor {} InwardNormalIndex {} InwardNormalList {} IterationValues {{} {physical dataarray}} NeumannData {} NormDefinitions {} NumberOfFamilies {{} {physical dataarray}} NumberOfZones {{} {physical dataarray}} Ordinal_t {{} {descriptor ordinal}} OriginLocation {} OversetHoles_t {{cnct OversetHoles} {connectivity overset}} ParentData {{} {grid elements}} ParentElements {{} {grid elements}} ParentElementsPosition {{} {grid elements}} Periodic_t {{cnct Periodic} {connectivity connproperty}} PointList {} PointListDonor {} PointRange {} PointRangeDonor {} ReferenceState_t {{misc ReferenceState} {auxiliary refstate}} ReferenceStateDescription {} RegionName {} RigidGridMotion_t {{timedep RigidGridMotion} {timedep rigid}} RigidGridMotionPointers {} RigidRotationAngle {} RigidRotationRate {} RigidVelocity {} Rind_t {{build Rind} {location rind}} RotatingCoordinates_t {{gridflow RotatingCoordinates} \ {grid rotatingcoordinates}} RotationAngle {} RotationCenter {} RotationRateVector {} SimulationType_t {{cgnsbase SimulationType} {structural simulationtype}} SolutionData {{dataname dataname_flow} {solution flowsolution}} SurfaceArea {} ThermalConductivityModel_t {{floweqn ThermalConductivityModel} \ {equation auxiliary}} ThermalRelaxationModel_t {{floweqn ThermalRelaxationModel} \ {equation auxiliary}} TimeValues {{} {physical dataarray}} Transform {} Translation {} TurbulenceClosure_t {{floweqn TurbulenceClosure} {equation auxiliary}} TurbulenceModel_t {{floweqn TurbulenceModel} {equation auxiliary}} UserDefinedData_t {{misc UserDefinedData} {auxiliary userdefined}} ViscosityModel_t {{floweqn ViscosityModel} {equation auxiliary}} WallFunction_t {{bc WallFunction} {bc bcproperty}} WallFunctionType_t {} Zone_t {{cgnsbase Zone} {structural zone}} ZoneBC_t {{bc ZoneBC} {bc}} ZoneGridConnectivity_t {{cnct ZoneGridConnectivity} {connectivity}} ZoneIterativeData_t {{timedep ZoneIterativeData} {timedep ziter}} ZonePointers {{} {physical dataarray}} ZoneType_t {} } set CGNSlibraryVersion 3.2 #----- initialize CGNS nodes proc cgns_init {{version ""}} { global CGNSlibraryVersion CGNSnodeChildren global CGNSnodeDesc CGNSdataValues if {$version == "" && [catch CGNSversion version]} { set CGNSlibraryVersion 3.2 } else { set CGNSlibraryVersion $version } set version [expr int(1000.0 * $CGNSlibraryVersion + 0.5)] if {$version < 2100} { array set CGNSnodeChildren { ArbitraryGridMotion_t {DataClass Descriptor DimensionalUnits \ GridLocation GridVelocity Rind} BaseIterativeData_t {DataArray DataClass Descriptor DimensionalUnits \ FamilyPointers IterationValues NumberOfFamilies NumberOfZones \ TimeValues ZonePointers} BCData_t {DataArray DataClass Descriptor DimensionalUnits} BCDataSet_t {DataClass Descriptor DimensionalUnits DirichletData \ NeumannData ReferenceState} ConvergenceHistory_t {ConvergenceDataArray DataClass Descriptor \ DimensionalUnits NormDefinitions} DiscreteData_t {DataClass Descriptor DimensionalUnits \ DiscreteDataArray GridLocation Rind} Elements_t {Descriptor ElementConnectivity ElementRange ParentData} Family_t {Descriptor FamilyBC GeometryReference Ordinal} FlowEquationSet_t {DataClass Descriptor \ DimensionalUnits EquationDimension GasModel GoverningEquations \ ThermalConductivityModel ThermalRelaxationModel TurbulenceClosure \ TurbulenceModel ViscosityModel} FlowSolution_t {DataClass Descriptor DimensionalUnits \ GridLocation Rind SolutionData} GasModel_t {DataArray DataClass Descriptor DimensionalUnits} GeometryReference_t {Descriptor GeometryEntity GeometryFile \ GeometryFormat} GridConnectivity1to1_t {Descriptor Ordinal PointRange PointRangeDonor \ Transform} GridCoordinates_t {CoordinateData DataClass Descriptor DimensionalUnits \ Rind} GoverningEquations_t {Descriptor DiffusionModel} IntegralData_t {DataClass Descriptor DimensionalUnits \ IntegralDataValue} OversetHoles_t {Descriptor GridLocation PointList PointRange} ReferenceState_t {DataClass Descriptor DimensionalUnits \ ReferenceStateDescription ReferenceStateValue} RigidGridMotion_t {DataArray DataClass Descriptor DimensionalUnits \ OriginLocation RigidRotationAngle RigidRotationRate \ RigidVelocity} ThermalConductivityModel_t {DataArray DataClass Descriptor \ DimensionalUnits} ThermalRelaxationModel_t {DataArray DataClass Descriptor \ DimensionalUnits} TurbulenceClosure_t {DataArray DataClass Descriptor \ DimensionalUnits} TurbulenceModel_t {DataArray DataClass Descriptor DiffusionModel \ DimensionalUnits} ViscosityModel_t {DataArray DataClass Descriptor DimensionalUnits} ZoneBC_t {BC DataClass Descriptor DimensionalUnits ReferenceState} ZoneGridConnectivity_t {Descriptor GridConnectivity \ GridConnectivity1to1 OversetHoles} ZoneIterativeData_t {ArbitraryGridMotionPointers DataArray DataClass \ Descriptor DimensionalUnits FlowSolutionPointers \ GridCoordinatesPointers RigidGridMotionPointers} } } else { array set CGNSnodeChildren { ArbitraryGridMotion_t {DataClass Descriptor DimensionalUnits \ GridLocation GridVelocity Rind UserDefinedData} BaseIterativeData_t {DataArray DataClass Descriptor DimensionalUnits \ FamilyPointers IterationValues NumberOfFamilies NumberOfZones \ TimeValues UserDefinedData ZonePointers} BCData_t {DataArray DataClass Descriptor DimensionalUnits UserDefinedData} BCDataSet_t {DataClass Descriptor DimensionalUnits DirichletData \ NeumannData ReferenceState UserDefinedData} ConvergenceHistory_t {ConvergenceDataArray DataClass Descriptor \ DimensionalUnits NormDefinitions} DiscreteData_t {DataClass Descriptor DimensionalUnits \ DiscreteDataArray GridLocation Rind UserDefinedData} Elements_t {Descriptor ElementConnectivity ElementRange \ ParentData UserDefinedData} Family_t {Descriptor FamilyBC GeometryReference Ordinal UserDefinedData} FlowEquationSet_t {ChemicalKineticsModel DataClass Descriptor \ DimensionalUnits EquationDimension GasModel GoverningEquations \ ThermalConductivityModel ThermalRelaxationModel TurbulenceClosure \ TurbulenceModel UserDefinedData ViscosityModel} FlowSolution_t {DataClass Descriptor DimensionalUnits \ GridLocation Rind SolutionData UserDefinedData} GasModel_t {DataArray DataClass Descriptor DimensionalUnits \ UserDefinedData} GeometryReference_t {Descriptor GeometryEntity GeometryFile \ GeometryFormat UserDefinedData} GridConnectivity1to1_t {Descriptor Ordinal PointRange PointRangeDonor \ Transform UserDefinedData} GridCoordinates_t {CoordinateData DataClass Descriptor DimensionalUnits \ Rind UserDefinedData} GoverningEquations_t {Descriptor DiffusionModel UserDefinedData} IntegralData_t {DataClass Descriptor DimensionalUnits \ IntegralDataValue UserDefinedData} OversetHoles_t {Descriptor GridLocation PointList PointRange \ UserDefinedData} ReferenceState_t {DataClass Descriptor DimensionalUnits \ ReferenceStateDescription ReferenceStateValue UserDefinedData} RigidGridMotion_t {DataArray DataClass Descriptor DimensionalUnits \ OriginLocation RigidRotationAngle RigidRotationRate \ RigidVelocity UserDefinedData} ThermalConductivityModel_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} ThermalRelaxationModel_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} TurbulenceClosure_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} TurbulenceModel_t {DataArray DataClass Descriptor DiffusionModel \ DimensionalUnits UserDefinedData} ViscosityModel_t {DataArray DataClass Descriptor DimensionalUnits \ UserDefinedData} ZoneBC_t {BC DataClass Descriptor DimensionalUnits ReferenceState \ UserDefinedData} ZoneGridConnectivity_t {Descriptor GridConnectivity \ GridConnectivity1to1 OversetHoles UserDefinedData} ZoneIterativeData_t {ArbitraryGridMotionPointers DataArray DataClass \ Descriptor DimensionalUnits FlowSolutionPointers \ GridCoordinatesPointers RigidGridMotionPointers UserDefinedData} } } if {$version < 2000} { array set CGNSnodeChildren { CGNSBase_t {DataClass Descriptor \ DimensionalUnits Family FlowEquationSet GlobalConvergenceHistory \ IntegralData ReferenceState Zone} BC_t {BCDataSet DataClass Descriptor DimensionalUnits \ ElementList ElementRange FamilyName GridLocation InwardNormalIndex \ InwardNormalList Ordinal PointList PointRange ReferenceState} GridConnectivity_t {CellListDonor Descriptor \ GridConnectivityType GridLocation InterpolantsDonor Ordinal \ PointList PointListDonor PointRange} Zone_t {DataClass Descriptor \ DiscreteData DimensionalUnits Elements FamilyName FlowEquationSet \ FlowSolution GridCoordinates IntegralData Ordinal ReferenceState \ ZoneBC ZoneConvergenceHistory ZoneGridConnectivity ZoneType} } } elseif {$version < 2100} { array set CGNSnodeChildren { CGNSBase_t {BaseIterativeData DataClass Descriptor \ DimensionalUnits Family FlowEquationSet GlobalConvergenceHistory \ IntegralData ReferenceState SimulationType Zone} BC_t {BCDataSet DataClass Descriptor DimensionalUnits \ FamilyName GridLocation InwardNormalIndex \ InwardNormalList Ordinal PointList PointRange ReferenceState} GridConnectivity_t {CellListDonor Descriptor \ GridConnectivityType GridLocation InterpolantsDonor Ordinal \ PointList PointListDonor PointRange} Zone_t {ArbitraryGridMotion DataClass Descriptor \ DiscreteData DimensionalUnits Elements FamilyName FlowEquationSet \ FlowSolution GridCoordinates IntegralData Ordinal ReferenceState \ RigidGridMotion ZoneBC ZoneConvergenceHistory ZoneGridConnectivity \ ZoneIterativeData ZoneType} } } elseif {$version < 2200} { array set CGNSnodeChildren { CGNSBase_t {BaseIterativeData DataClass Descriptor \ DimensionalUnits Family FlowEquationSet GlobalConvergenceHistory \ IntegralData ReferenceState SimulationType UserDefinedData Zone} BC_t {BCDataSet DataClass Descriptor DimensionalUnits \ FamilyName GridLocation InwardNormalIndex \ InwardNormalList Ordinal PointList PointRange \ ReferenceState UserDefinedData} GridConnectivity_t {CellListDonor Descriptor \ GridConnectivityType GridLocation InterpolantsDonor Ordinal \ PointList PointListDonor PointRange UserDefinedData} Zone_t {ArbitraryGridMotion DataClass Descriptor \ DiscreteData DimensionalUnits Elements FamilyName FlowEquationSet \ FlowSolution GridCoordinates IntegralData Ordinal ReferenceState \ RigidGridMotion UserDefinedData ZoneBC ZoneConvergenceHistory \ ZoneGridConnectivity ZoneIterativeData ZoneType} } } else { array set CGNSnodeChildren { CGNSBase_t {Axisymmetry BaseIterativeData DataClass \ Descriptor DimensionalUnits Family FlowEquationSet \ GlobalConvergenceHistory Gravity IntegralData ReferenceState \ RotatingCoordinates SimulationType UserDefinedData Zone} BC_t {BCDataSet BCProperty DataClass Descriptor DimensionalUnits \ ElementList ElementRange FamilyName GridLocation InwardNormalIndex \ InwardNormalList Ordinal PointList PointRange \ ReferenceState UserDefinedData} GridConnectivity_t {CellListDonor Descriptor GridConnectivityProperty \ GridConnectivityType GridLocation InterpolantsDonor Ordinal \ PointList PointListDonor PointRange UserDefinedData} Zone_t {ArbitraryGridMotion DataClass Descriptor \ DiscreteData DimensionalUnits Elements FamilyName FlowEquationSet \ FlowSolution GridCoordinates IntegralData Ordinal ReferenceState \ RigidGridMotion RotatingCoordinates UserDefinedData ZoneBC \ ZoneConvergenceHistory ZoneGridConnectivity ZoneIterativeData ZoneType} } } if {$version > 2300} { array set CGNSnodeChildren { BCDataSet_t {DataClass Descriptor DimensionalUnits DirichletData \ GridLocation NeumannData PointList PointRange ReferenceState \ UserDefinedData} DimensionalUnits_t {AdditionalUnits} DimensionalExponents_t {AdditionalExponents} EMConductivityModel_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} EMElectricFieldModel_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} EMMagneticFieldModel_t {DataArray DataClass Descriptor \ DimensionalUnits UserDefinedData} Family_t {Descriptor FamilyBC GeometryReference Ordinal \ RotatingCoordinates UserDefinedData} FamilyBC_t {BCDataSet} FlowEquationSet_t {ChemicalKineticsModel DataClass Descriptor \ DimensionalUnits EMConductivityModel EMElectricFieldModel \ EMMagneticFieldModel EquationDimension GasModel GoverningEquations \ ThermalConductivityModel ThermalRelaxationModel TurbulenceClosure \ TurbulenceModel UserDefinedData ViscosityModel} GridConnectivity1to1_t {Descriptor GridConnectivityProperty Ordinal \ PointRange PointRangeDonor Transform UserDefinedData} UserDefinedData_t {DataArray DataClass Descriptor DimensionalUnits \ FamilyName GridLocation Ordinal PointList PointRange UserDefinedData} } } if {$version >= 2500} { set CGNSnodeChildren(Elements_t) {Descriptor ElementConnectivity \ ElementRange ParentData Rind UserDefinedData} } if {$version >= 2530} { array set CGNSdataValues { DimensionalUnits_t {\ {Null UserDefined Kilogram Gram Slug PoundMass} \ {Null UserDefined Meter Centimeter Millimeter Foot Inch} \ {Null UserDefined Second} \ {Null UserDefined Kelvin Celsius Rankine Fahrenheit} \ {Null UserDefined Radian Degree}} TemperatureUnits_t {Null UserDefined Kelvin Celsius Rankine Fahrenheit} } } if {$version >= 3100} { array set CGNSnodeDesc { ZoneGridConnectivity_t {\ {ZoneGridConnectivity or user defined} \ ZoneGridConnectivity_t {0,N} MT {} {} {}} } array set CGNSnodeChildren { DiscreteData_t {DataClass Descriptor DimensionalUnits \ DiscreteDataArray GridLocation PointList PointRange Rind \ UserDefinedData} Elements_t {Descriptor ElementConnectivity ElementRange \ ParentElements ParentElementsPosition Rind UserDefinedData} FamilyBC_t {FamilyBCDataSet} FlowSolution_t {DataClass Descriptor DimensionalUnits \ GridLocation PointList PointRange Rind SolutionData \ UserDefinedData} ZoneIterativeData_t {ArbitraryGridMotionPointers DataArray DataClass \ Descriptor DimensionalUnits FlowSolutionPointers \ GridCoordinatesPointers RigidGridMotionPointers \ ZoneGridConnectivityPointers ZoneSubRegionPointers UserDefinedData} } if {$version >= 3200} { if {$version >= 3220} { array set CGNSnodeDesc { Elements_t {{user defined} Elements_t {0,N} I4 1 2 \ {ElementType, ElementSizeBoundary element types are: 0:Null, 1:UserDefined, 2:NODE, 3:BAR_2, 4:BAR_3,\ 5:TRI_3, 6:TRI_6, 7:QUAD_4, 8:QUAD_8, 9:QUAD_9, 10:TETRA_4, 11:TETRA_10,\ 12:PYRA_5, 13:PYRA_14, 14:PENTA_6, 15:PENTA_15, 16:PENTA_18, 17:HEXA_8,\ 18:HEXA_20, 19:HEXA_27, 20:MIXED, 21:PYRA_13, 22:NGON_n, 23:NFACE_n,\ 24:BAR_4, 25:TRI_9, 26:TRI_10, 27:QUAD_12, 28:QUAD_16, 29:TETRA_16,\ 30:TETRA_20, 31:PYRA_21, 32:PYRA_29, 33:PYRA_30, 34:PENTA_24,\ 35:PENTA_38, 36:PENTA_40, 37:HEXA_32, 38:HEXA_56, 39:HEXA_64,\ 40:BAR_5, 41:TRI_12, 42:TRI_15, 43:QUAD_P4_16, 44:QUAD_25, 45:TETRA_22,\ 46:TETRA_34, 47:TETRA_35, 48:PYRA_P4_29, 49:PYRA_50, 50:PYRA_55,\ 51:PENTA_33, 52:PENTA_66, 53:PENTA_75, 54:HEXA_44, 55:HEXA_98,\ 56:HEXA_125}} }} else { array set CGNSnodeDesc { Elements_t {{user defined} Elements_t {0,N} I4 1 2 \ {ElementType, ElementSizeBoundary element types are: 0:Null, 1:UserDefined, 2:NODE, 3:BAR_2, 4:BAR_3,\ 5:TRI_3, 6:TRI_6, 7:QUAD_4, 8:QUAD_8, 9:QUAD_9, 10:TETRA_4, 11:TETRA_10,\ 12:PYRA_5, 13:PYRA_14, 14:PENTA_6, 15:PENTA_15, 16:PENTA_18, 17:HEXA_8,\ 18:HEXA_20, 19:HEXA_27, 20:MIXED, 21:PYRA_13, 22:NGON_n, 23:NFACE_n,\ 24:BAR_4, 25:TRI_9, 26:TRI_10, 27:QUAD_12, 28:QUAD_16, 29:TETRA_16,\ 30:TETRA_20, 31:PYRA_21, 32:PYRA_29, 33:PYRA_30, 34:PENTA_24,\ 35:PENTA_38, 36:PENTA_40, 37:HEXA_32, 38:HEXA_56, 39:HEXA_64}} }} array set CGNSnodeChildren { BC_t {AdditionalFamilyName BCDataSet BCProperty DataClass Descriptor \ DimensionalUnits FamilyName GridLocation InwardNormalIndex \ InwardNormalList Ordinal PointList PointRange \ ReferenceState UserDefinedData} Family_t {Descriptor FamilyBC FamilyNameReference GeometryReference \ Ordinal RotatingCoordinates UserDefinedData} UserDefinedData_t {AdditionalFamilyName DataArray DataClass Descriptor \ DimensionalUnits FamilyName GridLocation Ordinal PointList \ PointRange UserDefinedData} Zone_t {AdditionalFamilyName ArbitraryGridMotion DataClass Descriptor \ DiscreteData DimensionalUnits Elements FamilyName FlowEquationSet \ FlowSolution GridCoordinates IntegralData Ordinal ReferenceState \ RigidGridMotion RotatingCoordinates UserDefinedData ZoneBC \ ZoneConvergenceHistory ZoneGridConnectivity ZoneIterativeData \ ZoneSubRegion ZoneType} ZoneSubRegion_t {AdditionalFamilyName BCRegionName DataArray DataClass \ DimensionalUnits Descriptor FamilyName GridConnectivityRegionName \ GridLocation PointList PointRange Rind UserDefinedData} } } else { array set CGNSnodeDesc { Elements_t {{user defined} Elements_t {0,N} I4 1 2 \ {ElementType, ElementSizeBoundary element types are: 0:Null, 1:UserDefined, 2:NODE, 3:BAR_2, 4:BAR_3,\ 5:TRI_3, 6:TRI_6, 7:QUAD_4, 8:QUAD_8, 9:QUAD_9, 10:TETRA_4, 11:TETRA_10,\ 12:PYRA_5, 13:PYRA_14, 14:PENTA_6, 15:PENTA_15, 16:PENTA_18, 17:HEXA_8,\ 18:HEXA_20, 19:HEXA_27, 20:MIXED, 21:PYRA_13, 22:NGON_n, 23:NFACE_n}} } array set CGNSnodeChildren { BC_t {BCDataSet BCProperty DataClass Descriptor DimensionalUnits \ FamilyName GridLocation InwardNormalIndex \ InwardNormalList Ordinal PointList PointRange \ ReferenceState UserDefinedData} Zone_t {ArbitraryGridMotion DataClass Descriptor DiscreteData \ DimensionalUnits Elements FamilyName FlowEquationSet FlowSolution \ GridCoordinates IntegralData Ordinal ReferenceState RigidGridMotion \ RotatingCoordinates UserDefinedData ZoneBC ZoneConvergenceHistory \ ZoneGridConnectivity ZoneIterativeData ZoneSubRegion ZoneType} } } } else { array set CGNSnodeDesc { Elements_t {{user defined} Elements_t {0,N} I4 1 2 \ {ElementType, ElementSizeBoundary element types are: 0:Null, 1:UserDefined, 2:NODE, 3:BAR_2, 4:BAR_3,\ 5:TRI_3, 6:TRI_6, 7:QUAD_4, 8:QUAD_8, 9:QUAD_9, 10:TETRA_4, 11:TETRA_10,\ 12:PYRA_5, 13:PYRA_14, 14:PENTA_6, 15:PENTA_15, 16:PENTA_18, 17:HEXA_8,\ 18:HEXA_20, 19:HEXA_27, 20:MIXED, 21+:NGON_n}} ZoneGridConnectivity_t {ZoneGridConnectivity \ ZoneGridConnectivity_t {0,1} MT {} {} {}} } } } #----- popup windows for node data proc cgns_data {} { global ProgData Node CGNSdataValues CGNSnodeDesc set label [string trim $Node(label)] if {$label != "" && [info exists CGNSdataValues($label)] && [$ProgData(text) cget -state] == "normal"} { if {$label == "DimensionalUnits_t" || $label == "AdditionalUnits_t"} { cgns_units $label } else { cgns_string $label } return } set name [string trim $Node(name)] if {$name == "" || ![info exists CGNSnodeDesc($name)]} { if {$label == "" || ![info exists CGNSnodeDesc($label)]} return set name $label } set data [string trim [lindex $CGNSnodeDesc($name) 6]] if {$data != ""} { popup_message $data -pos $ProgData(text) } } proc cgns_units {label} { global ProgData Node CGNSdataValues set data $CGNSdataValues($label) set cur [split [string trim [$ProgData(text) get 1.0 end]] "\n"] if {$label == "DimensionalUnits_t"} { set units {mass length time temp angle} set names {Mass Length Time Temperature Angle} } else { set units {current amount intensity} set names {ElectricCurrent SubstanceAmount LuminousIntensity} } set w .unitlist catch {destroy $w} toplevel $w -relief flat -bd 0 wm overrideredirect $w 1 wm transient $w . wm group $w . wm protocol $w WM_DELETE_WINDOW {set ProgData(done) 0} frame $w.outer -relief solid -bd 1 pack $w.outer -side top -fill both -expand 1 set top [frame $w.outer.top] pack $top -side top -padx 3 -pady 3 -fill x -expand 1 set n 0 foreach i $units { FrameCreate $top.$i -text [lindex $names $n] -pady 0 -padx 0 -width 15 pack $top.$i -side left -fill y -padx 2 set f [FrameGet $top.$i] foreach v [lindex $data $n] { set j [string tolower $v] radiobutton $f.$j -text $v -variable ProgData(units,$i) \ -value $v -highlightthickness 0 -bd 0 pack $f.$j -side top -anchor w } set v [string trim [lindex $cur $n]] if {$v != "" && [lsearch [lindex $data $n] $v] >= 0} { set ProgData(units,$i) $v } incr n } set b [frame $w.outer.but] pack $b -side top -pady 3 button $b.accept -text Accept -default active \ -command {set ProgData(done) 1} button $b.cancel -text Cancel -command {set ProgData(done) 0} pack $b.accept $b.cancel -side left -padx 5 bind $w {set ProgData(done) 1} center_window $w $ProgData(text) set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} tkwait visibility $w focus $w tkwait variable ProgData(done) destroy $w catch {focus $oldFocus} if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } if {$ProgData(done)} { set cnt [llength $units] set Node(type) C1 set Node(dim) "32 $cnt" set Node(size) [expr 32 * $cnt] $ProgData(text) delete 1.0 end incr cnt -1 for {set n 0} {$n < $cnt} {incr n} { set i [lindex $units $n] $ProgData(text) insert end "$ProgData(units,$i)\n" } set i [lindex $units end] $ProgData(text) insert end "$ProgData(units,$i)" } } proc cgns_string {label} { global ProgData Node CGNSdataValues set data $CGNSdataValues($label) set width 0 foreach i $data { set len [string length $i] if {$width < $len} {set width $len} } set cnt [llength $data] set w .datalist catch {destroy $w} toplevel $w -relief flat -bd 0 -cursor left_ptr wm overrideredirect $w 1 wm transient $w . wm group $w . wm protocol $w WM_DELETE_WINDOW {set ProgData(done) 0} bind $w {set ProgData(done) 0} bind $w {set ProgData(done) 0} bind $w {set ProgData(done) 0} bind $w {set ProgData(done) 0} set top [frame $w.top -relief solid -bd 1] pack $top -side top -fill both -expand 1 label $top.lab -text $label pack $top.lab -side top -fill x frame $top.sep -height 2 -bd 1 -relief sunken pack $top.sep -side top -fill x if {$cnt > 10} { listbox $top.list -relief flat -bd 0 -highlightthickness 0 \ -exportselection 0 -width $width -height 10 \ -yscroll "$top.scroll set" -takefocus 0 -cursor hand2 scrollbar $top.scroll -highlightthickness 0 -takefocus 0 \ -orient vertical -command "$top.list yview" pack $top.scroll -side right -fill y bind $top.scroll break } else { listbox $top.list -relief flat -bd 0 -highlightthickness 0 \ -exportselection 0 -width $width -height $cnt \ -takefocus 0 -cursor hand2 } pack $top.list -side left -fill both -expand 1 bind $top.list {set ProgData(done) 1; break} foreach i $data { $top.list insert end $i } set n [lsearch $data [string trim [$ProgData(text) get 1.0 end]]] if {$n >= 0} { $top.list selection set $n $n $top.list see $n } center_window $w $ProgData(text) set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} tkwait visibility $w focus $w tkwait variable ProgData(done) set sel [$top.list curselection] if {$sel == ""} { set data "" } else { set data [$top.list get $sel] } destroy $w catch {focus $oldFocus} if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } if {$data != "" && $ProgData(done)} { $ProgData(text) delete 1.0 end $ProgData(text) insert end $data set Node(type) C1 set Node(dim) [string length $data] set Node(size) $Node(dim) } } proc cgns_info {} { global ProgData Node CGNSnodeDesc Font set name [string trim $Node(name)] if {$name == "" || ![info exists CGNSnodeDesc($name)]} { set name [string trim $Node(label)] if {$name == "" || ![info exists CGNSnodeDesc($name)]} return } set labw 10 set wrap 30 set w .datainfo catch {destroy $w} toplevel $w -bg black wm overrideredirect $w 1 wm transient $w . frame $w.f -bg #ffffcc pack $w.f -side top -padx 1 -pady 1 set n 0 foreach i {"Node Name" "Node Label" Cardinality "Data Type"} { set f [frame $w.f.n$n -bg #ffffcc] pack $f -side top -padx 5 -anchor w label $f.lab -text "$i:" -width $labw -anchor w -font $Font(normal) \ -bg #ffffcc -fg black label $f.ent -font $Font(fixed) -bg #ffffcc -fg black \ -text [lindex $CGNSnodeDesc($name) $n] pack $f.lab $f.ent -side left incr n } if {[lindex $CGNSnodeDesc($name) 3] != "MT"} { foreach i {Dimension "Dim Values"} { set f [frame $w.f.n$n -bg #ffffcc] pack $f -side top -padx 5 -anchor w label $f.lab -text "$i:" -width $labw -anchor w -font $Font(normal) \ -bg #ffffcc -fg black label $f.ent -font $Font(fixed) -bg #ffffcc -fg black \ -text [lindex $CGNSnodeDesc($name) $n] pack $f.lab $f.ent -side left incr n } set data "" foreach line [split [lindex $CGNSnodeDesc($name) 6] "\n"] { if {$data != ""} {append data "\n"} set len 0 foreach word $line { set n [string length $word] if [expr {$len + $n + 1 > $wrap}] { append data "\n" set len 0 } if {$len} { append data " $word" incr n } else { append data $word } incr len $n } } set f [frame $w.f.data -bg #ffffcc] pack $f -side top -padx 5 -anchor w label $f.lab -text "Data:" -width $labw -anchor w -font $Font(normal) \ -bg #ffffcc -fg black label $f.ent -justify left -font $Font(fixed) -bg #ffffcc -fg black \ -text $data pack $f.lab $f.ent -side left -anchor n } center_window $w . bind $w {catch {destroy .datainfo};break} bind $w {catch {destroy .datainfo};break} bind $w {catch {destroy .datainfo}} set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} focus $w tkwait window $w catch {focus $oldFocus} if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } } proc cgns_tree {{top ""}} { global Font CGNSlibraryVersion CGNSnodes CGNSnodeChildren global CGNSdataValues CGNSdataDesc CGNSdata if {$top == ""} { set top .cgnstree } if {$top == "."} { set w "" } else { if {[winfo exists $top]} { wm deiconify $top return } toplevel $top set w $top } wm title $top "CGNS $CGNSlibraryVersion Node Reference" array set CGNSdata { node "" name "" label "" count "" type "" ndim "" dims "" sids "" midlevel "" } FrameCreate $w.tree -text "Node Tree" -font $Font(bold) pack $w.tree -side left -fill both -expand 1 set tree [FrameGet $w.tree] scrollbar $tree.ys -orient vertical -command "$tree.tree yview" pack $tree.ys -side right -fill y scrollbar $tree.xs -orient horizontal -command "$tree.tree xview" pack $tree.xs -side bottom -fill x TreeCreate $tree.tree -width 200 -height 300 -relief sunken \ -bd 2 -yscrollcommand "$tree.ys set" -xscrollcommand "$tree.xs set" \ -font $Font(normal) set CGSNdata(tree) $tree.tree pack $tree.tree -side left -fill both -expand 1 bind $tree.tree <1> {cgns:show_node %W [TreeAt %W %x %y]} bind $tree.tree {TreeToggle %W [TreeAt %W %x %y]} bind $tree.tree {cgns:tree %W %x %y open} bind $tree.tree {cgns:tree %W %x %y close} bind $tree.tree {cgns:tree %W %x %y expand} bind $tree.tree {cgns:tree %W %x %y collapse} TreeInsert $tree.tree / foreach n $CGNSnodeChildren(/) { cgns:add_node $tree.tree "" $n } set labw 10 set entw 32 FrameCreate $w.prop -text "Node Properties" -font $Font(bold) pack $w.prop -side right -fill y set prop [FrameGet $w.prop] foreach {i j} {name "Node Name" label "Node Label" count Cardinality \ type "Data Type" ndim Dimensions dims "Dim Values"} { set f [frame $prop.$i] pack $f -side top label $f.lab -width $labw -text $j -anchor w entry $f.ent -width $entw -textvariable CGNSdata($i) \ -state disabled -cursor {} pack $f.lab $f.ent -side left } set f [frame $prop.data] pack $f -side top -fill both -expand 1 label $f.lab -text "Data" pack $f.lab -side top -anchor w set CGNSdata(text) [text $f.text -width $entw -height 15 \ -wrap word -cursor {}] pack $CGNSdata(text) -side top -fill both -expand 1 frame $prop.sep -relief groove -bd 1 -height 2 pack $prop.sep -side top -fill x -pady 3 set f [frame $prop.but] pack $f -side top -fill x button $f.midlevel -text "MLL Doc..." -state disabled \ -command {cgns:help midlevel} button $f.sids -text "SIDS Doc.." -state disabled \ -command {cgns:help sids} pack $f.midlevel $f.sids -side left -expand 1 if {$top == "."} { button $f.setup -text "Setup..." -command help_setup pack $f.setup -side left -expand 1 } button $f.exit -text Exit -command "destroy $top" -width 6 pack $f.exit -side left -expand 1 set CGNSdata(buts) $f } proc cgns:add_node {tree parent child} { global CGNSnodes CGNSnodeChildren set node $parent/$child TreeInsert $tree $node set type [lindex $CGNSnodes($child) 1] if {[info exists CGNSnodeChildren($type)]} { foreach n $CGNSnodeChildren($type) { if {$n == $child} { TreeInsert $tree $node/$n } else { cgns:add_node $tree $node $n } } } } proc cgns:show_node {w node} { global CGNSnodes CGNSnodeDesc CGNSnodeRef CGNSdata TreeSelectionSet $w $node $CGNSdata(text) delete 1.0 end if {$node == "" || $node == "/"} { array set CGNSdata { node "" name "" label "" count "" type "" ndim "" dims "" sids "" midlevel "" } } else { set name [file tail $node] if {![info exists CGNSnodeDesc($name)]} { set name [lindex $CGNSnodes($name) 1] } set n 0 foreach i {name label count type ndim dims} { set CGNSdata($i) [lindex $CGNSnodeDesc($name) $n] incr n } $CGNSdata(text) insert end [lindex $CGNSnodeDesc($name) 6] set name [file tail $node] if {![info exists CGNSnodeRef($name)]} { set name [lindex $CGNSnodes($name) 1] } if {[info exists CGNSnodeRef($name)]} { set CGNSdata(sids) [lindex $CGNSnodeRef($name) 0] set CGNSdata(midlevel) [lindex $CGNSnodeRef($name) 1] } else { set CGNSdata(sids) "" set CGNSdata(midlevel) "" } } foreach i {sids midlevel} { if {$CGNSdata($i) == {}} { $CGNSdata(buts).$i configure -state disabled } else { $CGNSdata(buts).$i configure -state normal } } } proc cgns:tree {w x y mode} { set node [TreeAt $w $x $y] if {$node == ""} return if {$node != [TreeSelectionGet $w]} { cgns:show_node $w $node } switch $mode { expand {TreeExpand $w $node} collapse {TreeCollapse $w $node} open {TreeOpenLevel $w $node} close {TreeCloseLevel $w $node} } } proc cgns:format {text width} { if {[string trim $text] == ""} {return ""} return $data } proc cgns:help {type} { global CGNSdata set html [lindex $CGNSdata($type) 0] if {$html == ""} return help_show "$type/$html.html" [lindex $CGNSdata($type) 1] } CGNS-4.5.0/src/cgnstools/cgnsview/cgnsnodes.bat000066400000000000000000000020041474000356600213550ustar00rootroot00000000000000@echo off setlocal rem the standard wish command will work for this rem set wish=c:\progra~1\tcl\bin\wish83.exe set dir=%~dps0 if exist %dir%cgconfig.bat ( call %dir%cgconfig.bat goto getwish ) if exist %dir%..\cgconfig.bat call %dir%..\cgconfig.bat :getwish if "%CG_BIN_DIR%" == "" set CG_BIN_DIR=%dir% if not "%wish%" == "" goto getscript if exist %dir%cgiowish.exe ( set wish=%dir%cgiowish.exe goto getscript ) if exist %dir%cgnstools\cgiowish.exe ( set wish=%dir%cgnstools\cgiowish.exe goto getscript ) echo cgiowish.exe not found pause goto done :getscript if exist %dir%cgnsnodes.tcl ( set script=%dir%cgnsnodes.tcl goto run ) if not "%CG_LIB_DIR%" == "" ( if exist %CG_LIB_DIR%\cgnsnodes.tcl ( set script=%CG_LIB_DIR%\cgnsnodes.tcl goto run ) ) if exist %dir%..\share\cgnsnodes.tcl ( if "%CG_LIB_DIR%" == "" set CG_LIB_DIR=%dir%..\share set script=%dir%..\share\cgnsnodes.tcl goto run ) echo cgnsnodes.tcl not found pause goto done :run start /b %wish% %script% %1 :done endlocal CGNS-4.5.0/src/cgnstools/cgnsview/cgnsnodes.desktop000077500000000000000000000003061474000356600222660ustar00rootroot00000000000000[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=Application Name=CGNSnodes GenericName=CGNS node reference Terminal=false Categories=Development; Exec="./cgnsnodes" Icon=../share/cgnstools/cgns.png CGNS-4.5.0/src/cgnstools/cgnsview/cgnsnodes.sh000077500000000000000000000023131474000356600212270ustar00rootroot00000000000000#!/bin/sh # sh script to launch CGNS File viewer/editor dir=`dirname $0` # source the setup script for d in $dir $dir/cgnstools $dir/.. ; do if test -f $d/cgconfig ; then . $d/cgconfig break fi done # The normal wish will work here, but cgiowish should # be available, and may also be used cgiowish="" for d in $CG_BIN_DIR $dir $dir/cgnstools $dir/cgnsview \ /usr/local/bin /usr/local/bin/cgnstools ; do if test -x $d/cgiowish ; then cgiowish=$d/cgiowish break fi if test -x $d/cgnswish/cgiowish ; then cgiowish=$d/cgnswish/cgiowish break fi done if test -z "$cgiowish" ; then echo "Error: cgiowish executable not found" exit 1 fi # find the cgnsnodes tcl script cgnsnodes="" for d in $CG_LIB_DIR $dir $dir/cgnstools $dir/cgnsview \ $dir/../share/cgnstools \ /usr/local/share /usr/local/share/cgnstools ; do if test -f $d/cgnsnodes.tcl ; then cgnsnodes=$d/cgnsnodes.tcl break fi done if test -z "$cgnsnodes" ; then echo "Error: cgnsnodes.tcl script not found" exit 1 fi # check that display is set #if test -z "$DISPLAY" ; then # echo "Error: DISPLAY environment variable not set" # exit 1 #fi # execute exec $cgiowish $cgnsnodes CGNS-4.5.0/src/cgnstools/cgnsview/cgnsnodes.tcl000077500000000000000000000033011474000356600213750ustar00rootroot00000000000000#!/bin/sh # the next line restarts using wish \ exec adfwish -f "$0" "$@" proc error_exit {msg} { wm withdraw . tk_dialog .error Error $msg error 0 Exit exit 1 } if {[catch {package require Tk 8.0} msg]} { error_exit $msg } #----- check for CGNS version if {$argc} { set version [lindex $argv [expr $argc - 1]] if {[catch {expr $version < 1.1 || $version > 3.2} ok] || !$ok} { error_exit "invalid CGNS version number : $version" } } else { set version "" } #----- get startup directory and name set cmd_name [file tail $argv0] set cmd_dir [file dirname $argv0] if {![file exists $argv0] || [file isdirectory $argv0]} { if {$tcl_platform(platform) == "windows"} { set sep ";" } else { set sep ":" } foreach i [split $env(PATH) $sep] { if {$sep == ";"} { set i [join [split $i \\] /] } if {[file exists $i/$cmd_name] && ![file isdirectory $i/$cmd_name]} { set cmd_dir $i break; } } } set curdir [pwd] if ![catch {cd $cmd_dir}] { set cmd_dir [pwd] cd $curdir } if {$tcl_platform(platform) == "windows"} { set cmd_dir [file attributes $cmd_dir -shortname] } set auto_path "$cmd_dir $cmd_dir/../common $auto_path" if {[info exists env(TCL_PROC_DIR)]} { set auto_path "$env(TCL_PROC_DIR) $auto_path" } if [catch {config_defaults 1} msg] { error_exit $msg } if {$tcl_platform(platform) == "windows"} { set vers [join [split $tcl_version .] {}] catch {load tclreg$vers registry} } #---------- initialize set file ".cgnstools" set base "HKEY_CURRENT_USER/Software/CGNS" catch {tclreg_init -base $base -fname $file} help_init cgns_init $version cgns_tree . catch { config_icon . cgns [list $cmd_dir $cmd_dir/images $cmd_dir/../common] } CGNS-4.5.0/src/cgnstools/cgnsview/cgnsview.bat000066400000000000000000000016641474000356600212320ustar00rootroot00000000000000@echo off setlocal set HDF5_USE_FILE_LOCKING="FALSE" set dir=%~dps0 if exist "%dir%cgconfig.bat" ( call %dir%cgconfig.bat goto getwish ) if exist "%dir%..\cgconfig.bat" call "%dir%..\cgconfig.bat" :getwish if "%CG_BIN_DIR%" == "" set CG_BIN_DIR=%dir% if exist "%dir%cgiowish.exe" ( set wish=%dir%cgiowish.exe goto getscript ) if exist "%dir%cgnstools\cgiowish.exe" ( set wish=%dir%cgnstools\cgiowish.exe goto getscript ) echo cgiowish.exe not found pause goto done :getscript if exist "%dir%cgnsview.tcl" ( set script=%dir%cgnsview.tcl goto run ) if not "%CG_LIB_DIR%" == "" ( if exist "%CG_LIB_DIR%\cgnsview.tcl" ( set script=%CG_LIB_DIR%\cgnsview.tcl goto run ) ) if exist "%dir%..\share\cgnsview.tcl" ( if "%CG_LIB_DIR%" == "" set CG_LIB_DIR=%dir%..\share set script=%dir%..\share\cgnsview.tcl goto run ) echo cgnsview.tcl not found pause goto done :run start "" /b "%wish%" "%script%" %1 :done endlocal CGNS-4.5.0/src/cgnstools/cgnsview/cgnsview.desktop000077500000000000000000000003131474000356600221260ustar00rootroot00000000000000[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=Application Name=CGNSview GenericName=CGNS file structure viewer Terminal=false Categories=Development; Exec="./cgnsview" Icon=../share/cgnstools/cgns.png CGNS-4.5.0/src/cgnstools/cgnsview/cgnsview.sh000077500000000000000000000024551474000356600211000ustar00rootroot00000000000000#!/bin/sh # sh script to launch CGNS File viewer/editor dir=`dirname $0` # To let other tools access the file while cgnsview is running export HDF5_USE_FILE_LOCKING="FALSE" # source the setup script for d in $dir $dir/cgnstools $dir/.. ; do if test -f $d/cgconfig ; then . $d/cgconfig break fi done # get the cgiowish executable cgiowish="" for d in $CG_BIN_DIR $dir $dir/cgnstools $dir/cgnsview \ /usr/local/bin /usr/local/bin/cgnstools ; do if test -x $d/cgiowish ; then cgiowish=$d/cgiowish break fi if test -x $d/cgnswish/cgiowish ; then cgiowish=$d/cgnswish/cgiowish break fi done if test -z "$cgiowish" ; then echo "Error: cgiowish executable not found" exit 1 fi # find the cgnsview tcl script cgnsview="" for d in $CG_LIB_DIR $dir $dir/cgnstools $dir/cgnsview \ $dir/../share/cgnstools \ /usr/local/share /usr/local/share/cgnstools ; do if test -f $d/cgnsview.tcl ; then cgnsview=$d/cgnsview.tcl break fi done if test -z "$cgnsview" ; then echo "Error: cgnsview.tcl script not found" exit 1 fi # check that display is set #if test -z "$DISPLAY" ; then # echo "Error: DISPLAY environment variable not set" # exit 1 #fi # execute if test "$#" = 0 ; then exec $cgiowish $cgnsview else exec $cgiowish $cgnsview "$@" fi CGNS-4.5.0/src/cgnstools/cgnsview/cgnsview.tcl000066400000000000000000002343311474000356600212450ustar00rootroot00000000000000#!/bin/sh # the next line restarts using wish \ exec cgiowish -f "$0" "$@" proc error_exit {msg} { wm withdraw . tk_dialog .error Error $msg error 0 Exit exit 1 } if {[catch {package require Tk 8.0} msg]} { error_exit $msg } #---------- get platform set platform $tcl_platform(platform) if {$platform == "windows" && [info exists env(TERM)] && ($env(TERM) == "cygwin" || $env(TERM) == "xterm")} { set platform cygwin } #---------- setup paths to tcl files set cmd_name [file tail $argv0] set cmd_dir [file dirname $argv0] if {![file exists $argv0] || [file isdirectory $argv0]} { if {$platform == "windows"} { set sep ";" } else { set sep ":" } foreach i [split $env(PATH) $sep] { if {$sep == ";"} { set i [join [split $i \\] /] } if {[file exists $i/$cmd_name] && ![file isdirectory $i/$cmd_name]} { set cmd_dir $i break; } } } set curdir [pwd] if ![catch {cd $cmd_dir}] { set cmd_dir [pwd] cd $curdir } if {$tcl_platform(platform) == "windows"} { set cmd_dir [file attributes $cmd_dir -shortname] } set auto_path "$cmd_dir $cmd_dir/../common $auto_path" if {[info exists env(TCL_PROC_DIR)]} { set auto_path "$env(TCL_PROC_DIR) $auto_path" } #---------- initialize windows if {$platform == "windows"} { set vers [join [split $tcl_version .] {}] if {[info commands CGIOopen] == {}} { if {[catch {load cgiotcl$vers} msg]} { error_exit $msg } } catch {load tclreg$vers registry} } else { if {[info commands CGIOopen] == {}} { error_exit "need to run script with cgiowish" } } if [catch {config_defaults 1} msg] {error_exit $msg} #----- node tree icons image create photo dirimg -data { R0lGODlhFAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAUABAAAARF0MlJq5Un53sPWh9ycJQHnqK2VcfjvrB7AOyD\ 3t9chziolzaecPGbtIbCIibYy9GASJTS0Wqepqps9kkBeL9gMGlMLksiADs=} image create photo fileimg -data { R0lGODlhFAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAUABAAAAQ5EMlJq5Ug63wreGDIdRhInA+AqOQXgltroqL8\ vuzlnjxs377OjkcI6oA14ayX+gFzlo10RKpar5IIADs=} image create photo badimg -data { R0lGODlhFAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAUABAAAAQkEMlJq704S8K5pl34Id1UaifpoatKjGALp7Nc\ v3Ce0bfu/4gIADs=} image create photo dirlink -data { R0lGODlhFAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAUABAAAARR0MlJq5Un53sPWh9ycJQHnqK2VcfjvrB7AOyD\ 3t9chziolzHX7TdpPQBIwIMnogFdSRuPiIFGmVRHK6ocOotH5UuV+U6OsaTaAoWRKMHH2xEB\ ADs=} image create photo filelink -data { R0lGODlhFAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAUABAAAAQ/EMlJq5Ug63wreGDIdRhInA+AqOQXgltroqL8\ vqx1z3AHa7dcRZR50ISUXxHnA36OTdcOOUkFYxfYi5TccRERADs=} image create photo badlink -data { R0lGODlhFAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAUABAAAAQ5EMlJq704S8K5pl34Id1UaifpjeBqPXD8qEQG\ AzjwpFec7zXN7efCPH461lEXK/aYzaDtKFPKYJ8IADs=} image create photo invalid -data { R0lGODlhFAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAUABAAAARLEMmZap04A2B7/lzyjE/4YdVDrI93pmRbmR+8\ WuOVzSQ+0pQEIFdhlXTBoY8EDFpWRiRqGZNOVVCC7CQJxWQALmLTsWzETit6PYkAADs=} #----- initialize program data array set ProgData { libvers "" filevers "" supported "" extensions "" newfile "" format adf file "" readonly 1 follow 0 verify 1 backup 1 bakfile "" autoload 1 defsize 1024 maxsize 1024 defcnt 10 maxcnt 10 showlines 1 linenum "" linecnt "" lineval "" toolbar 1 tree "" buttons "" find "" case 0 fromtop 0 start / winwidth 640 winheight 500 seppos 0.4 sepwd 7 reg,file ".cgnstools" reg,base "HKEY_CURRENT_USER/Software/CGNS" reg,key "CGNSview" reg,vals {file follow verify backup autoload maxsize maxcnt toolbar \ find case fromtop showlines winwidth winheight seppos} cgnsdiff "" cgnscheck "" cgnsplot "" cgnscalc "" menucfg "" file,name "" file,dir "" file,size "" file,cgns "" file,type "" file,vers "" file,mode "" file,mtime "" file,atime "" units,mass Kilogram units,length Meter units,time Second units,temp Kelvin units,angle Radian units,current Ampere units,amount Mole units,intensity Candela } array set Node { parent "" name "" label "" type "" dim "" size "" lnode "" lfile "" trace 0 } foreach i [array names Node] { set NodeSave($i) $Node($i) } set ProgData(libvers) [CGNSversion] cgns_init $ProgData(libvers) set ProgData(supported) [CGIOsupported] set cgnsexts .cgns foreach ext $ProgData(supported) { lappend cgnsexts ".cg[string index $ext 0]" } set ProgData(extensions) [list [list "CGNS Files" $cgnsexts]] if {[CGIOsupported adf] != ""} { lappend ProgData(extensions) [list "ADF Files" [list .adf .cga]] } if {[CGIOsupported hdf5] != ""} { lappend ProgData(extensions) [list "HDF5 Files" [list .hdf .hdf5 .cgh]] } lappend ProgData(extensions) [list "All Files" *] array set Import { inputfile "" cgnsfile "" exefile "" options "" basename "" basename,flag 1 dupcheck,flag 0 dupcheck d duptol "" } array set Export { cgnsfile "" outputfile "" exefile "" options "" basenum "" zonenum "" solnum "" basenum,flag 1 zonenum,flag 1 solnum,flag 1 ascii 0 solution 1 weight 0 } array set Tools { cgnsinput "" cgnsoutput "" verbose "" warnings 2 errors "" exefile "" options "" weight "" basenum "" basename "" zonenum "" solnum "" solname "" basenum,flag 1 basename,flag 1 zonenum,flag 1 solnum,flag 1 solname,flag 1 background 0 nocase "" whitespace "" followlinks "" cmpdata "" cmptol 0 } set DataTypes { "MT (empty)" "C1 (character data)" "I4 (32-bit integer)" "R4 (32-bit real)" "R8 (64-bit real)" "B1 (byte data)" "U4 (unsigned 32-bit integer)" "I8 (64-bit integer)" "U8 (unsigned 64-bit integer)" "X4 (32-bit complex real)" "X8 (64-bit complex real)" } #----- read registry if {[tclreg_init -base $ProgData(reg,base) -fname $ProgData(reg,file)]} { foreach i $ProgData(reg,vals) { if {![catch {tclreg_get $ProgData(reg,key) $i} val] && $val != ""} { set ProgData($i) $val } } catch units_read } #----- setup search paths for executable files and script files set ProgData(exepath) [list $cmd_dir $cmd_dir/cgnstools] if {[info exists env(CG_BIN_DIR)] && $env(CG_BIN_DIR) != ""} { if {$platform == "windows"} { set bin_dir [file attributes $env(CG_BIN_DIR) -shortname] } else { set bin_dir $env(CG_BIN_DIR) } lappend ProgData(exepath) $bin_dir $bin_dir/cgnstools } set ProgData(libpath) [list $cmd_dir $cmd_dir/cgnstools] if {[info exists env(CG_LIB_DIR)] && $env(CG_LIB_DIR) != ""} { if {$platform == "windows"} { set lib_dir [file attributes $env(CG_LIB_DIR) -shortname] } else { set lib_dir $env(CG_LIB_DIR) } lappend ProgData(libpath) $lib_dir $lib_dir/cgnstools } set root_dir [file dirname $cmd_dir] foreach d {cgnscalc cgnsplot tools utilities} { if [file isdirectory $root_dir/$d] { lappend ProgData(exepath) $root_dir/$d lappend ProgData(libpath) $root_dir/$d } } proc get_executable {name {showerr 0}} { global ProgData set exe [find_file executable $name $ProgData(exepath) \$PATH] if {$exe == "" && $showerr} { set msg "$name executable not found in:" foreach p $ProgData(exepath) { append msg "\n $p" } append msg "\n \$PATH" errormsg $msg } return $exe } proc get_file {name {showerr 0}} { global ProgData set fname [find_file exists $name $ProgData(libpath) \$PATH] if {$fname == "" && $showerr} { set msg "$name file not found in:" foreach p $ProgData(libpath) { append msg "\n $p" } append msg "\n \$PATH" errormsg $msg } return $fname } #----- find cgnscheck, cgnsdiff, cgnsplot, cgnscalc set ProgData(cgnscheck) [get_executable cgnscheck] set ProgData(cgnsdiff) [get_executable cgnsdiff] set plotwish [get_executable plotwish] set cgnsplot [get_file cgnsplot.tcl] if {$plotwish != "" && $cgnsplot != ""} { set ProgData(cgnsplot) [list $plotwish $cgnsplot] } set calcwish [get_executable calcwish] set cgnscalc [get_file cgnscalc.tcl] if {$calcwish != "" && $cgnscalc != ""} { set ProgData(cgnscalc) [list $calcwish $cgnscalc] } #---------- main window wm title . CGNSview wm protocol . WM_DELETE_WINDOW do_quit bind . cgns_info #---------- menu menubar_create {File Config Tree Tools Help} #--- file menu set m [menubar_get File] $m add command -label "New..." -command file_new $m add command -label "Open..." -command file_load $m add command -label "Save..." -command file_save -state disabled $m add command -label "Compress..." -command file_compress -state disabled $m add separator $m add command -label "Reload" -command file_reload -state disabled $m add command -label "File Info..." -command file_info -state disabled $m add command -label "Restore" -command restore_backup -state disabled #--- config menu set m [menubar_get Config] $m add checkbutton -label " Show Lines" -variable ProgData(showlines) \ -onvalue 1 -offvalue 0 -command { TreeConfig $ProgData(tree) -lines $ProgData(showlines) } $m add checkbutton -label " Show Toolbar" -variable ProgData(toolbar) \ -onvalue 1 -offvalue 0 -command { if {$ProgData(toolbar)} { pack .toolbar.but -side left } else { pack forget .toolbar.but .toolbar configure -height 1 } } $m add checkbutton -label " Verify Delete" -variable ProgData(verify) \ -onvalue 1 -offvalue 0 $m add checkbutton -label " Auto Backup" -variable ProgData(backup) \ -onvalue 1 -offvalue 0 $m add checkbutton -label " Auto Load Data" -variable ProgData(autoload) \ -onvalue 1 -offvalue 0 $m add command -label " Auto Data Size..." -command auto_size #--- tree menu set m [menubar_get Tree] $m add checkbutton -label " Follow Links" -variable ProgData(follow) \ -onvalue 1 -offvalue 0 -command {follow_links $ProgData(follow)} $m add command -label " Expand All" -command {tree_expand /} \ -state disabled $m add command -label " Collapse All" -command {tree_collapse /} \ -state disabled $m add separator $m add command -label " Find Node..." -command find_node \ -state disabled $m add command -label " Find Again" -command find_again \ -state disabled #--- tools menu set m [menubar_get Tools] $m add command -label "Diff CGNS Files..." -state disabled -command diff_cgns $m add command -label "Check CGNS..." -state disabled -command check_cgns $m add command -label "Plot CGNS..." -state disabled -command plot_cgns $m add command -label "Calculate CGNS..." -state disabled -command calc_cgns $m add separator $m add command -label "Unit Conversions..." -command units_convert #--- help menu set m [menubar_get Help] $m add command -label "CGNSview..." \ -command {help_show cgnstools/cgnsview/index.html} $m add command -label "Utilities..." \ -command {help_show cgnstools/utilities/index.html} $m add command -label "CGNS..." -command {help_show} $m add separator $m add command -label "Configure..." -command help_setup $m add separator $m add command -label "CGNS Nodes..." -command cgns_tree $m add command -label "About..." -underline 0 -command do_about #----- add menu options proc next_line {fp} { set input "" while {[gets $fp line] >= 0} { set n [string first "\#" $line] if {$n == 0} { set line "" } elseif {$n > 0} { set line [string trim [string range $line 0 [expr $n - 1]]] } else { set line [string trim $line] } if {$line == ""} continue set end [expr [string length $line] - 1] if {[string index $line $end] == "\\"} { incr end -1 append input [string range $line 0 $end] continue } append input $line break } return $input } set menufiles [glob -nocomplain $cmd_dir/*.mnu] if {$menufiles == ""} { set menufiles [get_file utilities.mnu] } if {$menufiles != ""} { set cnt 0 foreach f $menufiles { if {![catch {open $f r} fp]} { while (1) { set line [next_line $fp] if {$line == ""} break set mnu [split [lindex $line 0] :] set len [expr [llength $mnu] - 1] if {$len < 1} { error_exit "invalid menu specification - [lindex $line 0]" } set m [menubar_add [lindex $mnu 0] Help] for {set i 1} {$i < $len} {incr i} { set entry [lindex $mnu $i] if {[catch {$m index $entry} n]} { $m add cascade -label $entry -menu $m.m$cnt set m $m.m$cnt incr cnt menu $m -tearoff 0 } else { set m [$m entrycget $n -menu] if {$m == ""} { error_exit "menu item is not a submenu - [lindex $line 0]" } } } set entry [lindex $mnu $len] if {[string match "sep*" $entry]} { $m add separator } else { set opts [list $entry] eval lappend opts [lrange $line 1 end] $m add command -label $entry -command "run_menu $opts" set class [string tolower [lindex $line 1]] if {[string match "ex*" $class] || [string match "con*" $class] || [string match "ut*" $class]} { set n [$m index end] $m entryconfigure $n -state disabled lappend ProgData(menucfg) [list $m $n] } } } close $fp } } } proc run_menu {args} { set n 0 foreach i {name class exe func script} { set $i [lindex $args $n] incr n } if {$func == ""} { switch -glob [string tolower $class] { im* {set func import_default} ex* {set func export_default} con* {set func tools_convert} ut* {set func tools_utility} default {set func tools_default} } } else { if {![get_external_proc $func $script]} return } if {[catch {$func .tools $name $exe} msg]} { errormsg $msg } catch {destroy .tools} } proc get_external_proc {func script} { if {[info commands $func] == "" && $script != ""} { set scr [get_file $script 1] if {$scr == ""} {return 0} if {[catch {uplevel \#0 source $scr} msg]} { errormsg $msg return 0 } if {[info commands $func] == ""} { errormsg "procedure $func not found in script $script" return 0 } } return 1 } #----- add Quit to file menu set m [menubar_get File] $m add separator $m add command -label "Quit" -command do_quit #----- toolbar frame .toolbar -height 1 pack .toolbar -side top -pady 3 -fill x set f [frame .toolbar.but] if {$ProgData(toolbar)} { pack $f -side left } #--- file image create photo img_new -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQvEMlJ6wQvaw0q3g8gdtQHZuR1ihZirt7JtbQ1\ 3mkMYrn07jpZ77cZylAeHK7GjAAAOw==} image create photo img_open -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQ4EMlJKwJvZcC7BxdnSV04nCgKjtR6vZgmZ49L\ bmlus7xV9j4QQPYRtWbI3RCXU10WgKaTVPQAexEAOw==} image create photo img_save -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAQwQ90MlJqwRjgM13BpeGjOSIgQ6mdYCphW1Jtugp\ z2/6sVye8rwLMKiL3Tiwm6smUp5Cmaj0A+Utq6yrZTuJAAA7} image create photo img_compress -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAcALAAAAAAQABAAAAQ7EMgJjr0XvL0lxtr0hJ8VclSpcWz1hRQpISbb\ ZnVMmrXdmR4YZYQ7rHwukG5iZJZeneTTOCJOe9ZrLAIAOw==} image create photo img_reload -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAcALAAAAAAQABAAAAQ98IBJ67kYvM33xJfWcRoAiqRHZePUmSFZkewD\ IDZq16K+x7aWp5YK/iQvDaJHrKBgSFmL6JkCR6+McwuLAAA7} image create photo img_info -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAQwRG0MlJqwMv64c5BSCIACNimgSBgVy4Wt95Auk6\ cmXo1G0behOXUAcLCneECokkQ/Bwy5KJpupllkBJZ7MBfLhcbxDcLZonEQA7} set b [frame $f.file] pack $b -side left -padx 5 button $b.new -image img_new -takefocus 0 -command file_new set_balloon $b.new "New File..." button $b.open -image img_open -takefocus 0 -command file_load set_balloon $b.open "Open File..." button $b.save -image img_save -takefocus 0 \ -command file_save -state disabled set_balloon $b.save "Save As..." button $b.compress -image img_compress -takefocus 0 \ -command file_compress -state disabled set_balloon $b.compress "Compress File" button $b.reload -image img_reload -takefocus 0 \ -command file_reload -state disabled set_balloon $b.reload "Reload File" button $b.info -image img_info -takefocus 0 \ -command "file_info $b.info" -state disabled set_balloon $b.info "File Information..." pack $b.new $b.open $b.save $b.compress $b.reload $b.info -side left #--- config image create photo img_size -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQ8EMlJq72V6M05/khHWNoHnEC2ScAhHSnWOs4b\ h2vqHC5yVz/WxNNCHGowUw9267BQgEHQJMWJVr4BCBgBADs=} set b [frame $f.config] pack $b -side left -padx 5 button $b.size -image img_size -takefocus 0 \ -command "auto_size $b.size" set_balloon $b.size "Auto Data Size..." pack $b.size -side left #--- tree image create photo img_follow -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQwEMlJq714jpHrWFwnbaFoVkAGrCnSIgSBrhIL\ P3JtV3FuvxgaJjYBWgi4YqZ3aloiADs=} image create photo img_expand -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQvEMlJq712DJzX5pP2VQBIWuWVUitBTCsMlMTz\ IrHl3jnYUy7J7Cep8UA7k3IpiQAAOw==} image create photo img_collapse -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQkEMlJq7046wrwGBQgXsMCTh35hRvbSqm1urJJ\ V98Jvzvv/5UIADs=} set b [frame $f.tree] pack $b -side left -padx 5 button $b.follow -image img_follow -takefocus 0 \ -command {follow_links ""} set_balloon $b.follow "Follow Links..." if {$ProgData(follow)} { $b.follow configure -relief sunken } button $b.expand -image img_expand -takefocus 0 \ -command {tree_open /} -state disabled set_balloon $b.expand "Open One Level" button $b.collapse -image img_collapse -takefocus 0 \ -command {tree_close /} -state disabled set_balloon $b.collapse "Close One Level" pack $b.follow $b.expand $b.collapse -side left image create photo img_find -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAAARC0MnpELiIagfQO4+1Sd1nihriPeyZUYDJgscB\ aADYmjbO8z2Yh/Y5qHAlmvEGe2BqS99lipFeRpPYFAu7cmHfMDYCADs=} image create photo img_again -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAAARH0MnpELiIagfQO4+1Sd1nihriPeyZUYDJgscB\ aADYmjbO8z2Yh/Y5qHAlmvEGe2BqS99lipFeRpPYFAu7km5XL6fLATO5mwgAOw==} set b [frame $f.find] pack $b -side left -padx 5 button $b.first -image img_find -takefocus 0 \ -command find_node -state disabled set_balloon $b.first "Find Node..." button $b.again -image img_again -takefocus 0 \ -command find_again -state disabled set_balloon $b.again "Find Again" pack $b.first $b.again -side left #--- tools image create photo img_diff -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAcALAAAAAAQABAAQwQ6EEh5qr1n6gqep930ANeEnZ33hSNVWqE0njSW\ qmR9r3iuITDVxxYU5mBFHGdT44xaRxR0pptGbRpJBAA7} image create photo img_check -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAAAQ3EMlJq70V6A0wAk8YapkEig/YfeuHplzrvqPs\ niKZjblOnRpYyoLjDHc1IBFVXNKOvxjHQ5VEAAA7} image create photo img_plot -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAUALAAAAAAQABAAQwRKEDEkq7UsaxaSD+Amakk4ip05TRU7BZdbdSVI\ MU6Og14N5jqgAwckYo43ytEFCrCWlJRTKXt9bIhhkHb9EbVDWhNM1oaEwaKQGAEAOw==} image create photo img_calc -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQ8EIFJ60RYvg14fx2AfSH4ceMGqmqYrmEJvuXE\ zRqro/nOir2d67X6UYg+3unUwpGSTk/MFDVNYSOL9hIBADs=} set b [frame $f.tools] pack $b -side left -padx 5 button $b.diff -image img_diff -takefocus 0 \ -command diff_cgns -state disabled set_balloon $b.diff "Diff CGNS Files..." button $b.check -image img_check -takefocus 0 \ -command check_cgns -state disabled set_balloon $b.check "Check CGNS File..." button $b.plot -image img_plot -takefocus 0 \ -command plot_cgns -state disabled set_balloon $b.plot "Plot CGNS File..." button $b.calc -image img_calc -takefocus 0 \ -command calc_cgns -state disabled set_balloon $b.calc "Calculate CGNS..." pack $b.diff $b.check $b.plot $b.calc -side left image create photo img_convert -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAA4ALAAAAAAQABAAQwQt0MlJq70VSO349B0ghhwYntuIXZ7YUmaWxeu3\ 3eTb4Sld8yngztYDuYbC3yQCADs=} button $f.convert -image img_convert -takefocus 0 \ -command "units_convert $f.convert" set_balloon $f.convert "Unit Conversions..." pack $f.convert -side left -padx 5 #--- help image create photo img_help -data {\ R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\ /wD//////yH5BAEAAAgALAAAAAAQABAAQwQiEMlJq50kX5kJ1hvShd+4mSJ4qmTrXl28ehw7\ t+j75joVAQA7} button $f.help -image img_help -takefocus 0 \ -command {help_show cgnstools/cgnsview/index.html} pack $f.help -side left -padx 5 set_balloon $f.help Help proc help_menu {} { if [help_valid] { menubar_state Help normal 0 menubar_state Help normal 1 menubar_state Help normal 2 .toolbar.but.help configure -state normal } else { menubar_state Help disabled 0 menubar_state Help disabled 1 menubar_state Help disabled 2 .toolbar.but.help configure -state disabled } } help_init #---------- main window frame .main -width $ProgData(winwidth) -height $ProgData(winheight) pack .main -side top -fill both -expand 1 -padx 5 -pady 5 #--- window separator frame .main.sep -width 6 -bd 2 -relief raised -cursor sb_h_double_arrow place .main.sep -relx $ProgData(seppos) -x -3 -rely 0 -relheight 1 bind .main.sep sep_begin_move proc sep_begin_move {} { set width [winfo width .main] set x [winfo rootx .main.sep] set y [winfo rooty .main.sep] set h [winfo height .main.sep] set xmin [expr [winfo rootx .main] + 100] set xmax [expr [winfo rootx .main] + $width - 100] set top [toplevel .main.move -borderwidth 1 \ -relief raised -cursor sb_h_double_arrow] wm overrideredirect $top 1 wm geom $top "4x$h+$x+$y" update idletasks grab set $top bind $top "sep_end_move $top $xmin $xmax %X" bind $top "sep_move $top $xmin $xmax %X $y" } proc sep_move {top xmin xmax x y} { if {$x < $xmin} { set x $xmin } elseif {$x > $xmax} { set x $xmax } wm geom $top "+$x+$y" } proc sep_end_move {top xmin xmax x} { global ProgData destroy $top if {$x < $xmin} { set x $xmin } elseif {$x > $xmax} { set x $xmax } set s [expr double($x - [winfo rootx .main]) / \ double([winfo width .main])] place .main.tree -relx 0 -relwidth $s -width -$ProgData(sepwd) \ -rely 0 -relheight 1 place .main.node -relx $s -x $ProgData(sepwd) \ -relwidth [expr 1.0 - $s] -width -$ProgData(sepwd) \ -rely 0 -relheight 1 place .main.sep -relx $s -x -3 -rely 0 -relheight 1 set ProgData(seppos) $s } #---------- node tree FrameCreate .main.tree -text "Node Tree" -font $Font(bold) place .main.tree -relx 0 -relwidth $ProgData(seppos) \ -width -$ProgData(sepwd) -rely 0 -relheight 1 set f [FrameGet .main.tree] set ProgData(tree) $f.tree scrollbar $f.ys -orient vertical -command "$ProgData(tree) yview" \ -takefocus 0 -highlightthickness 0 pack $f.ys -side right -fill y scrollbar $f.xs -orient horizontal -command "$ProgData(tree) xview" \ -takefocus 0 -highlightthickness 0 pack $f.xs -side bottom -fill x TreeCreate $ProgData(tree) -width 200 -height 400 -relief sunken \ -bd 2 -highlightthickness 1 -yscrollcommand "$f.ys set" -takefocus 1 \ -xscrollcommand "$f.xs set" -font $Font(normal) \ -lines $ProgData(showlines) pack $ProgData(tree) -side left -fill both -expand 1 bind $ProgData(tree) <1> {tree_show %W %x %y} bind $ProgData(tree) <2> {tree_info %W %x %y} bind $ProgData(tree) <3> {tree_menu %W %x %y} bind $ProgData(tree) {TreeToggle %W [TreeAt %W %x %y]} bind $ProgData(tree) {tree_at %W %x %y open} bind $ProgData(tree) {tree_at %W %x %y close} bind $ProgData(tree) {tree_at %W %x %y expand} bind $ProgData(tree) {tree_at %W %x %y collapse} bind $ProgData(tree) tree_next bind $ProgData(tree) tree_prev bind $ProgData(tree) tree_collapse bind $ProgData(tree) tree_expand bind $ProgData(tree) tree_toggle bind $ProgData(tree) tree_insert bind $ProgData(tree) tree_rename bind $ProgData(tree) tree_delete set ProgData(menu) [menu .nodemenu -tearoff 0] $ProgData(menu) add command -label "Expand" -command tree_expand $ProgData(menu) add command -label "Collapse" -command tree_collapse $ProgData(menu) add command -label "Info..." -command cgns_info $ProgData(menu) add separator set ProgData(insert) [menu .nodemenu.insert -tearoff 0] $ProgData(menu) add cascade -label "Insert" -menu $ProgData(insert) $ProgData(menu) add command -label "Rename" -command tree_rename $ProgData(menu) add command -label "Delete" -command tree_delete #---------- node data set wl 12 set we 30 frame .main.node place .main.node -relx $ProgData(seppos) -x $ProgData(sepwd) \ -relwidth [expr 1.0 - $ProgData(seppos)] -width -$ProgData(sepwd) \ -rely 0 -relheight 1 #----- node description FrameCreate .main.node.node -text "Node Description" -font $Font(bold) pack .main.node.node -side top -pady 2 -fill x set node [FrameGet .main.node.node] set f [frame $node.parent] pack $f -side top -fill x label $f.lab -text "Parent Node" -width $wl -anchor w pack $f.lab -side left entry $f.ent -textvariable Node(parent) -width $we -highlightthickness 0 pack $f.ent -side left -fill x -expand 1 entry_balloon $f.ent set f [frame $node.name] pack $f -side top -fill x label $f.lab -text "Node Name" -width $wl -anchor w pack $f.lab -side left ComboboxCreate $f.cb -width 5 -variable Node(name) \ -command set_node_name pack $f.cb -side top -fill x -expand 1 entry_balloon $f.cb.ent proc set_node_name {w n} { global Node NodeSave CGNSnodes _Combobox set name [ComboboxValue $w $n] if {$NodeSave(lnode) == ""} { set Node(label) [lindex $CGNSnodes($name) 1] set Node(type) [lindex $CGNSnodes($name) 2] set Node(dim) [lindex $CGNSnodes($name) 3] } if {[lindex $CGNSnodes($name) 0]} { $w.ent selection clear } else { set _Combobox($w,focus) $w.ent $w.ent delete 0 end $w.ent insert 0 $name $w.ent selection range 0 end } return $name } set f [frame $node.label] pack $f -side top -fill x label $f.lab -text "Node Label" -width $wl -anchor w pack $f.lab -side left ComboboxCreate $f.cb -width 5 -variable Node(label) pack $f.cb -side top -fill x -expand 1 entry_balloon $f.cb.ent #----- link description FrameCreate .main.node.link -text "Link Description" -font $Font(bold) pack .main.node.link -side top -pady 2 -fill x set link [FrameGet .main.node.link] foreach i {\ {lfile "Link File"} \ {lnode "Link Node"}} { set j [lindex $i 0] set f [frame $link.$j] pack $f -side top -fill x label $f.lab -text [lindex $i 1] -width $wl -anchor w pack $f.lab -side left entry $f.ent -textvariable Node($j) -width 5 -highlightthickness 0 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -padx 0 -pady 0 -command "select_$j $f.but" pack $f.but -side right -fill y entry_balloon $f.ent } #----- data description FrameCreate .main.node.fmt -text "Data Description" -font $Font(bold) pack .main.node.fmt -side top -pady 2 -fill x set fmt [FrameGet .main.node.fmt] set f [frame $fmt.type] pack $f -side top -fill x label $f.lab -text "Data Type" -width $wl -anchor w pack $f.lab -side left ComboboxCreate $f.cb -values $DataTypes -variable Node(type) \ -edit 0 -width 5 -height 5 -command set_data_type -post get_data_index pack $f.cb -side top -fill x -expand 1 proc set_data_type {w n} { global ProgData DataTypes Node set oldtype [ComboboxEntry $w] set newtype [lindex [lindex $DataTypes $n] 0] if {$oldtype == $newtype} {return $newtype} node_clear if {![string match {?[148]} $newtype] || ![string match {?[148]} $oldtype]} { set Node(dim) "" set Node(size) 0 $ProgData(buttons).read configure -state disabled return $newtype } $ProgData(buttons).read configure -state normal if {![catch {expr int($Node(size))} size]} { if {[string match "X?" $oldtype]} { set oldsize [expr 2 * [string index $oldtype 1]] } else { set oldsize [string index $oldtype 1] } if {[string match "X?" $newtype]} { set newsize [expr 2 * [string index $newtype 1]] } else { set newsize [string index $newtype 1] } set Node(size) [expr ($size * $newsize) / $oldsize] } return $newtype } proc get_data_index {w s} { global DataTypes return [lsearch -glob $DataTypes "$s*"] } set f [frame $fmt.dim] pack $f -side top -fill x label $f.lab -text Dimensions -width $wl -anchor w pack $f.lab -side left entry $f.ent -textvariable Node(dim) -width $we -highlightthickness 0 pack $f.ent -side left -fill x -expand 1 set f [frame $fmt.size] pack $f -side top -fill x label $f.lab -text Bytes -width $wl -anchor w pack $f.lab -side left entry $f.ent -textvariable Node(size) -width $we \ -state disabled -cursor {} -highlightthickness 0 pack $f.ent -side left -fill x -expand 1 #---------- buttons set ProgData(buttons) [frame .main.node.buttons] pack $ProgData(buttons) -side top -fill x -pady 3 foreach i {create modify read clear delete} { button $ProgData(buttons).$i -text $i -width 6 -state disabled \ -command node_$i pack $ProgData(buttons).$i -side left -expand 1 } #---------- node data FrameCreate .main.node.data -text "Node Data" -font $Font(bold) -pady 0 pack .main.node.data -side top -pady 2 -fill both -expand 1 set data [FrameGet .main.node.data] set f [frame $data.list] pack $f -side top -fill both -expand 1 -pady 2 scrollbar $f.ys -orient vertical -command "$f.text yview" \ -takefocus 0 -highlightthickness 0 pack $f.ys -side right -fill y scrollbar $f.xs -orient horizontal -command "$f.text xview" \ -takefocus 0 -highlightthickness 0 pack $f.xs -side bottom -fill x set ProgData(text) [text $f.text -width 40 -height 5 \ -wrap none -xscrollcommand "$f.xs set" \ -yscrollcommand "$f.ys set" -highlightthickness 0] pack $f.text -side top -fill both -expand 1 bind $ProgData(text) cgns_data bind $ProgData(text) {tkTabToWindow [tk_focusNext %W];break} bind $ProgData(text) {tkTabToWindow [tk_focusPrev %W];break} bind $ProgData(text) get_location bind $ProgData(text) get_location set f [frame $data.loc] pack $f -side top -fill x -pady 2 label $f.lab -text Line entry $f.ent -width 10 -textvariable ProgData(linenum) pack $f.lab $f.ent -side left bind $f.ent {set_location %W} label $f.val -textvariable ProgData(lineval) pack $f.val -side left -padx 5 frame $f.cnt pack $f.cnt -side right label $f.cnt.lab -text "Values/Line" entry $f.cnt.ent -width 8 -textvariable ProgData(linecnt) pack $f.cnt.lab $f.cnt.ent -side left bind $f.cnt.ent {set_perline %W} proc get_location {} { global ProgData set linenum [lindex [split [$ProgData(text) index insert] .] 0] set ProgData(linenum) $linenum if {$ProgData(linecnt) == ""} { set ProgData(lineval) "" } else { set ProgData(lineval) "([expr $ProgData(linecnt) * ($linenum - 1) + 1])" } } proc set_location {w} { global ProgData if {![catch {expr int([$w get])} linenum]} { catch { $ProgData(text) mark set insert $linenum.0 $ProgData(text) see $linenum.0 } } get_location focus $ProgData(text) } proc set_perline {w} { if {[catch {expr int([$w get])} cnt] || $cnt < 1} { set cnt 0 } node_read $cnt } #---------- update buttons when node changes trace variable Node(parent) w check_node trace variable Node(name) w check_node #========== procedures =============================================== proc do_quit {} { global ProgData if {![remove_backup]} return catch CGIOclose set ProgData(winwidth) [winfo width .main] set ProgData(winheight) [winfo height .main] foreach i $ProgData(reg,vals) { catch {tclreg_set $ProgData(reg,key) $i $ProgData($i)} } catch units_write catch tclreg_close catch {WinHtml close} destroy . exit 0 } image create photo img_about -data {\ R0lGODlhIAAgAMIEAAAAgICAAMDAwP/OIf///////////////yH5BAEKAAQALAAAAAAgACAA\ AAPASLrc/m7ICSucmFqbu9yXFwQZ2HRjGhCayWJptn4uOY2DAr85aEszFU/Xs+BoA9WxRzP+\ CKRFjNKsPFeNZa76WAK+AAUYMPiWyYSxA/dNh9sEQWBMhkNGZoF4PB9LwCdSZm2EAH1nR3Y6\ CwJqboVnZ4oLRSNDDCg2IQpTHhhQLZxEnJaeFD9FpJcpPDJEXFAzpyoyWCVZWjlKQq2wsVpS\ vJ5dnaamVsXGt3fJyr64ucZYPrSmli6ku7vYa9rX3OAJADs=} proc do_about {} { global ProgData dialog .about -1 -1 "About CGNSview" \ "CGNSview Version 3.2 CGNS Library Version $ProgData(libvers) Bruce Wedan leavingdust@gmail.com" img_about 0 Close } proc do_backup {} { global ProgData if {!$ProgData(backup) || $ProgData(bakfile) != ""} return set name "$ProgData(file,name).bak" if {[file exists $name]} { for {set n 1} {$n < 100} {incr n} { if {![file exists $name$n]} { append name $n break } } } dialog .backup -1 -1 "Back Up" "Backing up file to \"$name\"" \ hourglass 0 update if {![catch {file copy $ProgData(file,name) $name} msg]} { set msg "" } destroy .backup if {$msg == ""} { set ProgData(bakfile) $name menubar_state File normal 7 } else { errormsg $msg menubar_state File disabled 7 } } proc remove_backup {} { global ProgData if {$ProgData(bakfile) != "" && [file exists $ProgData(bakfile)]} { set del [dialog .delbak -1 -1 Delete \ "delete the backup file ?" question 0 Yes No Cancel] if {$del == 2} {return 0} if {$del == 0} {catch {file delete $ProgData(bakfile)}} } set ProgData(bakfile) "" menubar_state File disabled 7 return 1 } proc restore_backup {} { global ProgData if {$ProgData(bakfile) == "" ||![file exists $ProgData(bakfile)]} return catch CGIOclose if {[catch {file rename -force $ProgData(bakfile) \ $ProgData(file,name)} msg]} { errormsg $msg return } set ProgData(bakfile) "" menubar_state File disabled 7 file_reload } #----- configuration proc follow_links {state} { global ProgData if {$state == ""} { if {$ProgData(follow)} { set ProgData(follow) 0 } else { set ProgData(follow) 1 } } if {$ProgData(follow)} { .toolbar.but.tree.follow configure -relief sunken } else { .toolbar.but.tree.follow configure -relief raised } file_reload } proc auto_size {{loc .}} { global ProgData NewSize catch {destroy .size} toplevel .size wm title .size "Node Data Loading" wm transient .size . foreach i {maxsize maxcnt} { set NewSize($i) $ProgData($i) } FrameCreate .size.top pack .size.top -side top -padx 5 -pady 2 -fill x set top [FrameGet .size.top] set f [frame $top.size] pack $f -side top -fill x -padx 5 -pady 5 label $f.lab -width 24 -text "Auto Load Data Size (bytes)" -anchor w entry $f.ent -width 15 -textvariable NewSize(maxsize) pack $f.lab $f.ent -side left set f [frame $top.cnt] pack $f -side top -fill x -padx 5 -pady 5 label $f.lab -width 24 -text "Max Data Values per Line" -anchor w entry $f.ent -width 15 -textvariable NewSize(maxcnt) pack $f.lab $f.ent -side left set f [frame .size.but] pack $f -side top -fill x -expand 1 -padx 5 -pady 5 button $f.accept -text Accept -width 8 -default active -command { foreach i {maxsize maxcnt} { if {![catch {expr int($NewSize($i))} size]} { set ProgData($i) $size } } destroy .size } button $f.default -text Default -width 8 -command { foreach i {size cnt} { set NewSize(max$i) $ProgData(def$i) } } button $f.cancel -text Cancel -width 8 -command {destroy .size} pack $f.accept $f.default $f.cancel -side left -expand 1 bind .size "$f.accept invoke" center_window .size $loc set oldFocus [focus] set oldGrab [grab current .size] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab .size} tkwait visibility .size focus .size tkwait window .size catch {focus $oldFocus} if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } } #----- node operations proc check_links {node} { set path {} foreach p [split [file dirname $node] /] { if {$p != ""} { append path "/$p" if {[CGIOlink $path] != {}} {return 1} } } return 0 } proc recursive_link {node link} { set path {} foreach p [split $node /] { if {$p != ""} { append path "/$p" if {$link == $path} {return 1} } } return 0 } proc get_node {parent name} { if {$name == ""} {return ""} if {$parent == ""} { if {$name == "/"} {return "/"} return "" } if {$parent == "/"} {return "/$name"} return "$parent/$name" } proc delete_node {node} { global ProgData if {$node == ""} return if {$node == "/"} { errormsg "can't delete root node of CGNS file" return } if {[check_links $node]} { errormsg "can't delete child of a linked parent node" return } if {$ProgData(verify) && [dialog .delete -1 -1 "Delete Node" \ "Delete the node \"$node\" ?" warning 0 Yes No Cancel]} { return } do_backup if {[catch {CGIOdelete $node} msg]} { errormsg $msg file_reload } else { TreeDelete $ProgData(tree) $node update_node [TreeSelectionGet $ProgData(tree)] } } proc update_node {node} { global ProgData Node NodeSave CGNSnodes CGNSnodeChildren set Node(trace) 0 node_clear if {$node == {}} { array set Node { parent "" name "" node "" label "" type "" dim "" size "" lnode "" lfile "" link 0 } set size 0 } else { set ProgData(start) $node set Node(node) $node if {$node == "/"} { set Node(parent) {} set Node(name) $node } else { set Node(parent) [file dirname $node] set Node(name) [file tail $node] } catch {CGIOlabel $node} Node(label) if {![catch {CGIOtype $node} type]} { set Node(type) [string toupper $type] } else { set Node(type) $type } catch {CGIOdimensions $node} Node(dim) if {[catch {CGIOsize $node} Node(size)]} { set size 0 } else { set size $Node(size) } if {[catch {CGIOlink $node} link]} { set Node(lnode) $link } else { set Node(lnode) [lindex $link 0] set Node(lfile) [lindex $link 1] } set Node(link) [check_links $node] } foreach i [array names Node] { set NodeSave($i) $Node($i) } set node [FrameGet .main.node.node] set link [FrameGet .main.node.link] set fmt [FrameGet .main.node.fmt] if {$ProgData(readonly) || $Node(node) == "/" || $Node(link)} { $node.parent.ent configure -state disabled -cursor {} ComboboxConfig $node.name.cb -state disabled ComboboxConfig $node.label.cb -state disabled foreach i {lfile lnode} { $link.$i.ent configure -state disabled -cursor {} $link.$i.but configure -state disabled } ComboboxConfig $fmt.type.cb -state disabled $fmt.dim.ent configure -state disabled -cursor {} } else { $node.parent.ent configure -state normal -cursor xterm if {$Node(parent) == "/"} { set names $CGNSnodeChildren(/) } elseif {[catch {CGIOlabel $Node(parent)} label] || ![info exists CGNSnodeChildren($label)]} { set names "" } else { set names $CGNSnodeChildren($label) } ComboboxConfig $node.name.cb -values $names -state normal foreach i {lfile lnode} { $link.$i.ent configure -state normal -cursor xterm $link.$i.but configure -state normal } if {$Node(lnode) == ""} { set vallist {} foreach n $names { set val [lindex $CGNSnodes($n) 1] if {[lsearch $vallist $val] < 0} { lappend vallist $val } } ComboboxConfig $node.label.cb -values $vallist -state normal ComboboxConfig $fmt.type.cb -state normal $fmt.dim.ent configure -state normal -cursor xterm } else { ComboboxConfig $node.label.cb -state disabled ComboboxConfig $fmt.type.cb -state disabled $fmt.dim.ent configure -state disabled -cursor {} } } update idletasks set Node(trace) 1 check_node if {!$size} { $ProgData(buttons).read configure -state disabled } else { $ProgData(buttons).read configure -state normal if {$ProgData(autoload) && [expr $size <= $ProgData(maxsize)]} { node_read } } } proc show_node {node} { global ProgData TreeSelectionSet $ProgData(tree) $node update_node $node } proc check_node {args} { global ProgData Node NodeSave if {!$Node(trace)} return set parent [string trim $Node(parent)] set name [string trim $Node(name)] set node [get_node $parent $name] if {$ProgData(readonly)} { foreach b {create modify delete} { $ProgData(buttons).$b configure -state disabled } if {$NodeSave(node) == ""} { $ProgData(buttons).read configure -state disabled } else { $ProgData(buttons).read configure -state normal } $ProgData(text) configure -state disabled -cursor {} -takefocus 0 return } if {$NodeSave(node) == "" || $NodeSave(link)} { foreach b {modify delete} { $ProgData(buttons).$b configure -state disabled } if {$NodeSave(node) == ""} { $ProgData(buttons).read configure -state disabled } else { $ProgData(buttons).read configure -state normal } if {$node != "" && [CGIOnode $node] == ""} { $ProgData(buttons).create configure -state normal $ProgData(text) configure -state normal -cursor xterm -takefocus 1 } else { $ProgData(buttons).create configure -state disabled $ProgData(text) configure -state disabled -cursor {} -takefocus 0 } return } if {$node == $NodeSave(node)} { $ProgData(buttons).read configure -state normal if {$node == "/"} { foreach b {create modify delete} { $ProgData(buttons).$b configure -state disabled } $ProgData(text) configure -state disabled -cursor {} -takefocus 0 } else { $ProgData(buttons).create configure -state disabled foreach b {modify delete} { $ProgData(buttons).$b configure -state normal } if {[string trim $Node(lnode)] == ""} { $ProgData(text) configure -state normal -cursor xterm -takefocus 1 } else { $ProgData(text) configure -state disabled -cursor {} -takefocus 0 } } return } foreach b {create modify read delete} { $ProgData(buttons).$b configure -state disabled } $ProgData(text) configure -state disabled -cursor {} -takefocus 0 if {$node == "" || [CGIOnode $node] != ""} return if {$parent == "/" || [CGIOnode $parent] == "node"} { foreach b {create modify} { $ProgData(buttons).$b configure -state normal } $ProgData(text) configure -state normal -cursor xterm -takefocus 1 } } proc add_node {parent child args} { global ProgData Font set tree $ProgData(tree) set node $parent/$child if {[string first / $child] >= 0 || [catch {CGIOlink $node} link]} { if {$parent == ""} {set parent /} TreeInsert $tree $child -dir $parent -icon invalid -fill red return } if {$link == {}} { set img img set opts $args } else { if {[lindex $link 1] == "" && [recursive_link $node [lindex $link 0]]} { TreeInsert $tree $node -icon badlink -fill red return } set img link set opts "-fill blue -tag link" } if {[catch {CGIOnumchild $node} numchild]} { TreeInsert $tree $node -icon bad$img -fill red return } if {$numchild < 1} { eval TreeInsert $tree {$node} -icon file$img $args return } eval TreeInsert $tree {$node} -icon dir$img $args if {$link != {} && !$ProgData(follow)} return if {[catch {CGIOchildren $node} children] || $children == {}} { for {set n 1} {$n <= $numchild} {incr n} { if {[catch {CGIOchildname $node $n} name]} { TreeInsert $tree invalid$n -dir $node -icon invalid -fill red } else { eval add_node {$node} {$name} $opts } } } else { foreach n $children { eval add_node {$node} {$n} $opts } } } proc build_tree {} { global ProgData if {[catch {CGIOchildren /} children]} { TreeInsert $ProgData(tree) / -icon badimg return } dialog .build -1 -1 "Reading..." \ "Reading nodes and building node tree" hourglass 0 {} .build configure -cursor watch . configure -cursor watch update TreeInsert $ProgData(tree) / -icon dirimg foreach n $children { add_node "" $n } destroy .build . configure -cursor {} } #----- tree proc tree_show {w x y} { set node [TreeAt $w $x $y] if {$node != ""} { show_node $node } } proc tree_info {w x y} { set node [TreeAt $w $x $y] if {$node == ""} return if {$node != [TreeSelectionGet $w]} { show_node $node } cgns_info } proc insert_menu {w node} { global ProgData CGNSnodes CGNSnodeChildren set allowed {} if {$node == "/"} { set parent "" set type / } else { set parent $node if [catch {CGIOlabel $node} type] {set type ""} } if {$type != "" && [info exists CGNSnodeChildren($type)]} { set existing {} foreach child [TreeGet $w $node -children] { if [info exists CGNSnodes($child)] { if [lindex $CGNSnodes($child) 0] { lappend existing $child } else { lappend existing [lindex $CGNSnodes($child) 1] } } else { if {![catch {CGIOlabel $parent/$child} lab]} { lappend existing $lab } } } if {[lsearch $CGNSnodeChildren($type) PointList] >= 0} { foreach n {PointList PointRange ElementList ElementRange} { if {[lsearch $existing $n] >= 0} { lappend existing PointList PointRange ElementList ElementRange break } } if {$type == "GridConnectivity_t"} { if {[lsearch $existing PointListDonor] >= 0 || [lsearch $existing CellListDonor] >= 0} { lappend existing PointListDonor CellListDonor } } } foreach n $CGNSnodeChildren($type) { if [lindex $CGNSnodes($n) 0] { set i $n } else { set i [lindex $CGNSnodes($n) 1] } if {[lindex $CGNSnodes($n) 4] || [lsearch $existing $i] < 0} { lappend allowed $n } } } destroy $ProgData(insert) set m [menu $ProgData(insert) -tearoff 0] $m add command -label "New Node" -command tree_insert if {$allowed != {}} { $m add separator foreach n $allowed { $m add command -label $n -command "tree_insert $n" } } } proc tree_menu {w x y} { global ProgData set node [TreeAt $w $x $y] if {$node == ""} return if {$node != [TreeSelectionGet $w]} { show_node $node } if {$ProgData(readonly) || [TreeGet $w $node -tag] == "link"} { if {[TreeGet $w $node -children] == {}} return foreach n {0 1} { $ProgData(menu) entryconfigure $n -state normal } foreach n {4 5 6} { $ProgData(menu) entryconfigure $n -state disabled } } else { if {[TreeGet $w $node -children] == {}} { $ProgData(menu) entryconfigure 0 -state disabled $ProgData(menu) entryconfigure 1 -state disabled } else { $ProgData(menu) entryconfigure 0 -state normal $ProgData(menu) entryconfigure 1 -state normal } if {[string match "*link" [TreeGet $w $node -icon]]} { $ProgData(menu) entryconfigure 4 -state disabled } else { $ProgData(menu) entryconfigure 4 -state normal insert_menu $w $node } if {$node == "/"} { $ProgData(menu) entryconfigure 2 -state disabled $ProgData(menu) entryconfigure 5 -state disabled $ProgData(menu) entryconfigure 6 -state disabled } else { $ProgData(menu) entryconfigure 2 -state normal $ProgData(menu) entryconfigure 5 -state normal $ProgData(menu) entryconfigure 6 -state normal } } $ProgData(menu) post [expr [winfo rootx $ProgData(tree)] + $x] \ [expr [winfo rooty $ProgData(tree)] + $y] } proc tree_toggle {{node ""}} { global ProgData if {$node == ""} { set node [TreeSelectionGet $ProgData(tree)] if {$node == ""} return } TreeToggle $ProgData(tree) $node } proc tree_expand {{node ""}} { global ProgData if {$node == ""} { set node [TreeSelectionGet $ProgData(tree)] if {$node == ""} return } TreeExpand $ProgData(tree) $node } proc tree_open {{node ""}} { global ProgData if {$node == ""} { set node [TreeSelectionGet $ProgData(tree)] if {$node == ""} return } TreeOpenLevel $ProgData(tree) $node } proc tree_collapse {{node ""}} { global ProgData if {$node == ""} { set node [TreeSelectionGet $ProgData(tree)] if {$node == ""} return } TreeCollapse $ProgData(tree) $node } proc tree_close {{node ""}} { global ProgData if {$node == ""} { set node [TreeSelectionGet $ProgData(tree)] if {$node == ""} return } TreeCloseLevel $ProgData(tree) $node } proc tree_at {w x y mode} { set node [TreeAt $w $x $y] if {$node == ""} return if {$node != [TreeSelectionGet $w]} { show_node $node } switch $mode { expand {TreeExpand $w $node} collapse {TreeCollapse $w $node} open {tree_open $node} close {tree_close $node} } } proc tree_insert {{name "New Node"}} { global ProgData CGNSnodes if {$ProgData(readonly)} return set w $ProgData(tree) set parent [TreeSelectionGet $w] if {$parent == ""} return set icon [TreeGet $w $parent -icon] set open [TreeGet $w $parent -open] TreeSet $w $parent -icon dirimg -open 1 if {$parent == "/"} { set root "" } else { set root $parent } set node "$root/$name" if {[CGIOnode $node] != ""} { for {set n 1} {$n < 100} {incr n} { if {[CGIOnode "$node$n"] == ""} { append node "$n" break } } } if [info exists CGNSnodes($name)] { set cgnsnode $CGNSnodes($name) set fixed [lindex $cgnsnode 0] } else { set cgnsnode {} set fixed 0 } TreeInsert $w $node -icon fileimg if {!$fixed} { set name [TreeEdit $w $node] if {$name == ""} { TreeSet $w $parent -icon $icon -open $open TreeDelete $w $node return } TreeMove $w $node $name } do_backup if {[catch {CGIOcreate "$root/$name"} msg]} { errormsg $msg file_reload return } TreeSelectionSet $w "$root/$name" if {$cgnsnode != {}} { set labl [lindex $cgnsnode 1] set type [lindex $cgnsnode 2] set dims [lindex $cgnsnode 3] catch {CGIOlabel "$root/$name" $labl} if {$type == "C1"} { if {$labl == "DimensionalUnits_t"} { set data [list Kilogram Meter Second Kelvin Radian] } elseif {$labl == "AdditionalUnits_t"} { set data [list Ampere Mole Candela] } else { set data Null } if {$dims == {}} {set dims [string length $data]} catch {CGIOwrite "$root/$name" $type $dims $data} } elseif {$type != {} && $dims != {}} { catch {CGIOwrite "$root/$name" $type $dims 0} } else { if {$type != {}} { catch {CGIOtype "$root/$name" $type} } if {$dims != {}} { catch {CGIOdimensions "$root/$name" $dims} } } } update_node "$root/$name" } proc tree_delete {} { global ProgData if {$ProgData(readonly)} return delete_node [TreeSelectionGet $ProgData(tree)] } proc tree_rename {} { global ProgData if {$ProgData(readonly)} return set w $ProgData(tree) set node [TreeSelectionGet $w] if {$node == ""} return set name [TreeEdit $w $node] if {$name == "" || $name == [file tail $node]} return do_backup if {[catch {CGIOname $node $name} msg]} { errormsg $msg } else { TreeMove $w $node $name set node [get_node [file dirname $node] $name] } file_reload if {[CGIOnode $node] != ""} { TreeSelectionSet $w $node update_node $node } } proc tree_prev {{update 1}} { global ProgData set tree $ProgData(tree) set cur [TreeSelectionGet $tree] if {$cur == ""} { set node / } else { set node [TreePrev $tree $cur] } if {$node != ""} { TreeSelectionSet $tree $node TreeSee $tree $node if {$update} { update_node $node } } } proc tree_next {{update 1}} { global ProgData set tree $ProgData(tree) set cur [TreeSelectionGet $tree] if {$cur == ""} { set node / } else { set node [TreeNext $tree $cur] } if {$node != ""} { TreeSelectionSet $tree $node TreeSee $tree $node if {$update} { update_node $node } } } #----- node search proc find_node {} { global ProgData set w .find catch {destroy $w} toplevel $w wm title $w "Find Node..." wm transient $w . wm protocol $w WM_DELETE_WINDOW {set ProgData(done) 0} set f [frame $w.f1] pack $f -side top -fill x -padx 5 -pady 5 -fill x label $f.lab -text "Node:" pack $f.lab -side left entry $f.ent -relief sunken -width 20 -textvariable ProgData(find) \ -highlightthickness 0 pack $f.ent -side left -fill x -expand 1 set f [frame $w.f2] pack $f -side left -fill y -padx 5 -pady 5 checkbutton $f.case -text "Match Case" -variable ProgData(case) \ -onvalue 1 -offvalue 0 checkbutton $f.top -text "Start from Root" \ -variable ProgData(fromtop) -onvalue 1 -offvalue 0 pack $f.case $f.top -side top -anchor w -expand 1 set sel [TreeSelectionGet $ProgData(tree)] if {$sel == "" || ![TreeExists $ProgData(tree) $sel]} { set ProgData(start) / $f.top configure -state disabled } else { set ProgData(start) $sel } set f [frame $w.f3] pack $f -side right -fill y -padx 5 -pady 5 button $f.find -text Find -width 6 -default active \ -command {set ProgData(done) 1} button $f.cancel -text Cancel -width 6 -command {set ProgData(done) 0} pack $f.find $f.cancel -side top -expand 1 bind $w {set ProgData(done) 1} center_window $w . set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} tkwait visibility $w focus $w.f1.ent tkwait variable ProgData(done) destroy $w catch {focus $oldFocus} if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } if {$ProgData(done) && $ProgData(find) != ""} { if {$ProgData(fromtop)} { set ProgData(start) / } find_again } } proc find_again {} { global ProgData if {$ProgData(find) == ""} { find_node return } if {$ProgData(start) == ""} {set ProgData(start) /} set node [TreeFind $ProgData(tree) $ProgData(start) \ $ProgData(find) $ProgData(case)] if {$node == ""} { errormsg "node not found" set ProgData(start) / return } TreeSee $ProgData(tree) $node TreeSelectionSet $ProgData(tree) $node update_node $node set ProgData(start) $node } #----- file operations proc file_stats {} { global ProgData set ProgData(file,size) "[file size $ProgData(file,name)] bytes" set ProgData(file,type) [CGNSfile $ProgData(file)] set ProgData(file,vers) [CGIOversion] if [file writable $ProgData(file,name)] { set ProgData(file,mode) "read/write" } else { set ProgData(file,mode) "read-only" } foreach t {mtime atime} { if {[catch {clock format [file $t $ProgData(file,name)] \ -format "%a %b %d %Y %T"} time]} { set ProgData(file,$t) unknown } else { set ProgData(file,$t) $time } } if {[catch {CGIOread /CGNSLibraryVersion} cgns]} { set ProgData(filevers) "" set ProgData(file,cgns) unknown } else { set ProgData(filevers) $cgns set ProgData(file,cgns) "CGNS $cgns" } } proc file_extension {} { global ProgData } proc file_select {what name format} { global ProgData tcl_platform Font set ProgData(newfile) $name set ProgData(format) [string tolower $format] set w .selfile catch {destroy $w} toplevel $w wm title $w "$what File..." wm transient $w . wm protocol $w WM_DELETE_WINDOW {set ProgData(done) 0} FrameCreate $w.file -text "File Name" -font $Font(bold) pack $w.file -side top -pady 2 -fill x set file [FrameGet $w.file] entry $file.ent -textvariable ProgData(newfile) -width 30 pack $file.ent -side left -fill x -expand 1 button $file.but -text Browse -pady 0 -command " set fname \[FileSave {$what File} \$ProgData(newfile) . \ \$ProgData(extensions) \$ProgData(format)\] if {\$fname != {}} { set ProgData(newfile) \$fname } " pack $file.but -side right -fill y FrameCreate $w.format -text "File Type" -font $Font(bold) pack $w.format -side top -fill x set fmt [FrameGet $w.format] foreach i {adf hdf5} { radiobutton $fmt.$i -text [string toupper $i] \ -variable ProgData(format) -value $i -command file_extension if {[CGIOsupported $i] == ""} { $fmt.$i configure -state disabled } pack $fmt.$i -side left -expand 1 } set f [frame $w.but] pack $f -side top -pady 5 button $f.accept -text Accept -width 6 -default active \ -command {set ProgData(done) 1} button $f.cancel -text Cancel -width 6 -command {set ProgData(done) 0} pack $f.accept $f.cancel -side left -padx 5 bind $w {set ProgData(done) 1} center_window $w . set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} tkwait visibility $w focus $file.ent $file.ent selection range 0 end tkwait variable ProgData(done) catch {focus $oldFocus} destroy $w if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } if {$ProgData(done) && $ProgData(newfile) != ""} { return 1 } return 0 } proc file_new {} { global ProgData set name NewFile.$ProgData(format) if [file_select New $name $ProgData(format)] { catch CGIOclose if {[file exists $ProgData(newfile)] && [catch {file delete $ProgData(newfile)} msg]} { errormsg $msg return } catch {CGIOopen $ProgData(newfile) write $ProgData(format)} file_load $ProgData(newfile) } } proc file_load {{inpfile ""}} { global ProgData tcl_platform if {$inpfile == ""} { set inpfile [FileOpen "Open File" $ProgData(file) . \ $ProgData(extensions)] if {$inpfile == ""} return } if [catch {CGNSfile $inpfile} type] { errormsg $type return } if {[CGIOsupported $type] == ""} { errormsg "file type $type not supported" return } set dir [file dirname $inpfile] set fname [file tail $inpfile] catch CGIOclose remove_backup if {[catch {cd $dir} msg]} { errormsg $msg return } set dir [pwd] if [file writable $fname] { set mode modify set ProgData(readonly) 0 } else { set mode read set ProgData(readonly) 1 } dialog .open -1 -1 "Opening..." \ "Opening and reading $fname" hourglass 0 {} .open configure -cursor watch . configure -cursor watch update if {![catch {CGIOopen $fname $mode $type} msg]} { set msg "" } destroy .open . configure -cursor {} if {$msg != ""} { errormsg $msg return } set ProgData(file,name) $fname if {$tcl_platform(platform) == "windows"} { set ProgData(file,dir) [join [split $dir /] \\] } else { set ProgData(file,dir) $dir } set ProgData(file) $inpfile file_stats TreeDelete $ProgData(tree) / build_tree if {$ProgData(readonly)} { append fname " (read only)" } wm title . "CGNSview : $fname" foreach i {compress reload save info} { .toolbar.but.file.$i configure -state normal } foreach i {2 3 5 6} { menubar_state File normal $i } foreach i {tree.expand tree.collapse find.first find.again} { .toolbar.but.$i configure -state normal } foreach i {1 2 4 5} { menubar_state Tree normal $i } if {$ProgData(filevers) == ""} { set state disabled } else { set state normal } if {$ProgData(cgnsdiff) == ""} { .toolbar.but.tools.diff configure -state disabled menubar_state Tools disabled 0 } else { .toolbar.but.tools.diff configure -state $state menubar_state Tools $state 0 } if {$ProgData(cgnscheck) == ""} { .toolbar.but.tools.check configure -state disabled menubar_state Tools disabled 1 } else { .toolbar.but.tools.check configure -state $state menubar_state Tools $state 1 } if {$ProgData(cgnsplot) == ""} { .toolbar.but.tools.plot configure -state disabled menubar_state Tools disabled 2 } else { .toolbar.but.tools.plot configure -state $state menubar_state Tools $state 2 } if {$ProgData(cgnscalc) == ""} { .toolbar.but.tools.calc configure -state disabled menubar_state Tools disabled 3 } else { .toolbar.but.tools.calc configure -state $state menubar_state Tools $state 3 } foreach i $ProgData(menucfg) { catch {[lindex $i 0] entryconfigure [lindex $i 1] -state $state} } $ProgData(buttons).clear configure -state normal update_node "" } proc file_reload {} { global ProgData if {$ProgData(file,name) == ""} return catch {cd $ProgData(file,dir)} if [file writable $ProgData(file,name)] { set mode modify set ProgData(readonly) 0 wm title . "CGNSview : $ProgData(file,name)" } else { set mode read set ProgData(readonly) 1 wm title . "CGNSview : $ProgData(file,name) (read only)" } if {[catch {CGIOopen $ProgData(file,name) $mode $ProgData(file,type)} msg]} { errormsg $msg } else { build_tree } set node [TreeSelectionGet $ProgData(tree)] if {$node != "" && ![TreeVisible $ProgData(tree) $node]} { set node "" } update_node $node } proc file_compress {} { global ProgData if {$ProgData(file,name) == ""} return if {![file writable $ProgData(file,name)]} { errormsg "current file is not writable" return } do_backup catch {cd $ProgData(file,dir)} set oldsize [file size $ProgData(file,name)] if [catch {CGIOcompress $ProgData(file,name)} msg] { errormsg $msg catch CGIOclose } else { set newsize [file size $ProgData(file,name)] if {$newsize < $oldsize} { dialog .compress -1 -1 "Compression" \ "File size reduced from $oldsize to $newsize" info 0 Close } else { dialog .compress -1 -1 "Compression" \ "No reduction in File size" info 0 Close } } file_reload file_stats } proc file_save {} { global ProgData if {$ProgData(file,name) == "" || ![file_select Save $ProgData(file,name) $ProgData(file,type)]} return set fname $ProgData(newfile) if {[same_file $fname $ProgData(file)]} { errormsg "current file and save file are the same" return } if {[file exists $fname] && [catch {file delete $fname} msg]} { errormsg $msg return } if {$ProgData(format) == $ProgData(file,type)} { if [catch {file copy $ProgData(file) $fname} msg] { errormsg $msg return } } else { if [catch {CGIOsave $fname $ProgData(format)} msg] { errormsg $msg return } } catch {file attributes $fname -readonly 0} file_load $fname } proc file_info {{loc .}} { global ProgData tcl_platform if {$ProgData(file,name) == ""} return file_stats if {[winfo exists .info]} { wm deiconify .info raise .info return } toplevel .info wm title .info "File Information" wm resizable .info 0 0 set wl 10 frame .info.main pack .info.main -side top -padx 5 -pady 5 set base [frame .info.main.base -relief groove -bd 2] pack $base -side top -padx 5 -pady 5 foreach i {\ {name Name:} \ {dir Location:} \ {size Size:} \ {sep1 {}} \ {type Type:} \ {vers Version:} \ {cgns CGNSlib:} \ {sep2 {}} \ {mode Mode:} \ {mtime Modified:} \ {atime Accessed:}} { set j [lindex $i 0] if {[lindex $i 1] == {}} { set f [frame $base.$j -relief groove -bd 1 -height 2] pack $f -side top -fill x -pady 2 } else { set f [frame $base.$j] pack $f -side top -anchor w -padx 5 label $f.lab -text [lindex $i 1] -width $wl -anchor w label $f.dat -textvariable ProgData(file,$j) pack $f.lab $f.dat -side left } } set f [frame .info.main.but] pack $f -side top button $f.close -text Close -default active -command {destroy .info} button $f.stats -text Update -command file_stats pack $f.close $f.stats -side left -padx 5 bind .info {destroy .info} center_window .info $loc } #----- link selection proc select_lfile {{loc .}} { global ProgData Node tcl_platform set lfile [FileOpen "Link File" $Node(lfile) $loc $ProgData(extensions)] if {$lfile == ""} return if [catch {CGNSfile $lfile} type] { errormsg $type return } if {$type != $ProgData(file,type)} { errormsg "linked to files must be of the same file type" return } if {[same_file $lfile $ProgData(file)]} { set Node(lfile) "" } elseif {[same_file [file dirname $lfile] \ [file dirname $ProgData(file)]]} { set Node(lfile) [file tail $lfile] } elseif {$tcl_platform(platform) == "windows"} { set Node(lfile) [join [split $lfile /] \\] } else { set Node(lfile) $lfile } } proc select_lnode {{loc .}} { global Node ProgData Font if {$Node(lfile) == ""} { set lfile $ProgData(file) } else { set lfile $Node(lfile) } if {![file exists $lfile]} { errormsg "can't browse - link file does not exist" return } set type $ProgData(file,type) if {[catch {cd [file dirname $lfile]} msg] || [catch {CGIOopen [file tail $lfile] read $type} msg]} { errormsg $msg file_reload return } set tree $ProgData(tree) set w .lnode catch {destroy $w} toplevel $w wm title $w "Select Link Node" wm transient $w . wm withdraw $w label $w.file -text [file tail $lfile] pack $w.file -side top -padx 5 -pady 5 set f [frame $w.top] pack $f -side top -fill both -expand 1 -padx 5 set ProgData(tree) $f.tree scrollbar $f.ys -orient vertical -command "$ProgData(tree) yview" pack $f.ys -side right -fill y scrollbar $f.xs -orient horizontal -command "$ProgData(tree) xview" pack $f.xs -side bottom -fill x TreeCreate $ProgData(tree) -width 200 -height 300 -relief sunken \ -bd 2 -yscrollcommand "$f.ys set" -xscrollcommand "$f.xs set" \ -font $Font(normal) -lines $ProgData(showlines) pack $ProgData(tree) -side left -fill both -expand 1 bind $ProgData(tree) <1> { set node [TreeAt %W %x %y] if {$node != ""} { TreeSelectionSet %W $node } } bind $ProgData(tree) {TreeToggle %W [TreeAt %W %x %y]} bind $w {tree_next 0} bind $w {tree_prev 0} bind $w tree_collapse bind $w tree_expand bind $w tree_toggle set f [frame $w.but] pack $f -side top -fill x -padx 5 -pady 5 button $f.accept -text Accept -width 6 -default active -command { if {[TreeSelectionGet $ProgData(tree)] != ""} { set Node(done) 1 } } button $f.cancel -text Cancel -width 6 -command {set Node(done) 0} pack $f.accept $f.cancel -side left -expand 1 bind $w "$f.accept invoke" build_tree TreeSee $ProgData(tree) $Node(lnode) TreeSelectionSet $ProgData(tree) $Node(lnode) center_window $w $loc set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} tkwait visibility $w focus $w tkwait variable Node(done) if {$Node(done)} { set Node(lnode) [TreeSelectionGet $ProgData(tree)] } set ProgData(tree) $tree destroy $w catch {focus $oldFocus} if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } catch {cd $ProgData(file,dir)} if {$ProgData(readonly)} { set mode read } else { set mode modify } if {[catch {CGIOopen $ProgData(file,name) $mode $type} msg]} { errormsg $msg } } #----- operation buttons proc node_create {} { global ProgData Node set parent [string trim $Node(parent)] set name [string trim $Node(name)] if {$parent == "" || $name == ""} { errormsg "need to specify parent node and node name" return } set node [get_node $parent $name] if {[CGIOnode $node] != ""} { errormsg "node \"$node\" already exists" return } do_backup foreach i {label lfile lnode type dim} { set $i [string trim $Node($i)] } if {$lnode == ""} { if {[catch {CGIOcreate $node} msg]} { errormsg msg } } else { if {[catch {CGIOlink $node $lnode $lfile} msg]} { errormsg $msg } } if {$label != "" && [catch {CGIOlabel $node $label} msg]} { errormsg $msg } if {$lnode == "" && [string match {?[148]} $type]} { set data [string trim [$ProgData(text) get 1.0 end]] if {$data != ""} { if {$dim == ""} { if {$type == "C1"} { set dim [string length $data] } else { set dim [llength $data] } } if {$type == "C1" && [llength $dim] > 1} { set data [split $data "\n"] } if {[catch {CGIOwrite $node $type $dim $data} msg]} { errormsg $msg } } } file_reload if {[CGIOnode $node] != ""} { TreeSee $ProgData(tree) $node TreeSelectionSet $ProgData(tree) $node update_node $node } } proc node_modify {} { global ProgData Node NodeSave if {$NodeSave(node) == "" || $NodeSave(node) == "/" || [CGIOnode $NodeSave(node)] == ""} return foreach i {parent name label lfile lnode type dim} { set $i [string trim $Node($i)] } if {$parent == "" || $name == ""} return set node [get_node $parent $name] if {$node != $NodeSave(node)} { if {[CGIOnode $node] != ""} { errormsg "node \"$node\" already exists" return } } if {$lfile == ""} { if {$lnode != ""} { if {[recursive_link $node $lnode]} { errormsg "link is recursive" return } } } else { if {$lnode == ""} { errormsg "must specify the link node for a link" return } } if {$lnode != $NodeSave(lnode) || $lfile != $NodeSave(lfile)} { do_backup catch {CGIOdelete $NodeSave(node)} if {$lnode == ""} { if {[catch {CGIOcreate $node} msg]} { errormsg $msg } set NodeSave(label) "" } else { if {[catch {CGIOlink $node $lnode $lfile} msg]} { errormsg $msg } set label $NodeSave(label) } } else { if {$node != $NodeSave(node)} { do_backup if {$parent != $NodeSave(parent)} { if {[catch {CGIOmove $NodeSave(node) $parent} msg]} { errormsg $msg file_reload return } } if {$name != $NodeSave(name)} { set tmpnode [get_node $parent $NodeSave(name)] if {[catch {CGIOname $tmpnode $name} msg]} { errormsg msg } } } } if {$label != $NodeSave(label)} { do_backup if {[catch {CGIOlabel $node $label} msg]} { errormsg $msg } } if {$node != $NodeSave(node)} { TreeMove $ProgData(tree) $NodeSave(node) $node TreeSee $ProgData(tree) $node TreeSelectionSet $ProgData(tree) $node } if {$lnode != ""} { file_reload return } if {$type == "MT"} { if {$NodeSave(type) != "MT"} { do_backup if {[catch {CGIOtype $node MT} msg] || [catch {CGIOdimensions $node {}} msg]} { errormsg $msg } } file_reload return } set data [string trim [$ProgData(text) get 1.0 end]] if {$data == ""} { if {$dim != $NodeSave(dim)} { do_backup if {[catch {CGIOdimensions $node $dim} msg]} { errormsg $msg } } if {$type != $NodeSave(type)} { do_backup if {[catch {CGIOtype $node $type} msg]} { errormsg $msg } } } else { if {$dim == ""} { if {$type == "C1"} { set dim [string length $data] } else { set dim [llength $data] } } if {$type == "C1" && [llength $dim] > 1} { set data [split $data "\n"] } do_backup if {[catch {CGIOwrite $node $type $dim $data} msg]} { errormsg $msg } } file_reload } proc values_perline {} { global ProgData NodeSave if {$NodeSave(name) == "ElementConnectivity" && $NodeSave(label) == "DataArray_t" && ![catch {CGIOlabel $NodeSave(parent)} label] && $label == "Elements_t" && ![catch {CGIOdimensions $NodeSave(parent)} dim] && $dim == 2 && ![catch {CGIOread $NodeSave(parent)} data]} { switch [lindex $data 0] { 2 {return 1} 3 {return 2} 4 - 5 {return 3} 6 - 14 {return 6} 7 - 10 {return 4} 8 - 17 {return 8} 9 {return 9} 11 {return 10} 12 {return 5} 13 {return 14} 15 {return 15} 16 {return 18} 18 {return 20} 19 {return 27} } } set len [lindex $NodeSave(dim) 0] if {$ProgData(maxcnt) && $len > $ProgData(maxcnt)} { return $ProgData(maxcnt) } return $len } proc node_read {{perline 0}} { global ProgData NodeSave set state [$ProgData(text) cget -state] $ProgData(text) configure -state normal $ProgData(text) delete 1.0 end set ProgData(linecnt) "" set node $NodeSave(node) if {$node != "" && [CGIOnode $node] != ""} { . configure -cursor watch update if {[catch {CGIOread $node} data]} { $ProgData(text) insert end $data } else { set dim [llength $NodeSave(dim)] set cnt 1 for {set n 0} {$n < $dim} {incr n} { set cnt [expr $cnt * [lindex $NodeSave(dim) $n]] } if {$NodeSave(type) == "C1"} { if {$dim == 1 && $perline < 1} { $ProgData(text) insert end $data } else { if {$perline > 0} { set len $perline set ProgData(linecnt) $len } else { set len [lindex $NodeSave(dim) 0] } for {set n1 0} {$n1 < $cnt} {incr n1 $len} { set n2 [expr $n1 + $len - 1] $ProgData(text) insert end "[string range $data $n1 $n2]\n" } } } else { if {$perline > 0} { set len $perline } else { set len [values_perline] } for {set n1 0} {$n1 < $cnt} {incr n1 $len} { set n2 [expr $n1 + $len - 1] $ProgData(text) insert end "[lrange $data $n1 $n2]\n" } set ProgData(linecnt) $len } } . configure -cursor {} } $ProgData(text) mark set insert 1.0 $ProgData(text) configure -state $state get_location } proc node_clear {} { global ProgData set state [$ProgData(text) cget -state] if {$state == "normal"} { $ProgData(text) delete 1.0 end } else { $ProgData(text) configure -state normal $ProgData(text) delete 1.0 end $ProgData(text) configure -state $state } set ProgData(linenum) "" set ProgData(lineval) "" set ProgData(linecnt) "" } proc node_delete {} { global ProgData Node set node [get_node [string trim $Node(parent)] \ [string trim $Node(name)]] if {$node != "" && $node != "/"} { delete_node $node } } #---------- utility routines proc full_path {filename} { global tcl_platform set cdir [pwd] if {[catch {cd [file dirname $filename]}]} { return $filename } set pathname "[pwd]/[file tail $filename]" cd $cdir if {$tcl_platform(platform) == "windows"} { return [string tolower $pathname] } return $pathname } proc same_file {file1 file2} { global tcl_platform if {$tcl_platform(platform) == "windows"} { set file1 [join [split $file1 \\] /] set file2 [join [split $file2 \\] /] } set n [expr [file exists $file1] + [file exists $file2]] if {$n == 1} {return 0} if [string compare [full_path $file1] [full_path $file2]] {return 0} return 1 } proc ignore_quit {} {} proc run_command {title cmd {height 10} {width 60}} { global ProgData tcl_platform if {$tcl_platform(platform) == "windows"} { set exe [join [split [lindex $cmd 0] \\] /] set cmd [lreplace $cmd 0 0 $exe] } set w .command catch {destroy $w} toplevel $w wm title $w $title wm transient $w . wm protocol $w WM_DELETE_WINDOW ignore_quit frame $w.f pack $w.f -side top -fill both -padx 5 -pady 5 -expand 1 scrollbar $w.f.s -command "$w.f.t yview" pack $w.f.s -side right -fill y text $w.f.t -width $width -height $height -yscroll "$w.f.s set" pack $w.f.t -side top -fill both -expand 1 $w.f.t tag configure warning -foreground blue $w.f.t tag configure error -foreground red frame $w.b pack $w.b -side bottom button $w.b.close -text Close -command "destroy $w" -state disabled button $w.b.save -text Save -command "save_output $w" -state disabled pack $w.b.close $w.b.save -side left -padx 5 $w.f.t insert end "EXECUTING:\n$cmd\n\n" center_window $w . tkwait visibility $w update if {[catch {open |$cmd r} f]} { destroy $w errormsg $f return 0 } set ProgData(status) 0 fileevent $f readable "run_event $w $f" tkwait window $w return $ProgData(status) } proc run_event {w f} { global ProgData if {![eof $f]} { fconfigure $f -blocking 0 while {[gets $f line] >= 0} { if {[string match {WARNING:*} $line]} { $w.f.t insert end "$line\n" warning } elseif {[string match {ERROR:*} $line]} { $w.f.t insert end "$line\n" error } else { $w.f.t insert end "$line\n" } } fconfigure $f -blocking 1 $w.f.t yview -pickplace end update idletasks return } if {[catch {close $f} msg]} { errormsg $msg $w.f.t insert end "\nERROR:\n$msg" set ProgData(status) 0 } else { $w.f.t insert end "\nFINISHED\n" set ProgData(status) 1 } $w.f.t yview -pickplace end $w.b.close configure -state normal $w.b.save configure -state normal } proc save_output {w} { global ProgData if {$ProgData(file) == ""} { set outfile "output.txt" } else { set outfile [file rootname $ProgData(file)].txt } if {$ProgData(file,name) == ""} return set fname [FileSave "Save Output" $outfile $w \ {{{Text Files} {.txt .out .log}} {{All Files} {*}}} txt] if {$fname == ""} return if {[catch {open $fname w+} f]} { errormsg $f } else { puts $f [$w.f.t get 1.0 end] catch {close $f} } } #---------- initialize and display window catch { config_icon . [list cgnsview cgns] \ [list $cmd_dir $cmd_dir/images $cmd_dir/../common] } update_node "" if {$argc} { set fname [lindex $argv [expr $argc - 1]] if {[file isfile $fname] && [file readable $fname]} { file_load $fname } } CGNS-4.5.0/src/cgnstools/cgnsview/export.tcl000066400000000000000000000201341474000356600207330ustar00rootroot00000000000000# export.tcl - CGNS export routines proc export_default {w name cmd} { global ProgData Font Export tcl_platform if {$cmd != ""} { set exe [lindex $cmd 0] set exepath [get_executable $exe] if {$exepath != ""} {set exe $exepath} if {$tcl_platform(platform) == "windows"} { set Export(exefile) [join [split $exe /] \\] } else { set Export(exefile) $exe } set Export(options) [lrange $cmd 1 end] } set Export(cgnsfile) $ProgData(file,name) toplevel $w wm title $w $name wm transient $w . wm protocol $w WM_DELETE_WINDOW {set Export(done) 0} set labw 12 FrameCreate $w.top -text "Export Command" -font $Font(bold) pack $w.top -side top -padx 5 -pady 5 -fill x set top [FrameGet $w.top] set f [frame $top.exe] pack $f -side top -fill x -expand 1 label $f.lab -text Executable -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Export(exefile) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "export_browse $w exefile" pack $f.but -side right -fill y $f.ent xview [$f.ent index end] set f [frame $top.opts] pack $f -side top -fill x -expand 1 label $f.lab -text Options -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Export(options) -width 30 pack $f.ent -side left -fill x -expand 1 set f [frame $top.input] pack $f -side top -fill x -expand 1 label $f.lab -text "CGNS Input" -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Export(cgnsfile) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "export_browse $w cgnsfile" pack $f.but -side right -fill y set f [frame $top.output] pack $f -side top -fill x -expand 1 label $f.lab -text "Output File" -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Export(outputfile) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 \ -command "export_browse $w outputfile {$name}" pack $f.but -side right -fill y if {[export_buttons $w export_check]} { set cmd [tools_unix_path $Export(exefile)] foreach opt $Export(options) { lappend cmd $opt } lappend cmd $Export(cgnsfile) $Export(outputfile) run_command $name $cmd } } proc export_input {w {base 0} {zone 0} {sol 0} {labw ""}} { global Export Font if {$labw == ""} { if {$sol} { set labw 12 } else { set labw 10 } } FrameCreate $w.input -text "CGNS Input" -font $Font(bold) pack $w.input -side top -padx 5 -pady 2 -fill x set input [FrameGet $w.input] set f [frame $input.file] pack $f -side top -fill x label $f.lab -text Filename -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Export(cgnsfile) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "export_browse $w cgnsfile" pack $f.but -side right -fill y if {$base} { set f [frame $input.base] pack $f -side top -anchor w label $f.lab -text "Base Index" -width $labw -anchor w entry $f.ent -textvariable Export(basenum) -width 10 checkbutton $f.but -text default \ -variable Export(basenum,flag) -onvalue 1 -offvalue 0 \ -command "export_state basenum $f.ent" pack $f.lab $f.ent $f.but -side left export_state basenum $f.ent } if {$zone} { set f [frame $input.zone] pack $f -side top -anchor w label $f.lab -text "Zone Index" -width $labw -anchor w entry $f.ent -textvariable Export(zonenum) -width 10 checkbutton $f.but -text default \ -variable Export(zonenum,flag) -onvalue 1 -offvalue 0 \ -command "export_state zonenum $f.ent" pack $f.lab $f.ent $f.but -side left export_state zonenum $f.ent } if {$sol} { set f [frame $input.sol] pack $f -side top -anchor w label $f.lab -text "Solution Index" -width $labw -anchor w entry $f.ent -textvariable Export(solnum) -width 10 checkbutton $f.but -text default \ -variable Export(solnum,flag) -onvalue 1 -offvalue 0 \ -command "export_state solnum $f.ent" pack $f.lab $f.ent $f.but -side left export_state solnum $f.ent } } proc export_output {w ftype name exts {labw 10}} { global Export Font FrameCreate $w.output -text "$name Output" -font $Font(bold) pack $w.output -side top -padx 5 -pady 2 -fill x set f [FrameGet $w.output] label $f.lab -text Filename -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Export($ftype) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 \ -command "export_browse $w $ftype {$name} {$exts}" pack $f.but -side right -fill y } proc export_options {w {labw ""}} { global Export Font FrameCreate $w.opts -text "Command Line Options" -font $Font(bold) pack $w.opts -side top -padx 5 -pady 2 -fill x set f [FrameGet $w.opts] label $f.lab -text Options pack $f.lab -side left if {$labw != ""} { $f.lab configure -width $labw -anchor w } entry $f.ent -textvariable Export(options) -width 30 pack $f.ent -side left -fill x -expand 1 } proc export_browse {w ftype {name ""} {exts {}}} { global Export tcl_platform if {$ftype == "cgnsfile"} { set fname [FileOpen "CGNS Input File" $Export(cgnsfile) $w \ {{{CGNS Files} {.cgns .cgn .adf}} {{All Files} {*}}}] if {$fname != ""} { if {$tcl_platform(platform) == "windows"} { set Export(cgnsfile) [join [split $fname /] \\] } else { set Export(cgnsfile) $fname } } } elseif {$ftype == "exefile"} { if {$tcl_platform(platform) == "windows"} { set types {{{Executable Files} {.exe .cmd .bat .com}} {{All Files} {*}}} } else { set types {{{All Files} {*}}} } set fname [FileOpen "Export Executable" $Export(exefile) $w $types] if {$fname != ""} { if {$tcl_platform(platform) == "windows"} { set Export(exefile) [join [split $fname /] \\] } else { set Export(exefile) $fname } } } else { if {$name == ""} {set name Output} if {$exts == {}} { set types {{{All Files} {*}}} } else { set types [list [list "$name Files" $exts] [list "All Files" *]] } set fname [FileSave "$name File" $Export($ftype) $w $types] if {$fname != ""} { if {$tcl_platform(platform) == "windows"} { set Export($ftype) [join [split $fname /] \\] } else { set Export($ftype) $fname } } } } proc export_state {what ent {def 1}} { global Export if {$Export($what,flag)} { set Export($what) "" $ent configure -state disabled -cursor {} } else { if {$Export($what) == ""} { set Export($what) $def } $ent configure -state normal -cursor xterm } } proc export_buttons {w {check ""}} { global Export set f [frame $w.but] pack $f -side top -pady 5 button $f.accept -text Accept -width 6 -default active button $f.cancel -text Cancel -width 6 -command {set Export(done) 0} pack $f.accept $f.cancel -side left -padx 5 if {$check == ""} { $f.accept configure -command {set Export(done) 1} } else { $f.accept configure -command "$check $w" bind $w "$check $w" } center_window $w . set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} tkwait visibility $w focus $w tkwait variable Export(done) catch {focus $oldFocus} destroy $w if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } return $Export(done) } proc export_check {w} { global Export if {$Export(exefile) == "" || $Export(outputfile) == "" || $Export(cgnsfile) == ""} { errormsg "must specify an executable, CGNS file and an output file" $w return } if {![file exists $Export(exefile)] || ![file executable $Export(exefile)]} { errormsg "the export executable does not exist or is not executable" $w return } if {![file exists $Export(cgnsfile)]} { errormsg "the CGNS input file doesn't exist" $w return } set Export(done) 1 } CGNS-4.5.0/src/cgnstools/cgnsview/import.tcl000066400000000000000000000204361474000356600207310ustar00rootroot00000000000000# import.tcl - CGNS import routines proc import_default {w name cmd} { global ProgData Font Import tcl_platform if {$cmd != ""} { set exe [lindex $cmd 0] set exepath [get_executable $exe] if {$exepath != ""} {set exe $exepath} if {$tcl_platform(platform) == "windows"} { set Import(exefile) [join [split $exe /] \\] } else { set Import(exefile) $exe } set Import(options) [lrange $cmd 1 end] } set Import(cgnsfile) $ProgData(file,name) toplevel $w wm title $w $name wm transient $w . wm protocol $w WM_DELETE_WINDOW {set Import(done) 0} set labw 12 FrameCreate $w.top -text "Import Command" -font $Font(bold) pack $w.top -side top -padx 5 -pady 5 -fill x set top [FrameGet $w.top] set f [frame $top.exe] pack $f -side top -fill x -expand 1 label $f.lab -text Executable -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Import(exefile) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "import_browse $w exefile" pack $f.but -side right -fill y $f.ent xview [$f.ent index end] set f [frame $top.opts] pack $f -side top -fill x -expand 1 label $f.lab -text Options -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Import(options) -width 30 pack $f.ent -side left -fill x -expand 1 set f [frame $top.input] pack $f -side top -fill x -expand 1 label $f.lab -text "Input File" -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Import(inputfile) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 \ -command "import_browse $w inputfile {$name}" pack $f.but -side right -fill y set f [frame $top.output] pack $f -side top -fill x -expand 1 label $f.lab -text "CGNS Output" -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Import(cgnsfile) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "import_browse $w cgnsfile" pack $f.but -side right -fill y if {[import_buttons $w import_check]} { set cmd [tools_unix_path $Import(exefile)] foreach opt $Import(options) { lappend cmd $opt } lappend cmd $Import(inputfile) $Import(cgnsfile) import_run $name $cmd $Import(cgnsfile) } } proc import_input {w ftype name exts {labw 10}} { global Import Font FrameCreate $w.input -text "$name Input" -font $Font(bold) pack $w.input -side top -padx 5 -pady 2 -fill x set f [FrameGet $w.input] label $f.lab -text Filename -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Import($ftype) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 \ -command "import_browse $w $ftype {$name} {$exts}" pack $f.but -side right -fill y } proc import_output {w {use_base 0} {labw 10}} { global Import Font FrameCreate $w.output -text "CGNS Output" -font $Font(bold) pack $w.output -side top -padx 5 -pady 2 -fill x set output [FrameGet $w.output] set f [frame $output.file] pack $f -side top -fill x label $f.lab -text Filename -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Import(cgnsfile) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "import_browse $w cgnsfile" pack $f.but -side right -fill y if {$use_base} { set f [frame $output.basename] pack $f -side top -anchor w label $f.lab -text "Base Name" -width $labw -anchor w entry $f.ent -textvariable Import(basename) -width 30 checkbutton $f.but -text default \ -variable Import(basename,flag) -onvalue 1 -offvalue 0 \ -command "import_set_state basename $f.ent" pack $f.lab $f.ent $f.but -side left import_set_state basename $f.ent } } proc import_options {w {labw ""}} { global Import Font FrameCreate $w.opts -text "Command Line Options" -font $Font(bold) pack $w.opts -side top -padx 5 -pady 2 -fill x set f [FrameGet $w.opts] label $f.lab -text Options if {$labw != ""} { $f.lab configure -width $labw -anchor w } pack $f.lab -side left entry $f.ent -textvariable Import(options) -width 30 pack $f.ent -side left -fill x -expand 1 } proc import_browse {w ftype {name ""} {exts {}}} { global Import tcl_platform if {$ftype == "cgnsfile"} { set fname [FileSave "CGNS Output File" $Import(cgnsfile) $w \ {{{CGNS Files} {.cgns .cga .cgh .cgx}} {{All Files} {*}}} cgns] if {$fname != ""} { if {$tcl_platform(platform) == "windows"} { set Import(cgnsfile) [join [split $fname /] \\] } else { set Import(cgnsfile) $fname } } } elseif {$ftype == "exefile"} { if {$tcl_platform(platform) == "windows"} { set types {{{Executable Files} {.exe .cmd .bat .com}} {{All Files} {*}}} } else { set types {{{All Files} {*}}} } set fname [FileOpen "Import Executable" $Import(exefile) $w $types] if {$fname != ""} { if {$tcl_platform(platform) == "windows"} { set Import(exefile) [join [split $fname /] \\] } else { set Import(exefile) $fname } } } else { if {$name == ""} {set name Input} if {$exts == {}} { set types {{{All Files} {*}}} } else { set types [list [list "$name Files" $exts] [list "All Files" *]] } set fname [FileOpen "$name File" $Import($ftype) $w $types] if {$fname != ""} { if {$tcl_platform(platform) == "windows"} { set Import($ftype) [join [split $fname /] \\] } else { set Import($ftype) $fname } set Import(cgnsfile) [file rootname $Import($ftype)].cgns } } } proc import_check {w} { global Import if {$Import(exefile) == "" || $Import(inputfile) == "" || $Import(cgnsfile) == ""} { errormsg "must specify an executable, input file and a CGNS file" $w return } if {![file exists $Import(exefile)] || ![file executable $Import(exefile)]} { errormsg "the import executable does not exist or is not executable" $w return } if {![file exists $Import(inputfile)]} { errormsg "the input file doesn't exist" $w return } set Import(done) 1 } proc import_buttons {w {check ""}} { global Import set f [frame $w.but] pack $f -side top -pady 5 button $f.accept -text Accept -width 6 -default active button $f.cancel -text Cancel -width 6 -command {set Import(done) 0} pack $f.accept $f.cancel -side left -padx 5 if {$check == ""} { $f.accept configure -command {set Import(done) 1} } else { $f.accept configure -command "$check $w" bind $w "$check $w" } center_window $w . set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} tkwait visibility $w focus $w tkwait variable Import(done) catch {focus $oldFocus} destroy $w if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } return $Import(done) } proc import_run {title cmd {outfile ""}} { global ProgData if {$ProgData(file,name) == ""} { set same 0 } elseif {$outfile == ""} { set same 1 } elseif {[file dirname $outfile] == "."} { set same [same_file $outfile $ProgData(file,name)] } else { set same [same_file $outfile $ProgData(file)] } if {$same} { catch CGIOclose do_backup } update if {[run_command $title $cmd] && !$same} { file_load $outfile } else { file_reload } } proc import_dup_check {f} { global Import checkbutton $f.dup -text "Duplicate Node Checking" \ -variable Import(dupcheck,flag) -onvalue 1 -offvalue 0 pack $f.dup -side top -anchor w frame $f.tol pack $f.tol -side left label $f.tol.lab -text Tolerance entry $f.tol.ent -textvariable Import(duptol) -width 10 pack $f.tol.lab $f.tol.ent -side top frame $f.type pack $f.type -side left radiobutton $f.type.rel -text Relative -variable Import(dupcheck) -value d radiobutton $f.type.abs -text Absolute -variable Import(dupcheck) -value D pack $f.type.rel $f.type.abs -side top -anchor w } proc import_set_state {what ent} { global Import if {$Import($what,flag)} { set Import($what) "" $ent configure -state disabled -cursor {} } else { $ent configure -state normal -cursor xterm } } CGNS-4.5.0/src/cgnstools/cgnsview/tclIndex000066400000000000000000000040561474000356600204100ustar00rootroot00000000000000# Tcl autoload index file, version 2.0 # cgns.tcl set auto_index(cgns_init) "source $dir/cgns.tcl" set auto_index(cgns_data) "source $dir/cgns.tcl" set auto_index(cgns_tree) "source $dir/cgns.tcl" # import.tcl set auto_index(import_default) "source $dir/import.tcl" set auto_index(import_input) "source $dir/import.tcl" set auto_index(import_output) "source $dir/import.tcl" set auto_index(import_options) "source $dir/import.tcl" set auto_index(import_browse) "source $dir/import.tcl" set auto_index(import_check) "source $dir/import.tcl" set auto_index(import_buttons) "source $dir/import.tcl" set auto_index(import_run) "source $dir/import.tcl" set auto_index(import_dup_check) "source $dir/import.tcl" set auto_index(import_set_state) "source $dir/import.tcl" # export.tcl set auto_index(export_default) "source $dir/export.tcl" set auto_index(export_input) "source $dir/export.tcl" set auto_index(export_output) "source $dir/export.tcl" set auto_index(export_options) "source $dir/export.tcl" set auto_index(export_browse) "source $dir/export.tcl" set auto_index(export_buttons) "source $dir/export.tcl" set auto_index(export_state) "source $dir/export.tcl" set auto_index(export_check) "source $dir/export.tcl" # tools.tcl set auto_index(check_cgns) "source $dir/tools.tcl" set auto_index(diff_cgns) "source $dir/tools.tcl" set auto_index(plot_cgns) "source $dir/tools.tcl" set auto_index(calc_cgns) "source $dir/tools.tcl" set auto_index(tools_default) "source $dir/tools.tcl" set auto_index(tools_utility) "source $dir/tools.tcl" set auto_index(tools_convert) "source $dir/tools.tcl" set auto_index(tools_unix_path) "source $dir/tools.tcl" set auto_index(tools_cgnsinput) "source $dir/tools.tcl" set auto_index(tools_cgnsoutput) "source $dir/tools.tcl" set auto_index(tools_averaging) "source $dir/tools.tcl" set auto_index(tools_browse) "source $dir/tools.tcl" set auto_index(tools_state) "source $dir/tools.tcl" set auto_index(tools_check_input) "source $dir/tools.tcl" set auto_index(tools_interact) "source $dir/tools.tcl" set auto_index(tools_run) "source $dir/tools.tcl" CGNS-4.5.0/src/cgnstools/cgnsview/tools.tcl000066400000000000000000000367071474000356600205670ustar00rootroot00000000000000# tools.tcl - CGNS tool routines proc check_cgns {} { global ProgData Tools if {$ProgData(cgnscheck) == "" || $ProgData(file,name) == ""} return set w .cgnscheck toplevel $w wm title $w "Check CGNS File" wm transient $w . wm protocol $w WM_DELETE_WINDOW {set Tools(done) 0} FrameCreate $w.top pack $w.top -side top -padx 5 -pady 5 -fill x set top [FrameGet $w.top] set f [frame $top.opts] pack $f -side top -fill x -expand 1 checkbutton $f.verbose -text "Verbose Output" -variable Tools(verbose) \ -onvalue "-v" -offvalue "" checkbutton $f.errors -text "Show Errors" -variable Tools(errors) \ -onvalue "" -offvalue "-e" pack $f.verbose $f.errors -side left -fill x -expand 1 set f [frame $top.warn] pack $f -side top -fill x -expand 1 label $f.lab -text "Warning Level" pack $f.lab -side left foreach i {0 1 2 3} { radiobutton $f.f$i -text $i -variable Tools(warnings) -value $i pack $f.f$i -side left -fill x -expand 1 } if {[tools_interact $w ""]} { set cmd [tools_unix_path $ProgData(cgnscheck)] foreach i {verbose errors} { if {$Tools($i) != ""} {lappend cmd $Tools($i)} } lappend cmd -w$Tools(warnings) $ProgData(file,name) run_command "Check CGNS" $cmd 25 } } proc diff_cgns {} { global ProgData Tools if {$ProgData(cgnscheck) == "" || $ProgData(file,name) == ""} return set w .cgnsdiff toplevel $w wm title $w "Diff CGNS File" wm transient $w . wm protocol $w WM_DELETE_WINDOW {set Tools(done) 0} FrameCreate $w.top -text "Diff With ..." pack $w.top -side top -padx 5 -pady 5 -fill x set top [FrameGet $w.top] set f [frame $top.input] pack $f -side top -fill x label $f.lab -text "CGNS File" pack $f.lab -side left entry $f.ent -textvariable Tools(cgnsinput) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "tools_browse $f.but cgnsinput" pack $f.but -side right -fill y FrameCreate $w.opts -text "Options" pack $w.opts -side top -padx 5 -pady 5 -fill x set opts [FrameGet $w.opts] set f [frame $opts.f1] pack $f -side top -fill x -expand 1 checkbutton $f.case -text "Case-insensitive" -variable Tools(nocase) \ -onvalue "-c" -offvalue "" checkbutton $f.space -text "Ignore White Space" -variable Tools(whitespace) \ -onvalue "-i" -offvalue "" checkbutton $f.links -text "Follow Links" -variable Tools(followlinks) \ -onvalue "-f" -offvalue "" pack $f.case $f.space $f.links -side left -fill x -expand 1 set f [frame $opts.f2] pack $f -side top -fill x -expand 1 checkbutton $f.data -text "Compare Node Data" -variable Tools(cmpdata) \ -onvalue "-d" -offvalue "" pack $f.data -side left frame $f.tol label $f.tol.lab -text "Compare Tolerance" entry $f.tol.ent -width 10 -textvariable Tools(cmptol) pack $f.tol.lab $f.tol.ent -side left pack $f.tol -side right if {[tools_interact $w ""]} { set cmd [tools_unix_path $ProgData(cgnsdiff)] foreach i {nocase whitespace followlinks cmpdata} { if {$Tools($i) != ""} {lappend cmd $Tools($i)} } lappend cmd $ProgData(file,name) $Tools(cgnsinput) run_command "Diff CGNS" $cmd 25 } } proc plot_cgns {} { global ProgData tcl_platform if {$ProgData(cgnsplot) == "" || $ProgData(file,name) == ""} return set cmd [tools_unix_path $ProgData(cgnsplot)] lappend cmd $ProgData(file,name) if {[catch {eval exec $cmd &} msg]} { errormsg $msg return } } proc calc_cgns {} { global ProgData if {$ProgData(cgnscalc) == "" || $ProgData(file,name) == ""} return set cmd [tools_unix_path $ProgData(cgnscalc)] lappend cmd $ProgData(file,name) if {[catch {eval exec $cmd &} msg]} { errormsg $msg return } } proc tools_default {w name exe} { global ProgData Tools tools_window $w $name $exe run if {[tools_interact $w tools_check_exe]} { set cmd [tools_unix_path $Tools(exefile)] foreach opt $Tools(options) { lappend cmd $opt } if {$Tools(background)} { if {[catch {eval exec $cmd &} msg]} { errormsg $msg } } else { run_command $name $cmd } } } proc tools_utility {w name exe} { global ProgData Tools set Tools(cgnsinput) $ProgData(file,name) tools_window $w $name $exe utility if {[tools_interact $w tools_check]} { set cmd [tools_unix_path $Tools(exefile)] foreach opt $Tools(options) { lappend cmd $opt } lappend cmd $Tools(cgnsinput) if {$Tools(background)} { if {[catch {eval exec $cmd &} msg]} { errormsg $msg } } else { $name $cmd } } } proc tools_convert {w name exe} { global ProgData Tools set Tools(cgnsinput) $ProgData(file,name) if {$Tools(cgnsoutput) == ""} { set Tools(cgnsoutput) $ProgData(file,name) } tools_window $w $name $exe convert if {[tools_interact $w tools_check]} { set cmd [tools_unix_path $Tools(exefile)] foreach opt $Tools(options) { lappend cmd $opt } lappend cmd $Tools(cgnsinput) if {$Tools(cgnsoutput) != ""} { lappend cmd $Tools(cgnsoutput) } tools_run $name $cmd $Tools(cgnsoutput) } } proc tools_window {w name exe type} { global ProgData Tools Font tcl_platform if {$exe != ""} { set exename [lindex $exe 0] set exepath [get_executable $exename] if {$exepath != ""} {set exename $exepath} if {$tcl_platform(platform) == "windows"} { set Tools(exefile) [join [split $exename /] \\] } else { set Tools(exefile) $exename } set Tools(options) [lrange $exe 1 end] } toplevel $w wm title $w $name wm transient $w . wm protocol $w WM_DELETE_WINDOW {set Tools(done) 0} set labw 12 set lab "[string toupper [string index $type 0]][string range $type 1 end]" FrameCreate $w.top -text "$lab Command" -font $Font(bold) pack $w.top -side top -padx 5 -pady 5 -fill x set top [FrameGet $w.top] set f [frame $top.exe] pack $f -side top -fill x -expand 1 label $f.lab -text Executable -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools(exefile) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "tools_browse $w exefile" pack $f.but -side right -fill y $f.ent xview [$f.ent index end] set f [frame $top.opts] pack $f -side top -fill x -expand 1 if {$type == "run"} { set lab Arguments } else { set lab Options } label $f.lab -text $lab -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools(options) -width 30 pack $f.ent -side left -fill x -expand 1 if {$type != "run"} { set f [frame $top.input] pack $f -side top -fill x label $f.lab -text "CGNS Input" -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools(cgnsinput) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "tools_browse $f.but cgnsinput" pack $f.but -side right -fill y if {$type == "convert"} { set f [frame $top.output] pack $f -side top -fill x label $f.lab -text "CGNS Output" -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools(cgnsoutput) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 \ -command "tools_browse $f.but cgnsoutput" pack $f.but -side right -fill y } } if {$type != "convert"} { checkbutton $top.bg -text "Run Command in Background" \ -variable Tools(background) -onvalue 1 -offvalue 0 pack $top.bg -side top -anchor w } } proc tools_check_input {w} { global Tools if {$Tools(cgnsinput) == "" || ![file exists $Tools(cgnsinput)]} { errormsg "CGNS input file not specified or does not exist" $w return 0 } return 1 } proc tools_check_exe {w} { global Tools if {$Tools(exefile) == ""} { errormsg "must specify an executable" $w return 0 } if {![file exists $Tools(exefile)] || ![file executable $Tools(exefile)]} { errormsg "the utility executable does not exist or is not executable" $w return 0 } return 1 } proc tools_check {w} { if {[tools_check_exe $w] && [tools_check_input $w]} {return 1} return 0 } proc tools_unix_path {exepath} { global tcl_platform if {$tcl_platform(platform) == "windows"} { if {![catch {file attributes $exepath -shortname} name]} { return [join [split $name \\] /] } return [join [split $exepath \\] /] } return $exepath } proc tools_cgnsinput {w {loc 0} {labw 13}} { global ProgData Font Tools FrameCreate $w.cgnsinput -text "CGNS Input" -font $Font(bold) pack $w.cgnsinput -side top -padx 5 -pady 2 -fill x set wf [FrameGet $w.cgnsinput] set f [frame $wf.file] pack $f -side top -fill x label $f.lab -text Filename -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools(cgnsinput) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "tools_browse $f.but cgnsinput" pack $f.but -side right -fill y if {!$loc} return set f [frame $wf.basenum] pack $f -side top -fill x label $f.lab -text "Base Index" -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools(basenum) -width 10 pack $f.ent -side left checkbutton $f.but -text default \ -variable Tools(basenum,flag) -onvalue 1 -offvalue 0 \ -command "tools_state basenum $f.ent" pack $f.but -side left tools_state basenum $f.ent set f [frame $wf.zonenum] pack $f -side top -fill x label $f.lab -text "Zone Index" -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools(zonenum) -width 10 pack $f.ent -side left checkbutton $f.but -text "all zones" \ -variable Tools(zonenum,flag) -onvalue 1 -offvalue 0 \ -command "tools_state zonenum $f.ent" pack $f.but -side left tools_state zonenum $f.ent if {$loc < 2} return set f [frame $wf.solnum] pack $f -side top -fill x label $f.lab -text "Solution Index" -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools(solnum) -width 10 pack $f.ent -side left checkbutton $f.but -text "all solutions" \ -variable Tools(solnum,flag) -onvalue 1 -offvalue 0 \ -command "tools_state solnum $f.ent" pack $f.but -side left tools_state solnum $f.ent } proc tools_cgnsoutput {w {newloc ""} {labw 13}} { global Font Tools FrameCreate $w.cgnsoutput -text "CGNS Output" -font $Font(bold) pack $w.cgnsoutput -side top -padx 5 -pady 2 -fill x set wf [FrameGet $w.cgnsoutput] set f [frame $wf.file] pack $f -side top -fill x label $f.lab -text Filename -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools(cgnsoutput) -width 30 pack $f.ent -side left -fill x -expand 1 button $f.but -text Browse -pady 0 -command "tools_browse $f.but cgnsoutput" pack $f.but -side right -fill y if {$newloc == "solname"} { set lab "Solution Name" } elseif {$newloc == "basename"} { set lab "Base Name" } else { return } set f [frame $wf.newloc] pack $f -side top -fill x label $f.lab -text $lab -width $labw -anchor w pack $f.lab -side left entry $f.ent -textvariable Tools($newloc) -width 30 pack $f.ent -side left -fill x -expand 1 checkbutton $f.but -text default \ -variable Tools($newloc,flag) -onvalue 1 -offvalue 0 \ -command "tools_state $newloc $f.ent {}" pack $f.but -side left tools_state $newloc $f.ent "" } proc tools_averaging {w} { global Font Tools FrameCreate $w.avg -text Averaging -font $Font(bold) pack $w.avg -side top -padx 5 -pady 2 -fill x set avg [FrameGet $w.avg] set f [frame $avg.f] pack $f -side top -fill x -expand 1 radiobutton $f.a -text "Simple Averaging" \ -variable Tools(weight) -value "" radiobutton $f.w -text "Volume Weighting" \ -variable Tools(weight) -value w pack $f.a $f.w -side left -expand 1 return $avg } proc tools_options {w {bgopt 0} {labw ""}} { global Tools Font FrameCreate $w.opts -text "Command Line Options" -font $Font(bold) pack $w.opts -side top -padx 5 -pady 2 -fill x set opts [FrameGet $w.opts] set f [frame $opts.f] pack $f -side top -fill x -expand 1 label $f.lab -text Options if {$labw != ""} { $f.lab configure -width $labw -anchor w } pack $f.lab -side left entry $f.ent -textvariable Tools(options) -width 30 pack $f.ent -side left -fill x -expand 1 if {$bgopt} { checkbutton $opts.bg -text "Run Command in Background" \ -variable Tools(background) -onvalue 1 -offvalue 0 pack $opts.bg -side top -anchor w } return $opts } proc tools_browse {w ftype {name ""}} { global Tools tcl_platform if {$ftype == "exefile"} { if {$tcl_platform(platform) == "windows"} { set types {{{Executable Files} {.exe .cmd .bat .com}} {{All Files} {*}}} } else { set types {{{All Files} {*}}} } set fname [FileOpen Executable $Tools(exefile) $w $types] if {$fname != ""} { if {$tcl_platform(platform) == "windows"} { set Tools(exefile) [join [split $fname /] \\] } else { set Tools(exefile) $fname } } } elseif {$ftype == "cgnsoutput"} { set fname [FileSave "CGNS Output File" $Tools(cgnsoutput) . \ {{{CGNS Files} {.cgns .cgn}} {{All Files} {*}}} cgns] if {$fname != ""} { if {$tcl_platform(platform) == "windows"} { set Tools(cgnsoutput) [join [split $fname /] \\] } else { set Tools(cgnsoutput) $fname } } } else { if {$name == ""} {set name Input} set fname [FileOpen "CGNS $name File" $Tools($ftype) . \ {{{CGNS Files} {.cgns .cga .cgh .cgx}} {{All Files} {*}}}] if {$fname != ""} { if {$tcl_platform(platform) == "windows"} { set Tools($ftype) [join [split $fname /] \\] } else { set Tools($ftype) $fname } } } } proc tools_state {what ent {def 1}} { global Tools if {$Tools($what,flag)} { set Tools($what) "" $ent configure -state disabled -cursor {} } else { if {$Tools($what) == ""} { set Tools($what) $def } $ent configure -state normal -cursor xterm } } proc tools_interact {w {check_proc tools_check_input}} { global Tools set f [frame $w.but] pack $f -side bottom -pady 5 button $f.accept -text Accept -width 6 -default active button $f.cancel -text Cancel -width 6 -command {set Tools(done) 0} pack $f.accept $f.cancel -side left -padx 5 if {$check_proc == ""} { $f.accept configure -command {set Tools(done) 1} bind $w {set Tools(done) 1} } else { $f.accept configure -command " if {!\[catch {$check_proc $w} result\] && \$result} { set Tools(done) 1 } " bind $w " if {!\[catch {$check_proc $w} result\] && \$result} { set Tools(done) 1 } " } center_window $w . set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } catch {grab $w} tkwait visibility $w focus $w tkwait variable Tools(done) catch {focus $oldFocus} destroy $w if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } return $Tools(done) } proc tools_run {title cmd {outfile ""}} { global ProgData if {$outfile == ""} { set same 1 } elseif {[file dirname $outfile] == "."} { set same [same_file $outfile $ProgData(file,name)] } else { set same [same_file $outfile $ProgData(file)] } if {$same} { catch CGIOclose do_backup } update if {[run_command $title $cmd] && !$same} { file_load $outfile } else { file_reload } } CGNS-4.5.0/src/cgnstools/cgnsview/winmain.c000066400000000000000000000203611474000356600205160ustar00rootroot00000000000000/* * winMain.c -- * * Main entry point for wish and other Tk-based applications. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright (c) 1998-1999 by Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN #include #include "tkWinInt.h" #include #include extern int CGIOtcl_Init _ANSI_ARGS_((Tcl_Interp *interp)); #ifdef USE_HTMLHELP extern int WinHtml_Init _ANSI_ARGS_((Tcl_Interp *interp)); #endif /* * Forward declarations for procedures defined later in this file: */ static void setargv _ANSI_ARGS_((int *argcPtr, char ***argvPtr)); static void WishPanic _ANSI_ARGS_(TCL_VARARGS(char *,format)); static int Proc_LoadIcon _ANSI_ARGS_((ClientData data, Tcl_Interp *interp, int argc, char **argv)); static HINSTANCE myInstance; /* *---------------------------------------------------------------------- * * WinMain -- * * Main entry point from Windows. * * Results: * Returns false if initialization fails, otherwise it never * returns. * * Side effects: * Just about anything, since from here we call arbitrary Tcl code. * *---------------------------------------------------------------------- */ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { char **argv; int argc; char buffer[MAX_PATH+1]; char *p; Tcl_SetPanicProc((Tcl_PanicProc *)WishPanic); /* * Increase the application queue size from default value of 8. * At the default value, cross application SendMessage of WM_KILLFOCUS * will fail because the handler will not be able to do a PostMessage! * This is only needed for Windows 3.x, since NT dynamically expands * the queue. */ SetMessageQueue(64); /* * Set up the default locale to be standard "C" locale so parsing * is performed correctly. */ setlocale(LC_ALL, "C"); setargv(&argc, &argv); /* * Replace argv[0] with full pathname of executable, and forward * slashes substituted for backslashes. */ GetModuleFileName(NULL, buffer, sizeof(buffer)); argv[0] = buffer; for (p = buffer; *p != '\0'; p++) { if (*p == '\\') { *p = '/'; } } myInstance = hInstance; Tk_Main(argc, argv, Tcl_AppInit); return 1; } /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in the interp's result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(Tcl_Interp *interp) { if (Tcl_Init(interp) == TCL_ERROR) { goto error; } if (Tk_Init(interp) == TCL_ERROR) { goto error; } Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit); if (CGIOtcl_Init(interp) == TCL_ERROR) goto error; #ifdef USE_HTMLHELP if (WinHtml_Init(interp) == TCL_ERROR) goto error; #endif Tcl_CreateCommand (interp, "LoadIcon", (Tcl_CmdProc *)Proc_LoadIcon, (ClientData)0, (Tcl_CmdDeleteProc *)0); Tcl_SetVar(interp, "tcl_rcFileName", "~/wishrc.tcl", TCL_GLOBAL_ONLY); return TCL_OK; error: MessageBeep(MB_ICONEXCLAMATION); MessageBox(NULL, Tcl_GetStringResult(interp), "Error in Wish", MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); ExitProcess(1); /* we won't reach this, but we need the return */ return TCL_ERROR; } /* *---------------------------------------------------------------------- * * WishPanic -- * * Display a message and exit. * * Results: * None. * * Side effects: * Exits the program. * *---------------------------------------------------------------------- */ void WishPanic TCL_VARARGS_DEF(char *,arg1) { va_list argList; char buf[1024]; char *format; format = TCL_VARARGS_START(char *,arg1,argList); vsprintf(buf, format, argList); MessageBeep(MB_ICONEXCLAMATION); MessageBox(NULL, buf, "Fatal Error in Wish", MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); #ifdef _MSC_VER DebugBreak(); #endif ExitProcess(1); } /* *------------------------------------------------------------------------- * * setargv -- * * Parse the Windows command line string into argc/argv. Done here * because we don't trust the builtin argument parser in crt0. * Windows applications are responsible for breaking their command * line into arguments. * * 2N backslashes + quote -> N backslashes + begin quoted string * 2N + 1 backslashes + quote -> literal * N backslashes + non-quote -> literal * quote + quote in a quoted string -> single quote * quote + quote not in quoted string -> empty string * quote -> begin quoted string * * Results: * Fills argcPtr with the number of arguments and argvPtr with the * array of arguments. * * Side effects: * Memory allocated. * *-------------------------------------------------------------------------- */ static void setargv(int *argcPtr, char ***argvPtr) { char *cmdLine, *p, *arg, *argSpace; char **argv; int argc, size, inquote, copy, slashes; cmdLine = GetCommandLine(); /* INTL: BUG */ /* * Precompute an overly pessimistic guess at the number of arguments * in the command line by counting non-space spans. */ size = 2; for (p = cmdLine; *p != '\0'; p++) { if ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */ size++; while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */ p++; } if (*p == '\0') { break; } } } argSpace = (char *) Tcl_Alloc( (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1)); argv = (char **) argSpace; argSpace += size * sizeof(char *); size--; p = cmdLine; for (argc = 0; argc < size; argc++) { argv[argc] = arg = argSpace; while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */ p++; } if (*p == '\0') { break; } inquote = 0; slashes = 0; while (1) { copy = 1; while (*p == '\\') { slashes++; p++; } if (*p == '"') { if ((slashes & 1) == 0) { copy = 0; if ((inquote) && (p[1] == '"')) { p++; copy = 1; } else { inquote = !inquote; } } slashes >>= 1; } while (slashes) { *arg = '\\'; arg++; slashes--; } if ((*p == '\0') || (!inquote && ((*p == ' ') || (*p == '\t')))) { /* INTL: ISO space. */ break; } if (copy != 0) { *arg = *p; arg++; } p++; } *arg = '\0'; argSpace = arg + 1; } argv[argc] = NULL; *argcPtr = argc; *argvPtr = argv; } /*---------------------------------------------------------------------- * set the toplevel window icon *----------------------------------------------------------------------*/ typedef struct TkWmInfo { TkWindow *winPtr; HWND hwnd; } WmInfo; static int Proc_LoadIcon(ClientData data, Tcl_Interp *interp, int argc, char **argv) { TkWindow *winPtr; HANDLE hIcon; HWND hwnd = NULL; if (2 != argc) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " iconname\"", (char *) NULL); return TCL_ERROR; } winPtr = (TkWindow *) Tk_MainWindow (interp); if (NULL != winPtr && NULL != winPtr->wmInfoPtr) hwnd = winPtr->wmInfoPtr->hwnd; if (!hwnd) { Tcl_SetResult (interp, "toplevel window has not been created/mapped", TCL_STATIC); return TCL_ERROR; } if (argv[1][0] == '@') hIcon = LoadImage (NULL, &argv[1][1], IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE); else hIcon = (HANDLE) LoadIcon (myInstance, argv[1]); if (!hIcon) { Tcl_SetResult (interp, "icon not found", TCL_STATIC); return TCL_ERROR; } SetClassLongPtr (hwnd, GCLP_HICON, (LONG_PTR)hIcon); Tcl_ResetResult (interp); return TCL_OK; } CGNS-4.5.0/src/cgnstools/common/000077500000000000000000000000001474000356600163515ustar00rootroot00000000000000CGNS-4.5.0/src/cgnstools/common/CMakeLists.txt000066400000000000000000000011631474000356600211120ustar00rootroot00000000000000########## # common # ########## if (WIN32) install(FILES balloon.tcl color.tcl combobox.tcl config.tcl dialog.tcl editfile.tcl filesel.tcl findfile.tcl frame.tcl help.tcl menubar.tcl tclIndex tclreg.tcl tkdir.tcl tree.tcl units.tcl cgns.ico cgns.png cgns-icon.xbm cgns-mask.xbm DESTINATION share) else () install(FILES balloon.tcl color.tcl combobox.tcl config.tcl dialog.tcl editfile.tcl filesel.tcl findfile.tcl frame.tcl help.tcl menubar.tcl tclIndex tclreg.tcl tkdir.tcl tree.tcl units.tcl cgns.ico cgns.png cgns-icon.xbm cgns-mask.xbm DESTINATION share/cgnstools) endif () CGNS-4.5.0/src/cgnstools/common/balloon.tcl000066400000000000000000000055741474000356600205160ustar00rootroot00000000000000 array set Balloon { set 0 first 0 id "" } proc set_balloon {target message} { global Balloon set tags [bindtags $target] set n [lsearch $tags Balloon] if {$message == ""} { if {$n >= 0} { bindtags $target [lreplace $tags $n $n] } } else { if {$n < 0} { bindtags $target "Balloon $tags" } } set Balloon($target) $message } proc end_balloon {target} { set_balloon $target "" } bind Balloon { set Balloon(set) 0 set Balloon(first) 1 set Balloon(id) [after 500 {Balloon:show %W $Balloon(%W) %X %Y}] } bind Balloon