subroutine

fortran, passing allocatable arrays to a subroutine with right bounds

妖精的绣舞 提交于 2019-11-29 10:09:27
问题 I need in a program to pass some allocatable arrays to subroutines, and i need to know if the way I do it are in the standard or not. If you know where I can search for the standard of fortran, Tell me please. Here is a little code that will better explain than words program test use modt99 implicit none real(pr), dimension(:), allocatable :: vx allocate(vx(-1:6)) vx=(/666,214,558,332,-521,-999,120,55/) call test3(vx,vx,vx) deallocate(vx) end program test with the module modt99 module modt99

Calling an internal subroutine inside OpenMP region

对着背影说爱祢 提交于 2019-11-29 08:43:26
I have a module that contains a subroutine that contains another subroutine. The outer subroutine has a parallel OpenMP region in which I call the inner subroutine. The code compiles and runs without any error but the results are not correct. module my_module contains subroutine a(...) *...some variables* !$OMP PARALLEL DO DEFAULT(PRIVATE) SHARED(...) *...do some work* call b(...) !$OMP END PARALLEL DO contains subroutine b(...) *...some variables* *...do some work* end subroutine b end subroutine a end my module If I run the Intel Debugger idb , it will show me a SIGSEGV inside subroutine b .

FORTRAN - allocatable array in subroutine

无人久伴 提交于 2019-11-29 07:57:06
I'm trying to use an allocatable array in a subroutine but the compiler complains that Error: Dummy argument 'locs' with INTENT(IN) in variable definition context (ALLOCATE object) at (1) The only thing I could find was that I am supposed to use an explicit interface, which I am doing. Here the relevant code for the subroutine: RECURSIVE SUBROUTINE together(locs, LL, RL) INTEGER, DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: locs INTEGER, INTENT(IN) :: LL, RL ALLOCATE(locs(LL,RL)) END SUBROUTINE together The compiler's error message is one descriptive of the problem. With INTENT(IN) you are

Calling perl subroutines from the command line

眉间皱痕 提交于 2019-11-29 07:56:26
Ok so i was wondering how i would go about calling a perl subroutine from the command line. So if my program is Called test, and the subroutine is called fields i would like to call it from the command line like. test fields Use a dispatch table. #!/usr/bin/perl use strict; use warnings; use 5.010; sub fields { say 'this is fields'; } sub another { say 'this is another subroutine'; } my %functions = ( fields => \&fields, another => \&another, ); my $function = shift; if (exists $functions{$function}) { $functions{$function}->(); } else { die "There is no function called $function available\n";

Which is the diffeence between an INTERFACE block and a MODULE procedure in fortran?

荒凉一梦 提交于 2019-11-29 03:07:27
问题 I'm a bit confused about the use of an interface block inside a module and the use of the CONTAINS statement to create an "explicit interface" for a procedure inside a module. I usually write a procedure using an interface block inside a module. For example, MODULE ModExample INTERFACE SUBROUTINE Sumatory(a, b, c) IMPLICIT NONE INTEGER, INTENT(IN)::a INTEGER, INTENT(OUT)::b INTEGER, INTENT(OUT)::c END SUBROUTINE Sumatory END INTERFACE END MODULE ModExample SUBROUTINE Sumatory(a, b, c)

Passing two or more arrays to a Perl subroutine

随声附和 提交于 2019-11-28 23:34:27
I am having trouble passing and reading arguments inside subroutine which is expected to have two arrays. sub two_array_sum { # two_array_sum ( (1 2 3 4), (2, 4, 0, 1) ) -> (3, 6, 3, 5) # I would like to use parameters @a and @b as simply as possible } # I would like to call two_array_sum here and pass two arrays, @c and @d I have seen and tried several examples from the web, but none of them worked for me. There are two ways you can do this: by prototype by reference But before I discuss these--if what you show in your question is about the extent of what you want to do--let me suggest List:

Excel VBA calling sub from another sub with multiple inputs, outputs of different sizes

半世苍凉 提交于 2019-11-28 23:08:46
I would like to call a sub from another sub inside in the same module. The first sub would be my main code and there I would call the second subroutine. Second subroutine receives multiple inputs as integer, double, double arrays and double matrices. The size of the arrays and matrices are known and stored in an integer variable. The sub also returns several outputs. So, I would like to do something like this. sub Main() Nc As integer Dim kij(1 To Nc, 1 To Nc), xi(1 to Nc), a1 As Double 'I assign values to my variables from the excelsheet e.g. Nc=Cells(1,1) etc. CalculateA(Nc,kij, xi, a1, a)

Perl - Subroutine redefined

放肆的年华 提交于 2019-11-28 22:43:36
I have asked this question before or searched and seen others ask - why am I getting the warning " Subroutine mySub redefined at ../lib/Common.pm line x "? and you always get the answer you declared the sub twice in the same code . I created this test package: ENTIRE FILE --------------- package MyCommonPkg; use strict; sub thisSubroutineIsNotDefinedAnywhereElse{ } 1; ENTIRE FILE --------------- and I USE this package from a perl script, which uses other packages, that use this package also, and I get the warning: Subroutine ThisSubroutineIsNotDefinedAnywhereElse redefined at ../lib

Is there a difference between Perl's shift versus assignment from @_ for subroutine parameters?

一世执手 提交于 2019-11-28 21:25:58
Let us ignore for a moment Damian Conway's best practice of no more than three positional parameters for any given subroutine. Is there any difference between the two examples below in regards to performance or functionality? Using shift : sub do_something_fantastical { my $foo = shift; my $bar = shift; my $baz = shift; my $qux = shift; my $quux = shift; my $corge = shift; } Using @_ : sub do_something_fantastical { my ($foo, $bar, $baz, $qux, $quux, $corge) = @_; } Provided that both examples are the same in terms of performance and functionality, what do people think about one format over

What's the best way to discover all subroutines a Perl module has?

自闭症网瘾萝莉.ら 提交于 2019-11-28 18:42:19
What's the best way to programatically discover all of the subroutines a perl module has? This could be a module, a class (no @EXPORT), or anything in-between. Edit: All of the methods below look like they will work. I'd probably use the Class::Sniff or Class::Inspector in production. However, Leon's answer is marked as 'accepted' since it answers the question as posed, even though no strict 'refs' has to be used. :-) Class::Sniff may be a good choice as it progresses; it looks like a lot of thought has gone into it. sub list_module { my $module = shift; no strict 'refs'; return grep { defined