Adding grid generating data file opening and closing codes

Adds codes for opening and closing grid generating data file.

The grid generating program has to open calculation data file in the first step, and close it in the last step.

iRIC will handle the file name of grid generating data file as the first argument, so open that file.

The way to handle the number of arguments and the arguments differs by compilers. Refer to List 19 for the way to handle them with Intel Fortran Compiler and gfortran. In this chapter we will add codes that can be compiled using Intel Fortran Compiler.

List 19 shows the source code with the lines to open and close grid generating data file. The added lines are shown with highlight.

List 19 The source code with lines to open and close file
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
program SampleProgram
  implicit none
  include 'cgnslib_f.h'

  integer:: fin, ier
  integer:: icount, istatus

  character(200)::condFile

  icount = nargs()
  if ( icount.eq.2 ) then
    call getarg(1, condFile, istatus)
  else
    stop "Input File not specified."
  endif

  ! Opens grid generating data file
  call cg_open_f(condFile, CG_MODE_MODIFY, fin, ier)
  if (ier /=0) stop "*** Open error of CGNS file ***"

  ! Initializes iRIClib. ier will be 1, but that is not a problem.
  call cg_iric_init_f(fin, ier)

  ! Closes grid generating data file
  call cg_close_f(fin, ier)
end program SampleProgram

Compile the executable file, just like in Creating a scelton.

Check that the source code can be compiled successfully.

Refer to Opening a CGNS file, Initializing iRIClib and Closing a CGNS file for the details of the subroutines added in this section.