IGMBaseLib 1.0

src/io/netcdf/IcGrid_ncStream_helper.f90

Go to the documentation of this file.
00001 
00012 module IcGrid_ncStream_helper
00013   
00014   ! モジュール引用 ; Use statements
00015   !
00016 
00017   ! 種類型パラメタ 
00018   ! Kind type parameter
00019   !
00020   use dc_types, only: DP, &        ! 倍精度実数型. Double precision.
00021     &                 TOKEN, &
00022     &                 STRING
00023 
00024   ! メッセージ出力
00025   ! Message dump
00026   !
00027   use dc_message, only: &
00028     & MessageNotify
00029 
00030   ! NetCDF
00031   !
00032   !
00033   use netcdf
00034   
00035   ! 宣言文 ; Declaration statements
00036   !
00037   implicit none
00038   private
00039 
00040   ! 公開変数
00041   ! Public variables
00042   !
00043 
00044   !
00050   type, public :: Mesh_dim_element
00051 
00054     character(TOKEN) :: element_name
00055 
00058     integer :: num
00059 
00062     integer :: dimID
00063 
00064   end type Mesh_dim_element
00065 
00066   !
00072   type, public :: Mesh_coord_element
00073 
00076     type(Mesh_dim_element), pointer :: dimension_element
00077 
00080     character(TOKEN) :: element_name
00081 
00084     character(TOKEN) :: standard_name
00085 
00088     character(STRING) :: long_name
00089 
00092     character(STRING) :: units
00093 
00096     integer :: varID
00097 
00098   end type Mesh_coord_element
00099   
00105   type, public :: Mesh2_ncInfo
00106 
00109     type(Mesh_dim_element) :: node
00110 
00113     type(Mesh_dim_element) :: face
00114 
00117     type(Mesh_dim_element) :: edge
00118 
00121     type(Mesh_dim_element) :: face_links
00122     
00125     type(Mesh_coord_element) :: node_x
00126 
00129     type(Mesh_coord_element) :: node_y
00130 
00133     type(Mesh_coord_element) :: face_x, face_y
00134 
00137     type(Mesh_coord_element) :: edge_x, edge_y
00138     
00139   end type Mesh2_ncInfo
00140 
00141   ! 公開手続き
00142   ! Public procedure
00143   !
00144   public :: Mesh_coord_element_Init, Mesh2_ncInfo_Init, check_nf90_status
00145 
00146 contains
00147 
00148 !
00170 subroutine Mesh_coord_element_Init( &
00171   & self,                             &  ! (inout)
00172   & dimension_element,                &  ! (inout)
00173   & element_name, standard_name, long_name, units &  ! (in)
00174   & )
00175 
00176   ! 宣言文 ; Declaration statement
00177   !
00178   type(Mesh_coord_element), intent(inout) :: self
00179   type(Mesh_dim_element), intent(inout), target :: dimension_element
00180   character(*), intent(in) :: element_name
00181   character(*), intent(in) :: standard_name
00182   character(*), intent(in) :: long_name
00183   character(*), intent(in) :: units
00184 
00185   ! 実行文 ; Execuatble statement
00186   !
00187   self%dimension_element => dimension_element
00188   self%element_name = element_name
00189   self%standard_name = standard_name
00190   self%long_name = long_name
00191   self%units = units
00192 
00193 end subroutine Mesh_coord_element_Init
00194 
00195 !
00209 subroutine Mesh2_ncInfo_Init( &
00210   & self, icgrid2D &  ! (inout)
00211   & )
00212   
00213   ! モジュール引用 ; Use statements
00214   !
00215   
00216   ! 正二十面格子データの管理
00217   ! Manager of icosahedral grid data
00218   !
00219   use IcGrid2D_FVM_Manager, only: &
00220     & IcGrid2D_FVM, &
00221     & get_EffSize_Min, get_EffSize_Max, &
00222     & RC_REGIONS_NUM
00223 
00224   ! 宣言文 ; Declaration statements
00225   !
00226   type(Mesh2_ncInfo), intent(inout) :: self
00227   type(IcGrid2D_FVM), intent(inout) :: icgrid2D
00228 
00229   ! 作業変数
00230   ! Work variables
00231   !
00232   integer :: EMin, Emax
00233   character(TOKEN), parameter :: LAT = "latitude"
00234   character(TOKEN), parameter :: LON = "longitude"
00235   character(TOKEN), parameter :: LAT_UNITS = "degrees_north"
00236   character(TOKEN), parameter :: LON_UNITS = "degrees_east"
00237 
00238   ! 実行文 ; Executable statement
00239   !
00240 
00241   !
00242   EMin = get_EffSize_Min(icgrid2D)
00243   EMax = get_EffSize_Max(icgrid2D)
00244 
00245   !
00246   self%node%element_name = 'nMesh2_node'
00247   ! dimension: Mesh2_node 個数の設定
00248   self%node%num = RC_REGIONS_NUM * ( EMax - EMin + 1)**2
00249 
00250   ! Mesh2_node_x の初期化
00251   call Mesh_coord_element_Init( &
00252     & self%node_x, dimension_element=self%node, &
00253     & element_name='Mesh2_node_x', standard_name=LON, &
00254     & long_name='Latiude of 2D mesh node', units=LON_UNITS &
00255     & )
00256 
00257   ! Mesh2_node_y の初期化
00258   call  Mesh_coord_element_Init( &
00259     & self%node_y, dimension_element=self%node, &
00260     & element_name='Mesh2_node_y', standard_name=LAT, &
00261     & long_name='Latiude of 2D mesh node', units=LAT_UNITS &
00262     & )
00263 
00264 end subroutine Mesh2_ncInfo_Init
00265 
00266 !
00285 subroutine check_nf90_status( &
00286   & status, message &  ! (in)
00287   & )
00288   
00289   ! 宣言文 ; Declaration statement
00290   !
00291   integer, intent(in) :: status 
00292   character(*), intent(in), optional :: message
00293 
00294   ! 作業変数
00295   ! Work varibles
00296   !
00297   
00298   character(STRING) :: output_str
00299   character(STRING) :: netCDF_error 
00300  
00301   ! 実行文 ; Execuatble statements
00302   !
00303 
00304   if ( status /= nf90_noerr ) then
00305     ! ステータスを解析し, エラーの原因を取得する. 
00306     netCDF_error = '(netCDF error status:' // trim(nf90_strerror(status)) // ')'
00307  
00308     if ( present(message) ) then
00309       output_str = trim(message) // netCDF_error
00310     else
00311       output_str = netCDF_error
00312     end if
00313 
00314     ! エラー出力を行い, プログラムを停止する. 
00315 !    write(*,*) trim(output_str)
00316     call MessageNotify( 'E', 'IGMBaseLib IO:IcGrid_ncStream_helper:', trim(output_str) ) 
00317     stop
00318 
00319   end if
00320 
00321 end subroutine check_nf90_status
00322 
00323 end module IcGrid_ncStream_helper
 All Classes Namespaces Files Functions Variables