Can we compile fortran 90 on external hdd?

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

Discussion Overview

The discussion revolves around compiling a Fortran 90 program on an external hard drive and managing the output of a large number of data files. Participants explore the feasibility of using an external drive for both compilation and storage, as well as the necessary coding practices to ensure proper file handling in a Linux environment.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses the need to compile a Fortran 90 program and store a large number of output files on an external hard drive due to insufficient local storage.
  • Another participant suggests ensuring that the Fortran program allows for output redirection to the external drive and distinguishes between compiling and running the program.
  • A different participant emphasizes the importance of specifying proper path names in the OPEN statements for reading and writing files on the external drive.
  • Concerns are raised about the efficiency of storing 10,000 files in a single directory, which could slow down input/output operations.
  • One participant provides a command-line approach to compile and run the program from the external drive, while also suggesting the use of bash scripting for file management.
  • A later post reveals that the external drive could only be used for storage and not for compilation, leading to a code snippet shared by the user to write data to the external drive.
  • Another participant points out a potential issue in the user's code regarding how the filename is constructed, suggesting a need to concatenate the path with the filename correctly.
  • The user confirms that the suggested correction worked, indicating a successful resolution to their coding issue.

Areas of Agreement / Disagreement

Participants generally agree on the need for proper file path management when working with external drives, but there is some uncertainty regarding the capabilities of the external drive for compilation and the best practices for organizing a large number of output files.

Contextual Notes

Limitations include the user's initial misunderstanding of the external drive's capabilities and the specific requirements for file path formatting in Fortran on Linux systems.

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   Reactions: 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   Reactions: 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