Can I pass an array of arbitrary rank to a subroutine in Fortran? -
i'm writing general output numerical model i've written. produce arrays either 1,2,3 or 4 dimensions on unknown length. i'm running issues in how define array in subroutine (found in different module).
gfortran -g -o0 -i/usr/include -c analysis.f90 analysis.f90:136:32: call write_netcdf('domain', domain, 'binary_cloud_domain', 0) 1 error: rank mismatch in argument ‘data_out’ @ (1) (scalar , rank-4) the error comes subroutine:
subroutine binary_cloud_analysis use cloud, only: cloud_domain, cloud_smooth_domain use write, only: write_netcdf real, allocatable, dimension(:,:,:,:) :: domain, smth_domain allocate(domain(x_dim,y_dim,z_dim,t_dim), smth_domain(x_dim,y_dim,z_dim,t_dim)) call cloud_domain(domain) if (cloud_smooth) call cloud_smooth_domain(domain,smth_domain) domain = smth_domain endif call write_netcdf('domain', domain, 'binary_cloud_domain', 0) end subroutine binary_cloud_analysis at moment in subroutine write_netcdf i've assigned data_out
subroutine write_netcdf(var_name, data_out, output_name, output_type) !--------------------------------------------------------------------------! ! input variables ! !--------------------------------------------------------------------------! real(kreal), allocatable, intent (in) :: data_out understandably compiler taking scalar haven't included dimensions(:) type specifier because don't know type of array i'm passing in generality , i'd hoped might able massage dimensions due variable being allocatable. output_type variable specifies type of array have i.e. 3d, 4d etc define netcdf file.
i think able reshaping array 1d array , reshaping based on defining number of dimensions , passing lengths ideally wouldn't have these additional steps. there way define allocatable array in sufficient generality these purposes?
Comments
Post a Comment