home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!boulder!colorado.edu!ejh
- From: ejh@khonshu.colorado.edu (Edward J. Hartnett)
- Subject: passing a string constant to a subroutine
- Message-ID: <EJH.92Nov19160031@khonshu.colorado.edu>
- Sender: news@colorado.edu (The Daily Planet)
- Nntp-Posting-Host: khonshu.colorado.edu
- Organization: CIRES, University of Colorado
- Date: 19 Nov 92 16:00:31
- Lines: 31
-
- When I want to pass a string constant to a subroutine, what size do I
- declare the character variable to be in the subprogram. For example
- I have a subroutine:
-
- subroutine ask_data_type(prog, typenum)
-
- This is intended to be called from one of several programs, and the
- program name is to be passed in as the first parameter. Inside the
- subroutine I have:
- character*20 prog
-
- And when I called if from program atob.f this is what the call looked
- like:
- call ask_data_type('atob',typenum)
-
- I assumed that it would put 'atob' in prog and blank fill the rest.
- What it did instead was fill the rest with grabage, not blanks. I
- avoid this problem now by doing this in the calling program:
-
- character*20 prog
- parameter (prog = 'atob')
- c
- write(*,*) 'about to call ask_data_type'
- call ask_data_type(prog,typenum)
-
- But I'm just wondering if what I did was non-standard or what.
-
-
- --
- Edward Hartnett ejh@khonshu.colorado.edu
-
-