| Class | namelist_util |
| In: |
setup/namelist_util.f90
|
Note that Japanese and English are described in parallel.
| namelist_filename : | NAMELIST ファイルの名称. |
| MaxNmlArySize : | NAMELIST から読み込む配列の最大サイズ. |
| ———— : | ———— |
| namelist_filename : | NAMELIST file name |
| MaxNmlArySize : | Maximum size of arrays loaded from NAMELIST |
| NmlutilInit : | NAMELIST ファイル名の設定 |
| NmlutilMsg : | NAMELIST ファイル入力に関するメッセージ表示 |
| NmlutilAryValid : | NAMELIST ファイルから読み込んだ配列の有効性をチェック |
| ———— : | ———— |
| NmlutilInit : | Settings of NAMELIST file name |
| NmlutilMsg : | Print messages about NAMELIST file input |
| NmlutilAryValid : | Check validation of arrays loaded from NAMELIST file |
| Constant : | |||
| MaxNmlArySize = 256 : | integer, parameter, public
|
| Subroutine : | |||
| name : | character(*), intent(in)
| ||
| array(:) : | real(DP), intent(in)
| ||
| array_name : | character(*), intent(in)
| ||
| need_num : | integer, intent(in)
| ||
| need_num_name : | character(*), intent(in)
| ||
| valid_limit : | real(DP), intent(in), optional
|
NAMELIST から読み込んだ配列型データの妥当性を チェックします.
デフォルトでは, 正の値を有効と扱います. 無効であると検証された場合には, エラーを発生させます.
Check validation of array data loaded from NAMELIST.
By defaut, positive values are treated as valid values. If invalidation is checked, an error is occurred.
subroutine NmlutilAryValid( name, array, array_name, need_num, need_num_name, valid_limit )
!
! NAMELIST から読み込んだ配列型データの妥当性を
! チェックします.
!
! デフォルトでは, 正の値を有効と扱います.
! 無効であると検証された場合には, エラーを発生させます.
!
! Check validation of array data loaded from NAMELIST.
!
! By defaut, positive values are treated as valid values.
! If invalidation is checked, an error is occurred.
!
! モジュール引用 ; USE statements
!
! 種別型パラメタ
! Kind type parameter
!
use dc_types, only: DP ! 倍精度実数型. Double precision.
! 宣言文 ; Declaration statements
!
implicit none
character(*), intent(in):: name
! このサブルーチンを呼び出すモジュールの名称.
! Module name calling this subroutine
real(DP), intent(in):: array(:)
! 検証すべき配列データ.
! Checked array data
character(*), intent(in):: array_name
! 検証すべき配列データの名前.
! Name of checked array data
integer, intent(in):: need_num
! 必要なデータ数.
! 0 未満の数を与えるとエラーを生じます.
!
! Number of needed data.
! If number less than 0, an error is occurred.
character(*), intent(in):: need_num_name
! 必要なデータ数を示す変数の名前.
! Name of a variable that indicates number of needed data
real(DP), intent(in), optional:: valid_limit
! 有効下限値 (デフォルトは 0.0).
! Lower limit of validation (defalt is 0.0)
! 作業変数
! Work variables
!
real(DP):: valid_limit_work
! 有効下限値 (デフォルトは 0.0).
! Lower limit of validation (defalt is 0.0)
integer:: valid_count ! 配列データの有効値の数.
! Number of valid values in an array
integer:: size_array ! 配列データのサイズ
! Size of array data
! 実行文 ; Executable statement
!
! need_num が負ではないことをチェック
! Check that "need_num" is not negative
!
if ( need_num < 0 ) then
call MessageNotify( 'E', name, '%c=<%d> must not be negative.', c1 = trim(need_num_name), i = (/ need_num /) )
end if
! array のサイズが十分であることをチェック
! Check that size of "array" is enough
!
size_array = size(array)
if ( need_num > size_array ) then
call MessageNotify( 'E', name, 'Maximum size=<%d> of "%c" is too smaller than %c=<%d>. ' // 'Please search for a statement "MaxNmlArySize = %d" in ' // '"namelist_util.f90", and change it into "MaxNmlArySize = %d".', i = (/ size_array, need_num, MaxNmlArySize, need_num /), c1 = trim(array_name), c2 = trim(need_num_name) )
end if
! array をチェック
! Check "array"
!
if ( need_num > 0 ) then
valid_limit_work = 0.0_DP
if ( present( valid_limit ) ) valid_limit_work = valid_limit
if ( any( array(1:need_num) < valid_limit_work ) ) then
valid_count = count( .not. ( array(1:need_num) < valid_limit_work ) )
if ( valid_count > 0 ) then
call MessageNotify( 'E', name, 'Number of valid data of %c=<%*f> is %d. ' // 'Valid data is %c=<%d> necessary.', c1 = trim( array_name ), c2 = trim( need_num_name ), d = array(1:valid_count), n = (/ valid_count /), i = (/ valid_count, need_num /) )
else
call MessageNotify( 'E', name, 'Valid data of %c is nothing. ' // 'Valid data is %c=<%d> necessary.', c1 = trim( array_name ), c2 = trim( need_num_name ), i = (/ need_num /) )
end if
end if
end if
end subroutine NmlutilAryValid
| Subroutine : |
namelist_util モジュールの初期設定を行います.
Initialize "namelist_util" module.
subroutine NmlutilInit
!
! namelist_util モジュールの初期設定を行います.
!
! Initialize "namelist_util" module.
!
! モジュール引用 ; USE statements
!
! ファイル入出力補助
! File I/O support
!
use dc_iounit, only: FileOpen
! コマンドライン引数解析処理
! Command line option parser
!
use option_parser, only: opt_nml_file => namelist_filename
! 宣言文 ; Declaration statements
!
implicit none
!!$ integer:: unit_nml ! NAMELIST ファイルオープン用装置番号.
!!$ ! Unit number for NAMELIST file open
!!$ integer:: iostat_nml ! NAMELIST 読み込み時の IOSTAT.
!!$ ! IOSTAT of NAMELIST read
! 実行文 ; Executable statement
!
if ( namelist_util_inited ) return
call InitCheck
namelist_filename = opt_nml_file
! NAMELIST の読み込み
! NAMELIST is input
!
!!$ call FileOpen( unit_nml, & ! (out)
!!$ & namelist_filename, mode = 'r' ) ! (in)
!!$
!!$ rewind( unit_nml )
!!$ read( unit_nml, & ! (in)
!!$ & nml = namelist_util_nml, & ! (out)
!!$ & iostat = iostat_nml ) ! (out)
!!$ close( unit_nml )
!!$
!!$ call NmlutilMsg( iostat_nml, module_name ) ! (in)
! 印字 ; Print
!
call MessageNotify( 'M', module_name, '----- Initialization Messages -----' )
call MessageNotify( 'M', module_name, ' MaxNmlArySize = %d', i = (/ MaxNmlArySize /) )
call MessageNotify( 'M', module_name, '-- version = %c', c1 = trim(version) )
namelist_util_inited = .true.
end subroutine NmlutilInit
| Subroutine : | |||
| iostat : | integer, intent(in)
| ||
| name : | character(*), intent(in)
|
NAMELIST ファイル入力ステータスから 適切なメッセージを表示します.
Appropriate messages are output from status of NAMELIST file loading.
subroutine NmlutilMsg( iostat, name )
!
! NAMELIST ファイル入力ステータスから
! 適切なメッセージを表示します.
!
! Appropriate messages are output from
! status of NAMELIST file loading.
!
implicit none
integer, intent(in):: iostat
! NAMELIST 読み込み時のステータス.
! Status of NAMELIST loading
character(*), intent(in):: name
! モジュールの名称.
! Module name
! 実行文 ; Executable statement
!
if ( iostat == 0 ) then
call MessageNotify( 'M', name, 'NAMELIST group "%c" is loaded from "%c".', c1 = trim(name) // '_nml', c2 = trim(namelist_filename) )
else
call MessageNotify( 'W', name, 'NAMELIST group "%c" is not found in "%c" (iostat=%d).', c1 = trim(name) // '_nml', c2 = trim(namelist_filename), i = (/iostat/) )
end if
end subroutine NmlutilMsg
| Variable : | |||
| namelist_filename = ’’ : | character(STRING), save, public
|
| Variable : | |||
| namelist_util_inited = .false. : | logical, save, public
|
| Subroutine : |
依存モジュールの初期化チェック
Check initialization of dependency modules
subroutine InitCheck
!
! 依存モジュールの初期化チェック
!
! Check initialization of dependency modules
! モジュール引用 ; USE statements
!
! コマンドライン引数解析処理
! Command line option parser
!
use option_parser, only: option_parser_inited
! 実行文 ; Executable statement
!
if ( .not. option_parser_inited ) call MessageNotify( 'E', module_name, '"option_parser" module is not initialized.' )
end subroutine InitCheck
| Constant : | |||
| module_name = ‘namelist_util‘ : | character(*), parameter
|
| Constant : | |||
| version = ’$Name: dcpam5-20100224 $’ // ’$Id: namelist_util.f90,v 1.2 2008-11-16 17:50:56 morikawa Exp $’ : | character(*), parameter
|