0

I have a module in Fortran called QFoo. It defines a type QFooType.

I want to initialize all the elements of integer array 'is_n' to 0 and want to do it within the module. Could someone help? Thank you!

  module QFoo
      type QFooType              
          integer::i              
          integer, dimension(50) :: is_n                         
      end type QFooType

     !-----------
     ! I know the following code is wrong
     ! but I want to initialize all the is_n elements to 0
     !-----------
     ! do i = 1, 50
     !    is_n(i) = 0
     ! enddo
     !-----------
  end module QFoo

1 Answer 1

2
integer, dimension(50) :: is_n = 0

works on the latest version of the Intel Fortran compiler. My reading of the Fortran 95 standard suggests that this is standard behaviour.

Sign up to request clarification or add additional context in comments.

1 Comment

great! it worked.. thanks! I didn't think that the syntax we use for non array assignment will work here! Thanks again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.