PSMILe_f2c.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define INTEGER   int
#define REAL   float
#define LONG_INT_C   INTEGER
#define MALLOC(size)   malloc ((size_t) size)
#define FREE(ptr)   free (ptr)
#define ASSERT(c)

Functions/Subroutines

void psmile_redirstdout (char *filestem, INTEGER *lenstr, INTEGER *parallel, INTEGER *my_pe, INTEGER *npes, INTEGER *ierror)
void psmile_get_varsize (void *p1, void *p2, INTEGER *diff)

Define Documentation

#define ASSERT (  ) 
#define FREE ( ptr   )     free (ptr)

Definition at line 76 of file PSMILe_f2c.h.

Referenced by psmile_bsend_init(), psmile_redirstdout(), and release_buffer().

#define INTEGER   int

Definition at line 52 of file PSMILe_f2c.h.

Referenced by psmile_get_varsize().

#define LONG_INT_C   INTEGER

Definition at line 69 of file PSMILe_f2c.h.

#define MALLOC ( size   )     malloc ((size_t) size)

Definition at line 75 of file PSMILe_f2c.h.

Referenced by psmile_bsend(), psmile_bsend_init(), and psmile_redirstdout().

#define REAL   float

Definition at line 61 of file PSMILe_f2c.h.


Function Documentation

void psmile_get_varsize ( void *  p1,
void *  p2,
INTEGER *  diff 
)

Definition at line 41 of file psmile_get_varsize.c.

References INTEGER.

00049                    :
00050 
00051       void, Intent (In)               :: p1 (*)
00052       void, Intent (In)               :: p1 (*)
00053 
00054   !OUTPUT PARAMETERS:
00055 
00056       Integer, Intent (Out)           :: diff
00057 
00058   !DESCRIPTION:
00059 
00060   Get Size of Variables
00061 
00062   Routine "psmile_get_varsize" returns the difference between
00063   two pointers and is used to determine the size of variables.
00064 
00065   \underline{The calling sequence:}
00066 
00067   p1 = Pointer\\
00068   p2 = Pointer
00069 
00070   returns diff = p2 - p1
00071 
00072  
00073   !FILES USED:
00074 
00075          <stdio.h>
00076          <stddef.h>
00077          "PSMILe_f2c.h"
00078 
00079   !REVISION HISTORY:
00080 
00081     Date      Programmer   Description
00082   ----------  ----------   -----------
00083   06.07.03    H. Ritzdorf  created
00084  
00085 //EOP
00086 
00087  ----------------------------------------------------------------------
00088   $Id
00089   $Author
00090  ---------------------------------------------------------------------- */
00091 
00092 {
00093    *diff = (INTEGER) ((char *) p2 - (char *) p1);
00094    return;
00095 }

void psmile_redirstdout ( char *  filestem,
INTEGER *  lenstr,
INTEGER *  parallel,
INTEGER *  my_pe,
INTEGER *  npes,
INTEGER *  ierror 
)

Definition at line 23 of file psmile_redirstdout.c.

References ASSERT, FREE, LENGTH_OF_ERR, MALLOC, NUMBER_OF_EXTENSIONS, mpp_mod_oa::stderr(), and mpp_mod_oa::stdout().

Referenced by prism_init(), and prismdrv_init().

00028                    :
00029 
00030    filestem = Basename of stdout/stderr files
00031    lenstr   = Significant length (without \0) of "filestem"
00032    
00033    parallel = Flag for direction of output
00034               parallel = 1 : Create single output files for each process
00035               Otherwise    : Create output files only for process 0.
00036                              The output of other processes is not redirected.
00037 
00038    my_pe    = Rank
00039 
00040    npes     = number of processes
00041 
00042    !OUTPUT PARAMETERS:
00043 
00044    ierror   = Return code
00045               = 0 : No error
00046               = 1 : Error in malloc
00047 
00048   !DESCRIPTION:
00049 
00050    Redirect standard output
00051 
00052   !FILES USED:
00053 
00054          <math.h>
00055          <stdio.h>
00056          <stddef.h>
00057          "PSMILe_f2c.h"
00058 
00059   !REVISION HISTORY:
00060 
00061     Date      Programmer   Description
00062   ----------  ----------   -----------
00063   01.12.03    R. Redler    created
00064   01.12.05    H. Ritzdorf  revised
00065 
00066 //EOP
00067 
00068  ----------------------------------------------------------------------
00069   $Id
00070   $Author
00071  ---------------------------------------------------------------------- */
00072 
00073 {
00074    size_t len_alloc = *lenstr;
00075    register int n_digits, num;
00076    register int redirect = 1;
00077 
00078    char *sname, *ename;
00079    register char *p_err, *p_std;
00080 
00081    ASSERT (*lenstr > 0)
00082    ASSERT (*my_pe  >= 0)
00083 
00084    *ierror = 0;
00085 
00086    /* Get number of digits in rank */
00087 
00088    num = (*npes > 0) ? *npes : 1;
00089    n_digits = (int) (log10((double)(num) + (double) 0.5)) + 1;
00090    ASSERT (n_digits > 0)
00091 
00092    /* allocate file names */
00093 
00094 #define NUMBER_OF_EXTENSIONS 2
00095 #define LENGTH_OF_ERR 3
00096 
00097    len_alloc += n_digits + NUMBER_OF_EXTENSIONS + LENGTH_OF_ERR + 1;
00098 
00099    sname = (char *) MALLOC (len_alloc);
00100    ename = (char *) MALLOC (len_alloc);
00101 
00102    if (!sname || !ename) {
00103       fprintf (stderr, "PSMILe_redirstdout: Cannot allocate memory. %d bytes\n", len_alloc);
00104       *ierror = 1;
00105       return;
00106    }
00107 
00108    /* Copy base name to standard output and standard error file name */
00109 
00110    memcpy (sname, filestem, (size_t) *lenstr);
00111    memcpy (ename, filestem, (size_t) *lenstr);
00112 
00113    p_std = sname + (size_t) *lenstr;
00114    p_err = ename + (size_t) *lenstr;
00115 
00116    if(* parallel == 1) {
00117      /* all processes write into their own file */
00118 
00119      sprintf (p_std, ".%0*d",     n_digits, *my_pe);
00120      sprintf (p_err, ".err.%0*d", n_digits, *my_pe);
00121    }
00122    else {
00123      /* only local root redirectes stdout */
00124      redirect = (*my_pe == 0);
00125 
00126      if( redirect ) {
00127        sprintf (p_std, ".log");
00128        sprintf (p_err, ".err");
00129      }
00130    }
00131 
00132    /* Redirect STDOUT/STDERR */
00133 
00134    if (redirect) {
00135       freopen (sname, "w", stdout);
00136       freopen (ename, "w", stderr);
00137    }
00138 
00139    /* Free file names */
00140 
00141    FREE (ename);
00142    FREE (sname);
00143 }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1