OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
ftrim.c
Go to the documentation of this file.
1 /***************************************************************
2 
3  !C
4 
5  function ftrim(str, len)
6  !Description:
7  Remove trailing blanks from a FORTRAN string.
8  !Input Parameters:
9  str(char *) - string
10  len(int *) - length of string
11  !Output Parameters:
12  str(char *) - updated string
13  !Returns:
14  ftrim(int) - length of updated string
15 
16  !Revision History:
17  $Log: ftrim.c,v $
18  Revision 1.1 2010/08/07 18:44:32 sue
19  seadas 6.1 l2gen with modis dust and avhrr.
20 
21  Revision 1.1 2008/08/15 20:30:25 sue
22  NODC versions of the pathfinder processing programs.
23 
24  Revision 1.5 2002/08/23 20:50:22 sue
25  Update copyright notices to year 2002.
26 
27  Revision 1.4 1997/11/20 19:37:40 jim
28  Fix prologs.
29 
30  Revision 1.3 1997/09/22 16:39:14 jim
31  Change included function test program to not use a prohibited function.
32 
33  Revision 1.2 1996/09/16 22:14:14 sue
34  Fix prologues and get rid of compiler warnings.
35 
36  Revision 1.1 1996/09/16 15:07:43 sue
37  Modis versions of rtlib routines.
38 
39  * Revision 1.3 1994/07/25 18:16:19 angel
40  * Include "rtlib.h".
41  *
42  * Revision 1.2 1993/11/10 17:45:36 jim
43  * Only add _ on certain unix systems, never on vms.
44  *
45  * Revision 1.1 1992/02/26 19:57:51 angel
46  * Initial revision
47  *
48  */
49 
50 /*
51  !Team-unique Header:
52 
53  Copyright 1988-2002 by Rosenstiel School of Marine and Atmospheric Science,
54  University of Miami, Miami, Florida.
55 
56  All Rights Reserved
57 
58  Permission to use, copy, modify, and distribute this software and its
59  documentation for non-commercial purposes and without fee is hereby granted,
60  provided that the above copyright notice appear in all copies and that both
61  that copyright notice and this permission notice appear in supporting
62  documentation, and that the names of University of Miami and/or RSMAS not be
63  used in advertising or publicity pertaining to distribution of the software
64  without specific, written prior permission.
65 
66  UNIVERSITY OF MIAMI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
67  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
68  SHALL UNIVERSITY OF MIAMI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
69  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
70  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
71  OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
72 
73  !References and Credits:
74  Written by:
75  University of Miami
76  Rosensteil School for Marine and Atmospheric Science
77  Division of Meteorology and Oceanography Oceanography
78  4600 Rickenbacker Cswy.
79  Miami, Fl
80  33149
81 
82  contact: SWalsh@rsmas.miami.edu
83 
84  !Design Notes:
85 
86  !END****************************************************************
87  */
88 // #include "rtlib.h"
89 
90 /* To use this test, add a line at the end of main to print out buf,
91  * or change the sprintf to printf
92  */
93 #ifdef TEST
94 
95 main() {
96  char s[80];
97  int i;
98  int l = 80;
99  char buf[80];
100 
101  for (i = 0; i < 80; i++)
102  s[i] = ' ';
103  /*
104  s[0] = 'a';
105  s[1] = 'b';
106  */
107  l = ftrim(s, &l);
108  sprintf(buf, "%d %s\n", l, s);
109 }
110 #endif
111 
112 int ftrim_(str, len)
113 char *str;
114 int *len;
115 {
116  char *s;
117  int l = *len;
118  int i;
119 
120  i = l - 1;
121  for (s = str + i; i >= 0; i--, s--) {
122  if (*s != ' ') {
123  if (i != l - 1)
124  *(s + 1) = 0;
125  return i + 1;
126  }
127  }
128  str[0] = 0;
129  return 0;
130 }
const char * str
Definition: l1c_msi.cpp:35
int main(int argc, char *argv[])
Definition: afrt_nc4.cpp:30
data_t s[NROOTS]
Definition: decode_rs.h:75
int ftrim_(char *str, int *len)
Definition: ftrim.c:112
int i
Definition: decode_rs.h:71