fortran90

Error: Unexpected end of format string in format string in Fortran

你离开我真会死。 提交于 2019-12-02 08:59:29
问题 Getting this error while trying to compile a copied code from a Fortran 77 program. code: 900 FORMAT(1H0,2X,'ABSOLUTE GRID LIMITS FOR DATA RETENTION FOR RADAR',I3,' XMIN-XMAX ',2F8.3,' YMIN-YMAX ',2F8.3,' ZMAX ',F8.3, /3X,'WITH AZIMUTH LIMITS OF',2F8.2, 3X,'AND RANGE LIMITS OF',2F10.3,/) compiler error: messy21.f90:529.132: N FOR RADAR',I3,' XMIN-XMAX ',2F8.3,' YMIN-YMAX ',2F8.3,' ZMAX ',F8.3, /3X,(1) Error: Unexpected end of format string in format string at (1) I am not sure what the error

Zero indexed array in Fortran? [duplicate]

风流意气都作罢 提交于 2019-12-02 08:26:57
This question already has an answer here: Array First Index in Fortran 2 answers Can someone explain what is zero indexed array in Fortran along with example. I'm not getting any content on that on internet. A zero indexed array is an array who's index origin is ZERO . This means that the first element of the array is referenced by index 0 . Fortran arrays defaultly start with index 1 when you declare them INTEGER, DIMENSION(3) :: v Here, the symbol v represents a one-dimensional array of size 3 with elements v(1) , v(2) and v(3) . However, the Fortran standard gives you the possibility to set

Fortran Error: 'y' argument of 'datan2' intrinsic at (1) must be REAL

混江龙づ霸主 提交于 2019-12-02 08:03:10
问题 I want to calculate z value as the coordinate in range of x:-50~50 and y:-50~50 like below code. program test implicit none ! --- [local entities] real*8 :: rrr,th,U0,amp,alp,Ndiv real*8 :: pi,alpR,NR,Rmin,Rmax,z integer :: ir, i, j do i=0, 50 do j=0, 50 th=datan2(i,j) pi=datan(1.d0)*4.d0 ! Ndiv= 24.d0 !! Number of circumferential division alp = 90.d0/180.d0*pi !! phase [rad] U0 = 11.4d0 !! average velocity amp = 0.5d0 !! amplitude of velocity Rmin = 10 !! [m] Rmax = 50 !! [m] NR = 6.d0 !!

How to avoid declaring and setting the value of a variable in each subroutine?

雨燕双飞 提交于 2019-12-02 07:48:43
How to avoid repeated declaration of a variable that has a constant value in subroutines? For example: program test implicit none integer :: n integer :: time print*, "enter n" ! this will be a constant value for the whole program call Calcul(time) print*, time end program subroutine Calcul(Time) implicit none integer :: time ! i don't want to declare the constant n again and again because some times the subroutines have a lot of variables. time = n*2 end subroutine Sometimes there are a lot of constants that are defined by the user and I will make a lot of subroutines that use those constants

Fortran Error: 'y' argument of 'datan2' intrinsic at (1) must be REAL

霸气de小男生 提交于 2019-12-02 07:22:59
I want to calculate z value as the coordinate in range of x:-50~50 and y:-50~50 like below code. program test implicit none ! --- [local entities] real*8 :: rrr,th,U0,amp,alp,Ndiv real*8 :: pi,alpR,NR,Rmin,Rmax,z integer :: ir, i, j do i=0, 50 do j=0, 50 th=datan2(i,j) pi=datan(1.d0)*4.d0 ! Ndiv= 24.d0 !! Number of circumferential division alp = 90.d0/180.d0*pi !! phase [rad] U0 = 11.4d0 !! average velocity amp = 0.5d0 !! amplitude of velocity Rmin = 10 !! [m] Rmax = 50 !! [m] NR = 6.d0 !! Number of radial division ! rrr=dsqrt(i**2+j**2) ir=int((rrr-Rmin)/(Rmax-Rmin)*NR) alpR=2.d0*pi/dble(Ndiv

overwrite a file using fortran

血红的双手。 提交于 2019-12-02 07:22:37
问题 I am using a Fortran 90 program that writes a file. The first line of this file is supposed to indicate the number of lines in the remaining file. The file is written by the program when a certain criterion is met and that can't be determined beforehand. Basically, I will know the total number of lines only after the run is over. I want to do it in the following manner: 1) open the file and write the first line with some text say, " Hello " 2) Write rows in the file as desired and keep a

overwrite a file using fortran

雨燕双飞 提交于 2019-12-02 06:35:37
I am using a Fortran 90 program that writes a file. The first line of this file is supposed to indicate the number of lines in the remaining file. The file is written by the program when a certain criterion is met and that can't be determined beforehand. Basically, I will know the total number of lines only after the run is over. I want to do it in the following manner: 1) open the file and write the first line with some text say, " Hello " 2) Write rows in the file as desired and keep a counter for number of rows. 3) Once the run is over and just before closing the file, replace the first

way Fortran handles empty spaces

China☆狼群 提交于 2019-12-02 06:15:30
I would like to have some clarifications about the way Fortran handles "empty" characters in strings. Let us assume we have this situation: program main implicit none test('AB') end program where function test(name) implicit none character(10) :: name character(3) :: cutname write(*,*) '-'//name//'-' ! Gives output "-AB -" ! Space has then been added at the end cutname(1:3) = name(1:3) write(*,*) '1-'//cutname//'-' ! Gives output "-AB -" ! It seems there is a space then at the end ! of cutname write(*,*) (cutname(1:2) == 'AB') ! Gives output T (true) write(*,*) (cutname(3:3) == ' ') ! Gives

METIS seg faults when run from Fortran

牧云@^-^@ 提交于 2019-12-02 05:43:52
问题 I'm trying to use the METIS library for mesh partitioning as part of a Fortran program I've written for finite element computations. METIS is written in C but it's supposed to work just fine with Fortran 90. But I keep getting seg faults. One potential hiccup is that there are a few arguments to which I'm giving null pointers. Some other folks have had trouble getting a call to a C function from fortran to recognize a null pointer object. That was addressed here and I don't think that's the

Calling a subroutine in Fortran (Segmentation fault)

廉价感情. 提交于 2019-12-02 05:22:47
问题 The following code gives segmentation error when compiled with pgf90 on the Linux system, while is run successfully when I used the Intel Visual FORTRAN on Windows. program main implicit none integer:: a(3), b(3) ,c(3) a=[3, 4, 5] b=[1, 2, 3] call sub(a,b,c) write(*,*)'a+b = ',c end program main subroutine sub(a,b,c) implicit none integer, intent(in)::a(:),b(:) integer, intent(out)::c(:) c=a+b end subroutine sub Any explanation for this ? 回答1: When you call a subroutine which has assumed