由买买提看人间百态

topics

全部话题 - 话题: subroutine
首页 上页 1 2 3 4 5 下页 末页 (共5页)
g***p
发帖数: 139
1
来自主题: Programming版 - How to detect overflow in C?
google PCL(performance counter library) it will count how many overflows in
your subroutine?
A***l
发帖数: 461
2
i.e. in what format and what order
c*****t
发帖数: 1879
3
google C ABI.
e*r
发帖数: 1121
4
来自主题: Programming版 - QuickBasic grammer question
In the quickbasic program
"MENU:"
Is this a way to define the subroutine "MENU"?
k****z
发帖数: 550
5
来自主题: Programming版 - QuickBasic grammer question
As I remember this is simply a mark,
in QB you can use some command to call it just like a function/subroutine.
m***b
发帖数: 11
6
想从一个array中随机抽样,比如,取两个.应当是常见问题.
#!/usr/local/bin/perl
#Define an Array and sampling size
my @myArray=('a','c','d','e','f','g','h','j','k','m','n','t');
my $numPick=2;
#use sub:selection_sample()
my @randPick=selection_sample(\@myArray,$numPick);
print (@randPick);
#### subroutine from perlmonk ####
sub selection_sample {
my ($array,$num)=@_;
die "Too few elements (".scalar(@$array).") to select $num from\n"
unless $num<@$array;
my @results;
my $pos=0;
while ( @results
G*O
发帖数: 706
7

~~~~~~?
~~~~~~~~~~???
c******e
发帖数: 56
8
That's typo in the post.
G*O
发帖数: 706
9
post the error msg.
c******e
发帖数: 56
10
All right. Found the answer. Forgot to define it in the Export list.
t****t
发帖数: 6806
11
来自主题: Programming版 - setjmp() and longjmp()
不看手册?
DESCRIPTION
longjmp() and setjmp(3) are useful for dealing
with errors and interrupts encountered in a
low-level subroutine of a program. longjmp()
restores the environment saved by the last call
of setjmp(3) with the corresponding env argu-
ment. After longjmp() is completed, program
execution continues as if the corresponding
call of setjmp(3) had just returned the value
val. longjmp() cannot cause 0 to
h*******s
发帖数: 11
12
来自主题: Programming版 - FORTRAN 90 菜鸟问题
EB is the kind type parameter.
If EB is not defined in that program unit (program, module, subroutine, or
function), it will be defined in one of the modules that you "use" in
that program unit.
Given either of these definitions:
integer,parameter::eb=selected_real_kind(6,37)
integer,parameter::eb=kind(0.0e0)
then
real(eb)::a
a=2.0_eb/3.0_eb
gives the single-precision result of dividing 2.0 by 3.0.
If instead eb is defined as either of the following:
integer,parameter::eb=selected_real_kind(15,3
d****y
发帖数: 1650
13
来自主题: Programming版 - 一个fortran问题:
CHARACTER(3) SNAME
这个用法是哪个版本的fortran里的?g77认识,但是我在fortran77里的文档里都没找到。
SUBROUTINE XERBLA_ARRAY(SRNAME_ARRAY, SRNAME_LEN, INFO)
CHARACTER(1) SRNAME_ARRAY(SRNAME_LEN)
...
...
比如这里的语句,SRNAME_ARRAY是个多大的数组?
多谢
b***y
发帖数: 2799
14
来自主题: Programming版 - [合集] what's the trick of passing pointers
☆─────────────────────────────────────☆
ruisher (aa) 于 (Sat Aug 27 23:26:33 2005) 提到:
I created a vector of pointers to obejcts
std::vector< student* > studentVec;
then write
read_in_student_info(std::vector & studentVec)
{
........
basically, just build up and fill up the vector
.....
}
when it returns back to the main function, then I tried to print out each
element, it works fine.So I just assume this vector is already exist.Then I
call
another subroutine which I want to use th
O******e
发帖数: 734
15
来自主题: Programming版 - fortran里面common的问题
A common block is similar to a pointer to a contiguous
block global-access memory. In Fortran 77, a common
block is either named or unnamed. There can be only one
unnamed common block, but multiple named common blocks
in a program. Each common block is a separate chunk of
global memory.
In the program you showed, there is only one unnamed
common block, and this common block points to a single-
precision real array of four elements. This array is
referenced as DSTRESS in subroutine A, and ref
v****c
发帖数: 32
16
来自主题: Programming版 - Endless loop, what's wrong? Thanks.
subroutine finda(z,ua,ub,va,vb,uc,vc,du,dv,amin,g)
real ua,ub,uc,va,vb,vc,du,dv,amin,g
complex w, z, cpi, ci, c1, f
cpi=cmplx(g/(4.0*atan(1.0)), 0.0)
c1=cmplx(1.0,0.0)
ci=cmplx(0.0,1.0)
du=(ub-ua)/10.0
dv=(vb-va)/10.0
amin=100000.0
do 20 v=va,vb,dv
do 10 u=ua,ub,du
w=cmplx(u,v)
f=z-cpi*(csqrt(w-c1)*csqrt(w+c1)
+ -ci*(clog(ci+csqrt(w-c1)*csqrt(w+c1))-clog(w)))
c write(*,*) "w= ", w, " f= ", f , " cab
c******d
发帖数: 906
17
来自主题: Programming版 - 32/64bit Fortran编译器造成的错误
系统是win7 64bit
VS2008+IVF 11.1
定义了一个递增数组p
根据条件,先对p分配大小, allocate p(:)
然后在loop中对一个subroutine 传递p(i),所有的p值是不变的
简化程序如下
allocate (p(j))
loop1: do i=1,j
call MYSUB(p(i),xx,xx,xx)
end do loop1
用IA-32 IVF compiler,在loop到最后的p(i)时,p中有几个数值被冲掉
用IA-64 compiler就没有问题
想仔细请教一下怎么去分析解决这个问题
先谢过
C*******s
发帖数: 330
18
来自主题: Programming版 - 求助: Cygwin GCC g77编译.f文件出错
说好几个subroutine里面JiAnd 和 Jishft是unimplemented intrinsics,不能编译成
功。这个是因为Cygwin里面缺什么吗?如何解决?十个大包子奉上可以帮助成功编译的
朋友。:)
x********g
发帖数: 47
19
来自主题: Programming版 - MPI环境中用forran 调用 C 程序
我有如下程序,但是编译出错,请高手指教:
subroutine intensity(m_int, res, px, py, k, int_i, scatfact_e, istat)
!USE, intrinsic :: iso_c_binding
USE MPI_C_BINDING !mpi
IMPLICIT NONE
type(model), intent(in) :: m_int
real, intent(in) :: res, px, py
real, dimension(nk), intent(in) :: k
real, dimension(nk), intent(out) :: int_i
real, dimension(:,:), pointer, intent(in) :: scatfact_e
integer, intent(out) :: istat
! C-compatible variables for the model data
integer(C_INT), dimen
H***a
发帖数: 735
20
According to LZ "子函数(void)内用主函数通过参数传过来得指针malloc了空间,
然后做了一些操作之后,返回主函数,
在主函数里面再free这个空间", there I just created a critical example.
Caller - main function - might not need to use the array at all since all
the operations can be done in
subroutine. In this case, it's unfair to let main function free the resource.
That's just my 2 cents.
p*********g
发帖数: 226
21
来自主题: Programming版 - 问个简单的Fortran问题
代码在此
http://napsu.karmitsa.fi/lmbm/lmbmu/lmsub.f
用 Intel Visual Fortran 编译,结果报错
lmsub.f(3834): error #6407: This symbolic name is not an intrinsic function
name or an intrinsic subroutine name. [ETIME]
INTRINSIC ETIME
f******y
发帖数: 2971
22
Another ugly way to do it. This is still not nice. I want to know if there
is something we can declare in use clause, something like:
use xxxxxx;
{
use strict;
my $a = 0;
}
sub read {
return($a+1);
}
h**********c
发帖数: 4120
23
来自主题: Programming版 - C++方法全都内联有什么坏处?
A good s/w product should have the best possible CPU hit rate, given you
have full-filled 0. it does not crash 1. functional requirements.
hit-rate is NFR.
inline function will improve hit-rate for CPU given the code length is small.
if ( i>20)
incr(i);
else
decr(i);
inline void incr (int & i) {
i += 1;
}
inline void decr (int & i) {
i -= 1;
}
From CPU architecture view, inline function greatly increase the chance the
subroutine is within the same cache block as the caller -- a hit. If i... 阅读全帖
W**********r
发帖数: 61
24
you need reorder the matrix A first to minimize fill-in elements. And
perform symbolical LDU factorization for A. Then you can use Newton-Raphson
algorithm to solve. You can use Matlab, Python, C, whaterever u want.
BTW, remember to use subroutines.
z*******6
发帖数: 133
25
来自主题: Programming版 - 问个选语言的问题
https://developer.nvidia.com/cuBLAS
The NVIDIA CUDA Basic Linear Algebra Subroutines (cuBLAS) library
h******n
发帖数: 2795
26
来自主题: Programming版 - 被苹果给惊呆了!! (转载)
其实,Apple C(C++)编译器跟GNU GCC几乎是一样的。
你这段代码,很可能在Linux下也能通过。但在,MS Visual Studio C++上就通不过。
我前几天遇到很类似的代码(是别人写的),其中的一个subroutine,在一个特例情况
下(i=0),给开的1D数组大小是0,但程序默认给a[0]赋值。这个程序在RHEL 6.7下成
功运行。但是,我搬到Windows下来,则运行出错。通过debug,发现此处出错。
h******n
发帖数: 2795
27
来自主题: Programming版 - 被苹果给惊呆了!! (转载)
其实,Apple C(C++)编译器跟GNU GCC几乎是一样的。
你这段代码,很可能在Linux下也能通过。但在,MS Visual Studio C++上就通不过。
我前几天遇到很类似的代码(是别人写的),其中的一个subroutine,在一个特例情况
下(i=0),给开的1D数组大小是0,但程序默认给a[0]赋值。这个程序在RHEL 6.7下成
功运行。但是,我搬到Windows下来,则运行出错。通过debug,发现此处出错。
s*******k
发帖数: 71
28

Mathematical routines such as FFT shouldn't be machine dependent unless it
uses hardware accelerations (for example, Intel MMX instructions), so what
you have for SGI should be able to compile and run on any machine. If not,
try www.fftw.org, they have a free FFT library which works for almost all
platforms (well, maybe not PalmPC!)
SH
p*********w
发帖数: 23432
29
可以先把输入输出的文件名给统一了,然后编个简单的 fortran 读写文件。
也可以考虑把原有的 subroutine 编译了,然后在外围写个 bat 调用
(通过 cmd line 输入输出)
L********e
发帖数: 783
30
来自主题: Unix版 - how to fork a subroutine in unix?
just use fork() API. And you need to include "unistd.h"
j***y
发帖数: 87
31
来自主题: Unix版 - how to fork a subroutine in unix?
I think in the current systems, all the fork functions will work as vforks.
it means that the system won't copy the whole context until it's necessary.
L********e
发帖数: 783
32
来自主题: Unix版 - how to fork a subroutine in unix?
fork is different from vfork as after vfork the child process shares the
same address space as the calling process. Because of the shared address,
you must be careful to use vfork.
m*****e
发帖数: 4193
33
来自主题: Unix版 - how to fork a subroutine in unix?
You are definitely wrong.
j***y
发帖数: 87
34
来自主题: Unix版 - how to fork a subroutine in unix?
You are right that vfork does have some differences with fork. But I think
the difference between vork and the modern fork is that with vfork, you
yourself have to do a copy-on-write synchronization. But with fork, the system
will do it automatically.
In vfork, it does share address space with parent, but more exactly, it
borrows address space from parent. Because the parent will suspend as vfork
is called. But this is not consistant in all platforms, in some platforms,
after vfork, the parent w
L********e
发帖数: 783
35
来自主题: Unix版 - how to fork a subroutine in unix?
oh? where?
I hardly use vfork and i have no refernce book with
me right now.
L********e
发帖数: 783
36
来自主题: Unix版 - how to fork a subroutine in unix?
//nod nod
you are right. In some platforms, the parent will be suspended after vfork.
why not just use fork to avoid any possible problems neh.
s****r
发帖数: 27
37
来自主题: Unix版 - edit tool in unix
nedit? can i browse the subroutins like class view in VC?
s****r
发帖数: 27
38
来自主题: Unix版 - edit tool in unix
yeh! vi and emacs are all quite good. But I don't know how I can browse the
fortran subroutines as class view in VC
x*****n
发帖数: 3422
39
Unix下的fortran和c
complier根据版本和option不同,会在symbol后面加一个或者两个underscore,
for example: "mpi_init__"
如果想在fortran下调用c的subroutine, 问题来了。比方说fortran编译后的object要求
一个underscore,而如果c不巧要两个underscore,就会出现undefined reference的错误

我知道一些fortran compiler比如pgf90有-Mnosecond_underscore的option。但是由于某
些原因,我需要知道,c compiler比如gcc是否有对应的option?
谢谢啦
i**********r
发帖数: 36
40
【 以下文字转载自 Linux 讨论区 】
【 原文由 interstellar 所发表 】
how can i list all variables used in a perl subroutine?
i used to perl -d to do a very simple check, but it does not
list the variables used.
thanks,
s**s
发帖数: 242
41
in C:
....
float *B,...
B=(float *)malloc(N*sizeof(float));
fsub_(B,...)
in fortran:
subroutine fsub(B,....)
real B(1)
s**l
发帖数: 30
42
Can it be more specified?
like an example which is tested. Thanks.
I tested the following
Fortran part:
program test
real B(1)
call fsub(B)
end
subroutine fsub(B)
real B(1)
do i=1,10
B(i)=i*1.
write(6,*) B(i)
enddo
end
C part:
#include
#include
void aaa( )
{
float * B;
B=(float *)malloc(10*sizeof(float));
fsub_(B);
}
But it says segmentation fault.....
s**l
发帖数: 30
43
I want to call a "C" subroutine from Fortran.
s**l
发帖数: 30
44
Thanks, it works, but I need to allocate an array from C subroutine and
use it in fortran.
q*****m
发帖数: 73
45
那没戏.
Suggest you make the Fortran program as subroutine, then call from C.
q*****m
发帖数: 73
46
来自主题: Unix版 - 我决定给自己的程序加密?
good luck to you. hehe.
In the future, when I need some subroutine, I will email you ;)
t***u
发帖数: 20182
47
来自主题: Chemistry版 - 化学wsn应该quit Ph.D. program吗
go to subroutine 如果应该quit而不想quit
r*******s
发帖数: 12
48
来自主题: Computation版 - A fortran problem in CFDRC
I am now working on a user subroutine for CFD
and I Use fortran compiler to get a dll. But get errors when compiling.
e:\PROGRA~1\cfdrc6\bin\cfdrc_access_calls.f(17) : Error: Error in opening the Li
brary module file. [USER32]
USE dfwin, ONLY : loadlibrary, getprocaddress, freelibrary
a*******x
发帖数: 47
49
来自主题: Computation版 - <>全书下载
看了上面的贴子, 说说我的理解:
之所以FORTRAN比C/C++快, 一个重要的原因是FORTRAN标准规定子程序的参数之间不
允许有重叠的部分, 这样的话常常可疑保证计算结果于执行顺序无关, 从而使编译器
能够最大限度的优化:
比如以下的例子
SUBROUTINE ADD(N,A, B,C)
DIMENSION A(N),B(N),C(N)
DO I = 1, N
C(I) = A(I) +B(I)
ENDDO
END
由于A B C之间不允许有重叠,计算结果与执行顺序无关, 所以编译器可以进行
LOOP UNROLLING等优化.
而同样的C/C++程序, 如果不特别加上某些编译器开关的话, 就无法同样优化.因为
C允许参变量有重叠.
首页 上页 1 2 3 4 5 下页 末页 (共5页)