Fortran Can we compile fortran 90 on external hdd?

  • Thread starter Thread starter s_hy
  • Start date Start date
  • Tags Tags
    Fortran Hdd
Click For Summary
SUMMARY

The discussion focuses on compiling Fortran 90 programs on an external hard drive while using openSUSE 13.1 with Linux kernel 3.11.6-4-desktop. Users are advised to ensure that their Fortran programs can redirect output files to the external drive by specifying the correct path in the OPEN statements. Compiling can be done on the laptop, but proper organization of the output files is crucial to avoid performance issues. A solution was provided for correcting file path concatenation in the Fortran code to successfully write output files to the external drive.

PREREQUISITES
  • Familiarity with Fortran 90 programming
  • Understanding of file I/O operations in Fortran
  • Basic knowledge of Linux command line operations
  • Experience with openSUSE 13.1 or similar Linux distributions
NEXT STEPS
  • Learn how to manage file paths in Fortran using the OPEN statement
  • Research best practices for organizing large numbers of files on Linux
  • Explore bash scripting techniques for automating file management tasks
  • Investigate performance implications of file system choices on Linux
USEFUL FOR

Fortran developers, Linux users working with large datasets, and anyone involved in scientific computing requiring efficient file management and compilation techniques.

s_hy
Messages
57
Reaction score
0
Hi,

I need to compile a programming written in fortran90 and the output will be in 10 000 data files(maybe more) size 3.5Mb each. My notebook's memory is not enough to store all the data file, I am using Linux 3.11.6-4-desktop with openSUSE 13.1 (Bottle) (x86_64). I have 1TB external hdd and thinking about to compile the programming from external and store all the data files and figure inside external but I don't know how to do that. Can anyone teach me?

Thank you
 
Technology news on Phys.org
s_hy said:
Hi,

I need to compile a programming written in fortran90 and the output will be in 10 000 data files(maybe more) size 3.5Mb each. My notebook's memory is not enough to store all the data file, I am using Linux 3.11.6-4-desktop with openSUSE 13.1 (Bottle) (x86_64). I have 1TB external hdd and thinking about to compile the programming from external and store all the data files and figure inside external but I don't know how to do that. Can anyone teach me?

Thank you

Make sure your Fortran program allows you to redirect output data files to the external drive (letter D: or whatever). You haven't said if the filenames for all 10000 output files are generated by the program or by user input.

Compiling the program and running the program are two separate processes. Unless your program is totally huge, you probably can compile it on your laptop w/o needing the external drive.
 
Your program should be able to read input files from an external hard disk and write output files to an external hard disk, regardless of where the program itself is located. You need to know how to specify a proper path name for the input and output files in the OPEN statements. For example, under Mac OS I would specify '/Volumes/diskname/foldername/subfoldername/filename'. I don't know how you would do it under openSUSE.
 
s_hy said:
I need to compile a programming written in fortran90 and the output will be in 10 000 data files(maybe more) size 3.5Mb each.

You may want to think about the storage organization. Depending on the file system, 10000 files, if kept in a single directory, can seriously slow down input/output operations.
 
Reading input and writing output to the hdd shouldn't be a problem...simply compile your program wherever, then, change directories to the working directory in the hdd and run the program from there.

Code:
cd                              # cd alone takes you to your home directory
cd myprogram           # cd to where the fortran program is
gfortran myprog.f90  # compile

cd /path/to/externaldrive  # cd external drive top directory /mnt/something?
cd workingdirectory      # cd to working directory
~/myprogram/myprog < inputfile

As Borek said, you may want to develop a scheme to organize your files. Fortran is not a systems programming language and while passing a path filename to a file one, two or three directories deep may actually create the internediate directories if needed, it may not be the most efficient way...

...so, you may want to also brush up your bash scripting for creating ahead of time all those directories and possibly manipulating those 10000 files after the fact...you will need it...either to erase them, move them, filter them out looking for certain patterns, subsets, etc.
 
Last edited:
  • Like
Likes 1 person
thank you for all the reply. I have got the idea right now.
 
I have found out that my external couldn't do the compilation work. It happened to be as storage only. I have wrote a test code to write all the data into path

Code:
subroutine fd1d
implicit none

double precision                   :: f0,miu,delta,S,E0,Ca,Da,tdelta,c,Cb,Db,lambda               
integer                                 :: iinit,ilast,i,j,n 
double precision,dimension(202)    :: Ez,Hy
double precision, parameter   :: pi = 3.14159265
character(len=100)                :: filename

!character(len=100),parameter       :: filename = "/run/media/sharwani/TOSHIBAEXT/PHDresearch/1dtest"


 f0 = 100.0
 miu = 1.0
 delta = 1.e-3
 S = 1.0001
 E0 = 1.0
 iinit = 1 
 ilast = 100

 c = 1.0
 lambda = c/f0
 tdelta = (delta/c)/sqrt(2.0)

!initialization
do j = 1, 2*ilast
 If (Mod(j,2) == 0) then 
    Hy(j) = 0
    else
    Ez(j) = 0
 End if
end do


 Ca = 1.0
 Cb = (tdelta/delta)


 Da = 1.0
 Db = tdelta/(miu*delta)

do n = 1,200
   
  filename = "/run/media/sharwani/TOSHIBAEXT/PHDresearch/1dtest"
  write (filename,"('ez',I3.3,'.dat')") n
  open (unit=130,file = filename)  
  
  do j = 2, 2*ilast-1
     if (Mod(j,2) /= 0) then 
        Ez(j) = Ca*Ez(j) + Cb*(Hy(j+1)-Hy(j-1))
        write (130,*) Ez(j)
     end if
  end do !j

  do j = 2, 2*ilast-1
     if (Mod(j,2) == 0) then
        Hy(j) = Da*Hy(j) + Db*(Ez(j+1)-Ez(j-1))  
     end if 
  end do !j

  !plane wave source
   Ez(101) = E0*sin (2*pi*f0*n*tdelta)

 close (unit=130)

end do !n

end SUBROUTINE fd1d


the output file is assumed to be write into path which is the external hard disc, but it doesn't work. Can anyone advice me what is wrong with this code.


Thank you
 
It seems to me that you are overwriting the contents of "filename" with just "ez001.dat" on top of the previous (full path) contents. You do not want to write to "filename"...what you want is to concatenate to it.

or

Code:
write(filename, "('/run/media/sharwani/TOSHIBAEXT/PHDresearch/1dtest/ez',I3.3,'.dat')") n
 
  • Like
Likes 1 person
thank you gsal. it's worked!
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 16 ·
Replies
16
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 8 ·
Replies
8
Views
6K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K