File: fortran_base_strings.h

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (133 lines) | stat: -rw-r--r-- 5,527 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2005 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2005 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2010-2018 Cisco Systems, Inc.  All rights reserved
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#ifndef OMPI_FORTRAN_BASE_STRINGS_H
#define OMPI_FORTRAN_BASE_STRINGS_H

#include "ompi_config.h"

BEGIN_C_DECLS
    /**
     * Convert a fortran string to a C string.
     *
     * @param fstr Fortran string
     * @param len Fortran string length
     * @param cstr Pointer to C string that will be created and returned
     *
     * @retval OMPI_SUCCESS upon success
     * @retval OMPI_ERROR upon error
     *
     * This function is intended to be used in the MPI F77 bindings to
     * convert fortran strings to C strings before invoking a back-end
     * MPI C binding function.  It will create a new C string and
     * assign it to the cstr to return.  The caller is responsible for
     * eventually freeing the C string.
     */
    OMPI_DECLSPEC int ompi_fortran_string_f2c(char *fstr, int len, char **cstr);

    /**
     * Convert a C string to a fortran string.
     *
     * @param cstr C string
     * @param fstr Fortran string (must already exist and be allocated)
     * @param len Fortran string length
     *
     * @retval OMPI_SUCCESS upon success
     * @retval OMPI_ERROR upon error
     *
     * This function is intended to be used in the MPI F77 bindings to
     * convert C strings to fortran strings.  It is assumed that the
     * fortran string is already allocated and has a length of len.
     */
    OMPI_DECLSPEC int ompi_fortran_string_c2f(const char* cstr, char* fstr, int len);

    /**
     * Convert an array of Fortran strings that are terminated with a
     * blank line to an argv-style array of C strings.
     *
     * @param farray Array of fortran strings
     * @param string_len Length of each fortran string in the array
     * @param advance Number of bytes to advance to get to the next string
     * @param cargv Returned argv-style array of C strings
     *
     * @retval OMPI_SUCCESS upon success
     * @retval OMPI_ERROR upon error
     *
     * This function is intended to be used in the MPI F77 bindings to
     * convert arrays of fortran strings to argv-style arrays of C
     * strings.  The argv array will be allocated and returned; it is
     * the caller's responsibility to invoke opal_argv_free() to free
     * it later (or equivalent).
     *
     * For 1D Fortran string arrays, advance will == string_len.
     *
     * However, when this function is used (indirectly) for
     * MPI_COMM_SPAWN_MULTIPLE, a 2D array of Fortran strings is
     * converted to individual C-style argv vectors.  In this case,
     * Fortran will intertwine the strings of the different argv
     * vectors in memory; the displacement between the beginning of 2
     * strings in a single argv vector is (string_len *
     * number_of_argv_arrays).  Hence, the advance parameter is used
     * to specify this displacement.
     */
    OMPI_DECLSPEC int ompi_fortran_argv_blank_f2c(char *farray, int string_len,
                                                  int advancex, char ***cargv);

    /**
     * Convert an array of a specific number of Fortran strings to an
     * argv-style array of C strings.
     *
     * @param farray Array of fortran strings
     * @param farray_length Number of entries in the farray array
     * @param string_len Length of each fortran string in the array
     * @param advance Number of bytes to advance to get to the next string
     * @param cargv Returned argv-style array of C strings
     *
     * @retval OMPI_SUCCESS upon success
     * @retval OMPI_ERROR upon error
     *
     * This function is just like ompi_fortran_argv_blank_f2c(),
     * except that it uses farray_length to determine the length of
     * farray (vs. looking for a blank string to look for the end of
     * the array).
     */
    OMPI_DECLSPEC int ompi_fortran_argv_count_f2c(char *farray, int farray_length, int string_len,
                                                  int advancex, char ***cargv);

    /**
     * Convert an array of argvs to a C style array of argvs
     * @param count Dimension of the array of argvs
     * @param array Array of fortran argv
     * @param len Length of Fortran array
     * @param argv Returned C array of argvs
     *
     * This function is intended to be used in the MPI F77 bindings to
     * convert arrays of fortran strings to argv-style arrays of C
     * strings.  The argv array will be allocated and returned; it is
     * the caller's responsibility to invoke opal_argv_free() to free
     * each content of argv array and call free to deallocate the argv
     * array itself
     */
    OMPI_DECLSPEC int ompi_fortran_multiple_argvs_f2c(int count, char *array, int len,
                                                      char ****argv);

END_C_DECLS


#endif /* OMPI_FORTRAN_BASE_STRINGS_H */