Fortran How can I read a 2D character array in Fortran using f90?

  • Thread starter Thread starter Gugga
  • Start date Start date
  • Tags Tags
    Array Fortran
AI Thread Summary
The discussion revolves around the challenge of declaring a 2D character array in Fortran 90 (F90) when transitioning from Fortran 77 (F77). The original poster encountered an error while trying to declare the array, specifically receiving a message about requiring an initializer. They initially attempted to declare the array with parameters in parentheses, which led to compilation issues. The solution involved separating the parameter declarations from the array declaration, allowing for a successful compilation. The correct approach is to declare the parameters individually and then define the character array using those parameters, which resolves the issue and aids in continuing their thesis work.
Gugga
Messages
2
Reaction score
0
Hello all,

I have some data stored in character*1 array(value,value) apparently the code is in f77, i got the original reading code for the data as a text...
I am working in f90, and to the extend of my knowledge (not much in fortran) I can not declare such 2D array as character? http://www.ibiblio.org/pub/languages/fortran/ch2-13.html
How can I read this data using f90?
When I tried compiling the code, I declared it like this:

character(1) :: array(value,value)

and I get the error: "array requires initializer"

perhaps I am blind and super easy, but I am stuck and i need this to continue my thesis... thanks!
 
Technology news on Phys.org
So I figured it out... for future reference, depending on the compiler it is possible that won't accept a parameter declaration if it is in parenthesis... so I had declared like this:

integer(4), parameter :: (value1=4596, value2=1345)
character(1), dimension(value1,value2) :: array

instead it should be

integer(4), parameter :: value1=4596, value2=1345
character(1), dimension(value1,value2) :: array

Cheers.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
12
Views
3K
Replies
6
Views
2K
Replies
13
Views
2K
Replies
21
Views
3K
Replies
16
Views
2K
Replies
5
Views
9K
Replies
5
Views
3K
Back
Top