fortran 90/95 の MODULE 手続きのスケルトンコード
自分用の覚書。2012年3月5日の日記から転載したものをちょっと改変。fortranは名前(識別子)が、名前衝突を回避する文法になっていない*1ことや、識別子の長さが最長31文字*2であることがあって、スケルトン的なものと考えてはみたがなんとなくもやもやが取れない。
MOUDLE [module name] ! ! DESCRIPTION ! USE [external dependence] ,ONLY: [identifiers used in this MODULE] ... IMPLICIT REAL(KIND(0D0)) (a-h,o-z) ,INTEGER (i-n) ! some local variables (e.g. DO loop indices) are not ! explicitly declared PRIVATE [declarations of principal variables and arrays] PUBLIC:: [list of disclosed identifiers] CONTAINS SUBROUTINE setParam[module name] [TODO: initialize parameters that cannot be set with PARAMETER attribute] PI_ov_2= ASIN(1.D0); ! for example ... END SUBROUTINE SUBROUTINE alloc[module name] [TODO: allocate (large enough, maybe) arrays of this MODULE] IF(.NOT.ALLOCATED([array])) ALLOCATE([array]([its sizes])); ... END SUBROUTINE SUBROUTINE [purpose]_[module name] [([parameters])] ... END SUBROUTINE FUNCTION [function]_[module name] ([parameters]) RESULT ([output]) ... END FUNCTION END MOUDLE