Skip to content

Instantly share code, notes, and snippets.

View ashao's full-sized avatar

Andrew Shao ashao

  • Hewlett Packard Enterprise
  • Victoria, BC, Canada
View GitHub Profile
program mpi_array_exchange
use mpi
use iso_fortran_env, only : real64
implicit none
integer, parameter :: num_count = 9
integer, parameter :: num_iter = 50
integer, dimension(num_count), parameter :: counts =[1, 2, 4, 8, 16, 32, 64, 128, 256] ! How many arrays to send
integer, parameter :: num_elements = 64000 ! For double precision, corresponds to 512KB array
@ashao
ashao / mlp_train.py
Created May 21, 2024 05:31
Example for training a multilayer perceptron
import torch
import torch.nn as nn
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn import preprocessing
import torch.optim as optim
NUM_EPOCHS = 1000
DISPLAY_EPOCH_INTERVAL = 100
@ashao
ashao / make_om4_025_animations.py
Last active March 8, 2024 02:52
Make animations of OM4_025 in parallel
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import xarray as xr
import matplotlib.pyplot as plt
import matplotlib
import cmocean
import os
import json
import numpy as np
import pathlib
@ashao
ashao / P01_TTD_ages.ipynb
Created August 23, 2019 19:00
1D TTD derived CFC-11 and CFC-12 mean age
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ashao
ashao / barrow_co2_annual_cycle.ipynb
Last active July 5, 2019 15:59
Calculate the CO2 Annual Cycle at Barrow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ashao
ashao / DailyVariance_EOF.ipynb
Created March 22, 2019 00:21
Example of making normal subdaily variance via EOFs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ashao
ashao / checksums.F90
Created January 11, 2019 21:45
Checksum code for NEMO
MODULE checksums
!!======================================================================
!! *** MODULE checksums ***
!! Utility functions: Calculate checksums of arrays. Robust across PE
!! count and domain decomposition
!!
!!======================================================================
!! History : 3.4 ! Initial implementation 2018-04 (A.Shao)
!!----------------------------------------------------------------------
!! chksum : Calculates a checksum of a given 2d/3d array
@ashao
ashao / demonstrate_sorting.ipynb
Last active December 17, 2018 18:02
Demonstration of sorting algorithm for neutral diffusion using discontinuous reconstructions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.