Class axis_y_mod
In: axis/axis_y.f90

    Copyright (C) GFD Dennou Club, 2005. All rights reserved.

                                                                 !=begin

Module axis_y_mod

  * Developers: Morikawa Yasuhiro
  * Version: $Id: axis_y.f90,v 1.9 2005/01/19 08:52:24 morikawa Exp $
  * Tag Name: $Name:  $
  * Change History:

Overview

This module set axis Y or axis Latitude. Y 軸または緯度軸を設定する。

Error Handling

Known Bugs

netCDF データから Y 軸を入力する axis_y_netcdf にて、 元データが radians でも degrees でも、そのまま入力されるように なっている。本来は元データの units から判定すべき。

Note

Future Plans

                                                                 !=end

Methods

Included Modules

type_mod axis_type_mod type_mod nmlfile_mod grid_3d_mod spml_mod axis_type_mod gt4_history dc_types dc_url dc_trace dc_message constants_mod axis_type_mod spml_mod grid_3d_mod gt4_history dc_trace axis_type_mod constants_mod spml_mod dc_string dc_trace axis_type_mod spml_mod dc_trace axis_type_mod gt4_history dc_url dc_trace dc_trace

Public Instance methods

begin

Terminate module

((<axis_y_init>)) で設定された値を破棄し、デフォルトに戻す。

[Source]

subroutine axis_y_end ()

  !==== Dependency
    use dc_trace,  only: DbgMessage, BeginSub, EndSub
                                                                 !=end
    implicit none
    character(STRING), parameter:: subname = "axis_y_end"
  continue
    !----------------------------------------------------------------
    !   Check Initialization
    !----------------------------------------------------------------
    call BeginSub(subname)
    if ( .not. axis_y_initialized) then
       call EndSub( subname, 'axis_y_init was not called', &
            &       c1=trim(subname) )
       return
    else
       axis_y_initialized = .false.
       axis_y_data_from_spectral = .false.
       axis_y_data_from_manual   = .false.
       axis_y_data_from_netcdf   = ''

       !--------------------------------------------------------------
       !   Initialize y_Dim
       !--------------------------------------------------------------
       y_Dim%stored   = .false.
       y_Dim%axisinfo%name     = ''
       y_Dim%axisinfo%length   = 0
       y_Dim%axisinfo%longname = ''
       y_Dim%axisinfo%units    = ''
       y_Dim%axisinfo%xtype    = ''
       if ( allocated(y_Dim%a_Dim) ) then
          deallocate( y_Dim%a_Dim )
       endif

       if ( allocated(y_Dim%attrs) ) then
          deallocate( y_Dim%attrs )
       end if

       !--------------------------------------------------------------
       !   Initialize y_Dim_Weight
       !--------------------------------------------------------------
       y_Dim_Weight%axisinfo%name     = ''
       y_Dim_Weight%axisinfo%length   = 0
       y_Dim_Weight%axisinfo%longname = ''
       y_Dim_Weight%axisinfo%units    = ''
       y_Dim_Weight%axisinfo%xtype    = ''

       if ( allocated(y_Dim%a_Dim) ) then
          deallocate( y_Dim%a_Dim )
       end if

       if ( allocated(y_Dim%attrs) ) then
          deallocate( y_Dim%attrs )
       end if

    endif

    call EndSub( subname )

end subroutine

begin

Return Data of axis Y from NAMELIST

NAMELIST から代入されたデータを Y 軸データとして返す。

((< axis_y_init >)) の NAMELIST axis_y_nml の decision 変数で (({ ‘manual’ })) 以外が与えられた場合は値を代入しないで返す。

[Source]

subroutine axis_y_manual (Dim)

  !==== Dependency
    use axis_type_mod, only: axis_type_copy
    use spml_mod,   only: wa_module_y_Lat => y_Lat
    use dc_trace,   only: DbgMessage, BeginSub, EndSub
                                                                 !=end
    implicit none
                                                                 !=begin
    !==== In/Out
    !
    type(AXISINFO), intent(inout) :: Dim        ! 次元情報を包括する変数
                                                                 !=end
    character(STRING), parameter:: subname = "axis_y_manual"
  continue
    !----------------------------------------------------------------
    !   Check Initialization
    !----------------------------------------------------------------
    call BeginSub( subname )
    if (.not. axis_y_initialized) then
       call EndSub( subname, 'Call axis_y_init before call %c', &
            &       c1=trim(subname) )
       return
    endif

    !----------------------------------------------------------------
    !   decision が 'manual' でない場合は停止して返す。
    !----------------------------------------------------------------
    if (.not. axis_y_data_from_manual) then
       call EndSub( subname, &
            & 'In axis_y_nml, configurated to not generate from manual')
       return
    endif

    !----------------------------------------------------------------
    !   intent(out) の引数にデータを渡す。
    !----------------------------------------------------------------
    call axis_type_copy(y_Dim, Dim)
    call EndSub( subname )

end subroutine

begin

Return Data of axis Y from netCDF file

netCDF データから取得したデータを Y 軸のデータとして返す。

現在、取得先のデータの単位に関わらず、そのままデータが 入力される。((<Known Bugs>)) 参照。

((< axis_y_init >)) の NAMELIST axis_y_nml の decision 変数で gtool4 変数以外が与えられた場合は値を代入しないで返す。

[Source]

subroutine axis_y_netcdf (Dim)

  !==== Dependency
    use axis_type_mod, only: axis_type_copy
    use gt4_history,only: HistoryGet
    use dc_url  ,   only: UrlSplit
    use dc_trace,   only: DbgMessage, BeginSub, EndSub
                                                                 !=end
    implicit none
                                                                 !=begin
    !==== In/Out
    !
    type(AXISINFO), intent(inout) :: Dim        ! 次元情報を包括する変数
                                                                 !=end
    character(STRING)           :: file
    character(STRING)           :: varname

    character(STRING), parameter:: subname = "axis_y_netcdf"
  continue
    !----------------------------------------------------------------
    !   Check Initialization
    !----------------------------------------------------------------
    call BeginSub( subname )
    if (.not. axis_y_initialized) then
       call EndSub( subname, 'Call axis_y_init before call %c', &
            &       c1=trim(subname) )
       return
    endif

    !----------------------------------------------------------------
    !   decision が '***@lon' などでない場合は停止して返す。
    !----------------------------------------------------------------
    if (axis_y_data_from_netcdf == '') then
       call EndSub( subname, &
            & 'In axis_y_nml, configurated to not generate from netcdf data')
       return
    endif

    !----------------------------------------------------------------
    !   HistoryGet によるデータ入力
    !----------------------------------------------------------------
    call UrlSplit(axis_y_data_from_netcdf, file=file, var=varname)
    call HistoryGet(file, varname, y_Dim%a_Dim)
    y_Dim%stored   = .true.

    !  入力するデータの units が 'degree' か 'radian' か調べ、
    !  一時、'radian' に変換し、その後、y_Dim%axisinfo%units が
    ! 'degree' か 'radian' かに応じて 180. / pi を掛けるかどうか
    ! 判定すべき

    !----------------------------------------------------------------
    !   intent(out) の引数にデータを渡す。
    !----------------------------------------------------------------
    call axis_type_copy(y_Dim, Dim)
    call EndSub( subname )

end subroutine

begin

Return Data of axis Y for Spectral Method.

スペクトル法を用いる場合を想定した Y 軸のデータを返す。

((< axis_y_init >)) の NAMELIST axis_y_nml の units に (({ ‘radian’ })) または (({ ‘rad.’ })) を与える場合には 単位がラジアンでデータが返される。それ以外では度数でデータが返る。

((< axis_y_init >)) の NAMELIST axis_y_nml の decision 変数で (({ ‘spectral’ })) 以外が与えられた場合は値を代入しないで返す。

[Source]

subroutine axis_y_spectral (Dim)

  !==== Dependency
    use axis_type_mod, only: axis_type_copy
    use constants_mod, only: constants_init, pi
    use spml_mod,   only: wa_module_y_Lat => y_Lat
    use dc_string,  only: toChar, StrHead, LChar
    use dc_trace,   only: DbgMessage, BeginSub, EndSub
                                                                 !=end
    implicit none
                                                                 !=begin
    !==== In/Out
    !
    type(AXISINFO), intent(inout) :: Dim        ! 次元情報を包括する変数
                                                                 !=end
    character(STRING), parameter:: subname = "axis_y_spectral"
  continue
    !----------------------------------------------------------------
    !   Check Initialization
    !----------------------------------------------------------------
    call BeginSub( subname )
    if (.not. axis_y_initialized) then
       call EndSub( subname, 'Call axis_y_init before call %c', &
            &       c1=trim(subname) )
       return
    endif

    !----------------------------------------------------------------
    !   decision が 'spectral' でない場合は停止して返す。
    !----------------------------------------------------------------
    if (.not. axis_y_data_from_spectral) then
       call EndSub( subname, &
            & 'In axis_y_nml, configurated to not generate from spmodel')
       return
    endif

    !----------------------------------------------------------------
    !   Initialize Dependent module
    !----------------------------------------------------------------
    call constants_init()

    !----------------------------------------------------------------
    !   wa_module からスペクトルデータを受け取る。
    !----------------------------------------------------------------
    if (  StrHead( 'radians', trim(LChar(y_Dim%axisinfo%units)) ) .or. &
         & StrHead( 'rad.', trim(LChar(y_Dim%axisinfo%units)) )  ) then
       ! radian でそのまま代入
       y_Dim%a_Dim(:) = wa_module_y_Lat(:)
    else
       ! radian を degree に変換して代入
       y_Dim%a_Dim(:) = wa_module_y_Lat(:) * 180. / pi
    end if

    y_Dim%stored   = .true.

    call DbgMessage('y_Lat=<%c>', c1=trim(toChar(y_Dim%a_Dim)) )

    !----------------------------------------------------------------
    !   intent(out) の引数にデータを渡す。
    !----------------------------------------------------------------
    call axis_type_copy(y_Dim, Dim)
    call EndSub( subname )

end subroutine

begin

Return Weight of axis Y

重みデータとその付加情報を返す。 ((< axis_y_init >)) の NAMELIST axis_y_nml の decision 変数で (({ ‘spectral’ })) 以外が与えられた場合は値を代入しないで返す。

また、Y 軸の次元変数に重みデータに関する付加情報を加える。

[Source]

subroutine axis_y_weight (Dim_Weight)

  !==== Dependency
    use constants_mod, only: constants_init, pi
    use axis_type_mod, only: axis_type_copy, axis_attrs_copy, axis_attrs_init
    use spml_mod,   only: wa_module_y_Lat_Weight => y_Lat_Weight
    use grid_3d_mod,only: jm
    use gt4_history,only: GT_HISTORY_ATTR
    use dc_trace,   only: DbgMessage, BeginSub, EndSub
                                                                 !=end
    implicit none
                                                                 !=begin
    !==== Output
    !
    type(AXISINFO), intent(out) :: Dim_Weight ! 次元情報を包括する変数
                                                                 !=end
    type(GT_HISTORY_ATTR), allocatable :: attrs_tmp(:) ! 次元情報を一時格納

    character(STRING), parameter:: subname = "axis_y_weight"
  continue
    !----------------------------------------------------------------
    !   Check Initialization
    !----------------------------------------------------------------
    call BeginSub( subname )
    if (.not. axis_y_initialized) then
       call EndSub( subname, 'Call axis_y_init before call %c', &
            &       c1=trim(subname) )
       return
    endif

    !----------------------------------------------------------------
    !   decision が 'spectral' でない場合は停止して返す。
    !----------------------------------------------------------------
    if (.not. axis_y_data_from_spectral) then
       call EndSub( subname, &
            & 'In axis_y_nml, configurated to not generate from spmodel')
       return
    endif

    !----------------------------------------------------------------
    !   Initialize Dependent module
    !----------------------------------------------------------------
    call constants_init()

    !----------------------------------------------------------------
    !   y_Dim の情報から y_Dim_Weight の情報を生成。
    !----------------------------------------------------------------
    y_Dim_Weight%axisinfo%name     = trim(y_Dim%axisinfo%name) // '_weight'
    y_Dim_Weight%axisinfo%length   = y_Dim%axisinfo%length
    y_Dim_Weight%axisinfo%longname = trim(y_Dim%axisinfo%longname) // ' weight'
    y_Dim_Weight%axisinfo%units    = trim(y_Dim%axisinfo%units)
    y_Dim_Weight%axisinfo%xtype    = trim(y_Dim%axisinfo%xtype)
    if ( allocated(y_Dim_Weight%attrs) ) then
       deallocate( y_Dim_Weight%attrs )
    endif

    ! y_Dim にも情報付加
    if ( allocated(y_Dim%attrs) ) then
       allocate( attrs_tmp(size(y_Dim%attrs)) )
       call axis_attrs_copy(from=y_Dim%attrs(:), to=attrs_tmp(:))
       deallocate( y_Dim%attrs )
       allocate( y_Dim%attrs(size(attrs_tmp)+1) )
       call axis_attrs_copy(from=attrs_tmp(:), to=y_Dim%attrs(1:size(attrs_tmp)) )

       call axis_attrs_init( y_Dim%attrs(size(attrs_tmp)+1) )
       y_Dim%attrs(size(attrs_tmp)+1)%attrname = 'gt_calc_weight'
       y_Dim%attrs(size(attrs_tmp)+1)%attrtype = 'char'
       y_Dim%attrs(size(attrs_tmp)+1)%cvalue   = y_Dim_Weight%axisinfo%name
       y_Dim%attrs(size(attrs_tmp)+1)%array    = .false.
    else
       allocate( y_Dim%attrs(1) )
       call axis_attrs_init( y_Dim%attrs(1) )
       y_Dim%attrs(1)%attrname = 'gt_calc_weight'
       y_Dim%attrs(1)%attrtype = 'char'
       y_Dim%attrs(1)%cvalue   = y_Dim_Weight%axisinfo%name
       y_Dim%attrs(1)%array    = .false.
    endif

    !----------------------------------------------------------------
    !   wa_module からスペクトルデータを受け取る。
    !----------------------------------------------------------------
    allocate( y_Dim_Weight%a_Dim(jm) )
    ! ラジアンを度数に変換して代入
    y_Dim_Weight%a_Dim(:) = wa_module_y_Lat_Weight(:) * 180. / pi
    y_Dim_Weight%stored   = .true.

    !----------------------------------------------------------------
    !   intent(out) の引数にデータを渡す。
    !----------------------------------------------------------------
    call axis_type_copy(y_Dim_Weight, Dim_Weight)
    call EndSub( subname )

end subroutine

[Validate]