FAQ for Programming Assignment 2

Information will be added here are questions are generated and answered.

  1. What kinds of issues will we face in trying to handle this task?

    I'll add to this list as I think of things:

  2. Where is the test data located?

    There are two kinds of test data: non-image and image data. The non-image test cases are located in http://www.cs.rit.edu/usr/local/pub/ncs/parallel/Fortran/TestCases/. The image test cases are located in the sub-directories of http://www.cs.rit.edu/usr/local/pub/ncs/parallel/Fortran/ImageFiles/.

  3. We are able to read and process the times file and image data, but we are unsure how to convert the image data into something usable by contin. We even have the output formatting subroutine in a seemingly usable form, we're just very confused how to turn the image files into something that contin can process.

    Remember that contin analyzes the data Y(i) at each T(i). The Y's are the experimental data, the T's are the times at which the experimental data is "clocked". The image files are read one record at a time into an integer*2 type variable. That value should ultimately be stored in Y(i), a real. The value for the same pixel in each image file should be stored in the Y(i) related to the T(i) read from the times file.

  4. We added the reading of the data from the image files, but although it seems to read the data properly, we get a contin input error. What's happening?

    There is some processing after the y's and t's are read that happens in READYT that you'll need to add to your subroutine(s) that reads the y's. See the readts.f95 file in the http://www.cs.rit.edu/usr/local/pub/ncs/parallel/Fortran/AuxiliaryCode/ for guidance.

  5. When we do a diff between the output for testImage2X2.in and the FAKE2X2 image data, there are some YLYFIT's that are off among other data. What could we be doing wrong?

    I ran into a similar problem which I tracked to a need to reset the grid values (G) for EACH pixel. The G values are set in SETGRD, called from contin.f95. I'm not sure why/where the G values get altered, but they seemed to be off by a very little after the first run was finished. This generates tons of diff output making it very hard to debug.

  6. I'm having trouble debugging with so much output. Any suggestions?

    I found it easiest to write my debugging output to a completely different file, OUT. (Use an unused unit number, say 300 and write to it). So, for example, to debug the problem identified above, I would execute both the FAKE and the textImage data thru the new version of contin and diff the two OUT files.

    I also found that for debugging with MPI, that moving around a couple of statements:

    was useful in getting the output buffers flushed when I wanted them to be. Other things I tried were less successful. For example, if I would close the file I was writing to and there was later writing to that file, I would lose what was there to begin with. It may be possible to open the file in append mode, but then you need to make sure that you delete it/them each time before you run your tests.

    Also, it is important to be conscious of line length. I seem to remember 136 or 142 characters per line in free form Fortran. If you extend beyond that, particularly in output statements, you may get misleading results. I spent several hours tracking a problem that didn't exist because my output line was too long.

  7. I keep forgetting to delete a file I've written that is opened with status='NEW'. This is particularly painful if it happens after a lot of processing has passed. Is there anything I can do to prevent this from happening?

    Yes, use status='unknown'. Be aware though that this will allow you to overwrite your own files.

  8. What happens if I use a unit number, write to it, but don't open it?

    Fortran will create a file named fort.the_unit_number.

  9. Is there a limit to the number of files you may have open in Fortran?

    Although I did not find it documented anywhere, the limit seems to be 175.

  10. Does Fortran tell you you've run out of memory?

    Not until execution time with a criptic "BAD ADDRESS" message. There MAY be some environment variables that can be set to alleviate this problem.

  11. Is it all right to add more variables to the labeled commons?

    Yes, but I would suggest instead that you ADD your own labeled commons. It is a good idea to separate out the variables by type. I read somewhere, for example, that any character data must go in its own separately labeled common. I think this is a memory layout issue, but am not certain.

  12. Why might I need to swap bytes on input?

    Different computer systems store integers (e.g.) in different orders. Some put the high order byte on the left of the word, others do it in reverse. Therefor, the input data may be prepared on a machine uses a different format than the one contin is being used on.

  13. How do I know if I need to swap the input bytes ?

    All image input AND the mask will have a 1 written in pixel[1,1]. Then when read, if pixel[1,1] is 256 (1 shifted left 8 bits, i.e., written by a machine that stores the data in reverse), contin can modified to determine that it needs to swap image bytes as it is read. This will work regardless of where that data is being read.

  14. How do I swap the input bytes if I need to?

    contin can be modified to handle it internally:

    NOTE: In all cases, the mask file's format is identical to the image file format, i.e., 16 bits per pixel. You will NOT process the pixels for which the 16 bit reads from the mask file show a zero,i.e. there is no need to read these pixel values from the image files at all.

  15. What should the output look like again?

    See the output specifications for (hopefully) complete information. Be sure to add a .raw extension to the name. ReadTimesFile will show you how to do this. Also, IF you needed to swap the bytes in the input images, be sure to swap the bytes in the scaled YLYFIT's before you write them to the output images!. See the examples in the Auxiliary Code directory for examples of how to do this.

  16. I am trying to broadcast information kept in a common block filled with strings; I seem to get some of the data, but not all of it. What am I doing wrong?

    I ran into a similar (the same?) problem broadcasting the input image file names. I have 513 of them of length 40 characters. In order to do them properly I had to

    character*40 imageFilename(512) ! array to hold imageFilenames
    character*40 outName ! base for output image filename

    character*40 CIEQUIV(513)
    common /charImageData/ imageFilename, outName
    equivalence( CIEQUIV(1), imageFilename(1))


    Note that the length had to be set to the product of the number of filenames and the length of each.

  17. Are there any particular MPI options that might be helpful?

    Do a man mpirun when on parasite or paranoia. The ones that stand out are:

  18. Where can I find out more about the constants that are used for MPI Fortran, etc.?

    You might check out /opt/SUNWhpc/include/mpif.h and take a look at the examples in http://www.cs.rit.edu/usr/local/pub/ncs/parallel/Fortran/MPIFortranExamples/. Also, there is list of routines (given the C call order) at http://www.mpi-forum.org/docs/mpi-20-html/node306.htm. Just remember that you need to use Fortran MPI constants and add an error return value as the last parameter (See http://www.mpi-forum.org/docs/mpi-20-html/node19.htm.

Nan C. Schaller
Rochester Institute of Technology
Computer Science Department
102 Lomb Memorial Dr.
Rochester, NY 14623-5608
telephone: +1.585.475.2139
fax: +1.585.475.7100
e-mail: ncs@cs.rit.edu
May 7, 2004