 |
 |
Index ‹ fortran
|
- Previous
- 1
- Little question about FORTRAN programmingHi all,
I would like someone to help me with this problem. I have the following
lines in a FORTRAN program:
...
character*18 hosts(30)
integer i,tid(30)
...
3 format(A18,3X,A18,3X,A18)
31 format(I18,3X,A18,3X,I18)
...
print 3,'Llamada','Host','TID'
print 31,i,hosts(i),tid(i)
...
end
Note: 'LLamada' simply means 'call' in my home language (Spanish)
Well, when I run my program I get something like this:
Llamada Host TID
1 GnomeInTheShell 262206
As you can see, when using the 31 label format it shows a right-aligned
integer (i) in a 'cell' of 18 spaces, 3 blank spaces, a left-alligned
string (hosts(i)) in a 'cell' of 18 spaces, ...
What can I do to show the string right-alligned too? I think the
problem is because I am merging integers and characters in a format
specification, because the fomat specification with label 3 (which
contains only characters) works fine...
Thanks.
- 1
- 1
- Initializing Multi-dimensional array in Fortran 90 ModuleIn Fortran 90 Module, you can initialize an single dimensioned array
by doing, for example:
MODULE TEST
REAL :: VECTOR X = (/ 1., 2., 3. /)
END MODULE TEST
however, I have not figured out how to do this for a multi-dimensional
array. For example, the following does not work:
MODULE TEST
REAL :: I_MATRIX(3,3) = (/ 1., 0., 0., 0., 1., 0., 0., 0., 1. /)
END MODULE TEST
The compiler complains that the shape of the initialization expression
does not match that of variable "I_MATRIX".
I've tried doing the following, but this does not work also:
MODULE TEST
REAL :: I_MATRIX(3,3) = (/ 1., 0., 0. /, / 0., 1., 0. /, /0., 0.,
1. /)
END MODULE TEST
Any help would be appreciated. Thanks.
- 2
- Tholen's swan songHas Bruce AKA Tholen falled foul of the law? Or should that be fowl?
http://thescotsman.scotsman.com/index.cfm?id=296172005
Use OS/2 and you'll be eating crow instead.
- 3
- forall and do loophighegg <email***@***.com> wrote:
[about FORALL]
> Yes, I've read somewhere that it was regarded as a sort of "parallel
> DO" by many, even in the standardization committe.
I should hope not. That would be a pretty serious misunderstanding of
it. While people on the committee are certainly not immune to
misunderstanding things (by a long shot), they would have had to sleep
through an awful lot in order to have avoided getting this one hammered
into them.
It is an assignment and is not much like a DO at all. The fact that some
people confuse it for a parallel DO and thus try to do things other than
assignment with it, is perhaps one of its flaws (in addition to its
usually poor performance).
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
- 7
- Control of USB devicesI received a copy, but the post went missing. Here it is again:-
The new computers usually do not have an RS232c device, but now have 2
or
more USB ports.
I an interested in any advice or experience on reading and writing to/
from devices on these ports, where the device comunicates both ways
via ASCII strings.
I am assuming, from prior experience with specific devices that used
to come with a RS232c plug, and that now come with a USB plug, that
they
will work pretty much the same way as before, apart from the plug
hardware interface.
I want to do this in Fortran (as before).
How does one name and open such a device as a file?
Are there pre-determined file names for such devices?
Does the concept of a name exist?
- 7
- does this compile on your machine??Hi,
I had a horrific debugging day today, finally finding a construct like:
if (ivec(i >0 )) then
...
endif
- actually in a slightly more convolved form:
! Initialise network automatically.
conmat = .false.
do j=1,n
do i=1,n
call ij(i,j,n,n,ii,jj,peri)
do l=1,nb
if ( pix(i,j)/=pix(ii(l),jj(l)) .and. &
pix(i,j) > 0 .and. &
pix(ii(l),jj(l) > 0) ) then
conmat(pix(i,j),pix(ii(l),jj(l))) = .true.
end if
end do
end do
end do
Clearly a typo. I found the "error" going away, if I set
pix(ii(l),jj(l) to a small negative number!! Are there compilers which
give a warning for this?? I got none.
--
--------------------------------------------------------------------------
Dr. Christoph Arns
Dept. Applied Mathematics
Research School of Physical Sciences and Engineering
The Australian National University
Canberra ACT 0200 AUSTRALIA
Ph.: +61 (2) 6125 5170
Fax: +61 (2) 6125 0732
http://rsphysse.anu.edu.au/appmaths/~cha110/
- 7
- FORTRAN <--> C#. Am I stuck with File IO?I have a web-based application that I am using to make calls to my
number-crunching FORTRAN routines.
Because the output of the FORTRAN is largely variable-length, I am
writing the output to a file and then reading the file from C#. Yikes
this is relatively slow!
I estimate that my output will be anywhere from 100 to 500,000 bytes.
What kind of methods have you used successfully for this type of
communication?
Any simple examples would be appreciated.
Some background info:
Visual Fortran 8.1
C# with .NET 1.1
running on Windows 2003 Server
- 9
- Why these original FORTRAN quirks?; Now : Programming practicesAndrew Swallow wrote:
> Rostyslaw J. Lewyckyj wrote:
> [snip]
>
>> The eof status is determined when you try to fetch the data record
>> and needs to be acted on before you try to decode/interpret the
>> contents. But you don't want a great deal of extraneous program
>> steps (unrelated program execution) between when you inspect the
>> eof status and, if not eof, actually look at the data.
>
>
> The natural loop for read statements is the n+1/2 loop, unfortunately
> most languages do not explicitly support it.
>
> LOOP
> Read File
> On EOF, Break
> ... process record
> END LOOP
>
> Andrew Swallow
READ(unit[,fmt][,END=stmt]......}[list] :)
--
Rostyk
- 9
- what does "Leading Dimension" mean?I am using lapack subroutine
SUBROUTINE DSYEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, INFO )
to do a matrix inversion.
The fifth dummy argument is LDA,
* LDA (input) INTEGER
* The leading dimension of the array A. LDA >= max(1,N).
I don't understand its meaning. say I want to invert a NxN matrix A, what
value of LDA should I pass to DSYEV?
Many Thanks
best
Bin
- 10
- RESIZE in PL/I"David Frank" <email***@***.com> writes: >
> "William M. Klein" <email***@***.com> wrote in message
> news:0Xk0d.523878$email***@***.com...
> >
> > So again, what is your point? In this or any of your posts?
> The point is we face a PL/I fanatic who doesnt think twice about
> posting a completely fictitious code sample along with psuedo run results.
You know that's entirely false. The code is genuine PL/I code.
Those two sets of results were those actually obtained from
computer runs.
> I accuse him of posting a RESIZE statement without ANYTHING to back up
> whether or not he has coded a RESIZE function that accepts a argument like:
> v = [ v(3:), 13, v(4:) ]
>
> 1. its not even clear that [] chars are included in PL/I's active syntax
> set.
> 2. furthermore a PL/I function statement with syntax v = ..... as an
> argument
> is going to be errored by the compiler.
The code was not "errored by the compiler".
It compiles and runs cleanly.
The code does not use any run-time functions.
> IOW, its all a BIG lie, and your post above makes you part of the
> continuing PL/I cover-up or just plain ignorant.
To enlighten yourself, you should read the manual
(in particular, the preprocessor).
> If you disagree, try to get him to post his RESIZE function.
- 10
- A Remarkble Computation Program HistoryPenny Anderson wrote:
>Carl de Boor confirmed that he indeed was responsible for the original
>1960's FORTRAN code as he invented bicubic splines while at GM
Research at
>that time.
>Nice to know the power of MATLAB enabled him, decades later, to give
this
>user such a succinct and powerful solution in the Splines Toolbox.
If you have a working Fortran 77 subroutine, you can create an
interface in Fortran 90 as simple as that in MATLAB by using features
such as assumed shape arrays (array sizes do not need to be passed) and
optional arguments.
For example, a call to the LAPACK Fortran 77 library such as
call SGELSD(M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, WORK,LWORK,
IWORK, INFO)
can be replaced with just
CALL LA_GELSD (A, B)
in LAPACK95, a Fortran 95 interface for LAPACK.
De Boor's Fortran spline code is freely available at
http://www.cs.wisc.edu/~deboor/pgs/ , and there is also public domain
Fortran code for splines at http://www.netlib.org/dierckx/ . You can
create simpler interfaces for any of these codes in about an hour. Why
commit yourself to expensive, proprietary, platform-specific solutions
that may run slower and don't even produce stand-alone executables?
- 10
- Foray Build Tool Project StartedI have started a project at Google to develop the new Foray (formerly
TCBuild) Fortran build tool:
http://code.google.com/p/foraytool/
Foray is designed specifically for Fortran projects, and has a lot of
nice advanced features, similar to Scons. It is written in Python, and
anyone willing to contribute is most welcome.
Here is a short introduction from the project page:
Fortran 90 can include reasonably complex dependencies, which must be
taken into account when building a multiple-file program.
Unfortunately, most build tools either don't support Fortran, or don't
help the developer much. A standard make file, for example, requires
you to enter dependencies manually, or develop a script to do it for
you.
Foray is a build tool designed specifically for Fortran projects. It
can be applied to anything from a small utility program with tens of
files to a million line monster. Foray natively handles Fortran
dependencies, takes care of locating files in subdirectories, and
includes advanced features like multi-threading for better performance
on multi-core systems, and multiple build configurations (eg debug,
release, serial, parallel).
Drew McCormack
- 10
- Default initialization and saveI am in the process of investigating if I can port some code from intel
fortran (win and lin) to g95 so that it can run on other platforms (SGI
etc...)
In g95 it refuses to compile the following (which ifc accepts)
module test_mod
type test_type
REAL :: x = 1.0
end type test_type
type(test_type) :: a
end module test_mod
saying that:
In file test.f90:6
type(test_type) :: a
1
Error: Module variable 'a' at (1) with a default initialization must
have the SAVE attribute
My question is if g95 is being more picky about the standard, or just
forcing more explicit code (probably a good thing). I had assumed this
worked just like local variables where any initialization forces an
implicit save attribute.
Kevin
- 10
- Debug option in F77How do I turn on debug in F77. I have a complicated make file and
everytime a mistake is made, I cant debug with a great deal of
trouble. Any ideas welcome.
Thnx
|
| Author |
Message |
David Rudack

|
Posted: 2005-8-25 21:05:04 |
Top |
fortran, Fortran (Linux pgf90)
I have inherited a code that equivalences a four character string (TDLP)
to its integer value. The code first gets the integer value and then
checks if the integer value is equivalent to the 4 letter character
string TDLP. If they are the same, the program continues. The problem
is that I have compiled this code along with all other associated
codes on a Linux machine using the fortran compilation option of
-byteswapio. I need to do this because the input data is big endian.
When I run the program the subroutine compares the character string of
"PLDT" instead of what it should be comparing, mainly, "TDLP". If I
hardwire in "PLDT" as the character string, the code runs fine and all
the data is switched to little endian and I get good results. It seems
like the character string is not being treated correctly. Is there a
compiler option to get rid of this problem?? Thanx for any help.
---David
|
| |
|
| |
 |
glen herrmannsfeldt

|
Posted: 2005-8-25 22:17:00 |
Top |
fortran >> Fortran (Linux pgf90)
David Rudack wrote:
> I have inherited a code that equivalences a four character string (TDLP)
> to its integer value. The code first gets the integer value and then
> checks if the integer value is equivalent to the 4 letter character
> string TDLP. If they are the same, the program continues. The problem
> is that I have compiled this code along with all other associated
> codes on a Linux machine using the fortran compilation option of
> -byteswapio. I need to do this because the input data is big endian.
> When I run the program the subroutine compares the character string of
> "PLDT" instead of what it should be comparing, mainly, "TDLP". If I
> hardwire in "PLDT" as the character string, the code runs fine and all
> the data is switched to little endian and I get good results. It seems
> like the character string is not being treated correctly. Is there a
> compiler option to get rid of this problem?? Thanx for any help.
If it does byte swapping then no, it is not comparing to "PLDT",
but is byte swapping the input data before comparing it.
You can't expect it to know which integer inputs are to be byte
swapped and which aren't by magic. It seems to me that you have
the right solution, compare to "PLDT" instead.
In C, one would use the functions htonl() and ntohl() to do byte
swapping conditional on the machine not being big-endian.
You might see if those would help you here.
-- glen
|
| |
|
| |
 |
lindahl

|
Posted: 2005-8-26 2:21:00 |
Top |
fortran >> Fortran (Linux pgf90)
In article <dekgc3$eed$1@news.nems.noaa.gov>,
David Rudack <David.Rudack@noaa.gov> wrote:
> It seems like the character string is not being treated correctly.
But it sounds like it is read as an integer. If you read it as a
CHARACTER*4 instead, you'll get the result you're looking for. The
I/O runtime can only work with the type you tell it.
-- greg
|
| |
|
| |
 |
| |
 |
Index ‹ fortran |
- Next
- 1
- -QpathThe NAGWare and F compiler have an option to change the f95 compiler
library pathname from the default.
Does gfortran also have such an option? I've tried -B but somehow this
did not work...
I'm using GNU Fortran 95 (GCC 4.1.0 20050811 (experimental)) on a stable
Debian GNU/Linux box.
Regards,
Bart
--
"Share what you know. Learn what you don't."
- 2
- Need clarification on unformatted IOI am trying to read in a unformmated sequentail binary file generated
from someone else's code.
In his code, he has something like:
do j = 1, total
write(12) (buffer(i), i = 1, total2)
enddo
Here's my question:
When I try to read in the content of the file with the following code,
it crashes (segmentation fault):
do i = 1, total
read(12) differ_buffer(1:total2)
end do
However, if I use the following code, I can complete the read call:
do i = 1, total
read(12) (differ_buffer(j), j = 1, total2)
end do
>From what I've read from Fortran 90, don't the following code
fragements the same thing?
differ_buffer(A:B)
and
do i = A,B
differ_buffer(i)
enddo
and
differ_buffer(i), i = A,B
- 3
- calling c from fortran 90hello....i'm fairly new to fortran....
Actually i've recently joined a project which is being done in fortran
90. There is very little time in which the project has to be finished.
So, i wanted to ask if anyone can tell me if C or C++ functions can be
called from the fortran 90 program. Plz teel me the way of doing this,
the syntax and if possible how the c function which recieves arguments
from the fortran 90 program shud be defined.
- 4
- g77 & binary vs. unformattedIs there any way to get g77 to read/write files opened with the "
form='binary' " flag? If not, and if there are any g77 developers
listening, is there any chance that this capability will be added?
I've got a program that is primarially developed in Compaq Fortran on
Windows. I have been porting it to Linux/g77. When I have encountered
open(blah, blah, form='binary'), I have replaced it with 'unformatted'.
Everything runs fine, and all is well with the world.
Enter the program that converts the output of the analysis into an
unstructured Fieldview file. Similar problems, similar (attempted)
solutions. It now runs and outputs an unformatted Fieldview file.
Unfortunately, Fieldview can't read the file.
The 100% solution is for me to get g77 'binary' aware and switch everything
back to how it should've ben in the first place. This should also have some
significant performance benefits (see archives for earlier thread about
unformatted network writes).
The 75% solution is for me to get Compaq Fortran to detect the file format
at runtime, and develop a windows version of the converter that can handle
either file format. If I try to open a file created with 'unformatted' by
using 'binary' in Compaq Fortran, is there a reasonable way to trap this
error & act accordingly? Is there some other way in Compaq Fortran to
detect what format the file was created as?
Thanks for your time,
Rob
- 5
- g95 beta on Mac OS X - problemInstalled g95 beta via Fink (unstable) on Mac OS X 10.3.8
Want to use my present g77 libraries, but something is missing, I get
undefined symbols: _lnblnk_ / _G77_lnblnk_0 / _do_fio / _e_wsfi /
_s_cat / _s_copy / _s_stop / _s_wsfi / _G77_getenv_0 / _do_lio /
_e_rsfe / _e_rsli / _f_clos / _f_inqu / _f_open / _i_indx / _s_cmp /
_s_rsfe / _s_rsli / _e_wsfe / _s_wsfe / _f_end / _G77_fgetc_0 /
_G77_idate_0 / _G77_itime_0 / _e_rsfi / _s_rsfi /
Theese are not "my" symbols. Obvious some library is missing referenced
in the g95 command; but which ?
Anybody able to help ... ?
/ FL
- 6
- Multiple external MPI jobs and collection of output in a serial main program?Hello,
Please help me on this urgent need for my MPI program on a Linux
cluster (4 CPUs per node; 2 dual-cores per node).
I have a main Fortran program for a micro genetic algorithm
optimization. This main program calls one external code (it could be
a commercial or binary code without source code) with multiple data
sets iteratively. I use an MPI version of this program which uses 4
CPUs at one generation, and the external code is called by using "call
system( *** )" in the main Fortran program.
This was alright for a small external code in serial mode, but now I
have to use the external code in MPI mode which may need several
computing nodes for a speed-up. Here I got a problem. I don't know how
to write the main program which calls the external MPI code 4 times at
once at a time step. Of course at the end of each time step or
generation I need to collect the output from these 4 MPI jobs and
evaluate a fitness function.
I am trying to write the main program in serial mode, which calls the
external MPI program 4 times (it may need to be background jobs),
waits until these 4 MPI jobs are finished, and does some math and
moves on to the next time step or generation. This could be done using
a script file but I just don't know how to.
Thanks for your suggestions,
Nam
- 7
- integer*8 speed vs integer*4 speedDoes anyone know of the relative speed difference of generally
using integer*8 over integer*4 ? Specifically in Win32.
Thanks,
Lynn McGuire
- 8
- Memory allocatedDear users (of fortran90 :) ),
Is it possible to check how much of memory is allocated,
or how much of memory is still free?
- 9
- Public review - Impure elementalsIMPURE ELEMENTALs
I don't see the value in having IMPURE ELEMENTAL procedures.
There are no examples in the draft standard and the only
example in the document describing new features can be
rewritten without the procedure being ELEMENTAL at all.
The example in the document is:
impure elemental function accumulate (a,sum)
real :: accumulate
real, intent(in) :: a
real, intent(inout) :: sum
sum = sum + a
accumulate = sum
end function accumulate
Where the call is:
real a(n), sum
:
sum = 0.0
a = accumulate (a,sum)
This seems simple enough. But suppose SUM was also declared
to be an array. The procedure would no longer "accumulate".
Nor would it generate any error messages or warnings. An
elemental is simply not a good way of accompishing such things
in the first place. You're trying to graft inappropriate
functionality in a place it doesn't fit well.
Now, if the procedure were declared:
function accumulate (a,s)
real, intent(inout) :: s
real, intent(in) :: a(:)
real :: accumulate(size(a))
s = sum(a)
accumulate = s
end function accumulate
The caller could be the same. The SUM argument could even be made
optional - it is certainly required to remain a scalar.
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
"Simplicity is prerequisite for reliability" -- E. W. Dijkstra
- 10
- Compulsory spaces in free source formThe f95 standard requires a blank between a statement keyword, name,
constant or label and an adjacent name, constant or label in free source
form, and it's obvious why if, for example, a constant has a name. But
it's a pity that the rule prevents things like STOP'Now' where ambiguity
is impossible. (Some compilers e.g. g95 catch this error, others don't.)
But there are cases like PRINT* and STOP666 where the * or the 666 seems
not to be a name, constant or label (666 in some contexts is a constant
but here it's a string of up to 5 digits). The blank is then presumably
not needed, even though STOP666 looks as if it could also be the name
of a variable. F95 compilers disagree on how they treat the program
below; is it standard-conforming in free source form?
STOP666 = 666
PRINT*,'STOP666 =',STOP666
STOP666
END
John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington, New Zealand
e-mail email***@***.com phone (+64)(4)463 5341 fax (+64)(4)463 5045
- 11
- Reading TABs and viewing runtime errorsMattias Alveteg wrote:
> I have two problems
>
> 1) Reading TAB characters with Fortran program compiled with Absoft or
> CVF under Windows
>
I've never had a problem with CVF on this - the following works for me
with every version of CVF I've tried. With Absoft, I concocted
something using their FGETC routine.
program readtab
character*80 zline
open(10,file='tab.dat')
write(10,'(A)') char(9)//'abc'//char(9)//'def'
close(10)
open(11,file='tab.dat')
read(11,'(A)') zline
write(*,*) (ichar(zline(i:i)),i=1,20)
end
--
John Appleyard (for email, please use john@.. rather than news@..)
Polyhedron Software Ltd.
Programs for Programmers - QA, Compilers, Graphics, Cosultancy
********* Visit our Web site on http://www.polyhedron.co.uk/ *********
- 12
- Why these original FORTRAN quirks?In article <email***@***.com>,
email***@***.com wrote:
>
>Gene Wirchenko wrote:
>> email***@***.com (Richard E Maine) wrote:
>>
>> >Rostyslaw J. Lewyckyj <email***@***.com> wrote:
>>
>> [snip]
>>
>> >> purely Fortran? But I'd consider that to be rather unrealistic in a
>> >> production environment. Linkers, loaders, libraries etc. are a fact
>> >> of life.
>> >
>> >I think we are not communicating here. The linkers, loaders, etc, are
>> >part of the Fortran environment. That's why the Fortran standard (like
>>
>> They are? I used FORTRAN, back in the capitals days. The linker
>> and loader were part of the OS. Many language systems used them.
>
>Of course they are part of the Fortran environment. They were also part
>of the environment of any other language system that relied on them. A
>(viable) (fortran) compiler must (be designed to) deal with their
>conditions and influences (it is in effect surrounded by them) and the
>result of using the linkers and loaders must be a code that must be be
>usable within the system (including the OS) it is used in.
CAreful. The linkers and loaders aren't separate. What is even
worse is that the kiddies who think they know how machines work,
are not aware of the reasons for linkers and loaders; they assume,
rightly from their experience, that it is all one procedural step.
This is a loss of knowledge that is happening right now.
/BAH
- 13
- libshell32.a g77 (win98)hello,
i found <libshell32.a> in my g77 lib directory.
where can i get information about this lib?
what can i do with this lib?
klaus
- 14
- systemqq command in a DO loopHi, sorry I forgot to include this question in my other post.
Basically, do processes called by systemqq need to be explicitly shut
down (sort of like deallocate for arrays) or do they keep running as
long as the DO loop which called it has not ended?
For example:
-------------------------
Program execute
logical(4) result
open (1, file='output.txt')
do i = 1, 100
result = systemqq('run.exe')
read (1,*) random_number
enddo
end program execute
--------------------------
---------------------------
Program run
iseed = 187252
open (1,file='output.txt')
rnd = ran(iseed)
write (1,*) rnd
end program run
-------------------------------
In the above example, is 'run.exe' executed 100 times before shutting
down?
Also, implementing something similar to the above caused what I think
is a sharing violation. How do I fix it? (see other thread for more
info)
Thanks.
- 15
- !MS$LOCICAL:2Hi,
I put the following directives at the top of a module and it compiles
OK.
!MS$REAL:8
!MS$INTEGER:4
What is the equivalent for a logical. I get an 'Invalid DEC$ directive
!MS$LOGICAL:2' with the following...
!MS$LOGICAL:2
I am using CVF.
Thanks in advance,
Phil
|
|
|