fortran loop a list of 2D arrays using pointers -
I have allocated a lot of 2D arrays in my code, and I want to assign an array to each array Let's read from the name from the file. The problem is that the size of each array is different, so I am searching the most effective way. Code is like this:
Use the module exam ... contained a private public :: Initial test, real real (type = 8), dimension (:, :), allocated, target :: Ar1, ar2, ar3, ar4, ar5, ..., ar10 real (type = 8), dimension (:, :), indicator :: page included! Substantian startup integer :: k1, k2, k3, k4, k5 integer :: ind 1, ind2 object (ar1 (k1, k1), ar2 (k1, k2), ar3 (k2, k4), ar4 (k5, k5) ) ...)! Variable size! Automation is required here - its repeated PAR = & gt; Ar1 ind1 = Size (PAR, 1) Ind 2 = Size (PAR, 2) Call ref File (Equals, Ind 1, Ind 2) PAR => Ar2 ind1 = Size (PAR, 1) Ind 2 = Size (PAR, 2) Call ref File (Equal, Ind 1, Ind 2)! .... AR3, ..., AR 9 PAR => Ar10 ind1 = Size (PAR, 1) Ind 2 = Size (PAR, 2) Call ref File (Equal, Ind 1, Ind 2) End Subcutaneous Start Up! ! Subroutine ref file (AR, line, coil) real (type = 8), dimension (line, color) integer :: I, J, line, call! It should open the file with the same name as 'AR' Open (unit = 111, file = 'ARDT') I = 1, read row (222, *) (R (i, j), j = 1 , Call) End alignment import interval! ! Android Module Test
As far as I know, extracting the name of variable from variable to runtime not working.
If you need a lot of automation for the array, consider using an array of derivative types, as the answer suggests to each other, allocation and reading. Then you calculate the files You can, or store a label with a derived type.
By pasting specific array names, alternatively just read / write files with the necessary name as a logic:
module test ... ! Here's an auto-need - call it after its repeated call-reading file (R1, 'AR1') file (AR2, 'AR2')! .... AR3, ..., AR9 Call Reeffile (AR10, 'AR10') End Substrin Initial Test SubRuthine ReadFile (AR, Label) Real (Type = 8) :: AR (:, :) Character (Lenen = *) :: label integer :: I, j, nrow, ncol, fd nrow = size (ar, 1) ncol = (AI, 2) open (newunit = fd, file = label) I = 1, row Read (fd, *) (ar (i, j), j = 1, col) end subroutine readFile end module test
Some unfounded comments: Why do not I really get (this In the example) readFile
is public, why are the indicators required? In addition, type = 8
should not be used ().
Comments
Post a Comment