top of page
  • Writer's pictureAdisorn O.

How to pass array variables to F90 subroutine?



Consider this example of fix-sized and allocatable array

case I: Fix-sized array



Case II: Allocatable array




One important thing to remark is that if you want to declare an array inside a subroutine for a fixed-dimension array argument, you cannot use the dimension(:,:) syntax. The dimension(:,:) syntax is used for assumed-shape arrays, which are typically used with allocatable arrays or arrays passed from the calling program where the dimensions are not fixed within the subroutine.


For fixed-dimension arrays, you should explicitly declare the dimensions in the subroutine. Here’s how you can do it:

6 views

Comments


bottom of page