home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / fortran / 4375 < prev    next >
Encoding:
Text File  |  1992-11-19  |  1.4 KB  |  43 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!boulder!colorado.edu!ejh
  3. From: ejh@khonshu.colorado.edu (Edward J. Hartnett)
  4. Subject: passing a string constant to a subroutine
  5. Message-ID: <EJH.92Nov19160031@khonshu.colorado.edu>
  6. Sender: news@colorado.edu (The Daily Planet)
  7. Nntp-Posting-Host: khonshu.colorado.edu
  8. Organization: CIRES, University of Colorado
  9. Date: 19 Nov 92 16:00:31
  10. Lines: 31
  11.  
  12. When I want to pass a string constant to a subroutine, what size do I
  13. declare the character variable to be in the subprogram. For example
  14. I have a subroutine:
  15.  
  16.       subroutine ask_data_type(prog, typenum)
  17.  
  18. This is intended to be called from one of several programs, and the
  19. program name is to be passed in as the first parameter. Inside the
  20. subroutine I have:
  21.       character*20 prog
  22.  
  23. And when I called if from program atob.f this is what the call looked
  24. like:
  25.     call ask_data_type('atob',typenum)
  26.  
  27. I assumed that it would put 'atob' in prog and blank fill the rest.
  28. What it did instead was fill the rest with grabage, not blanks. I
  29. avoid this problem now by doing this in the calling program:
  30.  
  31.       character*20 prog
  32.       parameter (prog = 'atob')
  33. c
  34.       write(*,*) 'about to call ask_data_type'
  35.       call ask_data_type(prog,typenum)
  36.  
  37. But I'm just wondering if what I did was non-standard or what.
  38.  
  39.  
  40. --
  41. Edward Hartnett            ejh@khonshu.colorado.edu
  42.  
  43.