-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests_various.py
67 lines (49 loc) · 1.33 KB
/
tests_various.py
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
import numpy as np
from memory_usage import *
from time import time as runtimer
from read_functions import *
from mpi4py import MPI
# MPI data read/transfer test
comm = MPI.COMM_WORLD
# nproc = comm.Get_size()
datdir="/ourdisk/hpc/radclouds/auto_archive_notyet/tape_2copies/tc_ens/haiyan/memb_01/ctl/post/d02/"
t0=0
t1=30
nt, nz, nx1, nx2, pres = get_file_dims(datdir)
nt=t1
# Account for dropped edges
buffer = 80
nx1-=buffer*2
nx2-=buffer*2
# start = runtimer()
if comm.rank != 0:
variable = np.ndarray((nt,nz,nx1,nx2), dtype=np.float64)
varname='T'
if comm.rank == 0:
start = runtimer()
variable = np.ascontiguousarray(var_read_3d(datdir,varname,t0,t1,mask=True,drop=True), dtype=np.float64)
end = runtimer()
time_elapsed = end - start
print("Time elapsed part1: ", time_elapsed)
start = runtimer()
comm.Bcast(variable, root=0)
end = runtimer()
time_elapsed = end - start
print("Time elapsed part2: ", time_elapsed)
# Memory test
# print()
# print("Before function:")
# memory_usage()
# def init_vars():
# dims = 500000000
# var1 = np.arange(dims, dtype=np.float64)
# var2 = np.arange(dims, dtype=np.float64)
# var3 = np.arange(dims, dtype=np.float64)
# print()
# print("Inside function:")
# memory_usage()
# return
# init_vars()
# print()
# print("After function:")
# memory_usage()