Mac Tips

2016/11/04 の作業メモ

どこぞの計算機に netcdf-fortran をインストール したというので確認作業.

$ curl -O https://www.gfd-dennou.org/arch/dcpam/related-program/data_input_Earth/orog/prog-20140712.tgz
$ tar xvf prog-20140712.tgz
$ cd prog-20140712
$ vi Makefile

Makefile に書き込むライブラリのパスを探さなきゃ...

$ locate libnetcdf.a

locate 効かないし... .

$ port installed | less

netcdf, netcdf-fort... ?, netcdf-fortran ないし. 「馬...」

$ port search netcdf | less
$ port info netcdf
$ port contents netcdf

netcdf (-c) は動くのかな?

$ curl -O http://www.unidata.ucar.edu/software/netcdf/examples/programs/simple_xy_wr.c
$ gcc simple_xy_wr.c -I/opt/local/include -L/opt/local/lib -lnetcdf
$ ./a.out
$ ncdump simple_xy.nc
netcdf simple_xy {
dimensions:
        x = 6 ;
        y = 12 ;
variables:
        int data(x, y) ;
data:

 data =
  0, 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, 68, 69, 70, 71 ;
}

動くらしい.

Fortran ではこんな感じ?

$ curl -O http://www.unidata.ucar.edu/software/netcdf/examples/programs/simple_xy_wr.f90
$ gfortran simple_xy_wr.f90 -I/opt/local/include -L/opt/local/lib -lnetcdff
$ ./a.out
$ ncdump simple_xy.nc

どこぞの業者はほんとにレベルが低いんだな.