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
 1program SampleProgram
 2  implicit none
 3  include 'cgnslib_f.h'
 4  include 'iriclib_f.h'
 5  integer:: fin, ier
 6  integer:: icount, istatus
 7  character(200)::condFile
 8
 9  write(*,*) "Sample Program"
10
11  icount = nargs()
12  if ( icount.eq.2 ) then
13    call getarg(1, condFile, istatus)
14  else
15    write(*,*) "Input File not specified."
16    stop
17  endif
18
19  ! Opens calculation data file.
20  call cg_open_f(condFile, CG_MODE_MODIFY, fin, ier)
21  if (ier /=0) stop "*** Open error of CGNS file ***"
22
23  ! Initializes iRIClib
24  call cg_iric_init_f(fin, ier)
25  if (ier /=0) STOP "*** Initialize error of CGNS file ***"
26  ! Set options
27  call iric_initoption_f(IRIC_OPTION_CANCEL, ier)
28  if (ier /=0) STOP "*** Initialize option error***"
29
30  ! Closes calculation data file.
31  call cg_close_f(fin, ier)
32  stop
33end 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.