Adding calculation data file opening and closing codes

Adds codes for opening and closing calculation data file.

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

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

The way to handle the number of arguments and the arguments differs by compilers. Refer to Handling command line arguments in Fortran programs 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.

Table List 7 shows the source code with the lines to open and close calculation data file. The added lines are shown with highlight.

List 7 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
27
28
29
30
31
32
33
program SampleProgram
  implicit none
  include 'cgnslib_f.h'
  include 'iriclib_f.h'
  integer:: fin, ier
  integer:: icount, istatus
  character(200)::condFile

  write(*,*) "Sample Program"

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

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

  ! Initializes iRIClib
  call cg_iric_init_f(fin, ier)
  if (ier /=0) STOP "*** Initialize error of CGNS file ***"
  ! Set options
  call iric_initoption_f(IRIC_OPTION_CANCEL, ier)
  if (ier /=0) STOP "*** Initialize option error***"

  ! Closes calculation data file.
  call cg_close_f(fin, ier)
  stop
end program SampleProgram

Compile and deploy the executable file, just like in Creating a skelton.

Check whether it can be launched from iRIC successfully, just like in Creating a skelton.

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