use netcdftype(NC_DIMENSION):: dim type(NC_VARIABLE):: variable type(NC_LIMIT):: limit character(len = ...):: dimname integer:: start, count, stride integer:: starts(7), counts(7), strides(7)
! limit の生成と廃棄 type(NC_LIMIT) function WholeVariable(variable) subroutine Dispose(limit)
! limit の利用
logical function Slice(limit, dimname, start [, count [, stride]]) integer function Size(limit) starts = Start(limit) counts = Count(limit) strides = Stride(limit) ! イテレータ (利用例参照) subroutine Next(limit)
! limit について再定義された演算子・代入 ! limit = WholeVariable(variable) と等価 limit = variable if (.error. limit) ... ! 論理型を与える単項演算子
! 変数入力 character, pointer:: cpointer(:, :, :, :, :, :, :) integer, pointer:: ipointer(:, :, :, :, :, :, :) real, pointer:: rpointer(:, :, :, :, :, :, :)
subroutine Get(variable, cpointer [, limit] [, fail]) subroutine Get(variable, ipointer [, limit] [, fail]) subroutine Get(variable, rpointer [, limit] [, fail])
! 当然配列寸法は引用時に確定していなければならない character, pointer:: cbuffer(:, :, :, :, :, :, :) integer, pointer:: ibuffer(:, :, :, :, :, :, :) real, pointer:: rbuffer(:, :, :, :, :, :, :)
subroutine Put(variable, cbuffer [, limit]) subroutine Put(variable, ibuffer [, limit]) subroutine Put(variable, rbuffer [, limit)
NC_LIMIT 構造体は netCDF 変数の部分入出力の抽象化です。
real, pointer:: varptr(:, :, :, :, :, :, :) ... limit = WholeVariable(variable) if (.error. Slice(limit, 'longitude', 1)) stop 'slice' do varptr => get_real(variable, limit) if (.not.associated(varptr)) call NetcdfAssert ... deallocate(varptr) call Next(limit) if (.error. limit) exit enddo