/[MITgcm]/MITgcm/pkg/mnc/mnc_create_dir.c
ViewVC logotype

Contents of /MITgcm/pkg/mnc/mnc_create_dir.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Thu Jun 16 16:59:02 2005 UTC (18 years, 11 months ago) by ce107
Branch: MAIN
CVS Tags: checkpoint57t_post, checkpoint57o_post, checkpoint57v_post, checkpoint57m_post, checkpoint57s_post, checkpoint57k_post, checkpoint57i_post, checkpoint57y_post, checkpoint57y_pre, checkpoint57r_post, checkpoint58, checkpoint57x_post, checkpoint57n_post, checkpoint57w_post, checkpoint57p_post, checkpint57u_post, checkpoint58a_post, checkpoint57q_post, checkpoint57z_post, checkpoint57j_post, checkpoint57l_post
Changes since 1.2: +2 -1 lines
File MIME type: text/plain
Added include file string.h

1 /************************************************* -*- mode: C -*-
2 * $Header: /u/gcmpack/MITgcm/pkg/mnc/mnc_create_dir.c,v 1.2 2004/03/23 05:24:44 edhill Exp $
3 * $Name: $
4 */
5
6 /* Here, we get the definition of the FC_NAMEMANGLE() macro. */
7 #include "FC_NAMEMANGLE.h"
8
9 #include <time.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <assert.h>
14 #include <sys/stat.h>
15 #include <sys/types.h>
16 #include <sys/time.h>
17 #include <string.h>
18 void FC_NAMEMANGLE(mnccdir) ( int *nienc, int *ienc, int *idate )
19 {
20 char name[512], dname[512];
21 struct tm * tmp;
22 time_t tt;
23 int i, j, n, ntot, iyyyymmdd;
24 mode_t mode = 0x0;
25 char * cenc =
26 {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.,+-=/~\0"};
27 int ncenc = 70;
28
29 n = ((*nienc) > 100) ? 100 : (*nienc);
30 tt = time(&tt);
31 tmp = localtime(&tt);
32 iyyyymmdd = tmp->tm_mday
33 + 100*(tmp->tm_mon + 1 + 100*(1900+tmp->tm_year));
34 for (i=0; i<n; i++) {
35 /* printf("ienc = %d, %c\n", ienc[i], cenc[ienc[i] - 1]); */
36 name[i] = cenc[ienc[i] - 1];
37 }
38 name[n] = '\0';
39 /* printf("name = \"%s\", n = %d\n", name, n); */
40 for (i=1; i<10000; i++) {
41 if (*idate == 1)
42 snprintf(dname, 100, "%s%08d_%04d\0", name, iyyyymmdd, i);
43 else
44 snprintf(dname, 100, "%s%04d\0", name, i);
45 mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;
46 if (mkdir(dname, mode) == 0) {
47 break;
48 }
49 }
50 n = (int)(strlen(dname));
51 /* printf("dname = \"%s\", n = %d\n", dname, n); */
52 ntot = 0;
53 for (i=0; i<n; i++) {
54 for (j=0; j<ncenc; j++) {
55 if (cenc[j] == dname[i]) {
56 ienc[ntot] = j + 1;
57 ntot++;
58 break;
59 }
60 }
61 }
62 *nienc = ntot;
63 }
64
65

  ViewVC Help
Powered by ViewVC 1.1.22