2013年10月31日木曜日

GOTM developer's version (test cases)

現段階で生じているエラーはこちら:

    init_air_sea
 FATAL ERROR: I could not read airsea namelist
STOP init_airsea

このネームリストはgotmバージョン4から持ってきたものなのでこのファイルがdeveloper's versionの更新と同期されてないかまたはその逆でdeveloper's verisonのコードが書き換えられてからネームリストがモデルの更新に追いついていってないかのどっちかだと思うんだが新しい宿題が出たのでまた今度じっくりコードを眺めてみることにする。

2013年10月30日水曜日

NPZ Visualizerをhtml5&javascriptで作りたい

昨日の一年生のラボはNPZ model(栄養塩・植物プランクトン・動物プランクトン)で遊ぶというものでワシントン大学の教授が作ったプログラムを使っていた(http://coast.ocean.washington.edu/~neil/npzvisualizer/)。プログラムはJavaで書かれていてラボにあったパソコンからだとIEかつJavaが更新されていることが利用できる条件だった。ちょっと不便だよね。。

Javaは全くわからんがhtml5とjavascriptを使って書き直してみたいと思いいろいろ検索すると「HTML5による物理シミュレーション環境の構築 ~WebGLライブラリThree.js 入門」というのを見つけた。

これを参考にすれば上記のJavaプログラムと同じようなのを作れるかもしれない。

土日にやってみるかな。

こういうところで礼拝しています。

大学内での礼拝はできるだけ合同礼拝に参加するようにしています。
sedgewick buildingにある礼拝所
ビクトリア大学にはムスリム専用の礼拝所がSedgewick Buildingにあります(アルハムドゥリッラー)。流し台もあるのでウドゥーもしやすい。
しかしSedgewick buildingは立地が少々悪い(キャンパスの中央から若干距離がある)ので合同礼拝をしようとしてもあまり人が集まりません。そこで図書館の地下階の隅っこにある普段ほとんど人のくることのない通路に二人一組で並んで礼拝します。多い時で四列できたりします。もっともっと増えるといいが。
大学外ですがビクトリア唯一のモスク、マスジド・アル・イマーンの中です。歩いて十二分なので朝の礼拝は天気が悪くない限りここに来れるようにアラームをセットします。

この他に金曜礼拝は大学のチャペルでも行われます。またカモソンカレッジにもリッチモンドハウスという建物内に礼拝室が設けられています。ありがたいこってす(^ ^)

2013年10月29日火曜日

オンキャンパスハウジングの違い

この前友達が言っていた。ビクトリア大学の学生寮は一年生しか住めないらしい。一年後はみんな出て行かないといけないんだって。そしたらメモリアル大学や他の多くのカナダの大学みたいに上級生(senior)がfroshと呼ばれる新入生をいろいろいじったりいろんなことさせたりするfroshingという伝統のようなものはないんだろうな。寮別スポーツ大会とかもないんかな?

メモリアル大学の寮には初めて来た年に住んだけどあんまり馴染めなかったな。みんな高校卒業したて&親元離れたての人ばかりでパーティなんかしてはしゃぎたい年頃の人ばかりだった。自分はというと高卒後日本で一年間一人暮らしを経てやって来たわけだったのでそういう年頃はもう過ぎていたような。。

寮に住んでよかったことは

  • 家賃が安い(月$250ぐらいだったような?)
  • 授業にすぐ&Tシャツにスリッパで行ける(雪が積もっても移動できるようにメモリアル大学キャンパス内には地下トンネルが張り巡らされている)
  • 食事を作らなくていい(みんな食堂で食べる)
  • 友達といつでも遊べる(一年目にできた友達は寮又は学内アパートに住んでいた友達がほとんどだった)
逆に悪かったことは
  • 食費が高い(家賃が安いからかしらないが食事は一食10㌦ぐらいした)
  • プライバシーがほとんどない(新入生は基本二人一部屋。トイレ&シャワーは各階の住人と共有。男女別)
  • ほぼ毎週末パーティをやっている(quiet hourと呼ばれる静かにする時間帯あり。またquiet floorと呼ばれる静かにすることを約束された階もあるが部屋数に限りがある)
  • 勉強する環境には向いていない(友達の遊びの誘いが常にある状態)

大学留学で初めてカナダに来る、という人はいろいろ不安もあると思うので大学内の寮やアパートに住むことをお勧めします。オフキャパスはリース(賃貸契約)や電気代の支払いなど英語圏が初めての場合難しいことが多いと思います。

基本的にオンキャンパスハウジングは人気があるので早めに希望を出しておくことをお勧めします。場合によっては大学入学出願する前に希望を出すこともできます。僕の場合大学院(M1)の時大学院用の寮に住んだんですがそのときは住みたい一年前に希望をだしました。またビクトリア大学の家族用アパートにも入学願書を出した次の日(2月中旬)に希望を出しましたが希望者が多かった又は空き部屋が無く結局9月入居は無理っぽかったのであきらめました。まぁ今住んでいるところで十分満足しているんですが。

2013年10月18日金曜日

test case: nns_annual



Mixing in Northern North Sea including the NPZD bio-geochemical model: http://www.gotm.net/index.php?go=software&page=testcases

More about this case: http://www.gotm.net/pages/documentation/manual/stable/html/node237.html#nns_annual

Biogeochemical Model: NPZD (4 variables)
Advection scheme for vertical motion: TVD with ULTIMATE QUICKEST
ODE scheme for source and sink dynamics: Modified Patankar-RK (2. order, conservat., posit.)

bio_npzd.nml

I am going to play around with this file.

".value" files

This type of file gives you the list of parameters or T/F statements of your choice for the run. Can be useful to keep track of your simulation settings.

sst and sss restoring (every 3 hours with 3-D model output)

temperature and salinity resotring (whole depth, every 12 hours with 3-D model output)

dt = 1 hour

Sensitivity Analysis: Select 5 parameters.

Parameter Number.  Code Name: Default Value: Line Number in "bio_npzd.nml"

  1. I_min: 25.: L39
  2. rmax: 1.: L40
  3. gmax: 0.2: L41
  4. alpha: 1.35: L43
  5. rzd: 0.02: L49

How to rewrite a specific line using sed: http://www.linuxquestions.org/questions/programming-9/bash-replace-a-line-in-text-file-631208/#post3102926

c=1 for -5%
c=2 for +5%
c=3 for -25%
c=4 for +25%


I created a simpler script than the one I created before for PISCES:

sensitivity.sh


#---------------------------------------------------------------
for it in `seq 1 5`; #Number of cases
do
for it2 in `seq 1 4`; #Number of parameters
do

testname="p${it}c${it2}.nc" #p=parameter number, c=case number

casenum=${testname:3:1}
if [ $casenum -eq 1 ]
then
 variation="0.8"
elif [ $casenum -eq 2 ]
then
 variation="0.95"
elif [ $casenum -eq 3 ]
then
 variation="1.05"
elif [ $casenum -eq 4 ]
then
 variation="1.2"
fi

parnum=${testname:1:1}
if [ $parnum -eq 1 ]
then
 sed -i "39s/.*/  I_min=       `echo "scale=5;25.*$variation"|bc`/" bio_npzd.nml
 grep "I_min=" bio_npzd.nml >> samemo.txt
elif [ $parnum -eq 2 ]
then
 sed -i "40s/.*/  rmax=        `echo "scale=5;1.*$variation"|bc`/" bio_npzd.nml
 grep "rmax=" bio_npzd.nml >> samemo.txt
elif [ $parnum -eq 3 ]
then
 sed -i "41s/.*/  gmax=        `echo "scale=5;0.2*$variation"|bc`/" bio_npzd.nml
 grep "gmax=" bio_npzd.nml >> samemo.txt
elif [ $parnum -eq 4 ]
then
 sed -i "43s/.*/  alpha=       `echo "scale=5;1.35*$variation"|bc`/" bio_npzd.nml
 grep "alpha=" bio_npzd.nml >> samemo.txt
elif [ $parnum -eq 5 ]
then
 sed -i "49s/.*/  rzd=         `echo "scale=5;0.02*$variation"|bc`/" bio_npzd.nml
 grep "rzd=" bio_npzd.nml >> samemo.txt
fi
./rungotm
mv nns_annual.nc output/$testname
cp bio_npzd_original.nml bio_npzd.nml

done
done
#------------------------------------------------------



By producing output for each run in "samemo.txt", it helped me to check if the modifications were made in "bio_npzd.nml" appropriately.

One thing I learned from making this script: the square brackets [ ] in IF statements have to be isolated (a space before and after [ or ]).

図書館の違い

UVic(ビクトリア大学)へやってきてもう少しで2ヶ月が経とうとしている。まだ二ヶ月?っという感じだが毎日充実して過ごせている証拠だろう。

MUN(メモリアル大学)で修士論文を提出したことを証明するのに約2週間ほどかかってしまったがようやくStudent ID(学生証)が手に入ったので最近図書館をよく利用している。そこで双方の大学の図書館での違いに気づかされたので紹介する。

本の入手はMUNのほうが簡単

図書館のウェブサイトから欲しい本を検索してその本が借りられていない場合その本がどこにあるかをメモして自分で足を運んで手に入れる。

これは多分普通のことだと思うがMUNではリクエストすれば職員の方が事前に見つけて本を受付カウンターに保管しておいてもらうことができる。本が見つかり次第Eメールで連絡が入り5日以内に受け取ればいい。これは今思うとすごくありがたいサービスだった。

UVicでは本の貸し出しをセルフサービスできる

リコールした本が届いたというメールが図書館からあったので受付カウンターへ行ってみると「リコールされた本は向こうの戸棚に並べてあるから自分で探してからここで借りるかそこにある機械を使って借りて」と言われた。

本のバーコードと学生証を画面の指示に従って自分でスキャンする。これは便利。

2013年10月9日水曜日

Successfully compiled FABM!

With the developer's version of GOTM (GOTM/gotm-git), I was able to follow all the steps including the simulation of 0d test case: http://sourceforge.net/apps/mediawiki/fabm/index.php?title=Downloading_and_compiling_FABM_(Windows,_Linux)

However, I get errors when I try to do the same with the stable version of GOTM (i.e. gotm-4.0.0). Perhaps, FABM only couples with the developers version?

Anyways, at the end of the step, I get the following files in the "testcases/0d" directory:

-rw-r--r-- 1 hakase users  723 Oct  4 14:25 run.nml
-rw-r--r-- 1 hakase users  524 Oct  4 14:25 plotresults.py
-rw-r--r-- 1 hakase users  233 Oct  4 14:25 Makefile
-rw-r--r-- 1 hakase users   65 Oct  4 14:25 env.dat
drwxr-sr-x 5 hakase users 4.0K Oct  7 15:53 ..
-rwxr-xr-x 1 hakase users  356 Oct  9 10:45 doit
-rwxr-xr-x 1 hakase users 318K Oct  9 10:45 fabm0d
lrwxrwxrwx 1 hakase users   30 Oct  9 10:47 fabm.nml -> ../fabm-gotm-multiple-npzd.nml
-rw-r--r-- 1 hakase users  22M Oct  9 10:47 output.dat
-rw-r--r-- 1 hakase users 2.5K Oct  9 10:47 log

By default, the output is produced in .dat format. Plotting of this output data can be done simply executing:

python plotresults.py

Then,

swr.png

is produced, which looks like:
swr.png
Pretty cool! Now I can create my own testcases.

2013年10月8日火曜日

ビクトリア大学(UVic)大学院の学費はいくら?

ビクトリア大学(University of Victoria)へ大学院留学を考えている方の参考になればと思い今年度の秋&春学期の学費を紹介します。これは大学院博士課程(理系)の場合です。理系と文系、または学科によって支払う金額が異なるかもしれませんが目安として考えていただけたらいいと思います。
こちらが秋学期(9月ー12月)。赤い線は気にしないでください。

そしてこちらが春学期(1月ー4月)。
項目が少なくてわかりやすいですね。UVIC Athleticsは体育館や施設の利用料、Grad Student Societyは院学生会(ユニオン)、GSS Extended Healthはユニオンが提供する追加医療保険、GSS Dental Planはユニオンが提供する歯科保険、GSS Bus Passはユニオンが提供するバス定期券、Graduate -International-Wは大学院留学生学費(Wの意味はわかりません)。

保険料は秋学期に年間費として支払いますがユニオンに頼めば月1回の12回払いにすることもできます(この場合手数料$25がかかります)。

いつから支払うことができるのか?

それぞれの学期の登録(registration)をした時点で支払いをすることができます。

いつまでに支払わなければいけないのか?

それぞれの学期の初めの月の月末までに学費は納めないといけません。つまり秋学期の場合9月30日、春学期の場合1月31日。

夏学期は…?

夏学期は春学期と同等の学費を納めます(夏学期の登録がまだなので絶対とは言えませんが恐らく)。

2013年10月7日月曜日

FABM compilation (Progress 4)

Following, http://sourceforge.net/apps/mediawiki/fabm/index.php?title=Downloading_and_compiling_FABM_(Windows,_Linux), I get an error at the step 'compile the 0d test driver...':

fabm0d.F90:14.11:

   use time
           1
Fatal Error: Can't open module file 'time.mod' for reading at (1): No such file or directory
make[1]: *** [fabm0d.o] Error 1




Not too sure where fabm0d.F90 is located (or even if it exists).

Fixing this will be the next step.

FABM compilation with gotm-git (Progress 3)

Problem after an attempting to compile FABM:

fabm_standard_variables.F90:205.133:

flux = collection%attenuation_coefficient_of_photosynthetic_radiative_flux
                                                                           1                                                        
Warning: Line truncated at (1)
fabm_standard_variables.F90:206.6:

      cell_thickness = collection%cell_thickness, &
      1
Error: Unclassifiable statement at (1)
fabm_standard_variables.F90:229.133:

_air = collection%surface_downwelling_photosynthetic_radiative_flux_in_air
                                                                           1                                                        
Warning: Line truncated at (1)
fabm_standard_variables.F90:230.6:

      surface_downwelling_shortwave_flux = collection%surface_downwelling_short
      1
Error: Unclassifiable statement at (1)
make: *** [fabm_standard_variables.o] Error 1


I added an extra option in 'compilers/compiler.GFORTRAN':

EXTRAS = -ffree-line-length-135






Then, it works.. Then a new error arises:


Problem:

fabm_types.F90:2325.134:

nk%target%standard_variable,horizontal_link2%target%standard_variable).and. 
                                                                           1                                                           
Error: Syntax error in expression at (1)
fabm_types.F90:2326.44:

                   is_null_standard_variable(horizontal_link2%target%standard_v
                                            1
Error: 'is_null_standard_variable' at (1) is not a variable
fabm_types.F90:1202.30:

subroutine append_string(array,string,exists)
                              1
Error: Dummy 'array' at (1) cannot have an initializer
make: *** [fabm_types.o] Error 1

Solution:

This was actually again related to the length of the statement. So instead of 135, I gave a larger number (e.g. 200) then it was solved.

EXTRAS = -ffree-line-length-200

Alternatively,

EXTRAS = -ffree-line-length-none

is ok too.


What's next?

Problem:

fabm_types.F90:1202.30:

subroutine append_string(array,string,exists)
                              1
Error: Dummy 'array' at (1) cannot have an initializer
make: *** [fabm_types.o] Error 1

Solution:

I modified few lines as follows (!HakaseA is the beginning and !HakaseZ is the end of modifications).

subroutine append_string(array,string,exists)
!HakaseA
!   character(len=attribute_length),dimension(:),_ALLOCATABLE_ :: array _NULL_
   character(len=attribute_length),dimension(:),_ALLOCATABLE_ :: array
!HakaseZ
   character(len=*),intent(in) :: string
   logical,intent(out),optional :: exists
   integer :: i
   character(len=attribute_length),allocatable :: oldarray(:)
   if (.not._ALLOCATED_(array)) then
      allocate(array(1))
   else
      do i=1,size(array)
         if (array(i)==string) then
            if (present(exists)) exists = .true.
            return
         end if
      end do

      allocate(oldarray(size(array)))
      oldarray = array
      deallocate(array)
      allocate(array(size(oldarray)+1))
      array(1:size(oldarray)) = oldarray
      deallocate(oldarray)
   end if

   array(size(array)) = string
   if (present(exists)) exists = .false.
!HakaseA
   nullify(array)
!HakaseZ

I have replaced the position of the nullify(array) command from the previous attempt (http://abdulhaqq09.blogspot.ca/2013/10/fabm-compilation-progress-1.html), which gives a different result. Not sure which would be the right choice.. I switched the position this time based on the fact that nullify(variable) was used twice in this file and both were placed at the end of function.



More and more problems!!


Problem:

npzd.F90:504.200:

elf%id_p%state_index) + (primprod);pp (i__-fabm_loop_start+1,self%id_p%stat
                                                                           1                                                                                                                             
Error: 'stat' at (1) is not a member of the 'type_state_variable_id' structure
npzd.F90:505.200:

elf%id_z%state_index) + (fpz(self,p,z));pp (i__-fabm_loop_start+1,self%id_z
                                                                           1                                                                                                                             
Error: Invalid form of array reference at (1)
npzd.F90:506.200:

elf%id_n%state_index) + (self%rpn*p);pp (i__-fabm_loop_start+1,self%id_n%st
                                                                           1                                                                                                                             
Error: 'st' at (1) is not a member of the 'type_state_variable_id' structure
npzd.F90:507.200:

elf%id_n%state_index) + (self%rzn*z);pp (i__-fabm_loop_start+1,self%id_n%st
                                                                           1                                                                                                                             
Error: 'st' at (1) is not a member of the 'type_state_variable_id' structure
npzd.F90:508.200:

elf%id_n%state_index) + (self%rdn*d);pp (i__-fabm_loop_start+1,self%id_n%st
                                                                           1                                                                                                                             
Error: 'st' at (1) is not a member of the 'type_state_variable_id' structure
npzd.F90:509.200:

elf%id_d%state_index) + (rpd*p);pp (i__-fabm_loop_start+1,self%id_d%state_i
                                                                           1                                                                                                                             
Error: 'state_i' at (1) is not a member of the 'type_state_variable_id' structure
npzd.F90:510.200:

elf%id_d%state_index) + (self%rzd*z);pp (i__-fabm_loop_start+1,self%id_d%st
                                                                           1                                                                                                                             
Error: 'st' at (1) is not a member of the 'type_state_variable_id' structure
make[3]: *** [npzd.o] Error 1
make[3]: Leaving directory `/HOME/hakase/FABM/fabm-git/src/models/gotm/npzd'
make[2]: *** [objs] Error 2
make[2]: Leaving directory `/HOME/hakase/FABM/fabm-git/src/models/gotm'
make[1]: *** [objs] Error 2
make[1]: Leaving directory `/HOME/hakase/FABM/fabm-git/src/models'
make: *** [models] Error 2

Solution:

The problem here again is the length of the statement. I guess '200' is not enough. Maybe better off with the option:

EXTRAS = -ffree-line-length-none




Following http://sourceforge.net/apps/mediawiki/fabm/index.php?title=Obtaining_and_compiling_FABM, I think it is done as it successfully created lib/$(FABMHOST)/$(FORTRAN_COMPILER)/libfabm_prod.a

2013年10月4日金曜日

Things learnt today by playing with GOTM

Biogeochemical models:

I downloaded the case "gotland": http://www.gotm.net/cases/v4.0/gotland.tar.gz

This configuration contains biogeochemical component, defined by 'bio.nml'.

'gotmrun.nml':

model basics: time step, time resolution, space, input/output, title, etc.

'bio.nml':

settings for biogeochemical model: which model? choice of advective schemes? etc.

In 'gotland' case, 'bio_model = 2', meaning the biogeochemical model is IOW-ERGOM (9 state variables).

There are three other models to choose from: NPZD, Suspended matter only (not sure what it is), and Fasham et al 1990 7-compartment model.

All biological models are stored in "src/extras/bio/" directory. You have to recompile GOTM (i.e. reproduce gotm_prod_GFORTRAN) if and when you want to modify these models.

I've confirmed this by modifying the parameter for IOW-ERGOM model (bio_iow.F90):

      iopt=max(0.25*I_0,I_min)

I change the default value of 0.25 to 100 (randomly selected), and recompile GOTM, then compare the results for diatoms concentration at the end of 1-year model integration by "ncdump -v dia gotland.nc" then the values were much different, as expected!

Next I should find out how to create my own configuration (e.g. via CPP keys as in NEMO? or something else?)

At this point, I still can't compile FABM (some fortran errors).

Testing with ows_papa

Following [5.4] of http://www.gotm.net/index.php?go=software&page=installation, the executable 'gotm_prod_GFORTRAN' was created, which was placed in '~/GOTM/gotm-git/bin' directory.

Now, I test-run the model with the case 'ows_papa'. First, download the two files (http://www.gotm.net/cases/v4.0/ows_papa.tar.gz and http://www.gotm.net/cases/v4.0/ows_papa.gotmscenario) here: http://www.gotm.net/index.php?go=software&page=testcases

Then I placed all the downloaded files into 'ows_papa' directory.

Then I created '~/GOTM/gotm-git/mine' directory, in which all my scenarios will be stored. I stored 'ows_papa' here.

In 'ows_papa', do:

ln -sf ../../bin/gotm_prod_GFORTRAN gotm

Then for the rest, follow 6.3-6.5 of http://www.gotm.net/index.php?go=software&page=installation. Step 6.3 is not applicable to ows_papa.

As I execute './gotm', I get the following error:

init_observations
At line 449 of file observations.F90 (unit = 10, file = 'obs.nml')
Fortran runtime error: End of file


I am not sure what this means. The same problem arises if I test-run with the case 'couette'.

However, such problem does not occur with the stable (non-developer) version 'gotm-4.0.0', as 'src/observations/observations.F90' in 'gotm-4.0.0' is not the same as that in 'gotm-git' apparently.

I guess I will use this version for now..

GOTM-FABM developers version compilation progress 2

Following this instruction (http://www.gotm.net/index.php?go=software&page=installation), I had some technical (fortran) problem during the step 5.3-5.4.

Problem 1: input/input.F90 Line 158

      FATAL 'input module has been initialized without depth information; depth-explicit inputs can therefore not be registered.'

My compiler (gfortran) seems not to like words being too long. I thought of two solutions:

1) make the compiler being able to deal with long statements; or
2) make the sentence short.

Solution 1:

I modified my executable file for 'make' as follows:

#HakaseA
EXTRAS = -ffree-line-length-none
#HakaseZ


Solution 2: 

I modified 'input.F90' as follows:

!HakaseA
!      FATAL 'input module has been initialized without depth information; depth-explicit inputs can therefore not be registered.'
      FATAL 'Check input/input.F90 line 158 for detail.'
!HakaseZ

Either way works but I decided to stick with Solution 2, as I was not sure what else the compiler option 1 could do. 

2013年10月3日木曜日

FABM compilation Progress 1

Problem:


fabm_types.F90:1202.??:

   
   subroutine append_string(array,string,exists)
                                                   1
Error: Dummy 'array' at (1) cannot have an initializer

Solution:

I modified "fabm_types.F90" in "fabm-git/src". Reference: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45337#c2

subroutine append_string(array,string,exists)
!HakaseA
!   character(len=attribute_length),dimension(:),_ALLOCATABLE_ :: array _NULL_
   character(len=attribute_length),dimension(:),_ALLOCATABLE_ :: array
!HakaseZ
   character(len=*),intent(in) :: string
   logical,intent(out),optional :: exists
   integer :: i
   character(len=attribute_length),allocatable :: oldarray(:)
!HakaseA
   nullify(array)
!HakaseZ

Problem:

phy.F90:199.18:

   primprod = fnp(self,n,p,par,iopt)
                  1
Error: Type mismatch in argument 'self' at (1); passed CLASS(type_examples_npzd_phy) to TYPE(type_examples_npzd_phy)

Solution:

Not sure... Working on it. Relevant resource: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46990