Can we compile fortran 90 on external hdd?

  • Fortran
  • Thread starter s_hy
  • Start date
  • Tags
    Fortran Hdd
In summary, the programmer was compiling a program written in Fortran and the output will be in 10 000 data files(maybe more) size 3.5Mb each. The external hard drive was not large enough to store all of the data files. The programmer has 1TB external hard drive and was thinking about compiling the program from external and storing all the data files and figuring inside external.
  • #1
s_hy
61
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
  • #2
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.
 
  • #3
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.
 
  • #4
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.
 
  • #5
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
  • #6
thank you for all the reply. I have got the idea right now.
 
  • #7
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
 
  • #8
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
  • #9
thank you gsal. it's worked!
 

1. Can I compile Fortran 90 on an external HDD?

Yes, it is possible to compile Fortran 90 on an external HDD. However, the process may vary depending on your operating system and compiler.

2. What are the advantages of compiling Fortran 90 on an external HDD?

Compiling Fortran 90 on an external HDD allows you to save space on your main hard drive and keep your code and data separate. It also allows you to easily transfer your code and compiled programs to other computers.

3. How do I set up my system to compile Fortran 90 on an external HDD?

The steps to set up your system will depend on your operating system and compiler. Generally, you will need to configure your compiler to use the external HDD as the destination for compiled programs and set the appropriate paths in your code.

4. Can I run my compiled Fortran 90 program directly from the external HDD?

Yes, once you have compiled your program on the external HDD, you can run it directly from there. However, it is recommended to copy the compiled program to your main hard drive for better performance.

5. Are there any limitations to compiling Fortran 90 on an external HDD?

There are no inherent limitations to compiling Fortran 90 on an external HDD. However, the speed of compilation may be affected by the speed of the external HDD. Additionally, some operating systems may have restrictions on running programs directly from external drives.

Similar threads

  • Programming and Computer Science
Replies
8
Views
3K
  • Nuclear Engineering
Replies
6
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
8
Views
5K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
12
Views
6K
Back
Top