Showing posts with label Science and Technology. Show all posts
Showing posts with label Science and Technology. Show all posts

Thursday, April 30, 2026

Research Note #33 - Instalasi WRF-Chem 4.7.1 + KPP di HPC BRIN (Mahameru)

Kinetic PreProcessor (KPP) adalah tool untuk menerjemahkan reaksi kimia kompleks ke dalam kode program (misal Fortran atau C) dan umumnya digunakan pada pemodelan kimia atmosfer, termasuk WRF-Chem. Dengan sekian banyaknya pilihan opsi mekanisme kimia yang dapat digunakan pada WRF-Chem, KPP membantu developer untuk mengaplikasikan skema kimia kompleks yang mereka bangun tanpa harus 'mengganggu' kode program WRF-Chem itu sendiri. Beberapa mekanisme kimia yang menerapkan reaksi kimia kompleks, misalnya untuk simulasi fase gas pada secondary aerosol, antara lain: MOZART, MOZCART, RADM, MOSAIC dll. Dengan kata lain, bila ingin menggunakan mekanisme-mekanisme tersebut untuk simulasi, WRF-Chem yang digunakan wajib hukumnya dikompilasi dengan dukungan KPP.

Tulisan ini berasumsi bahwa environment yang digunakan adalah HPC BRIN, dengan bash shell, gcc 12.2.0 dan pembaca telah mengetahui dasar-dasar kompilasi WRF-Chem ver. 4.7.1 (misal, sudah memiliki library-library yang dibutuhkan, seperti NetCDF, MPICH dll). Bila belum, silakan membaca tulisan berikut: https://sketsa-langit.blogspot.com/2025/10/research-note-29-instalasi-wrf-chem-di.html.

Berikut langkah-langkah kompilasi WRF-Chem dengan KPP pada HPC BRIN. 

Temukan path library flex di sistem. Library flex ini akan digunakan untuk kompilasi KPP:

module load gcc flex
module show flex

------------------------------------------------------------------------------------------------------------------------------------------------------------
   /mgpfs/shared/apps/mod/library/flex/2.6.4:
------------------------------------------------------------------------------------------------------------------------------------------------------------
load("gcc/12.2.0")
whatis("flex 2.6.4 - The fast lexical analyzer generator")
setenv("FLEXHOME","/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0")
prepend_path("PATH","/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0/bin")
prepend_path("CPATH","/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0/include")
prepend_path("INCLUDE_PATH","/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0/include")
prepend_path("INCLUDE_LIBRARY_PATH","/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0/include")
prepend_path("LIBRARY_PATH","/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0/lib")
prepend_path("LD_LIBRARY_PATH","/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0/lib")
prepend_path("INFOPATH","/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0/share/info")
prepend_path("MANPATH","/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0/share/man")


Deklarasikan WRF_CHEM, WRF_KPP dan FLEX_LIB_DIR di environment bash:

export WRF_CHEM=1
export WRF_KPP=1
export FLEX_LIB_DIR=/mgpfs/shared/apps/app/flex/2.6.4/GCC/12.2.0/lib

Masuk ke interactive-node HPC karena proses kompilasi ini akan memakan memori sistem yang besar. Proses kompilasi pada login-node hampir bisa dipastikan akan gagal (akan di-kill oleh sistem).

srun --partition=interactive --pty /bin/bash

Setelah masuk ke interactive-node, masuk ke direktori WRF dan jalankan konfigurasi kompilasi wrf.

./clean -aa
./configure

Pilih 34 (dmpar) untuk GCC compiler. Untuk nesting, pilih 1 (basic).

Pastikan proses konfigurasi berjalan lancar, tanpa ada pesan masalah pada compiler. Bila ada masalah, bereskan dulu masalah compiler, lalu lakukan konfigurasi ulang. Bila tak ada masalah, buka dan edit file configure.wrf.

Hilangkan 'time' pada deklarasi fortran compile 'FC':

FC = time $(DM_FC)  menjadi  FC = $(DM_FC)

Simpan file dan keluar dari configure.wrf. Selanjutnya, pada direktori WRF, buka dan edit file scan.h dan scan.y yang terdapat pada direktori chem/KPP/kpp/kpp-2.1/src/

Pada file scan.h (dan scan.y), temukan kode baris void yyerror( char * str ) ; pada baris ke-101 (390 pada scan.y), dan ubah menjadi void yyerror( const char * str ) ;. Simpan perubahan dan keluar dari kedua file tersebut.

Buka file compile_wkc pada direktori chem/KPP dan ubahlah baris kode pada baris 121:

 $WKC_HOME/util/wkc/tuv_kpp FIRST ../../inc/

menjadi:

 $WKC_HOME/util/wkc/tuv_kpp FIRST ../../../../inc/

Simpan perubahan dan keluar dari file. Sekarang anda bisa melakukan kompilasi wrf.

./compile -j 2 em_real >& compile.log

Proses kompilasi akan memakan waktu kurang lebih 30 menit - 1 jam. Pastikan tidak ada Error yang tercatat pada file compile.log dan file-file exe berhasil dibuat.

--->                  Executables successfully built                  <---

-rwxr-xr-x 1 ardh003 researcher 63915712 Apr 30 10:35 main/ndown.exe
-rwxr-xr-x 1 ardh003 researcher 64055224 Apr 30 10:35 main/real.exe
-rwxr-xr-x 1 ardh003 researcher 57765544 Apr 30 10:35 main/tc.exe
-rwxr-xr-x 1 ardh003 researcher 85490080 Apr 30 10:29 main/wrf.exe

==========================================================================

Friday, October 17, 2025

Research Note #32 - Instalasi ARWpost pada HPC BRIN

Update: 27 April 2026 (fix untuk WRF-Chem)

ARWpost adalah salah satu tool untuk mengolah keluaran (post-processor) dari WRF. Tool ini sebenarnya sudah termasuk 'kuno', dengan versi terakhir yang bisa diunduh adalah V3.1 (2 Maret 2011). Lalu kenapa saya pake tool ini? Alasannya karena keluaran dari ARWpost ini adalah data dalam format GrADS, dan saya sudah sangat terbiasa (dan nyaman) pake GrADS untuk analisis data.

Masalah utama dari ARWpost ini (seperti yg sudah-sudah) adalah kode programnya yang jadul, sehingga bila diinstall dengan compiler modern akan terjadi error, sehingga untuk instalasi pada Mahameru, diperlukan sedikit trik.

Pertama, download source ARWpost pada link ini. Ekstrak dan jalankan, script configurenya. Sebelum menjalankan configure, pastikan anda sudah memuat path NetCDF aktif pada enviroment sistem.

$ mkdir ARWpost
$ cd ARWpost
$ wget https://www2.mmm.ucar.edu/wrf/src/ARWpost_V3.tar.gz
$ tar -xzvf  ARWpost_V3.tar.gz
$ ./configure
Will use NETCDF in dir: /mgpfs/home/ardh003/source/wrf_dependencies/netcdf
------------------------------------------------------------------------
Please select from among the following supported platforms.
   1.  PC Linux i486 i586 i686 x86_64, PGI compiler
   2.  PC Linux i486 i586 i686 x86_64, Intel compiler
   3.  PC Linux i486 i586 i686 x86_64, gfortran compiler
Enter selection [1-3] : 3
------------------------------------------------------------------------
Configuration successful. To build the ARWpost, type: compile
------------------------------------------------------------------------

Sampai sini jangan langsung compile, karena perlu beberapa modifikasi pada file configure.arwp dan Makefile.

Penting: 
Bila tidak menggunakan WRF-Chem, silakan lanjut ke configure.arwp. 

Bila menggunakan WRF-Chem, perlu ada modifikasi pada source code salah satu script Fortran dalam direktori /src. Modifikasi ini diperlukan agar ARWpost bisa melakukan identifikasi header pada file wrfout yang akan diproses. Tanpa modifikasi ini, wrfout masih bisa diproses namun ARWpost tidak akan melakukan interpolasi pada level model (meskipun opsi interpolasi diaktifkan pada namelist.ARWpost) karena wrfout dianggap bukan keluaran wrf.exe. Tanpa interpolasi, beberapa fungsi diagnostic ARWpost, misalnya cape, cin dll tidak akan bisa aktif dan file GrADS yang dihasilkan hanya akan memiliki level vertikal yang linear, tidak logaritmik seperti level tekanan pada umumnya.

Buka /src/input_module.f90, dan cari blok berikut:

!! Any unknown program (including WRFSI) will be 0
      iprogram = 0
      title(:) = ' '
      istatus = NF_GET_ATT_TEXT(ncid, nf_global, 'TITLE', title)
      IF ( INDEX(title,'OUTPUT FROM GEOGRID') /= 0 ) iprogram = 1 !! geogrid output
      IF ( INDEX(title,'OUTPUT FROM GRIDGEN') /= 0 ) iprogram = 1 !! old geogrid output
      IF ( INDEX(title,'OUTPUT FROM METGRID') /= 0 ) iprogram = 3 !! metgrid output
      IF ( INDEX(title,'OUTPUT FROM OBSGRID') /= 0 ) iprogram = 3 !! obsgrid output
      IF ( INDEX(title,'OUTPUT FROM REAL_EM') /= 0 ) iprogram = 6 !! real.exe output
      IF ( INDEX(title,'OUTPUT FROM WRF') /= 0 )     iprogram = 8 !! wrf.exe output
      IF ( iprogram == 0 ) THEN
         print*," "
         print*,"  WARNING --- I do not recognize this data."
         print*,"             ",trim(title)
         print*,"              Will make an attempt to read it."
         print*," "
      END IF

Sisipkan baris kode setelah IF ( INDEX(title,'OUTPUT FROM WRF') /= 0 )     iprogram = 8 !! wrf.exe output

Kodenya:

IF ( INDEX(title,'OUTPUT FROM *             PROGRAM:WRF-Chem V4.7.1 MODEL') /= 0 ) iprogram = 8 !! wrfchem output

Setelah itu, simpan file fortran yang telah dimodifikasi tersebut, dan lanjutkan ke configure.arwp.

$ vi configure.arwp

Modifikasi baris C-Pre-Processor (CPP) pada file tersebut menjadi:

CPP = gfortran -E -x f95-cpp-input -P

Kemudian tambahkan argumen untuk Fortran compiler (FFLAGS) sehingga menjadi seperti ini:

FFLAGS          =       -ffree-form -O -fno-second-underscore -fconvert=big-endian -frecord-marker=4 -std=legacy -fallow-argument-mismatch

Lalu simpan perubahan dan keluar dari file configure.arwp. Berikutnya, masuk ke direktori /src dan modifikasi file Makefile.

$ cd src
$ vi Makefile

Lalu tambahkan linker untuk Fortran compiler. Perhatikan urutannya.
 
ARWpost.exe: $(OBJS)
        $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $(OBJS)  \
                -L$(NETCDF)/lib -I$(NETCDF)/include -lnetcdff -lnetcdf

Setelah itu simpan dan keluar dari Makefile. Sekarang anda bisa menjalankan compilernya.

$ ./compile

Pastikan tidak ada pesan error pada display. Berikut contoh beberapa baris terakhir proses compile bila tidak terjadi error.

gfortran -ffree-form -O -fno-second-underscore -fconvert=big-endian -frecord-marker=4 -std=legacy -fallow-argument-mismatch  -o ARWpost.exe module_model_basics.o constants_module.o gridinfo_module.o ARWpost.o input_module.o output_module.o module_map_utils.o misc_definitions_module.o module_date_pack.o module_debug.o process_domain_module.o module_get_file_names.o module_interp.o module_basic_arrays.o module_diagnostics.o module_arrays.o module_pressure.o module_calc_height.o module_calc_pressure.o module_calc_theta.o module_calc_tk.o module_calc_tc.o module_calc_td.o module_calc_td2.o module_calc_rh.o module_calc_rh2.o module_calc_uvmet.o module_calc_slp.o module_calc_dbz.o module_calc_cape.o module_calc_wdir.o module_calc_wspd.o module_calc_clfr.o  \
        -L/mgpfs/home/ardh003/source/wrf_dependencies/netcdf/lib -I/mgpfs/home/ardh003/source/wrf_dependencies/netcdf/include -lnetcdff -lnetcdf

Setelah itu pastikan file ARWpost.exe sudah terdapat pada direktori.

$ ls -alh ARWpost.exe
lrwxrwxrwx 1 ardh003 researcher 15 Oct 16 15:09 ARWpost.exe -> src/ARWpost.exe

Pastikan ARWpost.exe menggunakan library yg benar:

$ ldd ARWpost.exe
 linux-vdso.so.1 (0x00007ffd717be000)
        libnetcdff.so.7 => /mgpfs/home/ardh003/source/wrf_dependencies/netcdf/lib/libnetcdff.so.7 (0x000014756b874000)
        libnetcdf.so.15 => /mgpfs/home/ardh003/source/wrf_dependencies/netcdf/lib/libnetcdf.so.15 (0x000014756b564000)
        libgfortran.so.5 => /mgpfs/home/ardh003/source/wrf_dependencies/netcdf/lib64/libgfortran.so.5 (0x000014756b097000)
        libm.so.6 => /lib64/libm.so.6 (0x000014756ad15000)
        libgcc_s.so.1 => /mgpfs/home/ardh003/source/wrf_dependencies/netcdf/lib64/libgcc_s.so.1 (0x000014756aaf6000)
        libquadmath.so.0 => /mgpfs/home/ardh003/source/wrf_dependencies/netcdf/lib64/libquadmath.so.0 (0x000014756a8b1000)
        libc.so.6 => /lib64/libc.so.6 (0x000014756a4ec000)
        libhdf5_hl.so.100 => /mgpfs/home/ardh003/source/wrf_dependencies/netcdf/lib/libhdf5_hl.so.100 (0x000014756a2c7000)
        libhdf5.so.103 => /mgpfs/home/ardh003/source/wrf_dependencies/netcdf/lib/libhdf5.so.103 (0x0000147569cf7000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000147569af3000)
        libz.so.1 => /mgpfs/home/ardh003/source/wrf_dependencies/grib2/lib/libz.so.1 (0x00001475698d8000)
        /lib64/ld-linux-x86-64.so.2 (0x000014756bb33000)

Bila tidak ada error/library yang hilang, anda bisa langsung memodifikasi file konfigurasi namelist.ARWpost dan menjalankan ARWpost.exe. 

Thursday, October 16, 2025

Research Note #31 - Contoh Perintah Linux dan Slurm untuk Bekerja di HPC BRIN (updated)

Berikut beberapa perintah yang berguna untuk bekerja menggunakan fasilitas parallel computing di HPC BRIN (Mahameru). Perintah-perintah ini umumnya digunakan untuk mengetahui spesifikasi sistem yang digunakan sebelum menjalankan batch job pada slurm workload manager.

1. Mengetahui spesifikasi lengkap HPC

$ lscpu

2. Mengetahui jumlah processor pada node saat ini

$nproc
128

128 adalah jumlah cpu pada node yang aktif.

3. Mengetahui konfigurasi cluster HPC (Slurm)

$ sinfo -p medium-small -o "%N %c %m %G"
NODELIST CPUS MEMORY GRES
trembesi[51-72] 128 256000 (null)

trembesi[51-72] adalah node yang digunakan pada partisi medium-small, dengan jumlah cpu dan memori max masing-masing 128 dan 256 GB.

4. Submit dan menghentikan batch job (Slurm)

$ sbatch <script program.sh>  --> menjalankan script untuk batch job 

$ scancel -u <nama_user> --> menghentikan batch job oleh <nama_user>

5. Melihat status batch job dari user (slurm)

$ squeue -u 'whoami' --> melihat status batch job oleh user saat ini

$ squeue -u <nama_user> --> melihat status batch job oleh <nama_user>

$ sqeueu -all --> melihat status batch job oleh semua user

6. Melihat daftar seluruh partisi yang tersedia pada HPC (slurm)

$ sinfo -all

7. Masuk ke mode interaktif (slurm)

$ srun --partition=interactive --pty /bin/bash

Setelah masuk ke mode interaktif, anda bisa menjalankan script/program yang anda inginkan. Bila ingin keluar dari mode interaktif, ketik perintah 'exit' pada prompt shell.



Sunday, October 12, 2025

Research Note #30 - Instalasi Ncview dengan Miniconda3 di HPC BRIN

Conda adalah suatu package manager yang memungkinkan anda untuk menggunakan aplikasi scientific pada Linux tanpa harus repot menginstall/mengkonfigurasi library khusus pada sistem (seperti yg terjadi pada WRF-Chem). Dengan conda, anda dapat memilih instalasi aplikasi yang diinginkan dan menjalankannya pada environment khusus tanpa khawatir akan terjadi konflik dengan library lain pada system.

Pada tulisan ini, contoh aplikasi yang akan diinstall adalah ncview yang biasa digunakan untuk visualisasi data NetCDF (misal data domain WRF yang dibuat oleh geogrid). Salah satu kesulitan ketika instalasi ncview adalah tidak adanya library X11 untuk visualisasi pada server, terutama bila anda user biasa yang tidak punya akses admin untuk instalasi X11 pada sistem Linux. Pada HPC BRIN (Mahameru), ada beberapa jenis Conda yang bisa dipakai seperti Anaconda3 dan Miniconda3, tapi pada tulisan ini saya menggunakan Miniconda3.

Langkah pertama, pastikan conda sudah tersedia di module yang ada di Mahameru.

 $ module avail conda
----------- /mgpfs/shared/apps/mod/tools ---------------------
   Anaconda/3-2023.09-0
----------- /mgpfs/apps/modulefiles ---------------------------
   ai-ml/Anaconda/3-2023.09              earth/anaconda3/2019.07          earth/miniconda3/24.7.1
   bioinformatics/anaconda3/2023.09-0    earth/anaconda3/2023.09-0 (D)    earth/miniconda3/24.11.1 (D)

Berikutnya muat module miniconda3 24.11.1 dan periksa path 'bin'nya.

$ module load earth/miniconda3/24.11.1
$ module show earth/miniconda3/24.11.1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
   /mgpfs/apps/modulefiles/earth/miniconda3/24.11.1:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
load("readline/8.2")
whatis("miniconda3 2023.09-0 - anaconda3 is environment management system.")
setenv("RHOME","/mgpfs/apps/earth/apps/miniconda3/24.11.1")
prepend_path("PATH","/mgpfs/apps/earth/apps/miniconda3/24.11.1/bin")
prepend_path("LIBRARY_PATH","/mgpfs/apps/earth/apps/miniconda3/24.11.1/lib")
prepend_path("LD_LIBRARY_PATH","/mgpfs/apps/earth/apps/miniconda3/24.11.1/lib")
prepend_path("MANPATH","/mgpfs/apps/earth/apps/miniconda3/24.11.1/share/man")
help([[
        This module is for use of earth/miniconda3/24.11.1.
        use example:
            $ module load earth/miniconda3/24.11.1
]])

Berikutnya, muat path bin miniconda3 ke environment. Bila dilakukan dengan benar, kita dapat menjalankan conda pada shell, misal untuk melihat versi miniconda.

$ export PATH=/mgpfs/apps/earth/apps/miniconda3/24.11.1/bin:$PATH
$ conda --version
conda 25.1.1

Bila conda sudah bisa dijalankan, selanjutnya inisiasi conda pada shell. Perhatikan prompt shell berubah setelah aktivasi (anda masuk ke environment conda). 

$ source /mgpfs/apps/earth/apps/miniconda3/24.11.1/etc/profile.d/conda.sh
$ conda activate
(base) $

Setelah masuk ke environment conda, buat environment baru (sebut saja 'wrfvis') dan install ncview dan netcdf4. NetCDF pada conda ini tidak ada hubungannya alias terisolasi dari NetCDF yang sudah terinstall pada sistem). Tunggu sampai proses instalasi selesai, lalu aktifkan wrfvis.

(base) $ conda create -n wrfvis -c conda-forge ncview netcdf4
(base) $ conda activate wrfvis

Setelah wrfvis aktifkan, anda bisa menjalankan ncview untuk melihat isi data NetCDF. Tentu saja, X-server (misal X-ming) sudah harus terinstall dan aktif pada ssh client yang anda gunakan.

(wrfvis) $ ncview WPS/geo_em.d01.nc

Untuk keluar dari environment conda yang saat ini aktif:

(wrfvis) $ conda deactivate
$

Agar tidak perlu repot memuat conda ke environment tiap kali login, tambahkan dua baris ini pada file .bashrc.

export PATH=/mgpfs/apps/earth/apps/miniconda3/24.11.1/bin:$PATH
source /mgpfs/apps/earth/apps/miniconda3/24.11.1/etc/profile.d/conda.sh

Selanjutnya, anda bisa langsung masuk-keluar environment conda.

conda activate wrfvis
coda deactivate

Thursday, October 9, 2025

Research Note #29 - Instalasi WRF-Chem di HPC BRIN (Mahameru)

Last edited on 16-10-2022

Instalasi model WRF itu selalu menantang (baca: bikin stress), apalagi kalau terakhir kali installnya itu lebih dari 5 tahun yang lalu. Butuh waktu untuk mereview ulang langkah-langkah yang dulu pernah dilakukan, termasuk merefresh ilmu per-Linux-an yang sudah lumayan lama terlupa. Untungnya, berkat catatan-catatan proses instalasi njelimet yang masih tersimpan rapih di blog ini, ditambah dengan bantuan asisten virtual yang setia mendampingi (baca: chatGPT), akhirnya WRF bisa terinstall di HPC BRIN (selanjutnya kita sebut saja Mahameru). Yang lebih bikin senang, yg terinstall bukan cuma WRF, tapi juga WRF-Chem, dan ada beberapa hal baru yang saya pelajari dari proses instalasi ini.

Secara umum, proses intalasi model WRF-Chem di Mahameru hampir sama dengan Oakforest UTokyo dulu, dengan beberapa trik baru. Kalau dirangkum prosesnya kurang lebih seperti ini:

  1. Pastikan jenis C dan Fortran compiler yang tersedia di sistem. Mahameru menggunakan gcc dan gfortran, berbeda dengan Oakforest yang menggunakan icc dan ifort.  
  2. Install library-library yg dibutuhkan WRF, seperti NetCDF, grib2, Jasper, LibPNG dll. Sebagian library ini sudah tersedia di Mahameru, tinggal di-load saja modulnya. Untuk kasus saya, seluruh library ini saya install kembali di direktori user saya. Kenapa? Karena kl misal ada masalah, akan lebih gampang melacak dan memodifikasi path library-nya tanpa harus memuat ulang modul yang ada di sistem.
  3. Cara paling mudah instalasi library adalah dengan mengikuti panduan yang ada di website ini. Ikuti saja langkah-langkahnya sampai sebelum instalasi WRF/WPS, kecuali untuk MPICH, WRF dan WPS. MPICH tidak digunakan karena Mahameru sudah menggunakan OpenMPI untuk parallel computing. Instalasi WRF/WPS di Mahameru juga perlu beberapa trik khusus yang tidak ada di panduan tersebut.
  4. Download WRF dan WPS terbaru via github. Ini termasuk hal baru karena sebelumnya saya download manual dari website WRF (UCAR). Bedanya, download WRF via github memungkin modul WRF seperti Chem, WRFDA dll otomatis terunduh, jadi tidak perlu didownload satu-per-satu lagi. Praktis.
  5. Mulai dengan konfigurasi kompilasi WRF dahulu. Bila menggunakan bash shell, pastikan WRF_CHEM=1 dan NETCDF_classic=1 sudah tersimpan di environment. Jalankan configure script, pilih opsi #34 (dmpar, gcc/gfortran) dan basic nesting (#1). Pastikan proses configure berjalan normal.
  6. Untuk WRF-Chem, pastikan YACC (Yet Another Compiler-Compiler) sudah terinstall. Bila tidak ada (di Mahameru tidak ada), lakukan instalasi manual dengan Bison (YACC sudah include di dalamnya). Jangan lupa, deklarasikan pathnya, misal: export YACC="$CUSLIB/bison/bin/yacc -d". Bison bisa diunduh di sini.
  7. Trik pertama. Setelah configure selesai, edit file configure.wrf, dan hilangkan 'time' pada bagian deklarasi variabel FC (fortran compiler). Misal:   FC  =  time $(DM_FC) menjadi  FC  =  $(DM_FC). Kenapa ini penting? Karena script compiler WRF menggunakan 'time' untuk mencatat proses kompilasi, sedangkan Mahameru tidak memiliki modul 'time' ini, sehingga kalau script configure.wrf tidak diubah, maka proses kompilasi nantinya akan gagal (dikenal juga dengan Error 127).
  8. Trik berikutnya, jalankan kompilasi dengan batch job di Mahameru. Kenapa harus pakai batch job? Proses kompilasi ini memakan memori yg besar, sehingga bila dijalankan langsung dari login node (shell tempat anda mulai login), akan ada suatu saat di mana sistem akan menghentikan proses kompilasi secara paksa (kill/terminate) karena batasan memori untuk login node (dikenal juga dengan Error 1). Untuk instalasi ini, saya menggunakan opsi  #SBATCH --mem-per-cpu=16G pada script batch job untuk memastikan kompilasi mendapat alokasi yang cukup. Contoh script ada di catatan 3 di bawah.
  9. Bila proses kompilasi berjalan lancar, beberapa file executable akan tersedia di direktori /main WRF, antara lain: real.exe, wrf.exe, ndown.exe dan tc.exe. Kalau tidak ada, ya berarti proses kompilasi gagal dan kompilasi WPS selanjutnya tidak akan bisa dilakukan.
  10. Untuk WPS, pastikan library fortran yg dibutuhkan sudah dimuat pada environment. Bila belum, jalankan: export LD_LIBRARY_PATH=$NETCDF/lib64, di mana $NETCDF adalah direktori library netcdf yg aktif digunakan. Pastikan juga WRF_DIR=[direktori WRF] karena WPS perlu executable WRF untuk mengkompilasi WPS.
  11. Jalankan script configure WPS, pilih opsi #1 (serial), dan pastikan proses configure lancar. Bila ada pesan "Your Fortran + NETCDF did not run successfully" itu artinya langkah 10 di atas msh belum benar.
  12. Jalankan script kompilasi WPS. Proses ini bisa dilakukan di login node dan tidak sampai 5 menit selesai. Bila proses lancar, akan ada tiga file executable baru di direktori WPS: geogrid.exe, metgrid.exe dan ungrib.exe.
  13. Pastikan ketiga file tadi terhubung dengan library yang dibutuhkan dengan menggunakan perintah 'ldd'. Misalnya: ldd geogrid.exe. Kalau tidak ada masalah, seharusnya sistem akan menunjukkan link ke tiap library untuk file tersebut tanpa ada pesan error.


Catatan #1: WRF-Chem yang diinstall tidak menggunakan KPP Library

Catatan #2:
Dengan asumsi langkah 1-4 tidak ada masalah, saya menggunakan konfigurasi berikut untuk file ~/.bashrc, supaya langkah 5 dst tidak perlu capek-capek memuat konfigurasi ke environment sistem tiap kali login. Konfigurasi ini bisa berbeda-beda untuk tiap orang/user dan sistemnya.

export CUSLIB=$HOME/source/wrf_dependencies
export NETCDF=$CUSLIB/netcdf
export LD_LIBRARY_PATH=$NETCDF/lib:$CUSLIB/grib2/lib:$CUSLIB/flex/lib:$NETCDF/lib64:/opt/ohpc/pub/mpi/openmpi4-gnu12/4.1.4/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/ohpc/localpub/libs/hwloc/lib:$LD_LIBRARY_PATH
export PATH=$NETCDF/bin:$HOME/opengrads/Contents:/opt/ohpc/pub/mpi/openmpi4-gnu12/4.1.4/bin:$PATH
export JASPERLIB=$CUSLIB/grib2/lib
export JASPERINC=$CUSLIB/grib2/include
export YACC="$CUSLIB/bison/bin/yacc -d"

Catatan #3: 
Script batch job untuk instalasi WRF-Chem di Mahameru (untuk mencegah Error 1):

#!/bin/bash
#SBATCH --job-name=insjob
#SBATCH --ntasks=1
#SBATCH --partition=short
#SBATCH --cpus-per-task=4
#SBATCH --mem-per-cpu=16G
module load  openmpi4/4.1.4
export LD_LIBRARY_PATH=/opt/ohpc/pub/mpi/openmpi4-gnu12/4.1.4/lib:$LD_LIBRARY_PATH
export PATH=/opt/ohpc/pub/mpi/openmpi4-gnu12/4.1.4/bin:$PATH
# Your script goes here
./compile em_real >& log.compile


Tuesday, January 7, 2020

Research Note #26 - Filtering Data and Making Standard Deviation using Google Earth Engine

So, there are two main objectives of this script: display data based on a certain threshold value (in this case, reflectance < 1000) and make a standard deviation from the results. The Data used in this example was Sentinel-2 MSI Level 2A, in the period between November 1 - 15, 2019. Cloud masking was utilized at the beginning of the script to choose granules which were clear from clouds.

// Create a geometry representing the analysis region.
var daerah = ee.Geometry.Rectangle([72.611536, 28.354144, 78.807625, 32.630466]); 

/**
 * Function to mask clouds using the Sentinel-2 QA band
 * @param {ee.Image} image Sentinel-2 image
 * @return {ee.Image} cloud masked Sentinel-2 image
 */
function maskS2clouds(image) {
  var qa = image.select('QA60');

  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;

  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0)

 // Choose pixels with reflectance < 1000
      .and(image.lt(1000))
      );

  return image.updateMask(mask).divide(10000);
}

// Map the function over the analysis region and period
// Load Sentinel-2 TOA reflectance data.
var datasentinel = ee.ImageCollection('COPERNICUS/S2')
                  .filterDate('2019-11-01', '2019-11-15')
                  .filterBounds(daerah)
                  // Pre-filter to get less cloudy granules.
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))
                  .map(maskS2clouds)
                  ;

// Get the standard Deviation.
var hasil = datasentinel.reduce(ee.Reducer.stdDev());

// Define the plot parameter, use the standard deviation of Band 4 only  
var stdevVis = {
  min: 0,
  max: 0.005,
  bands: ['B4_stdDev'],
  palette: ['0000FF', '00FFFF', '00FF00', 'FFFF00', 'FF0000']
};

// Add the plot layer on the map
Map.addLayer(hasil, stdevVis, 'Std Deviation');
Map.setCenter(75.7095805, 30.492305, 14);

And the result will be like this:


You may seen some pixels with very high standard deviation values (shown in red, cyan or anything else other than blue). To 'clean-up' these pixels, we can add another filter to the standard deviation results. For example to show the values no higher than 0.000001:

// Get the standard Deviation.
var hasil = datasentinel.reduce(ee.Reducer.stdDev());
var hi_stddev = hasil.lt(0.000001);
var hasil = hasil.updateMask(hi_stddev);

The result will be like this:


Finally, we can overlay the base Google Map using the result by choosing the Satellite map (button on the right corner of the map).


Wednesday, November 6, 2019

Research Note #25 - Reading a Text File Line-by-Line with Fortran

Again, this is actually a very simple task which I usually deal with ... and forget, most of the time! That's why this post exists. The following is a basic Fortran code to enable you reading the contents of a text file, line-by-line. 

As an example, let's make a text file (named 'list.txt') containing a list of files with their complete paths on Linux:

$ ls ../gcom-c/aerosol/0524/pl/* > list.txt
$ cat list.txt

../gcom-c/aerosol/0524/pl/GC1SG1_20190901D01D_T0524_L2SG_ARPLK_1001.h5
../gcom-c/aerosol/0524/pl/GC1SG1_20190902D01D_T0524_L2SG_ARPLK_1001.h5
../gcom-c/aerosol/0524/pl/GC1SG1_20190903D01D_T0524_L2SG_ARPLK_1001.h5
../gcom-c/aerosol/0524/pl/GC1SG1_20190904D01D_T0524_L2SG_ARPLK_1001.h5

Now, this is the Fortran code to read file 'list.txt':

PROGRAM READTEXT
IMPLICIT NONE
CHARACTER(LEN=8) :: listfile
CHARACTER(LEN=70) :: filecontents
INTEGER :: io

listfile="list.txt"

OPEN(10, FILE=listfile, FORM="FORMATTED", STATUS="OLD",&
        ACTION="READ")

DO
   READ(10,"(A70)",IOSTAT=io) filecontents
   IF (io/=0) EXIT
   PRINT *, filecontents
END DO
CLOSE(10)

END PROGRAM READTEXT

How it works?

The program will open file 'list.txt', then read the first line of the file and put the (string) contents into variable 'filecontents'. It will then print the contents of variable onto the screen. Since there's a DO.. END DO statement, this process will repeat, with the next line being read, replacing the contents of variable 'filecontents'. This looping process will end once there are no more lines found in the file, invoking IOSTAT to a value other than 0 (0 means no I/O error occurred, other values mean there are I/O errors), then program will exit. That's all!

Some important notices:
  • The absence of 'DO ... END DO' will make the program only reads the first line of the file.
  • The absence of 'IF (io/=0) EXIT' will make the program runs endlessly, with the last line of the file kept being showed on the screen.
  • If the output format is not determined (for example, FMT=* instead of A70), the program will not correctly show the file's contents. The (character) length of this format should be same or more than the one at variable declaration. Why 70? Because in this case, the full path of file list (in one line) has 70 characters. 

Tuesday, November 5, 2019

Research Note #24 - Showing GCOM-C/SLGI Dataset Header/Metadata

One of the most important things to do while working with binary satellite data is checking the header/metadata of the dataset. By doing so, you could know the dimensions, parameters, variables and attributes of the data which will be needed for analysis (with program, script, etc.). These are three methods to show the GCOM-C/SLGI dataset header and attributes. I made this post because I always forget the quickest way to do it and ended up wasting too much time just for knowing some attributes of the data.

1. Using HDF View
This is definitely the quickest way and the most convenient way to check the headers and attributes of HDF data file. It works perfectly with MODIS as well as GCOM-C/SLGI. Just open the HDF file, and browse into the dataset directories. Simple!


2. Using h5dump
Works in similar fashion with ncdump. Just type the command and you're good to go. Not so convenient for non-Linux user.

Example:
h5dump -H <filename> --> Show header contents of a datafile
h5dump -a /Image_data/LST/Slope <filename> --> Show the contents of attribute 'Slope' (scaling factor) of dataset 'LST' of a datafile



3. Using SGLI Tool
This is by far the most not-convenient way to see the headers. Not only it's slow and taking so much of system resources, it also shows the header only (no attributes). To see the header, open a HDF file and go to Menu->View->Meta Data


Tuesday, October 15, 2019

Research Note #23 - GEE Script to Overlay Sentinel 2A with MODIS Terra/Aqua Hotspots

The main purpose of this script is to overlay MODIS Terra/Aqua hotspots product MOD14A1/MYD14A1 (daily thermal anomalies, lev3, 1km grid) over Sentinel-2A Thermal Reflectance (lev2, 10-20m spatial resolution). The channels used for Sentinel data is 11, 8 and 4 (SWIR1, NIR, RED) hence creating false color image over area of Sri Mukhtar Sahib city in Punjab region, India (14x zoom) on Google Map. Observation time was set between November 1 - 15, 2018.



/**
 * Function to mask clouds using the Sentinel-2 QA band
 * @param {ee.Image} image Sentinel-2 image
 * @return {ee.Image} cloud masked Sentinel-2 image
 */
function maskS2clouds(image) {
  var qa = image.select('QA60');

  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;

  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));

  return image.updateMask(mask).divide(10000);
}

// Map the function over one year of data and take the median.
// Load Sentinel-2 TOA reflectance data.
var dataset = ee.ImageCollection('COPERNICUS/S2')
                  .filterDate('2018-11-01', '2018-11-15')
                  // Pre-filter to get less cloudy granules.
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))
                  .map(maskS2clouds);

var rgbVis = {
  min: 0.0,
  max: 0.3,
  bands: ['B11', 'B8', 'B4'],
};


Map.addLayer(dataset.median(), rgbVis, 'RGB');

Map.setCenter(74.516872, 30.475603, 14);

var aqua = ee.ImageCollection('MODIS/006/MYD14A1')
                  .filter(ee.Filter.date('2018-11-01', '2018-11-15'));
var fireMaskVis = {
  min: 9.936350984054926,
  max: 107.38312795164352,
  bands: ['MaxFRP', 'FireMask', 'FireMask'],
};

Map.addLayer(aqua, fireMaskVis, 'Fire Mask');

var terra = ee.ImageCollection('MODIS/006/MOD14A1')
                  .filter(ee.Filter.date('2018-11-01', '2018-11-15'));
var fireMaskVis = {
  min: 9.936350984054926,
  max: 107.38312795164352,
  bands: ['MaxFRP', 'FireMask', 'FireMask'],
};

Map.addLayer(terra, fireMaskVis, 'Fire Mask');

Friday, June 14, 2019

Research Note #22 - Reading GCOM-C 250m-Res HDF5 Data with Fortran

There were not so many references about 'simple' ways to open and read HDF5 data file with Fortran as well as compiling the codes. I said 'simple', because there are actually manuals and tutorials about that purpose, however, most of them were too complicated and refer to other sub-references, thus blah .. blah ... it takes too much time, especially if you just simply want to open, read and compile a HDF dataset. Here, I posted a very basic way to access HDF5 data, using very minimal Fortran code. Before starting, here's the convention:
  • I used Linux OS. 
  • I used Fortran 90 for programming.
  • HDF5 (ver 1.8.17) libraries has been already installed in my system as module.
  • I used JAXA's GCOM-C NDVI Monthly statistics (Level-2 data) with 250m spatial resolution with Sinusoidal/EQA projection. This data contains 4800x4800 pixels. For exemplary purpose, I renamed it to "ndvi.h5".
So, the following is a very basic example of Fortran code to open and read HDF5 data:

PROGRAM HDF5test

   USE HDF5
   IMPLICIT NONE

   INTEGER :: hdferr, i, j
   INTEGER(HID_T) :: fileid, dset
   CHARACTER(LEN=7), PARAMETER :: filename = "ndvi.h5"
   CHARACTER(LEN=19), PARAMETER :: dataset = "Image_data/NDVI_AVE"
   INTEGER, PARAMETER :: xdim = 4800
   INTEGER, PARAMETER :: ydim = 4800
   INTEGER, DIMENSION(1:xdim, 1:ydim) :: ndvi_ave
   INTEGER(HSIZE_T), DIMENSION(1:2) :: dims = (/xdim, ydim/)
   
   CALL h5open_f(hdferr)
   CALL h5fopen_f(filename, H5F_ACC_RDONLY_F, fileid, hdferr)
   CALL h5dopen_f(fileid, dataset, dset, hdferr)
   CALL h5dread_f(dset, H5T_NATIVE_INTEGER, ndvi_ave, dims, hdferr)

    DO j = 1, ydim
      DO i = 1, xdim
         print *, ndvi_ave(i,j)
      ENDDO
   ENDDO

  CALL h5dclose_f(dset, hdferr)
  CALL h5fclose_f(fileid, hdferr)
  CALL h5close_f(hdferr)

END PROGRAM HDFtest

The most important lines are:
  • CALL h5open_f(hdferr)This function initializes HDF5 library for Fortran uses. Returns 0 (to hdferr variable) if it's successful, and -1 if it's failed.
  • CALL h5fopen_f(filename, H5F_ACC_RDONLY_F, fileid, hdferr). This function opens an existing HDF5 file. In this example, I just want to read it, hence H5F_ACC_RDONLY_F was used as argument. This function will return integers for file identifier and status to fileid and hdferr variables, respectively.
  • CALL h5dopen_f(fileid, dataset, dset, hdferr). This function opens an existing dataset in the opened file. Take notice that it needs file identifier (from h5fopen_f), dataset name, dataset identifier and status (as previous functions).
  • CALL h5dread_f(dset, H5T_NATIVE_INTEGER, ndvi_ave, dims, hdferr). This function reads raw data from dataset of the file, into a buffer. The buffer means a space in the computer memory, this could be a variable or array. Take notice that it need dataset identifier (from h5dopen_f), memory data type (Native integer), buffer, dimension (to store buffer dimension) and as always, status (hdferr).
To make it simple, the program will firstly initialize HDF5 library, opens an existing HDF5 datafile, opens a dataset from that file (a file could consist of many datasets), read the raw data from the dataset, put the data into an array buffer, then prints the contents of the buffer into the screen. Finally, it closes the dataset, closes the file and ultimately deactivates HDF5 library (flush and cleans the memory). That's all.

Another important thing is variable declaration. HID_T and HSIZE_T are parameters for predefined datatype used by HDF5 library. So, don't be confused with them (for details, just read: https://support.hdfgroup.org/HDF5/doc/fortran/index.html).

Finally, save and give the codes a name (for example: test.f90). To compile the code, just use this command on (bash) shell:

$ h5fc -o test.exe test.f90

It's just similar with a normal Fortran compiler command. If you don't specify a name for the output, a file named 'a.out' will be generated by the compiler.

Wednesday, March 13, 2019

Research Note #21 - Compiling Fortran Script for NetCDF Data Processing

NetCDF data is become more and more important for my research, thus it's necessary to work with it with my own program, in Fortran (F90). The compilation anyway, a little bit tricky and slightly different with ordinary Fortran compilation. Here are the simple steps to compile it, using Intel Fortran compiler:

1. Make sure NetCDF module has been installed and declared in the system path.

The path for NetCDF module is : $NETCDF/include

If the path has not yet existed, make a soft link of the module file to current directory:

ln -sf $NETCDF/include/netcdf.mod

2. Compile the Fortran code to make an object file

Let's say the code file name is 'test.f90', then execute:

$ ifort -c test.f90 -I$NETCDF/include

Or, if the path of NetCDF module has existed, just simply:

$ ifort -c test.f90

Make sure no problems occur.

3. Finally, link the object file to an executable file:

$ ifort -o test.exe test.o -I$NETCDF/include -L$NETCDF/lib -lnetcdff -lnetcdf

Same as step 2, if the module path has existed:

$ ifort -o test.exe test.o -L$NETCDF/lib -lnetcdff -lnetcdf

If everything's OK, then an exe file will be created in the current directory. The most important thing, don forget to include '-lnetcdff', because since release 4.1.3, the Fortran library is no longer combined with C library. One hint is by checking if there are file named 'libnetcdff' in the $NETCDF/lib directory. If they are there, the argument '-lnetcdff' should be added in the compile command. 

Thursday, February 7, 2019

Research Note #20 - Preparing Emission Data with PREP-CHEM-SRC and CONVERT_EMISS for WRF-Chem

It took quite a while before I could post this, mainly because everything becomes more and more complicated. The deeper I dig into WRF-Chem, the more complex the problems are. Successfully compiling PREP_CHEM_SRC didn't make things easier as more questions keep coming into my mind about how the system actually works, thanks to the oblivious manual. Well, at least the emission data could be prepared and seems to be simulated in the model now.

Here are the steps to prepare emission data for WRF-Chem using PREP-CHEM-SRC and CONVERT_EMISS utilities.

1. Download and Link the Emission Data
Download the latest emission data from this link. It was in the same directory with PREP-CHEM-SRC source codes. Extract the data inside any desired directory and it is recommended to make a soft link to the location to avoid long-directory listing in the input namelist file which will be explained soon. Locate the softlink in the same directory with the PREP-CHEM-SRC utility (and its namelist input file), and name it 'datain' (the name is actually up to you). 

$ mkdir wrf/EMISSION
$ cd wrf/EMISSION
$ tar -xzvf global_emissions_v3_24aug2015.tar.gz
$ cd PREP-CHEM-SRC-1.5/bin
$ ln -sf ../../Global_emissions_v3/ datain

The directory should similar like this (after executing ls command):

[c24223@ofp05 bin]$ ls -alh
total 3.9M
drwxr-s--- 4 c24223 gi55 4.0K Feb  7 19:06 .
drwxr-s--- 8 c24223 gi55 4.0K Aug 25  2015 ..
drwxr-s--- 3 c24223 gi55  12K Jan 31 20:24 build
lrwxrwxrwx 1 c24223 gi55   26 Jan 31 20:24 datain -> ../../Global_emissions_v3/
-rw-r----- 1 c24223 gi55 6.0K Feb  6 20:38 prep_chem_sources.inp
-rwxr-x--- 1 c24223 gi55 3.9M Jan 31 20:22 prep_chem_sources_RADM_WRF_FIM_.exe
drwxr-s--- 6 c24223 gi55 4.0K Apr 30  2015 .svn

2. Configure using Namelist Input File
This step is really important to determine what kind of emission data, map projections, grid configuration, output format etc. used by the utility. These configurations are stored inside namelist input file: prep_chem_sources.inp

Ideally, we could run the utility without any changes to namelist file, but unfortunately, it is not the case this time. The main contents of the file contain paths of emission data from step #1, and it seems the developers didn't update it according the latest path in the data. Therefore, you MUST re-check and confirm the path inside the namelist file by your own, otherwise you will get errors while executing the utility.

A sample of 'working' configuration for my case could be download here

Some important points are before using the namelist file above:
  • The emission dataset used this post is published does not contain MEGAN emission data.
  • I didn't use bbem/bbem plumerise and volcanic emission data.
  • The map projection used in my simulation is mercator/ii. 
  • For more detailed information about the configurations in the namelist file, read this guide (it is much better than the original emission guide of WRF-Chem).
3. Execute prep_chem_src utility
This step is quite straight forward, except that some nasty things could happen during the process. 

$ ./prep_chem_sources_RADM_WRF_FIM_.exe

You could just sit down nicely until the utility finishes preparing the emission data. Anyway, if you find that the utility crashes midway with some scary segmentation fault messages, you should check the compilation of it. One possible cause is, the compiler option used while compiling the utility. For more detail, check the previous post about installing prep_chem_src utility.

Another possible reason is the program overloads the memory because of compilation or grid settings in the namelist file, causing crash. If it's the case, execute 'ulimit -s unlimited' and try again.

Anyway, if the program successfully works, you will see files similar like the following in the directory:

-rw-r----- 1 c24223 gi55  27M Feb  7 20:03 matrixfire-T-2018-01-01-000000-g1-ab.bin
-rw-r----- 1 c24223 gi55  35M Feb  7 20:03 matrixfire-T-2018-01-01-000000-g1-bb.bin
-rw-r----- 1 c24223 gi55 6.5K Feb  7 20:02 matrixfire-T-2018-01-01-000000-g1.ctl
-rw-r----- 1 c24223 gi55 168M Feb  7 20:03 matrixfire-T-2018-01-01-000000-g1-gocartBG.bin
-rw-r----- 1 c24223 gi55  70M Feb  7 20:03 matrixfire-T-2018-01-01-000000-g1.gra
-rw-r----- 1 c24223 gi55  71M Feb  7 20:03 matrixfire-T-2018-01-01-000000-g1.vfm

So, here are some explanations for the files:
  • g1-ab.bin file is anthropogenic emission data (+ biogenic emission data, if you use it) for WRF-Chem
  • g1-bb.bin file is biomass burning (+ plume rise, if you use it) emission data for WRF-Chem
  • g1-gocartBG.bin is GOCART background emission data for WRF-Chem
  • g1.gra and g1.vfm are binary files in GrADS format to visualize the emission data
  • g1.ctl is GrADS control/descriptor file
You can now check the emission data using GrADS (don't forget to add 'options big_endian' into the descriptor file).

 --- To be continued --- 


Monday, December 24, 2018

Research Note #19 - Installing prep_chem_sources Utility for WRF-Chem

This has been probably one of the trickiest installations I've ever experienced, thanks to the lack of necessary library, limited references and bug in the source code. 

In order to install (or rather, compile) prep_chem_sources tool (I'll call it PCS from now on), HDF5, NetCDF and ZLIB libraries are necessary. Since NetCDF and ZLIB have been already available from previous WRF installation, one should only care about HDF5. Be advised though, HDF5 library of Oakforest super computer module was not compatible with the installation script. Thus, newly fresh HDF5 library is necessary (latest version might be compatible, thus keep checking updates of the super computer).

1. HDF5 Library Installation
Download the latest version from HDF group website. For this case, the version used is HDF5-1.10.4. Extract the file in a directory and execute installation script. Since PCS needs ZLIB and Fortran library, do not forget to mention them during the configuration.

$ ./configure --prefix=/work/gi55/c24223/libs/hdf5 --enable-fortran --enable-cxx --with-zlib=/work/gi55/c24223/libs/grib2
$ ./make
$ ./make check
$ ./make install

Make sure no errors occurred during the installation. After installing HDF5, put its path and LD_LIBRARY_PATH in the .bash_profile and re-load the file.

export HDF5=$PACSLIB/hdf5
export PATH=$HDF5/bin:$PATH

export LD_LIBRARY_PATH= ... :/work/gi55/c24223/libs/hdf5/lib

2. Download PCS tool
Download the tool from this ftp site directory: ftp://aftp.fsl.noaa.gov/divisions/taq/global_emissions

By the time this note was written, the latest version of PCS tool is ver. 1.5. Extract the tools inside any desired directory. Once extracted, there will a directory PREP-CHEM-SRC-1.5 with several sub-directories such as: /bin, /src, /extra etc.

3. Edit  convert_edgar_to_RELACS_REAC.f90 Script
This step should be done, otherwise PCS installation will fail with following messages:

convert_edgar_to_RELACS_REAC.f90(17): error #6405: The same named entity from different modules and/or program units cannot be referenced. [CO]
,CO &
-----------------------------^
convert_edgar_to_RELACS_REAC.f90(20): error #6405: The same named entity from different modules and/or program units cannot be referenced. [CH4]
,CH4 &
-----------------------------^
convert_edgar_to_RELACS_REAC.f90(21): error #6405: The same named entity from different modules and/or program units cannot be referenced. [SO2]
,SO2 &
-----------------------------^
compilation aborted for convert_edgar_to_RELACS_REAC.f90 (code 1)

make: *** [convert_edgar_to_RELACS_REAC.o] Error 1

The cause of this error is ironically simple: the absence of remark symbol ('!') in front of the 9th line of script convert_edgar_to_RELACS_REAC.f90 in the /src sub-directory:

8 subroutine convert_edgar_to_relacs_reac(isp,iespc,ident,spc_name_dummy)  !kml
9 use chem1_list
10 !use chem1_list, only : alke, bio,ora2,aro,ket,alka,ald

Thus, edit the script by adding '!' symbol in front of the said line using vi or other text editor.

4. Edit include.mk.intel.wrf Option Script and Compile PCS
This step is briefly explained on emission guide of WRF-Chem, however no further explanation about the script options available since it will strictly depend on the machine/system architecture. Anyway, one useful hint is: use the same options with WRF-Chem installation used, which are stored inside file configure.wrf inside /WRFV3 sub-directory.

Go to /bin/build sub-directory of PCS, and edit include.mk.intel.wrf option script (since the compiler used is intel compiler). Change these settings as follows:

update 2019/01/31:
Changed F_OPTS because the "longer" version caused crash during execution of utility for GOCART background data.

NETCDF=/work/gi55/c24223/libs/netcdf
HDF5=/work/gi55/c24223/libs/hdf5
HDF5_LIB=-L$(HDF5)/lib -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5 -L/work/gi55/c24223/libs/grib2/lib -lz -ldl

F_COMP=mpif90 -f90=ifort
C_COMP=mpicc -cc=icc -DMPI2_SUPPORT
LOADER=$(F_COMP)
C_LOADER=$(C_COMP) -DFSEEKO64_OK
F_OPTS=-fpp -D$(CHEM) -O3 -convert big_endian
C_OPTS= -O2

LOADER_OPTS= -O2

Save the script and compile PCS (for GOCART chem option):

$ make OPT=intel.wrf CHEM=RADM_WRF_FIM

If everything's going well, an executable prep_chem_sources_RADM_WRF_FIM_.exe will be created in /bin sub-directory. Check with ldd command to make sure there are no missing shared library links of the executable.

$ ldd prep_chem_sources_RADM_WRF_FIM_.exe
        linux-vdso.so.1 =>  (0x00007ffc35bbe000)
        libnetcdff.so.6 => /work/gi55/c24223/libs/netcdf/lib/libnetcdff.so.6 (0x00007ff8b2825000)
        libnetcdf.so.11 => /work/gi55/c24223/libs/netcdf/lib/libnetcdf.so.11 (0x00007ff8b23cf000)
        libhdf5hl_fortran.so.100 => /work/gi55/c24223/libs/hdf5/lib/libhdf5hl_fortran.so.100 (0x00007ff8b21a8000)
        libhdf5_fortran.so.100 => /work/gi55/c24223/libs/hdf5/lib/libhdf5_fortran.so.100 (0x00007ff8b1f45000)
        libhdf5_hl.so.100 => /work/gi55/c24223/libs/hdf5/lib/libhdf5_hl.so.100 (0x00007ff8b1d1c000)
        libhdf5.so.103 => /work/gi55/c24223/libs/hdf5/lib/libhdf5.so.103 (0x00007ff8b1679000)
        libz.so.1 => /work/gi55/c24223/libs/grib2/lib/libz.so.1 (0x00007ff8b145a000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007ff8b1237000)
        libmpifort.so.12 => /home/opt/local/cores/intel/impi/2018.1.163/intel64/lib/libmpifort.so.12 (0x00007ff8b0e8d000)
        libmpi.so.12 => /home/opt/local/cores/intel/impi/2018.1.163/intel64/lib/libmpi.so.12 (0x00007ff8b0208000)
        librt.so.1 => /lib64/librt.so.1 (0x00007ff8b0000000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff8afde3000)
        libm.so.6 => /lib64/libm.so.6 (0x00007ff8afae1000)
        libc.so.6 => /lib64/libc.so.6 (0x00007ff8af71e000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff8af507000)
        libhdf5_hl.so.10 => /work/opt/local/apps/intel/2017.1.132/hdf5/1.8.17/lib/libhdf5_hl.so.10 (0x00007ff8af2db000)
        libhdf5.so.10 => /work/opt/local/apps/intel/2017.1.132/hdf5/1.8.17/lib/libhdf5.so.10 (0x00007ff8aebb3000)
        libifport.so.5 => /home/opt/local/cores/intel/compilers_and_libraries_2018.1.163/linux/compiler/lib/intel64/libifport.so.5 (0x00007ff8ae984000)
        libifcoremt.so.5 => /home/opt/local/cores/intel/compilers_and_libraries_2018.1.163/linux/compiler/lib/intel64/libifcoremt.so.5 (0x00007ff8ae5f0000)
        libimf.so => /home/opt/local/cores/intel/compilers_and_libraries_2018.1.163/linux/compiler/lib/intel64/libimf.so (0x00007ff8ae061000)
        libsvml.so => /home/opt/local/cores/intel/compilers_and_libraries_2018.1.163/linux/compiler/lib/intel64/libsvml.so (0x00007ff8ac9ae000)
        libintlc.so.5 => /home/opt/local/cores/intel/compilers_and_libraries_2018.1.163/linux/compiler/lib/intel64/libintlc.so.5 (0x00007ff8ac740000)
        libirng.so => /home/opt/local/cores/intel/compilers_and_libraries_2018.1.163/linux/compiler/lib/intel64/libirng.so (0x00007ff8ac3cc000)
        /lib64/ld-linux-x86-64.so.2 (0x00005572db0f7000)