Skip to content

Instantly share code, notes, and snippets.

View raphaeldussin's full-sized avatar

raphael dussin raphaeldussin

View GitHub Profile
@raphaeldussin
raphaeldussin / install_esmf7.0.0_osx_macports.bash
Last active June 22, 2016 20:33
installing ESMF library version 7.0.0 on OSX el Capitan with macports (gcc4.9, netcdf4, openmpi)
#!/bin/bash
# 1. as normal user,extract archive :
#tar -xf esmf_7_0_0_src.tar
# 2. change the file esmf/build_config/Darwin.gfortran.default/build_rules.mk
# OpenMPI --------------------------------------------------
#ifeq ($(shell $(ESMF_DIR)/scripts/available mpifort),mpifort)
#ESMF_F90DEFAULT = mpifort
@raphaeldussin
raphaeldussin / install_esmf7.0.0_linux.bash
Created July 24, 2016 20:14
installing ESMF 7.0.0 on Ubuntu Linux gfortran+netcdf+openmpi
#!/bin/bash
# installing ESMF on Ubuntu Linux
# pre-req : gfortran, netcdf, openmpi, python3
# first mkdir /opt/esmf/7.0.0 and chown to yourself
# you also need a copy of esmf_7_0_0_src.tar
# Raphael Dussin, July 2016
PYTHONBIN=/opt/Anaconda3/4.1.1/bin/
CUSTOMINSTALLDIR=/opt/esmf/7.0.0
#!/usr/bin/env python
import os
import h5py
import numpy as np
import netCDF4 as nc
# ------------------------------ Download from NASA server and convert to hdf5 --------------------------------------------------
os.system('wget ftp://goldsmr2.sci.gsfc.nasa.gov/data/s4pa//MERRA_MONTHLY/MAC0NXASM.5.2.0/1979/MERRA300.prod.assim.const_2d_asm_Nx.00000000.hdf')
try:
@raphaeldussin
raphaeldussin / compile_mom6.bash
Created January 13, 2017 19:43
Compiling MOM6 on triton (linux cluster gcc4.4.7+openmpi1.8.5+netcdf4.3.0
#!/bin/bash
MOM6_installdir=#'where you cloned ESMG-configs'
MOM6_rundir=#'where you want to run the code (usually scratch)'
compile_fms=1
compile_mom=1
debug=0
#---------------------------------------------------------------
@raphaeldussin
raphaeldussin / install_esmf7.1.0beta_linux.bash
Last active January 23, 2024 18:28
install ESMF 7.1.0beta + python3 ESMPy
# installing ESMF on Ubuntu Linux
# pre-req : gfortran, netcdf, openmpi, python3
# first mkdir /opt/esmf/7.0.0 and chown to yourself
# you also need a copy of esmf_7_0_0_src.tar
# Raphael Dussin, July 2016
PYTHONBIN=/opt/Anaconda3/4.1.1/bin/
CUSTOMINSTALLDIR=/opt/esmf/7.1.0beta
#------------------ installing the ESMF libraries ---------------
@raphaeldussin
raphaeldussin / purge_ubuntu.bash
Created April 28, 2017 02:54
purge ubuntu old kernels
#!/bin/bash
sudo apt-get update
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get autoremove
kernel_pkgs=$( dpkg -l | grep -E 'linux-image-[0-9]' | awk '{ print $2 }' )
current_kernel=$( uname -r )
@raphaeldussin
raphaeldussin / sections_roms.py
Created May 1, 2017 19:15
plot sections of constant lon/lat from irregular ROMS grid
import pyroms
import matplotlib.pylab as plt
import numpy as np
def lon_section(grd,lon,debug=False):
''' return i,j for the section of given lon '''
# use a single contour of the desired longitude
cont = plt.contour(grd.hgrid.lon_vert,[lon])
plt.close() # contour triggers a figure
isection, jsection = get_broken_line_from_contour(cont,debug=debug)
@raphaeldussin
raphaeldussin / clone_ncfile.py
Created June 29, 2017 22:44
cloning a netcdf file (base for modifying it)
def clone_ncfile(self,filein,fileout):
fidin = nc.Dataset(filein,'r')
fidout = nc.Dataset(fileout,'w',format='NETCDF3_CLASSIC')
fidout.description = ''
#Copy dimensions
for dname, the_dim in fidin.dimensions.iteritems():
fidout.createDimension(dname, len(the_dim) if not the_dim.isunlimited() else None)
# Copy variables
@raphaeldussin
raphaeldussin / gist:656bb249f1763845192c95b2500b8a35
Created January 9, 2018 21:10
Subsetting a ROMS grid/output file
#!/bin/bash
# interior rho points + 1 point on each side
imin=135
imax=155
jmin=375
jmax=380
iminv=$(( $imin ))
imaxv=$(( $imax ))
@raphaeldussin
raphaeldussin / build_rules.mk.patch
Created March 2, 2018 16:52
Installing ESMF 7.0.2 + ESMPy on OSX High Sierra with macports
--- build_rules.mk.orig 2018-03-01 10:28:42.000000000 -0500
+++ build_rules.mk 2018-03-01 10:29:01.000000000 -0500
@@ -63,7 +63,7 @@
ESMF_CXXLINKLIBS += -lmpi_mpifh
else
ESMF_F90DEFAULT = mpif90
-ESMF_CXXLINKLIBS += -lmpi_f77
+ESMF_CXXLINKLIBS += $(shell mpif90 --showme:linking)
endif
ESMF_CXXCOMPILECPPFLAGS+= -DESMF_NO_SIGUSR2