[comp.lang.fortran] Basic Questions

winstead@faraday.ECE.CMU.EDU (Charles Holden Winstead) (03/25/91)

Hi everyone!

   I am a novice FORTRAN programmer, and these will probably be easy questions
but so what, maybe someone else has some of the same.  I program on a Sun 
Spark station, and would like to tell you the version number but I don't have
access to the man pages.  I apologize if these have been answered already.  
I'm not aware of a Freq.Asked.Ques for this group.  Anyway, here are my 
questions, I appreciate any answers you may have.

-Charles Winstead
 Carnegie Mellon

1. If I use write(*,*), and then redirect my output to a file when running, is
   there a way to write to the screen, say accessing standard error instead of
   standard output?

2. Are there function cosh, sinh, and conjugate for double complex?  What are
   they?

3. Where do I get a list of all the intrinsic functions?  As in the specific 
   name differences for using a double precision one, or a double complex one.

4. Is there a way for a subroutine to know from which module it was called? 
   i.e. was it called from line ## from main, or line # from subroutine foo?

5. What is a good FORTRAN book that tells me how to write efficient code, how
   fortran looks at data and pointers etc.  I'd like a book that assumes that
   I know something about programming and want to be better.

6. If I divide a double complex by a double precision am I safe or should I 
   somehow cast my dp variable as a dc one.  Are there other pitfalls in
   mixing types?  I know about mixed integer, but am not sure about double
   precision, float, complex, and double complex.

7. I just started using dbx.  I've heard about toolbox.  What is toolbox and
   what can it do?  I tried downloading it, but it was too huge for my quota.
   Since I'm the only FORTRAN programmer around here, I'd need to be able to
   tell the administrator why I need 10 MEgs of space for toolbox before he'll
   do it.

8. Where do I get f2c, and a renumbering program?

khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup) (03/26/91)

In article <1991Mar25.063607.7530@fs7.ece.cmu.edu> winstead@faraday.ECE.CMU.EDU (Charles Holden Winstead) writes:


    I am a novice FORTRAN programmer, and these will probably be easy questions
...
   Spark station, and would like to tell you the version number but I
       ^

   SPARC, but spelling flames are absurd ;> (and I am a frequent offender)

>   access to the man pages

If you have the compiler legally you have at least the online man
pages! In general, it isn't very efficient to ask the thousands of
folks on the net to key in parts of the manual for you (at least not
globally efficient, it may be easy for you ;>). Seriously, please
score a copy of the documentation, it will make your life easier in
many ways.


 1. If I use write(*,*), and then redirect my output to a file when running, is
    there a way to write to the screen, say accessing standard error instead of
    standard output?

Yes. write(0,*) "foo" goes to standard error. 

...

   3. Where do I get a list of all the intrinsic functions?  As in the
      specific name differences for using a double precision one, or a
      double complex one. 

Typically in Appendix B of the Sun FORTRAN Reference Manual. In
general, it is best to avoid specific names, use the generic ones.

   4. Is there a way for a subroutine to know from which module it was called? 
      i.e. was it called from line ## from main, or line # from
      subroutine foo?

Not in any socially approved way. The traceback mechanism clearly
knows how, but it relies on knowing far more about the OS than is
healthy. It isn't a public interface, because it is subject to much
change. 

   5. What is a good FORTRAN book that tells me how to write efficient
      code, how fortran looks at data and pointers etc.  I'd like a
      book that assumes that 
      I know something about programming and want to be better.


J. M. Levesque AND J. W. Williamson
"A Guidebook to Fortran on Supercomputers"
Academic Press
San Diego, CA, 1989

Metcalf's "FORTRAN Optimization. and "Effective Fortran 77" Oxford
Science Publications ISBN 0-19-853709 (I forget the isbn of the
optimization book).

Come to mind. 


   6. If I divide a double complex by a double precision am I safe or should I 
      somehow cast my dp variable as a dc one.  Are there other pitfalls in
      mixing types? 

Read the standard carefully. It is safe, if you and it agree. It is
often the case that folks are surprised by what happens ....

   8. Where do I get f2c, and a renumbering program?

responses posted privately.

cheers
--
----------------------------------------------------------------
Keith H. Bierman    kbierman@Eng.Sun.COM | khb@chiba.Eng.Sun.COM
SMI 2550 Garcia 12-33			 | (415 336 2648)   
    Mountain View, CA 94043

corrigan@weber.ucsd.edu (Michael J. Corrigan) (03/27/91)

In article <1991Mar25.063607.7530@fs7.ece.cmu.edu> winstead@faraday.ECE.CMU.EDU (Charles Holden Winstead) writes:
}Hi everyone!
}
}   I am a novice FORTRAN programmer, and these will probably be easy questions
}but so what, maybe someone else has some of the same.  I program on a Sun 
}
....
}1.

 Answered already

}2. Are there function cosh, sinh, and conjugate for double complex?  What are
}   they?
}

If they are there they may well be called zcosh, although that would be 
an extension. I would suspect that zexp *is* there so you can roll your own.

}3. Where do I get a list of all the intrinsic functions?  As in the specific 
}   name differences for using a double precision one, or a double complex one.
}

Since you don't have the man pages, try
% foreach file ( /usr/lib/lib*77.a )
ar t $file
end

assuming that it is "f77" and you are using the C-shell
and you will see some names that are sort of close to the 
names you should use, but you should have the manual/man pages.

Remainder answered already.