CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

On compiling examples of CGNS

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By mfolusiak

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 20, 2015, 02:02
Default On compiling examples of CGNS
  #1
Member
 
Join Date: Jul 2014
Posts: 31
Rep Power: 12
nba1942 is on a distinguished road
Hi

I am working on installing CGNS on Ubuntu. Well, actually I am already done with installing it but the problem is about actually using it.

I followed the guide I found from a personal blog which is like as below; (in case I did it in a wrong way)

================================================== ================================================== ===============
1. installing "cmake-gt-gui" from Ubuntu Software Center.

2. installing "libx11-dev", "libxmu-dev" from Synaptic Package Manager

3. installing "OpenGL";
* sudo apt-get install libg11-mesa-dev
* sudo apt-get install libglul-mesa-dev
* sudo apt-get install mesa-common-dev

4. installing "szip", "zlib", "HDF5", "tcl/tk";

4.1 zlib
- downloading "zlib-1.2.8" from http://zlib.net
- unzip it
* ./configure -prefix=/opt/hdf5-1.8.14
* make
* make check
* sudo make install

4.2 szip
- downloading "szip-2.1"
- unzip it
* ./configure -prefix=/opt/hdf5-1.8.14
* make
* make check
* sudo make install

4.3 HDF5
- downloading "hdf5-1.8.14"
- unzip it
* ./configure -prefix=/opt/hdf5-1.8.14 --with-zlib=/opt/hdf5-1.8.14 --with-szip=/opt/hdf5-1.8.14
* make
* make check
* sudo make install

% if C++ error occurs : * sudo apt-get install build-essential

4.4 tcl/tk
- downloading "tcl8.6.4-src" & "tk8.6.4-src"
- unzip them
* ./configure -prefix=/opt/tcl8.6.4
* make
* make check
* sudo make install
&
* ./configure -prefix=/opt/tcl8.6.4
* make
* make check
* sudo make install

5. cmake
* sudo cmake-gui
- options are like figure 1
- configure & generate

6. make install(@ /home/kim/Downloads/build)
* sudo make
* sudo make install
================================================== ================================================== ===============

This is what I did to intall CGNS on Ubuntu.

I tried to use the library on an example(cgns_test.f90) but an error occures saying;

"Error: Can't open included file 'cgnslib_f.h"

I thought maybe I need to make a link of "cgnslib_f.h" in the directory in which "cgns_test.f90" is.

then tons of errors occure like figure 2.

I really don't know what to do. Can anyone help me?

I am desperately waiting for any help.

Thank you for reading.
Attached Images
File Type: jpg figure 1.jpg (46.3 KB, 25 views)
File Type: jpg figure 2.jpg (40.1 KB, 28 views)

Last edited by nba1942; May 20, 2015 at 03:23.
nba1942 is offline   Reply With Quote

Old   May 20, 2015, 02:03
Default by the way, "cgns_test.f90" is like this;
  #2
Member
 
Join Date: Jul 2014
Posts: 31
Rep Power: 12
nba1942 is on a distinguished road
program cgns_test
implicit none
include 'cgnslib_f.h'

integer :: i, j, k
integer :: ni, nj, nk
real, allocatable :: x(:,:,: ), y(:,:,: ), z(:,:,: )
ni=21
nj=17
nk=9
allocate(x(ni,nj,nk),y(ni,nj,nk),z(ni,nj,nk))
do k=1, nk
do j=1, nj
do i=1, ni
x(i,j,k)=real(i-1)
y(i,j,k)=real(j-1)
z(i,j,k)=real(k-1)
enddo
enddo
enddo

write(6,'(''created simple 3-D grid points'')')
call cg_open_f('grid.cgns',CG_MODE_WRITE,index_file,ier )
end program

Last edited by nba1942; May 20, 2015 at 03:25.
nba1942 is offline   Reply With Quote

Old   October 8, 2015, 16:34
Default
  #3
New Member
 
Michal Folusiak
Join Date: Oct 2015
Location: Bergen, Norway / Warsaw, Poland
Posts: 3
Rep Power: 11
mfolusiak is on a distinguished road
Hi,
I assume you didn't solve this yet.
Did you add the path to the header file to the include path during compilation?
See also the header comment of the file that you include. It says to use the module cgns from file cgns_f.F90
Regards,
Michal
mfolusiak is offline   Reply With Quote

Old   October 8, 2015, 22:28
Default @ Michal
  #4
Member
 
Join Date: Jul 2014
Posts: 31
Rep Power: 12
nba1942 is on a distinguished road
Yes you are right

I solved the problem by adding the path as you said.

Now I am facing another problem..

Anyway thanks for your reply!
nba1942 is offline   Reply With Quote

Old   October 9, 2015, 04:27
Default Use cmake if possible
  #5
New Member
 
Michal Folusiak
Join Date: Oct 2015
Location: Bergen, Norway / Warsaw, Poland
Posts: 3
Rep Power: 11
mfolusiak is on a distinguished road
It is me again,
let me just use this thread to encourage anyone starting with CGNS to use CMake if only possible. It will save you a lot of time and nerves, while trying to set correct include and linking paths.
Here is my test project with CGNS used as a subproject:
Code:
> tree -L 1 .
.
├── CGNS
├── cgns_test.f90
└── CMakeLists.txt
Code:
> cat CMakeLists.txt 
cmake_minimum_required(VERSION 2.6)

##########################################################
# configure CGNS subproject
# the following must be here for the DSGNS to build
set(CMAKE_BUILD_TYPE "release" CACHE STRING
  "one of: Release, Debug, RelWithDebInfo or MinSizeRel")
# variables passed to CGNS subproject
set(CGNS_ENABLE_HDF5    "ON" CACHE INTERNAL "Force CGNS to use HDF5.")
set(CGNS_ENABLE_FORTRAN "ON" CACHE INTERNAL "Force CGNS to use Fortran.")
set(FORTRAN_NAMING      "LOWERCASE_" CACHE INTERNAL "Configures how to link the Fortran components into the C library.")
add_subdirectory(CGNS)
##########################################################

project("CGNS test" Fortran)
set(EXE_NAME CGNS_test)

include_directories(
  ${PROJECT_BINARY_DIR}/CGNS/src/ # module cgns
)

add_executable(${EXE_NAME} cgns_test.f90)

# link to cgns_static library and other libraries if necessary
target_link_libraries(${EXE_NAME} cgns_static)
if (CGNS_ENABLE_HDF5)
  find_library(HDF5_LIBRARY hdf5)
  target_link_libraries(${EXE_NAME} hdf5)
endif (CGNS_ENABLE_HDF5)
Code:
 > cat cgns_test.f90 
program cgns_test
use cgns
implicit none
write(*,*) 'Hello world, cgns_test'
call cg_error_exit_f()
end program cgns_test
Now, from Build directory just type:
Code:
cmake /path/to/Source && make && ./CGNS_test
nba1942 likes this.
mfolusiak is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CGNS Compiling Diego Main CFD Forum 17 December 21, 2014 02:40
Compiling with CGNS Support granbycools SU2 Installation 6 March 31, 2014 07:52
Errors when compiling CGNS 3.1.3 Tommy Chen SU2 8 January 19, 2014 15:41
CGNS fortran code compiling with intel visual fortran xe dokeun Main CFD Forum 1 April 5, 2012 22:01
CGNS libraries, compiling and linking... Ironman80 Main CFD Forum 2 February 14, 2006 23:36


All times are GMT -4. The time now is 11:10.