I am faced with this problem that I couldn't figure out yet, if you can point me to some direction that'll be of great help. So here's what I want to do.
I have let's say 10000 files which contains same number of Z coordinates in each file. I have to find the distance of those coordinates from a metal atom whose coordinate is constant, create an interval array (like 0.1,0.2...) then check how many atoms lie between 0.1 & 0.2, 0.2 & 0.3...Then I have to find the probability, just dividing by number of total atoms for each interval. At last I have to add those probabilities of each interval from all 10000 files and average those. I will try to make my self easier with example.
So what I did was a loop over files that will read coordinates, calculate distances. But how do I count or get probabilities for the intervals? I tried creating mask and using a loop for counting before file loop starts but honestly I have no clue how should I progress. Cause has to go through all the distances to check how many atoms lie in that interval. I thought of giving this post last night but I slept over it but still have nothing. I also tried creating a mask but I'm pretty sure I'm doing it wrong.
I'm showing the audacity to post my terrible code here, if you have sometime to look over it.
This code shows run time error after showing distance for the 1st coord of the 1st file. Obviously cause I have no idea what I'm doing. Also I've 10000's of files to read. So if in the loop over files I put I4 instead of I1 it can't read files which are numbered as 1,2 or 10,100,1000. It can only read 10000. And if I put I1, it can only read up to 9. Also I don't know how to average those probabilities at the end. In essence I'm in a big mess. If you guys could just point me to a direction, that will be of great help.
What be the verbatim msg of your run time error? I don't know what happens if you open a unit twice without closing it, but this is what you do in the file loop.
Thank you so much for answering! I almost solved my problem but stuck in one single step. I have to read 10000 files which are named as
like this.
The problem is when I read files like this-
it can read only upto 9 files. To read from to 10 to 99 I have to make that I2! I tried adding 0's on the left like
but then when I say
it can't read those files!!
Thanks RudiC. But It seems like the concatenation operator only works for character strings, doesn't work with character and integer. I tried this way too.
Shows run time error!Seems like this damn thing vowed not to work.
Thanks a lot man!
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
Using the short code:
compiling with gfortran one.f90 and running ./a.out | specimen 5:5:5
produces:
( The specimen code is a local code for looking at beginning:middle:end of a file. )
Is that what you were trying to do? ... cheers, drl
Thanks a lot drl! I actually had no time at that moment so I just converted all the files to 5 digits, like 1 to 10001 and 10000 to 20000. Your solution is the one I was looking for. I'll try it sometime.
What would be an accurate and efficient computation of the p-norm in Fortran?
Integer :: p
Real :: sum, pn
Do i = 1, Size (a)
sum = sum + ((Abs a(i)) ** p)
End Do
pn = sum ** (1.0/ Real(p)) (0 Replies)
I am writing some code in fortran that defines certain shapes.
Currently I have a cuboid and a prism. Now a parallelepiped is both a cuboid and a prism. Is there a way to code this?
Currently I only have
Type, Extends (Cuboid) :: Parallelepipied
How can I do so that Parallelepipied is... (3 Replies)
Need assistance in Fortran Compiler
I need to install Fortran compiler on Linux distribution . I don't have root access to use rpm or yum to install compiler . Is there any way I can get it ?
Are there any sites that has fortran compiler . Any links to download and install . (10 Replies)
Hi
I am reading a book about Fortran 90 and I write the following code, to test my understanding of the first chapter. I have a problem with the last section of the code with deals with an IF, ELSEIF, and GOTO statements. Here is my Code
PROGRAM sim
! This code is used to solve two... (3 Replies)
Hello everyone,
I am trying to compile a code under fedora14.Kernel Linux 2.6.35.6-45fc14.i686-GNOME 2.32.0. I use f77,g77 and gfortran to compile but I get the same error all ways.
Unsupported OPEN control item at (^) -- ACTION=, ASSOCIATEVARIABLE=, BLOCKSIZE=, BUFFERCOUNT=,... (1 Reply)
Hi!
I have a program in fortran77. This program was compiled with pgf90, but now, I need compiled it with gfortran.
I show a bit of code.
program hello
PARAMETER(a=100)
integer a
write(*,*)'value ', a
end program hello
What's the problem?
Thanks (2 Replies)
Can anyone recommend a very good Fortran online course for unix. It should also cover Fortran X11 programming if possible. I understand this learning cannot be rushed but a course that addresses useful topics sooner is best. If it isn't free, that's okay. (1 Reply)
Hello,
I have a FORTRAN code that I want to compile using F90 compiler. However,
when I enter the command:
f90 ./code.f -o ./code.out
It would give me prompt saying that absoft license has failed, or something.
I remember, however, that I could enter some keyword that ends with 'soft'
in... (1 Reply)