Questions tagged [subroutine]

A subroutine (e.g. procedure or subprogram) is a portion of code within a larger program, which performs a specific task and can be relatively independent of the remaining code. The syntax of many programming languages includes support for creating self contained subroutines, and for calling and returning from them. They are in many ways similar to functions, but usually have side-effects outside of the simple "return value" that functions return.

-2
votes
0answers
68 views

why calling many N times a serial subroutine is faster than calling N times the parallel version of the same subroutin

I have a serial version of a subroutine "serial" and the parallel versione of the same subroutine "paral". I'm using openmp. When i call the serial one I measure 0.475 seconds of wall clock time. ...
0
votes
1answer
21 views

Calling a Sub (containing a Do until loop) within a IF/Else Statement

I have a do until loop I keep having to repeat within an IF/ELSE statement.I want to call a sub (containing the do until loop) inside IF/Else If/Then statements instead. Please help This code works ...
2
votes
2answers
101 views

segmentation fault when calling fortran subroutine in C++

I am trying to call a Fortran subroutine in C++. this is the subroutine start: subroutine fireballess(ear,ne,parames,ifl,photar,photer) integer ne,ifl real*4 ear(0:ne),parames(10),...
0
votes
1answer
35 views

Calling a sub routine from within at half the current rate

I have a subroutine that is being called to the beat of a playing track to trigger DMX lighting. So the routine is not being called by a Timer event and the calls might increase or decrease with the ...
0
votes
0answers
14 views

Explanation of coroutine execution control sequences

I'm studying a course that goes over the foundations to programming and how different programming languages are built. In one of the workshops I came across and question involving coroutines and to ...
-1
votes
1answer
48 views

Variable not getting expanded

Variable not getting substituted Even after defining the 2 variable explicitly it's not getting substituted sub updatekey{ my $key_url = File::Spec->catfile($dir. "/keys/cert.key.$label.$...
0
votes
1answer
21 views

trying to pass this graphic subroutine, but having issues

currently have items that have been populated from a listview that print, and i have done this without subroutines, but i want to organize the code and put each part in its own subroutine. ive tried ...
-1
votes
1answer
47 views

Sub calls First Sub but does not call second sub

I am trying to have a sub run a series of other subs but am not having much luck. The Sub looks like this: Private Sub OKCommand_Click() new_tab metric_transfer End Sub When I comment out the ...
2
votes
1answer
95 views

Best practices of using constant in perl

I just started learning perl, I came to know that, constant are treated as subroutines in perl. I wonder then why the use of constants can be a good practice if everytime, it is making subroutine call ...
0
votes
1answer
45 views

can someone explain how this reference function work with this perl subroutine?

this is the sub routine which i could not understand , i tried to pass some array and hash as argument but could not figure it out sub List { my $value = shift; my $key = shift; ...
0
votes
1answer
21 views

Debugger always throws error on second procedure

I am trying to debug my program so I can work through a HW problem. The HW problem is not relevant to the issue as I tested it with 2 seperate procedures. Essentially when I am trying to debug I can ...
0
votes
1answer
46 views

Why isn't there any RET instruction in MIPS, while x86 has a RET instruction?

Why do MIPS subroutines return by jr while x86 return by using ret? Why isn't there any ret instruction in MIPS? Alternatively, why doesn't x86 use jr?
0
votes
0answers
116 views

how do i code a subroutine in marie that uses division to find the median

I need to run a code that sets the input values in order, divides the numbers by two then produces a median, I coded the division part but I do not know how to arrange the values Load A ...
0
votes
1answer
87 views

Subroutines with nested calls in MIPS

This program is meant to replace all the lowercase letters in a string with the character *. The problem I am having is in the nested call of subroutines. I.e. some same $t and $a registers are being ...
0
votes
0answers
41 views

How do I implement a sorting function(ascending order) after every input given on mips?

I want to sort the integers from input every time it is given instead of sorting after all the integers are known. I have already tried to implement conventional sorting methods but they kind of ...
1
vote
1answer
51 views

How can I implement if(condition1 && condition2) in MIPS?

I have written the following function to check whether a character is a digit or not: # IsDigit - tests a if a character a digit or not # arguments: # $a0 = character byte # return value: # $v0 =...
0
votes
1answer
136 views

How can I pass floating point numbers through $a0 in MIPS?

I am writing a MIPS library in which I am planning to pass all the arguments through $aX registers and return all the values through $vX registers. I have written the following function: # ...
0
votes
1answer
50 views

how can I pass 10 arguments in MIPS?

.data .text main: # 5 parameters li $s0, 2 li $s1, 3 li $s2, 5 li $s3, 10 li $s4, 20 addi $sp, $sp, -20 # 5 Words are 5 * 4 bytes ...
0
votes
2answers
159 views

Getting error "local variable referenced before assignment - how to fix?

I'm making a gambling program (i know this shouldn't be incredibly hard), and want to have multiple games which will be in subroutines. However, python seems to think my variables are being assigned ...
1
vote
3answers
80 views

Return multiple array from perl subroutine

I am giving four arguments to a perl subroutine, using them the routine creates two separate arrays @temp_Vand @temp_t. When I try to return them to my main program, I don't get two separate arrays ...
-1
votes
1answer
27 views

Subroutine always returns the -1 value , how do I rearrange to make it function?

/ * Finds the first vowel in a word and returns its location * */ public static int findFirstVowel (String word) { int consonant = 0; for(int count = 0; count < word.length(...
0
votes
0answers
62 views

Allocating array of abstract type in Fortran

Basically, I have an abstract class a wrapper class and a base class which are defined in the Base Module. The abbstract class holds an allocatable array and a subroutine. In the constructor I want to ...
0
votes
2answers
25 views

How to make a subroutine in vb.net?

So I recently took it upon myself to make a little program to make my job little easier. However, much of the code is repetitive, so was wondering if there is a way to make this easier. Below is the ...
0
votes
0answers
85 views

Overflow error when using large size pointer array in Intel fortran

how can I avoid getting an overflow error when using a big size pointer array My code is simply creating a subroutine to read a file and get data and store it in two arrays (the dimension of the ...
0
votes
0answers
38 views

Push/pop on subroutine in assembly? [duplicate]

I am trying to figure out what the dx value would be after this subroutine is called: ax = 0008, bx = 0006, cx = 0004, dx = 0002 subr: push ax pop bx push cx pop dx add dx,bx ...
1
vote
1answer
175 views

Abaqus DFLUX subroutine in Fortran

this is my first post here and I hope I will be clear describing the issues I'm having with Abaqus subroutine. I'm quite a newbie using Fortran. Basically, my goal is to define a non-uniform surface ...
0
votes
0answers
53 views

Call a vb subroutine from c# generic handler

I have a legacy application in asp. Code behind is written in vb, which I am not much aware of. So I added a generic handler and call it from Ajax. Now I have a subroutine in code behind, which is ...
1
vote
3answers
63 views

Can I call a superclass sort with a subclass compare in perl?

I want to use a superclass sort which uses a subclass compare function. I've tried to distill the nature of the question in the following code. This isn't the "production" code, but is presented ...
-1
votes
1answer
75 views

Fortran Subroutine not returning value

i run into a strange problem. I am using the locate subroutine from the Fortran-Recipe book. The goal is to find a random number in a CDF-table and return the index of the arrax, such that i can look ...
0
votes
0answers
54 views

The arrays automatically change within the subroutine they have readed

Im not expert but I'm writing a code using Absoft Fortran 2016. Briefly: It seems the arrays write on each other or maybe they use the same part of memory. I figured out that the output values are ...
2
votes
2answers
49 views

How do I declare an optional parameter in a signature?

Let's say I have use v5.026; use feature 'signatures'; sub foo ($opt1, $opt2) { say $opt1 if $opt2; } main::foo(1,2); main::foo(1); Now I want to call foo with and without opt2: foo(1); # ...
0
votes
1answer
61 views

How to get total increments in Disp subroutine in ABAQUS

I am using Disp subroutine in ABAQUS. I want to apply a specific boundary condition to my model. This a part of my code: IF (NODE==mst(2,1)) THEN IF (JDOF .EQ. 1) THEN U(1)=0.01 ...
0
votes
1answer
47 views

MS Access VBA - Private Subs with Same Name

I have a database which has an 'exit database' button on every form. I have an event procedure that is executed 'on-click', every 'exit database' button in the database has the same sub name : ...
0
votes
2answers
100 views

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

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 ...
0
votes
0answers
56 views

How to integrate in a User Routine in Simpack?

I want to program a force Element in Simpack, in return i have to integrate a variable. The User Routines in Simpack are programmed in Fortran. For my output i want to have the Force. This is ...
1
vote
0answers
50 views

When Returning 2 or more values from a Subroutine only the last varaible returns defined

I'm currently writing a small Perl script to act as a cronjob. The task of the Subroutinen is to check whether the file I'm writing to is a valid json file or not and to then proceed based on the ...
0
votes
1answer
25 views

Why does my sub-routine continue to carry out all of my if statements after I've called another sub-routine

My logins() sub routine will continue to carry out both the else and elif parts after it has found a login and has verified the password. I cant seem to understand why its doing this but is really ...
0
votes
1answer
40 views

Javascript any click a value for multiple instances

I have an SVG composite image of a skeleton and what I want is that, anytime you click on a bone it changes color and a textfield gets a specific value: basically on the first click the filling of the ...
3
votes
0answers
74 views

Dimension check of automatic objects in explicit interfaces

I always assumed that giving values in automatic sized dummy arguments within subroutine definitions has some benefit in error detection, when the routine is defined inside a module that gives an ...
2
votes
1answer
83 views

Conditional use of subroutines in Fortran

My scenario: I would like to have my Fortran (>=95) program choose one of two subroutines in a calculation, based on a parameter. As an example, let's have two subroutines, foo, which subtracts; and ...
-2
votes
1answer
67 views

(M68k) Why is my value not getting passed into D0?

So I am writing a program and subroutine where this is basically the pseudocode. int findmin(int* vals, int count){ if(count == 1){ return vals[0]; }else{ int minrest ...
1
vote
0answers
39 views

How can I run a perl subroutine from cli input?

I have a program I run called arsed (https://github.com/KD8EYF/TRBO-NET). In the main program there is a routine like so: sub send_help($) { my($id) = @_; $net->{'tms'}->queue_msg($id, ...
-2
votes
2answers
79 views

Perl Sub routine to get the square of a number

I am trying to write a subroutine to demonstrate getting a subroutine of a number as a function in Perl. I have no idea how to use the @_ operator in perl #!/usr/bin/perl use strict ; use warnings ;...
2
votes
1answer
157 views

Why does my program return inaccurate result?

I wrote the well-known spectral-norm algorithm in Fortran after I initially wrote (and optimized) it in MATLAB. The speedup after naive conversion to Fortran is at least 18X, but the problem is that ...
1
vote
1answer
165 views

How to write Fortran modules in UMAT subroutine in ABAQUS?

I have 3 modules (in free form .f90 format) which are being called from inside of UMAT subroutine, such as: module module_A use module_C use module_B .... end module_A module module_B ...
1
vote
0answers
163 views

Executing UMAT subroutine in .f90 form through ABAQUS?

I am using 'Abaqus standard 6.14-4' with 'Microsoft Visual Studio Ultimate 2012' and 'Intel composer XE 2013 for windows'. I have written a UMAT subroutine in free form .f90 format. Now when I try to ...
0
votes
0answers
48 views

Call by value subroutine ; NASM x86 in SASM IDE

Now, I want to call a subroutine by value. My source said you do so by call subroutineName, (var1, var2) subroutineName(var3, var4): ;code I don't know how, it gives me a "invalid combination ...
1
vote
1answer
60 views

I can't figure out how to correctly call the information in my module to the program and make the calculations work?

Basically what I have to do is read in a file called "sounding.txt" that has 100 rows of data. I'm reading that data in and doing different calculations from that data. I'm calculating the freezing ...
0
votes
0answers
77 views

How to apply swap in subroutine in FASM assembly language? [duplicate]

format PE console entry start include 'win32a.inc' section '.text' code executable start: push NumA push NumB call swap add esp, 8 push [NumB] push [NumA] push msg ...
2
votes
1answer
62 views

Why glGetSubroutineIndex returns the same value for different function?

I have got a fragment shader that should operate 2 colors - red and blue. #version 460 core layout (location = 0) out vec4 outColor; subroutine vec4 colorRedBlue(); subroutine (colorRedBlue) vec4 ...