Sponsored Content
Full Discussion: Error running FORTRAN code
Top Forums Programming Error running FORTRAN code Post 302535060 by LMHmedchem on Wednesday 29th of June 2011 01:57:03 PM
Old 06-29-2011
It would be very helpful if you could post your code examples using code tags, [code ][/code ], there is a space before the ] that you don't actually put in, but I have added it so you could read the tag text.

Here is an example,
Code:
DO i=1,numfiles
  tmp = trim(basefile)
  WRITE(tmp(LEN_TRIM(tmp)+1:LEN_TRIM(tmp)+4),33) i
  OPEN(unit=10+i, file=tmp, status='old' iostat=ios)
  IF ( ios /= 0 ) THEN
    PRINT *,'Unable to open',TRIM(tmp)
  ELSE
    IF(verbose) PRINT *,TRIM(tmp),' opened   succesfully'
  ENDIF
ENDDO

C All the files are closed at the end of the program as

CLOSE ( unit = 10 );
DO i=1,numfiles
  CLOSE (unit=10+i)
ENDDO

I still program in fortran 77, so this syntax is not clear to me. I would set up a do loop with a control line number and not an ENDDO. I would also evaluate with .NE. instead of /=. etc.

The thing to do is to create a small program that just opens your files, closes your files, and prints something to confirm success. Get that to work. You can post that here with a sample input file so others can test it.

Most likely, you are exceeding the capacity of some data structure that stores the contents of the files, but that is hard to know without seeing the declarations. After you get the files opening and closing, you can look at the data structures in the program and add what is necessary to store the data. It can be helpful to have apps like this process one input file at a time if that is possible. Then it shouldn't matter how many input files you process, only how large the largest file is.

Fortran doesn't have dynamic memory allocation, so you have to pre-size your data structures to be larger than needed and also trap out the data loading process so you can quit with a handled exception if your data is larger than the available space. If that is a huge issue, you may consider re-writing some of the subroutines in c++, which has containers like vectors and maps that can re-size on the fly. It is generally not a problem to have mixed language code and calling a c++ function from Fortran code is not that difficult as long as you can compile both languages.

Fortran is a beastly language for file I/O and I'm sure it wold be very much easier to write this program in c++, or better yet, and interpreter like perl, python, or ruby. If the app is 500 lines of f95, it is probably 200 lines of c++, or 15 lines of python.

LMHmedchem
 

9 More Discussions You Might Find Interesting

1. Programming

Error while running the C code

Hi Sir, I am running C program which include directfb.h header files. root@lxdevenv:~/Desktop# vi n.c root@lxdevenv:~/Desktop# gcc n.c -o n -I/usr/local/include/directfb -L/usr/local/lib -ldirectfb -lfusion -ldirect -lpthread -lm n.c: In function ‘main':... (2 Replies)
Discussion started by: Ravikishore
2 Replies

2. Programming

Making FORTRAN code more efficient

Hi, I have a very large, very old FORTRAN code that I work with. The code is quite messy and I was wondering if I can speed up execution time by finding subroutines that code execution spends the most time in. Is there any kind of software I can use to see where the code spends most of the... (1 Reply)
Discussion started by: rks171
1 Replies

3. UNIX and Linux Applications

Getting error code when running the script 2 (RC)2

hi All, we have a script to remove the files from particular path,when we tryingto run manually the script went to success and removed the files but the same script which is running by other team it got failed and giving the error "2 (RC)2 "..what is the cause of the failure..and we passing the... (2 Replies)
Discussion started by: nagavenkatesh
2 Replies

4. Programming

Help with make this Fortran code more efficient (in HPC manner)

Hi there, I had run into some fortran code to modify. Obviously, it was written without thinking of high performance computing and not parallelized... Now I would like to make the code "on track" and parallel. After a whole afternoon thinking, I still cannot find where to start. Can any one... (3 Replies)
Discussion started by: P_E_M_Lee
3 Replies

5. Programming

Using Doxygen on Fortran code

I am using doxygen for documenting my fortran code. I want to write some notes after the header in different parts of the subroutine. Any idea what the tags should be as anything I write after the header is not displayed ... (0 Replies)
Discussion started by: kristinu
0 Replies

6. Programming

Removing goto statements in FORTRAN code

I have the code below and I want to remove the "go to" statements. Any idea how I can do it? if (iorder == 0) then tmincurrent = 1.0e11 if(ireverse == 0 .or. istop /= 1) then do i = 1, 6 if ((side(i) /= sidelimit(i)) .and. (tminside(i) < tmincurrent)) then ... (1 Reply)
Discussion started by: kristinu
1 Replies

7. Programming

Strange characters in FORTRAN code output

Hi guys, After compiling a .f90 code and executing it, i get strange characters in the output file like : ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ Are these windows characters? how can i get rid of this? Much appreciated. Paul (1 Reply)
Discussion started by: Paul Moghadam
1 Replies

8. Homework & Coursework Questions

FORTRAN error *** glibc detected ***

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I'm doing aproximation of derivative called five-point stencil. For every value of x, in interval , in step... (0 Replies)
Discussion started by: antonija
0 Replies

9. Programming

Error in my FORTRAN program

I have a Fortran program and I am writing out to logical unit 7. The program is reading from a text file and writing to the new file formatted. It gets through the read and writes some to the file but then stops with the following error: 1525-013 The sequential WRITE statement cannot be... (5 Replies)
Discussion started by: KathyB148
5 Replies
DH_MOVEFILES(1) 						     Debhelper							   DH_MOVEFILES(1)

NAME
dh_movefiles - move files out of debian/tmp into subpackages SYNOPSIS
dh_movefiles [debhelperoptions] [--sourcedir=dir] [-Xitem] file...] DESCRIPTION
dh_movefiles is a debhelper program that is responsible for moving files out of debian/tmp or some other directory and into other package build directories. This may be useful if your package has a Makefile that installs everything into debian/tmp, and you need to break that up into subpackages. Note: dh_install is a much better program, and you are recommended to use it instead of dh_movefiles. FILES
debian/package.files Lists the files to be moved into a package, separated by whitespace. The filenames listed should be relative to debian/tmp/. You can also list directory names, and the whole directory will be moved. OPTIONS
--sourcedir=dir Instead of moving files out of debian/tmp (the default), this option makes it move files out of some other directory. Since the entire contents of the sourcedir is moved, specifying something like --sourcedir=/ is very unsafe, so to prevent mistakes, the sourcedir must be a relative filename; it cannot begin with a `/'. -Xitem, --exclude=item Exclude files that contain item anywhere in their filename from being installed. file ... Lists files to move. The filenames listed should be relative to debian/tmp/. You can also list directory names, and the whole directory will be moved. It is an error to list files here unless you use -p, -i, or -a to tell dh_movefiles which subpackage to put them in. NOTES
Note that files are always moved out of debian/tmp by default (even if you have instructed debhelper to use a compatibility level higher than one, which does not otherwise use debian/tmp for anything at all). The idea behind this is that the package that is being built can be told to install into debian/tmp, and then files can be moved by dh_movefiles from that directory. Any files or directories that remain are ignored, and get deleted by dh_clean later. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 9.20120909 2012-05-19 DH_MOVEFILES(1)
All times are GMT -4. The time now is 05:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy