astay13
astay13

Reputation: 6937

Format statements in Fortran modules

I have a module with a number of subroutines that all use the same set of formats for output. Right now, I have to declare the formats in every subroutine. Is there a way to declare them in the module so all the subroutines have access to them?

Upvotes: 4

Views: 826

Answers (1)

janneb
janneb

Reputation: 37228

You can store the format as a character at the module level. E.g.


module foo
  implicit none
  character(len=20), parameter :: form = "(1X,A)"
contains
subroutine bar
  ...
   write(my_unit, form) "Hello, World"
end subroutine bar
end module foo

Upvotes: 7

Related Questions