Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Can we compile fortran 90 on external hdd?

  1. Jun 22, 2014 #1
    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
     
  2. jcsd
  3. Jun 23, 2014 #2

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    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.
     
  4. Jun 23, 2014 #3

    jtbell

    User Avatar

    Staff: Mentor

    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.
     
  5. Jun 23, 2014 #4

    Borek

    User Avatar

    Staff: Mentor

    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.
     
  6. Jun 23, 2014 #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 (Text):

    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: Jun 23, 2014
  7. Jun 23, 2014 #6
    thank you for all the reply. I have got the idea right now.
     
  8. Jul 7, 2014 #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 (Text):
    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
     
  9. Jul 7, 2014 #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 (Text):

    write(filename, "('/run/media/sharwani/TOSHIBAEXT/PHDresearch/1dtest/ez',I3.3,'.dat')") n
     
     
  10. Jul 7, 2014 #9
    thank you gsal. it's worked!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Can we compile fortran 90 on external hdd?
  1. Fortran 90 (Replies: 7)

  2. Fortran Compiler (Replies: 2)

  3. Fortran 90 (Replies: 1)

  4. Fortran Compiler (Replies: 0)

  5. Fortran 90 (Replies: 1)

Loading...