fortran

Sign of infinity on division by zero

ε祈祈猫儿з 提交于 2021-01-27 10:49:59
问题 I've implemented code to find the polar coordinates of a point in 2D space. if the point lies in the 1st or 2nd Quadrant, 0<=theta<=pi and if it lies in the 3rd or 4th Quadrant, -pi <= theta <= 0 . module thetalib contains real function comp_theta( x1, x2) implicit none real , intent(in) :: x1, x2 real :: x1p, x2p real :: x1_c=0.0, x2_c=0.0 real :: pi=4*atan(1.0) x1p = x1 - x1_c x2p = x2 - x2_c ! - Patch !if ( x1p == 0 .and. x2p /= 0 ) then ! comp_theta = sign(pi/2.0, x2p) !else ! comp_theta

How to construct a matrix containing 9 smaller matrix

陌路散爱 提交于 2021-01-27 06:43:13
问题 I have nine matrices whose dimension as (N by N) A1(i,j),A2(i,j),A3(i,j),A4(i,j),A5(i,j),A6(i,j),A7(i,j),A8(i,j),A9(i,j) Then I want to construct a larger matrix (3N by 3N) including these nine matrices as: A = [A1 A2 A3 A4 A5 A6 A7 A8 A9] In fortran, can I use the command line as do i=1,FN do j=1,FML A(i,j) = [A1(i,j),A2(i,j),A3(i,j);A4(i,j),A5(i,j),A6(i,j);A7(i,j),A8(i,j),A9(i,j)] end do end do 回答1: Just for fun, you can also make the large A matrix by using do-loops as do i = 1, N A( i, :

How to construct a matrix containing 9 smaller matrix

橙三吉。 提交于 2021-01-27 06:43:08
问题 I have nine matrices whose dimension as (N by N) A1(i,j),A2(i,j),A3(i,j),A4(i,j),A5(i,j),A6(i,j),A7(i,j),A8(i,j),A9(i,j) Then I want to construct a larger matrix (3N by 3N) including these nine matrices as: A = [A1 A2 A3 A4 A5 A6 A7 A8 A9] In fortran, can I use the command line as do i=1,FN do j=1,FML A(i,j) = [A1(i,j),A2(i,j),A3(i,j);A4(i,j),A5(i,j),A6(i,j);A7(i,j),A8(i,j),A9(i,j)] end do end do 回答1: Just for fun, you can also make the large A matrix by using do-loops as do i = 1, N A( i, :

Is there anything wrong with passing an unallocated array to a routine without an explicit interface?

牧云@^-^@ 提交于 2021-01-27 06:12:48
问题 Consider: program main real, allocatable, dimension(:) :: foo integer n n=10 call dofoo(foo,n,1) allocate(foo(n)) call dofoo(foo,n,0) end program main subroutine dofoo(foo,n,mode) real foo(n) integer i,n,mode if(mode.eq.1)then n=6 return endif do i=1,n foo(i)=i enddo return end subroutine dofoo Is there anything wrong with the above code? (It works with gfortran) I pass in an un-allocated array the first time, but I don't touch it -- Is there anything in the standard that could cause this to

Why does COBOL have to be indented? [closed]

无人久伴 提交于 2021-01-26 20:53:06
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . Improve this question Why does COBOL have to be indented, as in, have additional spacing in each sourcefile? Consider this code (note the additional whitespace): IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. PROCEDURE DIVISION. DISPLAY 'Hello, world'. STOP RUN. A similar

Why does COBOL have to be indented? [closed]

只谈情不闲聊 提交于 2021-01-26 20:49:56
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . Improve this question Why does COBOL have to be indented, as in, have additional spacing in each sourcefile? Consider this code (note the additional whitespace): IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. PROCEDURE DIVISION. DISPLAY 'Hello, world'. STOP RUN. A similar

Call specific C++ DLL from Fortran

拈花ヽ惹草 提交于 2021-01-24 11:11:42
问题 I received a DLL made in C++, and I'm building a Fortran program to call the C++ DLL. My compiler (gfortran) shows no warnings, but it crashes during runtime with the following description: forrtl: severe (157): Program Exception - access violation Image PC Routine Line Source MainDLL_v10.dll 0B7A6B01 Unknown Unknown Unknown MainDLL_v10.dll 0B7A1BEF Unknown Unknown Unknown ... I guess something is wrong with my call arguments. The C++ DLL includes the following: #include <DllClasses.h> ...

Call specific C++ DLL from Fortran

那年仲夏 提交于 2021-01-24 11:10:31
问题 I received a DLL made in C++, and I'm building a Fortran program to call the C++ DLL. My compiler (gfortran) shows no warnings, but it crashes during runtime with the following description: forrtl: severe (157): Program Exception - access violation Image PC Routine Line Source MainDLL_v10.dll 0B7A6B01 Unknown Unknown Unknown MainDLL_v10.dll 0B7A1BEF Unknown Unknown Unknown ... I guess something is wrong with my call arguments. The C++ DLL includes the following: #include <DllClasses.h> ...

Call specific C++ DLL from Fortran

不问归期 提交于 2021-01-24 11:09:58
问题 I received a DLL made in C++, and I'm building a Fortran program to call the C++ DLL. My compiler (gfortran) shows no warnings, but it crashes during runtime with the following description: forrtl: severe (157): Program Exception - access violation Image PC Routine Line Source MainDLL_v10.dll 0B7A6B01 Unknown Unknown Unknown MainDLL_v10.dll 0B7A1BEF Unknown Unknown Unknown ... I guess something is wrong with my call arguments. The C++ DLL includes the following: #include <DllClasses.h> ...

Call specific C++ DLL from Fortran

懵懂的女人 提交于 2021-01-24 11:06:21
问题 I received a DLL made in C++, and I'm building a Fortran program to call the C++ DLL. My compiler (gfortran) shows no warnings, but it crashes during runtime with the following description: forrtl: severe (157): Program Exception - access violation Image PC Routine Line Source MainDLL_v10.dll 0B7A6B01 Unknown Unknown Unknown MainDLL_v10.dll 0B7A1BEF Unknown Unknown Unknown ... I guess something is wrong with my call arguments. The C++ DLL includes the following: #include <DllClasses.h> ...