subroutine

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

假装没事ソ 提交于 2019-12-29 04:35:27
问题 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

Perl: Return hash from subroutine

拥有回忆 提交于 2019-12-28 18:11:20
问题 I have been trying examples for hours but I can't seem to grasp how to do what I want to do. I want to return a hash from a subroutine, and I figured a reference was the best option. Here's where it gets a bit tricky. I want to reference a hash like $hash{$x}. I am still a noob at perl :/ 1.First question, the examples I use seem to show it is ok to use $hashTable{$login}, should I be using %hashTable{$login} or does it not matter? Below is the code: sub authUser { $LocalPath = "/root

slow-down when using OpenMP and calling subroutine in a loop

一个人想着一个人 提交于 2019-12-25 11:56:08
问题 Here I present a simple fortran code using OpenMP that calculate a summation of arrays multiple times. My computers has 6 cores with 12 threads and memory space of 16G. There are two versions of this code. The first version has only 1 file test.f90 and the summation is implemented in this file. The code is presented as follows program main implicit none integer*8 :: begin, end, rate integer i, j, k, ii, jj, kk, cnt real*8,allocatable,dimension(:,:,:)::theta, e allocate(theta(2000,50,5))

Undefined reference to a function in a module

北城余情 提交于 2019-12-25 08:03:00
问题 I was going through all the other threads about undefined reference and I was unable to figure out why this piece of codes is not working. I am basically trying to run a function from a module into a subroutine in the main program. But I keep getting an error Main: program main use m1 implicit none integer, dimension(:,:), allocatable :: A,AFun integer :: n,i,j print *, "enter value for n" read *, n do i=1,n do j=1,n A(i,j)=i**2-j**3 end do end do print *, "Matrix A: " call prMat(A,n) call

Perl Passing arguments to subroutine not working

无人久伴 提交于 2019-12-25 04:33:09
问题 I'm trying to pass parameters to a perl subroutine and for whatever reason inside the subroutine the parameters are coming out empty. ... ... ... print "Passing arguments $a, $b, $c, $d \n"; beforeEnd($a, %b, $c, $d); sub beforeEnd() { my ($a, %b, $c, $d) = @_; print "a is $a, b is $b, c is $c, d is $d \n"; } The output of the print statements give me an idea that something is wrong. The weird part? The first 2 parameters are passing properly. > Passing arguments 1, (1,2,3), 2, 3 > a is 1, b

Subroutine not working, error message saying variable is not defined

自闭症网瘾萝莉.ら 提交于 2019-12-25 04:29:06
问题 i am using a subroutine and i think it is the cause of my problem, here is my code : def sub1(): dob=input('Please enter the date of the person (dd) : ') while dob not in ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31']: print('you have entered an incorrect day') dob=input('Please enter the date of the person (dd) : ') sub1() if month == '02' : if dob == ['30','31'] : print('You have

Hold Subroutine response and set to variable in Perl

醉酒当歌 提交于 2019-12-25 03:13:59
问题 My code: #!/usr/bin/perl use strict; use warnings; thesub("hello"); sub thesub { my $class = shift; my $self = shift; return $self; } my $testvar = thesub(); print $testvar; $testvar print nothing, I want to print hello. I have intent to change thesub() to \&thesub, but not work. I read that In Perl, scalar variables cannot hold subroutines directly. How can I fixed this case ? Thanks. 回答1: You don't have package, so I'll assume you don't want to use a class, use strict; use warnings; use v5

Hold Subroutine response and set to variable in Perl

痞子三分冷 提交于 2019-12-25 03:13:00
问题 My code: #!/usr/bin/perl use strict; use warnings; thesub("hello"); sub thesub { my $class = shift; my $self = shift; return $self; } my $testvar = thesub(); print $testvar; $testvar print nothing, I want to print hello. I have intent to change thesub() to \&thesub, but not work. I read that In Perl, scalar variables cannot hold subroutines directly. How can I fixed this case ? Thanks. 回答1: You don't have package, so I'll assume you don't want to use a class, use strict; use warnings; use v5

ABAQUS subroutine runs when configured as a program but not as a subroutine

微笑、不失礼 提交于 2019-12-25 02:55:56
问题 I am writing a DISP subroutine for ABAQUS 6.14, starting with small steps -- trying to open and read the file containing the displacement data. So far I have a fortran script which runs perfectly when configured as an independent program but crashes when ABAQUS runs it as a subroutine. The working version : PROGRAM DISP INTEGER nnodes, IOS PARAMETER (nnodes = 5652) REAL A(nnodes,4) WRITE(*,*) 'hello world' OPEN(UNIT=11,FILE ="displaced_shape.dat",IOSTAT=IOS) WRITE(*,*) IOS DO ix = 1,nnodes

LC3 assembly language - create 2 arrays, multiply, and add sums

二次信任 提交于 2019-12-24 15:23:21
问题 I am trying to figure out how to create two arrays (hardcoded), multiply them together (a[0]x b[0], a[1]x b[1] ...etc.) and then add the sums together and print it. I don't have much yet but that's because I am still getting used to this. Please please please help! What I have so far is listed below - .ORIG x3000 LEA R1, arr1 LEA R2, arr2 AND R3, R3, #0 ;index AND R4, R4, #0 ;total LOOP ADD R4, R3, #4 BRzp DONE ADD R5, R1, R3 LDR R6, R5, #0 ADD R4, R4, R6 ADD R3, R3, #-1 BR LOOP HALT arr1