Fortran Dimension of arrays (RESHAPE) in Fortran 90

AI Thread Summary
The discussion revolves around a Fortran program named "testmatek" that attempts to create and manipulate a complex matrix. The code initializes parameters and attempts to populate a 2x2 matrix using the RESHAPE function. However, an error occurs due to a syntax issue at line 20, where the program expects an identifier but encounters a closing parenthesis instead. Participants discuss the purpose of the RESHAPE function, clarifying that it is intended to convert Fortran arrays to C-compatible formats. A user expresses frustration over their lack of understanding of Fortran and seeks assistance in resolving the syntax error. The conversation highlights the challenges faced by beginners in Fortran programming and the importance of understanding array manipulation functions.
MahdiI84
Messages
22
Reaction score
1
TL;DR Summary
Hello everyone. I am new to Fortran. The following coding is for a 2x2 matrix whose original diameter is zero and its non-original diameter requires writing a loop. The code I wrote now has an error that I am unable to fix. Please help me solve it. Thanks
Fortran:
program testmatek
implicit none
integer :: Nc=1000 ,k
integer,parameter :: N=2
REAL :: kx ,a0=1.0 ,t0=0.25
DOUBLE PRECISION :: pi=4*ATAN(1.)
COMPLEX , PARAMETER :: i=(0,1)
complex :: ek1 ,ek2
complex ::  MATRIX_ek(N,N)  
   
 open(1,file='matek.txt')  
 
    MATRIX_ek(N,N)=(0,0)
 
 DO k=-Nc,+Nc
    
    kx=(pi*k)/(1000*a0) 
    ek1=t0*(1+EXP(-2*i*kx*a0))
    ek2=t0*(1+EXP(2*i*kx*a0))
   
    MATRIX_ek=RESHAPE((/0.0,eK2,ek1,0.0/ ) , (/2,2/))
    write(1,*) MATRIX_ek
   
 end do
 end program testmatek
1>C:\Users\mahdi\Documents\Visual Studio 2012\Projects\Console4\Console4\Source1.f90(21): error #5082: Syntax error, found ')' when expecting one of: ( <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> <INTEGER_CONSTANT> ...
 
Technology news on Phys.org
The error appears at line 20. Have you searched online for examples of using the RESHAPE function?
 
Why in heaven's name are you using RESHAPE?

RESHAPE is there to convert FORTRAN-type arrays to C-type arrays, so you can pass them to C functions.
 
jedishrfu said:
The error appears at line 20. Have you searched online for examples of using the RESHAPE function?
Yes, I know where the error is. Of course, I searched the internet. But since I am new to Fortran, I did not understand how I could fix the error. Thank you for your help
 
Vanadium 50 said:
Why in heaven's name are you using RESHAPE?

RESHAPE is there to convert FORTRAN-type arrays to C-type arrays, so you can pass them to C functions.
Thank you for your help
 
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...
hi; i purchased 3 of these, AZDelivery 3 x AZ-MEGA2560-Board Bundle with Prototype Shield and each is reporting the error message below. I have triple checked every aspect of the set up and all seems in order, cable devices port, board reburn bootloader et al . I have substituted an arduino uno and it works fine; could you help please Thanks Martyn 'avrdude: ser_open(): can't set com-state for "\\.\COM3"avrdude: ser_drain(): read error: The handle is invalid.avrdude: ser_send(): write...

Similar threads

Replies
16
Views
2K
Replies
20
Views
3K
Replies
4
Views
2K
Replies
21
Views
3K
Replies
13
Views
3K
Replies
8
Views
3K
Replies
1
Views
7K
Replies
5
Views
9K
Back
Top