ラベル NEMO-PISCES の投稿を表示しています。 すべての投稿を表示
ラベル NEMO-PISCES の投稿を表示しています。 すべての投稿を表示

2017年4月26日水曜日

Generating PIOMAS_initialization.nc

 1014  vi namelist.piomas2naa 
 1015  ../bin/sosie.x -f namelist.piomas2naa 
 1016  vi namelist.piomas2naa 
 1017  ../bin/sosie.x -f namelist.piomas2naa 
 1019  ncks -h -A SIC_PIOMAS_1979_2013-naa_arlan.nc4 SIT_PIOMAS_1979_2013-naa_arlan.nc4 
 1021  mv SIT_PIOMAS_1979_2013-naa_arlan.nc4 PIOMAS_NAA_1979_2013.nc4
 1022  mv PIOMAS_NAA_1979_2013.nc4 ~/scratch/input_naa/hhayashi/piomas/
 1024  cdo seltimestep,1/1 ~/scratch/input_naa/hhayashi/piomas/PIOMAS_NAA_1979_2013.nc4 PIOMAS_initialization.nc
 1031  cdo chname,SIT,hicif PIOMAS_initialization.nc PIOMAS_initialization.nc2 
 1033  cdo chname,SIC,frld PIOMAS_initialization.nc2 PIOMAS_initialization.nc3 
 1041  ncap -s "frld2=1.-frld" PIOMAS_initialization.nc3 PIOMAS_initialization.nc4
 1043  ncks -x -v frld PIOMAS_initialization.nc4 PIOMAS_initialization.nc5
 1046  cdo chname,frld2,frld PIOMAS_initialization.nc5 PIOMAS_initialization.nc6
 1050  mv PIOMAS_initialization.nc6 ~/scratch/input_naa/hhayashi/piomas/PIOMAS_initialization.nc 

References:
https://code.zmaw.de/boards/1/topics/996 
http://research.jisao.washington.edu/data_sets/nco/#example5

2017年4月17日月曜日

LIM2 read air temperature to decide if snow or rain

CORE2で行くのでもう必要ないけどもしいつか必要になった時のために残しておくことにする。


2017年4月12日水曜日

random notes

one way to make existing "time" dimension to be "unlimited": 

cdo seltimestep,1/12 ifile ofile
 
where 1/12 is the first and last indices of your time record. 
Ref: https://code.zmaw.de/boards/1/topics/798


 1057  cdo seltimestep,1/1 sic_G10010_SIBT1850_v1.1-naa_icecon.nc4 sic.nc
 1058  cdo seltimestep,1/1 sit_G10010_SIBT1850_v1.1-naa_icecon.nc4 sic.nc
 1059  cdo seltimestep,1/1 sit_PIOMAS_1979_2013-naa_arlan.nc4 sit.nc 
Add all variables in sic.nc to sit.nc
 1062  ncks -h -A sic.nc sit.nc 
Remove time_counter dimension from the lists of dimensions and variables. 
 1065  ncwa -a time_counter sit.nc sit2.nc





Same names (labels) but different IDs for nodes in PyGraphviz:
 
add_node(1,label=A)
add_node(2,label=B)
add_node(3,label=A)
 
will create three nodes consisting of two As and one B. 
Ref: http://stackoverflow.com/questions/15711909/how-to-create-duplicate-nodes-in-pygraphviz


2017年4月5日水曜日

interpolate woa13 no3 field onto NAA grid using SOSIE

I had little trouble interpolating the woa13 no3 data onto NAA grid. SOSIE was creating high values (first figure; set to the prescribed vmax of 100. in this plot) along the coast lines. I was not sure why, but what solved this issue was to change ldrown from F to T:

cf_lsm_in = 'missing_value' ! we use 'missing_value' of input field to determine
cv_lsm_in = ''                ! the land-sea-mask

ldrown    = F            ! we want to propagate sea values onto the land-sea mask


Here, the last line is modified as follows:

ldrown    = T 


Then the interpolation improved (second figure).

Furthermore, the interpolation is not too bad compared to the original file (third figure), although it may underestimate no3 in the beaufort region.

interpolated field with ldrown = F

interpolated field with ldrown = T

comparison between the original 1x1 degree data (left) and the interpolated data (right)

2017年4月3日月曜日

snow and ice melt rate

rdmsnif/rdt_ice is snow melt rate (m/s) averaged over ice covered area, and not over the entire grid cell. Otherwise the code below should include the coefficient "1-frld" in the last term:

limsbc_2.F90

!  computing freshwater exchanges at the ice/ocean interface
            zemp = + emp(ji,jj)     *         frld(ji,jj)      &   !  e-p budget over open ocean fraction 
               &   - tprecip(ji,jj) * ( 1. -  frld(ji,jj) )    &   !  liquid precipitation reaches directly the ocean
               &   + sprecip(ji,jj) * ( 1. - pfrld(ji,jj) )    &   !  change in ice cover within the time step

               &   + rdmsnif(ji,jj) * r1_rdtice                    !  freshwater flux due to snow melting 


2017年3月14日火曜日

iceno3 initialization problem

Issue: iceno3 was initialized to a spatially uniform value defined in PISCES/trcini_pisces.F90. This is not what we want. Later, PISCES jpno3 is updated by initialized by WOA data, which is what we want iceno3 to be initialized with.

Here is to show that iceno3 was initialized to a spatially uniform value across the domain:

 iceno3 initialized to:    31.0400000000000        31.0400000000000
   31.0400000000000        31.0400000000000        31.0400000000000
   31.0400000000000        31.0400000000000        31.0400000000000
   31.0400000000000        31.0400000000000        31.0400000000000
   31.0400000000000        31.0400000000000        31.0400000000000
   31.0400000000000        31.0400000000000        31.0400000000000
   31.0400000000000        31.0400000000000        31.0400000000000
   31.0400000000000        31.0400000000000        31.0400000000000
   31.0400000000000        31.0400000000000        31.0400000000000


Here is to show that initialization of my_trc tracers is done before pisces tracers are updated with input data (trcini.F90):


      IF( lk_pisces  )       CALL trc_ini_pisces       ! PISCES  bio-model
      IF( lk_cfc     )       CALL trc_ini_cfc          ! CFC     tracers
      IF( lk_c14b    )       CALL trc_ini_c14b         ! C14 bomb  tracer
      IF( lk_my_trc  )       CALL trc_ini_my_trc       ! MY_TRC  tracers

      IF( lwp ) THEN
         !
         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
         !
      ENDIF

      IF( ln_trcdta )      CALL trc_dta_init


      IF( ln_rsttr ) THEN
        !
        CALL trc_rst_read              ! restart from a file
        !
      ELSE
        !
        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
            !
            CALL wrk_alloc( jpi, jpj, jpk, nb_trcdta, ztrcdta )    ! Memory allocation
            !
            CALL trc_dta( nit000, ztrcdta )   ! read tracer data at nit000
            !
            DO jn = 1, jptra
               IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
                  jl = n_trc_index(jn)
                  trn(:,:,:,jn) = ztrcdta(:,:,:,jl) * tmask(:,:,:)
               ENDIF
            ENDDO
            CALL wrk_dealloc( jpi, jpj, jpk, nb_trcdta, ztrcdta )
        ENDIF
        !
        trb(:,:,:,:) = trn(:,:,:,:)
        !
      ENDIF
I tried to add the following line just before the second last "ENDIF" statement above:

iceno3(:,:)=trn(:,:,1,jpno3)

However, the compilation error occurred which appears to be related to the ordering:

No rule to make target `trc_sms_my_trc.o', needed by `trcini.o'.

Thus, I had to instead initialize the ice BGC tracers in trcsms_my_trc.F90 instead of trcini_my_trc.F90 as follows:

      IF( kt == nit000 ) THEN
       IF( .NOT. ln_rsttr .AND. ln_trcdta ) THEN
        icedia(:,:) = trn(:,:,1,jpdia)
        write(numout,*) "iceno3 before is: ",iceno3
        iceno3(:,:) = trn(:,:,1,jpno3)
        write(numout,*) "iceno3 after is: ",iceno3
        icenh4(:,:) = trn(:,:,1,jpnh4)
       END IF
      END IF

The output from WRITE statements prove that the values have changed:

 iceno3 before is:   0.000000000000000E+000  0.000000000000000E+000
  0.000000000000000E+000  0.000000000000000E+000  0.000000000000000E+000
  0.000000000000000E+000  0.000000000000000E+000  0.000000000000000E+000
  0.000000000000000E+000  0.000000000000000E+000  0.000000000000000E+000
  0.000000000000000E+000  0.000000000000000E+000  0.000000000000000E+000
   31.9878976156660        31.0438701002330        31.0369201106744
   31.0369205118954        31.0383482948276        31.0616767301434
   31.0677629528971        31.0492132090291        31.0419920432535
   31.0440657798248        31.0444710620824        31.0447721884932
   31.0375292688435        31.0382076116362        31.0373801558268
   31.0398029146832        31.0397625744607        31.0331636088933
   31.0327651221495        31.0220553651313        31.0230092701832
   31.0342232771140        31.0552545248760        31.0397772061968
   31.0473470388971        31.0546418640872        31.0543800885964


 iceno3 after is:   0.000000000000000E+000  6.051918107557494E-007
  6.110130904164567E-007  6.165130718275732E-007  6.223610345536756E-007
  6.282784081119133E-007  6.347854462720852E-007  6.416655223934390E-007
  6.425374792240063E-007  6.518916947527300E-007  6.615196029420712E-007
  6.710462543721832E-007  6.779537599405078E-007  6.832150836929839E-007
  1.485887675109245E-002  0.101301152128998       0.192842913115538
  0.288261717144609       0.410586225212846       0.567104111609461
  0.750865673296165       0.954964841291094        1.17256469087027
   1.39693899756850        1.62147709851657        1.83974371937518
   5.90219173052099        5.72045383050733        5.52942332795475
   5.33964213875681        5.16237601645325        4.98851212702143
   4.79097327138552        4.58829697326475        4.38163145548577
   4.17732627934004        3.98400314182262        3.81032497675204
   3.66491610553454        3.57114941381793        3.59987527391656

Although this may not be the best method (i.e. IF statement if not desirable for fast computing), this is it for now.

2016年11月28日月曜日

ttest in namelist_ice

Why set ttest? Shouldn't we be creating ice if sst is at freezing point of sea water?


namelist_ice

ttest       =  2.0      !  threshold water temperature for initial sea ice


Source: http://forge.ipsl.jussieu.fr/little_nemo/browser/vendor/nemo/current/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90?rev=2

95

      t_bo(:,:) = tfreez( tsn(:,:,1,jp_sal) ) * tmask(:,:,1)       ! freezing/melting point of sea water [Celcius]
96
97      DO jj = 1, jpj                                       ! ice if sst <= t-freez + ttest
98         DO ji = 1, jpi
99            IF( tsn(ji,jj,1,jp_tem)  - t_bo(ji,jj) >= ttest ) THEN   ;   zidto(ji,jj) = 0.e0      ! no ice
100            ELSE                                                     ;   zidto(ji,jj) = 1.e0      !    ice
101            ENDIF
102         END DO
103      END DO

2016年10月20日木曜日

lbc_lnk in TOP_SRC

In LOBSTER, lbc_lnk is called for the prognostic variables in the uppermost layer only:

LOBSTER/trcbio.F90:            CALL lbc_lnk( zw2d(:,:,jl),'T', 1. )
LOBSTER/trcbio.F90:            CALL lbc_lnk( zw3d(:,:,:,jl),'T', 1. )
LOBSTER/trcbio.F90:            CALL lbc_lnk( trbio(:,:,1,jl),'T', 1. )
LOBSTER/trcexp.F90:      CALL lbc_lnk( sedpocn, 'T', 1. )
LOBSTER/trcini_lobster.F90:      CALL lbc_lnk( cmask, 'T', 1. )

While in PISCES, it is called for the entire water column:

PISCES/p4zsed.F90:         CALL lbc_lnk( zcmask , 'T', 1. )      ! lateral boundary conditions on cmask   (sign unchanged)
PISCES/p4zsed.F90.v1:         CALL lbc_lnk( zcmask , 'T', 1. )      ! lateral boundary conditions on cmask   (sign unchanged)
PISCES/p4zsed.F90.v2:         CALL lbc_lnk( zcmask , 'T', 1. )      ! lateral boundary conditions on cmask   (sign unchanged)
PISCES/trcsms_pisces.F90:        CALL lbc_lnk( trn(:,:,:,jn), 'T', 1. )
PISCES/trcsms_pisces.F90:        CALL lbc_lnk( trb(:,:,:,jn), 'T', 1. )
PISCES/trcsms_pisces.F90:        CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )
PISCES/trcsms_pisces.F90:           CALL lbc_lnk( trn(:,:,:,jn), 'T', 1. )

While CFC and C14b do not use "lbc_lnk" subroutine.


2016年10月13日木曜日

model stops running after tra_nxt

On Nestor, the biogeochemical model with MY_TRC stops after this step in ocean.output:

 tra_nxt : achieve the time stepping by Asselin filter and array swap
 ~~~~~~~

tracer.stat only has the output for the first time step.

         1  0.7887250137E+03

This problem still occurs after recompiling the model without MY_TRC, so it's not the problem with MY_TRC.

I copied the source code for TOP_SRC that works on Jasper to Nestor, and tested (b4_tra_nxt_ref_cmoc06.7/EXP01). But the problem still exists. Thus, this might be specific to Nestor.

I increased from procs=12 to =24, but still the model hangs at "tra_nxt".

UPDATE on Oct.16
This issue is fixed. Although I cannot be 100% certain (because of my forgetfulness), this problem might have been due to the compiler option not being correctly set. In particular in arch-nestor_hh.fcm:

%FC                  mpif90 -r8 -i4 -fp-model source

The bolded flags were missing. I should double-check this.

2016年10月11日火曜日

makenemo fails in nestor

I can compile (./makenemo) in Japer, while I cannot in Nestor. With Nestor, I get the following error:

./makenemo -m ifort_hpcnestor_pisces_x -n physics_only_naa

mpif90 -o nemo.exe /home/hhayashi/nemo_eric/CONFIG/physics_only_naa/BLD/obj/nemo.o -L/home/hhayashi/nemo_eric/CONFIG/physics_only_naa/BLD/lib -l__fcm__nemo -shared-intel -mcmodel=medium -L/global/software/netcdf-4.1.3/lib -lnetcdf -lnetcdff
ld: cannot find -ltorque
fcm_internal load failed (256)
gmake: *** [nemo.exe] Error 1
gmake -f /home/hhayashi/nemo_eric/CONFIG/physics_only_naa/BLD/Makefile -j 1 all failed (2) at /g01/home/hhayashi/nemo_eric/EXTERNAL/fcm/bin/../lib/Fcm/Build.pm line 597

torque library does exist:

ldconfig -p | grep libtorque

    libtorque.so.2 (libc6,x86-64) => /opt/torque-2.5.13/lib/libtorque.so.2
    libtorque.so (libc6,x86-64) => /opt/torque-2.5.13/lib/libtorque.so

After some googling, I found the solution (ref: http://stackoverflow.com/a/16710346). I had to explicitly locate the library path for torque in the ARCH file (for %NCDF_LIB):

-L/opt/torque-2.5.13/lib -ltorque



2016年10月10日月曜日

blow up issue solved!

tracer.stat indicates undesirable increase in concentrations of some state variable(s) at the 7th time step:

         1  0.7887250195E+03
         2  0.7887190683E+03
         3  0.8475861522E+03
         4  0.9302648776E+03
         5  0.1044380477E+04
         6  0.1170169324E+04
         7  0.2228768128E+11
         8  0.2853781480E+11
         9  0.5271543990E+11
        10  0.7216373356E+11

After commenting and uncommenting source/sink terms in the equations, I discovered that this was due to fmort1 and fmort2 not property flushed into the water column:

        tra(ji,jj,1,jpgoc) = tra(ji,jj,1,jpgoc) &
                           ! source1: flushing
                           + (1.-f_p2)*flushdia*(1.-frld(ji,jj))*z_ia/e3t(ji,jj,1) &
                           ! source2: linear mortality
                           +0.
!                          + 0.7*fmort1 &
                           ! source3: quadratic mortality
!                          + fmort2


After commenting fmort1 and fmort2 terms above, tracer.stat looks more reasonable:

         1  0.7887289636E+03
         2  0.7887230246E+03
         3  0.7890159536E+03
         4  0.7902228379E+03
         5  0.7905440777E+03
         6  0.7908932570E+03
         7  0.7910913500E+03
         8  0.7913530813E+03
         9  0.7915290453E+03
        10  0.7917645388E+03

2016年10月5日水曜日

When all three my_trc components are added, the tracer.stat increases too rapidly:

tail tracer.stat
         1  0.7895863787E+03
         2  0.3124101036E+04
         3  0.1067765821E+13
         4  0.2180091013E+27
         5  0.8173235638E+41

This still occurs even I remove the icedms component:

         1  0.7895863787E+03
         2  0.3056491046E+04
         3  0.1034367164E+13
         4  0.2180090884E+27
         5  0.8173235638E+41

When I removed the chunk of code about ice ablation/accretion, the tracer.stat became normal:

         1  0.7895862638E+03
         2  0.7895870356E+03
         3  0.7913792876E+03
         4  0.7936409329E+03
         5  0.7949360900E+03

Thus, the problem is here:

         ! Lateral accretion/ablation
        IF(frld(ji,jj)-pfrld(ji,jj) > 0.) THEN ! In case of accretion, newly formed ice will have a tracer concentration of an underlying seawater value.
          icechl(ji,jj) = (1.-pfrld(ji,jj))/(1.-frld(ji,jj)+epsilon10)*icechl(ji,jj) + ((1.-frld(ji,jj))-(1.-pfrld(ji,jj)))/(1.-frld(ji,jj)+epsilon10)*trn(ji,jj,1,jpdch)
          iceno3(ji,jj) = (1.-pfrld(ji,jj))/(1.-frld(ji,jj)+epsilon10)*iceno3(ji,jj) + ((1.-frld(ji,jj))-(1.-pfrld(ji,jj)))/(1.-frld(ji,jj)+epsilon10)*trn(ji,jj,1,jpno3)
          icenh4(ji,jj) = (1.-pfrld(ji,jj))/(1.-frld(ji,jj)+epsilon10)*icenh4(ji,jj) + ((1.-frld(ji,jj))-(1.-pfrld(ji,jj)))/(1.-frld(ji,jj)+epsilon10)*trn(ji,jj,1,jpnh4)
        END IF

2016年10月4日火曜日

interesting segfault

I had a segmentation fault which is due to NaN. However, this was interesting because although the IF statement was always false, it gave me segfault because NaN would result if the IF statement was true.. 

        write(numout,*) 'hhpass: nancheck ',(1.-pfrld(ji,jj))/(1.-frld(ji,jj)+epsilon30)
        IF(frld(ji,jj)-pfrld(ji,jj) > 0.) THEN ! In case of accretion, newly formed ice will have a tracer concentration of an underlying seawater value.
          write(numout,*) 'hhpass: inside if statement'
          icechl(ji,jj) = icechl(ji,jj)/(trn(ji,jj,1,jpdch)+epsilon30)!((1.-pfrld(ji,jj))/(1.-frld(ji,jj)+epsilon30)*icechl(ji,jj) + ((1.-frld(ji,jj))-(1.-pfrld(ji,jj)))/(1.-frld(ji,jj)+epsilon30)*trn(ji,jj,1,jpdch)
        END IF


 Update: This seems to have to do with floating points.

Writing out the output for the variables in dinomenator and numerator show a particular floating point (i.e. 14):

 hhpass: pfrld    1.00000000000000
 hhpass: frld    1.00000000000000





In the example above, I tried avoid the division by zero by introducing epsilon number 30 (i.e. 1.e-30), but the division produced NaN:

hhpass: nancheck    NaN

After this, I instead introduced a epsilon number that is smaller than the floating point of the two variables (i.e. 4). Then the division produced zero:

 hhpass: nancheck   0.000000000000000E+000


Epsilon30 worked for biogeochemical tracers. But not for ice physical tracers (probably a specic floating point number is defined in LIM_SRC_2 for these tracers?)

2016年10月3日月曜日

NaN in tracer.stat --> found the problem!

I used to see NaN in the second time step of tracer.stat. In the first time step you dont see Nan because it is the initial condition.

In the second time step, seawater NO3 was NaN because it was exchanging the NaN value coming from the sea ice NO3, which was due to the lack of epsilon number.

For example, the sink for sea ice NO3 due to ice algal uptake is calculated based on the ratio of NO3 and all other available nitrogen (i.e. NO3 and NH4). When NO3 and NH4 are initially set to 0 in the model (for now), the denominator becomes zero, therefore the sink = NaN, therefore the ice NO3 in the next time step as well as the oceanic NO3 became NaN.

So I fixed this by adding a very small epsilon number to avoid this division by zero.

2014年1月19日日曜日

gen1d.f90

↓最近作ったプログラム(2012年夏)。

! This script extracts the 1-D data from 3-D offline dynamics.

program generate1d
implicit none
INCLUDE 'netcdf.inc'
integer,parameter::jpi=499,jpj=604,jpk=46,jpt=31
integer::ncid,ncfile,tempid,saliid,windid,wateid,swrnid,turbid,icecid,dim1,dim2,dim3,dim4,it,dtemp,dsali,dwind,dicec,dswrn,dturb,dwate
real,dimension(jpi,jpj,jpk,jpt)::temp,sali
real,dimension(jpi,jpj,jpt)::wind,wate,swrn,turb,icec
integer,dimension(3)::stnx,stny,dim1d
integer,dimension(4)::dim2d
real,dimension(3,1,jpk,jpt)::temp1,sali1
real,dimension(3,1,jpt)::wind1,wate1,swrn1,turb1,icec1

! Open the data file
ncfile=nf_open('Lab_T_94_07.nc',nf_nowrite,ncid)
! Inquire the variables
ncfile=nf_inq_varid(ncid,'votemper',tempid)
ncfile=nf_inq_varid(ncid,'vosaline',saliid)
ncfile=nf_inq_varid(ncid,'sowindsp',windid)
ncfile=nf_inq_varid(ncid,'sowaflcd',wateid)
ncfile=nf_inq_varid(ncid,'soshfldo',swrnid)
ncfile=nf_inq_varid(ncid,'somixhgt',turbid)
ncfile=nf_inq_varid(ncid,'soicecov',icecid)
! Extract 3D data
ncfile=nf_get_var_real(ncid,tempid,temp)
ncfile=nf_get_var_real(ncid,saliid,sali)
ncfile=nf_get_var_real(ncid,windid,wind)
ncfile=nf_get_var_real(ncid,wateid,wate)
ncfile=nf_get_var_real(ncid,swrnid,swrn)
ncfile=nf_get_var_real(ncid,turbid,turb)
ncfile=nf_get_var_real(ncid,icecid,icec)
! Close the data file
ncfile=nf_close(ncid)

stnx=(/ 282, 301, 350 /)
stny=(/ 382, 416, 500 /)
do it=1,3
 temp1(it,1,:,:)=temp(stnx(it),stny(it),:,:)
 sali1(it,1,:,:)=sali(stnx(it),stny(it),:,:)
 wind1(it,1,:)=wind(stnx(it),stny(it),:)
 wate1(it,1,:)=wate(stnx(it),stny(it),:)
 swrn1(it,1,:)=swrn(stnx(it),stny(it),:)
 turb1(it,1,:)=turb(stnx(it),stny(it),:)
 icec1(it,1,:)=icec(stnx(it),stny(it),:)
end do

ncfile=nf_create('Lab_T_1d_94_07.nc',nf_share,ncid)
ncfile=nf_def_dim(ncid,'nlon',3,dim1)
ncfile=nf_def_dim(ncid,'nlat',1,dim2)
ncfile=nf_def_dim(ncid,'ndepth',jpk,dim3)
ncfile=nf_def_dim(ncid,'ntime',jpt,dim4)
dim2d(1)=dim1
dim2d(2)=dim2
dim2d(3)=dim3
dim2d(4)=dim4
dim1d(1)=dim1
dim1d(2)=dim2
dim1d(3)=dim4
ncfile=nf_def_var(ncid,'nvotemper',nf_real,4,dim2d,dtemp)
ncfile=nf_def_var(ncid,'nvosaline',nf_real,4,dim2d,dsali)
ncfile=nf_def_var(ncid,'nsowindsp',nf_real,3,dim1d,dwind)
ncfile=nf_def_var(ncid,'nsoshfldo',nf_real,3,dim1d,dswrn)
ncfile=nf_def_var(ncid,'nsoicecov',nf_real,3,dim1d,dicec)
ncfile=nf_def_var(ncid,'nsowaflcd',nf_real,3,dim1d,dwate)
ncfile=nf_def_var(ncid,'nsomixhgt',nf_real,3,dim1d,dturb)
ncfile=nf_enddef(ncid)
ncfile=nf_put_var_real(ncid,dtemp,temp1)
ncfile=nf_put_var_real(ncid,dsali,sali1)
ncfile=nf_put_var_real(ncid,dwind,wind1)
ncfile=nf_put_var_real(ncid,dswrn,swrn1)
ncfile=nf_put_var_real(ncid,dicec,icec1)
ncfile=nf_put_var_real(ncid,dwate,wate1)
ncfile=nf_put_var_real(ncid,dturb,turb1)
ncfile=nf_close(ncid)

end program generate1d

subroutine handle_err(errcode)
        implicit none
        include 'netcdf.inc'
        integer errcode
       
        print *, 'Error: ', nf_strerror(errcode)
        stop 2
        end

2014年1月11日土曜日

メモリアル大での研究のメモ

Dropboxを整理しておくといろんなものが出てくる。

中にNEMOモデルを使ってラブラドール海のモデルシミュレーションをやっていた頃の過程ノートがテキストファイルであったので削除する前にここに載せておく。

以下stn_note.txt

USE:
namelist_pisces
voddmavs or votkeavt
atcco2=280 (349ppm in 1987, but use 280 for equilibrium state)
nrdttrc=1
ln_pisdmp=true (relaxation) ---> currently works only with "orca" configuration and NOT 1D. Thus, this does nothing for my case.
nn_pisdmp=end of year
namelist_top
ln_trcdta=true
ln_trcdmp=true (damping)!
nn_hdmp_tr=89
namelist
rn_rdt<86400 (1day)
nn_msh=1 (mesh file)
ln_dynwzv=false (read w from file)
stn15/

case3+: dt=6hr
case3333&33333:no initialization
---> unrealistic value of NO3 (x2 greater)

case10+:dt=1day
10years simulation

10&10_1:no initialization
10:no damp or relax
10_1:damp & relax on every 365days (whole column)
10_2&10_3:seems to be the same...
10_3: same as 10_1 except initialization used.
10_4:same as 10_3 except constant & weak eddy diffusivity (10^-5)
10_5:same as 10_3 except no damping or relax.

case30+:30 years simulation
30_1:same as 10_3 except 280ppm & 30 years

Tracer damping or relaxation do not work in 1D...

DONE:
deleted: 10_2, 10_4,10_5


Above setups are all WRONG UP UNTIL NOW because the mesh_mask.nc was wrong.

case30_2: dt=1day; 30 years; 280ppm
case10_6: dt_1hr; 10 years; 280ppm (hopefully this will improve case30_2 since including diurnal cycle)


case1_1: dt=1hr; 1yr;
case1_2: dt=1hr; 2yr; <-- I want to see if model results improve after 1st year. --> can't see it very clearly :(
case1_3: dt=1hr; 10yr; --> it drifts away (same as case2_1).
case2_1: dt=1day; 10yr; <-- I want to see if model results improve with time resolution. --> no, rather it drifts away.

With the new physical data:

case3_1: dt=1hr; 2yr; (same as case2_1, but new physical data)

run0: This is the old physical data, which I might use?
run1: This is what I use for my thesis. conditions are:

280ppm
monthly-mean offline dynamics for 1987


damping???

以下LABSEA_note.txt

case1_3: new offline dynamics: NaN at kt=93; dt=1hr
case1_4: same as case1_3 except damping 1day

==========
beta2:
the model works with dt=100sec
instability at bottom left corner, as well as reduction of DIC in the whole domain (unrealistic)
suggesions: reduce horizontal eddy diffusivity (currently 2000)

beta3:
same as beta2 except reduced horizontal eddy diffusivity in namelist_top (changed to 90)
--> still instability. --> needs to modify the code to make it OBC instead of CBC.


20minutes work!
must use 32 CPUs.

2013年8月7日水曜日

NCOというnetCDFのアドオンのようなものがすごく便利。


netCDF Operator (NCO)

っというものがあるんですね。

この中にあるncksというコマンドを使えばnetCDFファイルの中から不要な変数を取り除くことができる→容量を減らすことができる。

以下はあるncファイルからPISCESのオフラインシミュレーションに必要な変数だけを出力するコマンドです:

ncks -v nav_lon,nav_lat,deptht,time_counter,votemper,vosaline,somixhgt,sowaflcd,soicecov,soshfldo,sowindsp Lab_T_94_01.nc ~/newdirectory/Lab_T_94_01.nc

ncks -v nav_lon,nav_lat,depthw,time_counter,votkeavt,vovecrtz Lab_W_94_01.nc ~/newdirectory/Lab_W_94_01.nc

ncks -v nav_lon,nav_lat,depthu,time_counter,vozocrtx Lab_U_94_01.nc ~/DATA1/Lab_Sea/Lab_U_94_01.nc

ncks -v nav_lon,nav_lat,depthv,time_counter,vomecrty Lab_V_94_01.nc ~/DATA1/Lab_Sea/Lab_V_94_01.nc

ここのオプション「-v」のあとに定義しているのが出力したい変数。

おかげさまで…

 11G Aug  6 17:47 Lab_T_94_01.nc
 1.7G Aug  6 17:50 Lab_U_94_01.nc
 1.7G Aug  6 17:53 Lab_V_94_01.nc
 8.1G Aug  6 18:08 Lab_W_94_01.nc

↑これだけあったファイルが→→→

 3.4G Aug  7 11:15 Lab_T_94_01.nc
 1.7G Aug  7 11:39 Lab_U_94_01.nc
 1.7G Aug  7 11:42 Lab_V_94_01.nc
 3.3G Aug  7 11:20 Lab_W_94_01.nc

まさに劇的ビフォーアフター☆4Dデータが多いTとWファイルはかなり容量を減らすことができました。U&Vはさほどかわりはない。

ちなみにACEnetのクラスターでは

module load nco

と打てばncoのコマンドが使えるようになっている♪

追伸:

「-A」オプションを使えばファイルの内容を書き換えることができる!



file1.ncに入っているvovecrtzという変数をfile2.ncに上書き保存する場合:

ncks -A -v vovecrtz file1.nc file2.nc

2013年7月12日金曜日

simulate PISCES monthly 続き

スクリプトをいくつか編集してシミュレーションをしやすくした。手順は以下の通り

一月はスクリプトを使わずに手動で行う。確認することは:

  • 大気co2濃度設定
  • namelist_topでの初期値設定:
    • ln_rsttr      = .true.   !  start from a restart file (T) or not (F)
一月が終わったらln_rsttrを.true.に変更してあとは何も変えずに./dailyrun.shを実行して完了。

dailyrun.shには新しくreplaceコマンドとarray(列)を取り入れた:


tstep=(744 672 744 720 744 720 744 744) #January to August
for month in 02 03 04 05 06 07
do
replace "${tstep[${month}-2]}" "${tstep[${month}-1]}" -- namelist namelist_top
replace "010`echo "${month}-1" | bc`01" "01${month}01" -- namelist
for it in T U V W
do
ln -fs Lab_${it}_94_m${month}.nc Lab_${it}_94.nc
done
mv LABSEA_*_*T.nc ../MY_SRC/daily94/
cp LABSEA_*_restart_trc.nc ../MY_SRC/daily94/restart_trc_${month}.nc
mv -f LABSEA_*_restart_trc.nc restart_trc.nc
./opa
done


replaceは便利なコマンド。

例: file1とfile2内のabcをedfに書き換える

replace "abc" "edf" -- file1 file2

これにarrayを使って月別のタイムステップを各ループで自動変更させることにした。これで毎月ごとのシミュレーションを手動でせんでよかごとなったけんまぁだいぶ楽にはなったなぁ。

monthly simulation in offline version of PISCES

昨日の問題が解決した!

以下のエラー文を参考にわかったことは、1月のシミュレーションをするのに12月(先月)のデータが必要なのは最初の計算に必要だから。

                     iom_nf90_open ~~~ open existing file: ./Lab_T_94_m02.nc in READ mode
                    ---> ./Lab_T_94_m02.nc OK
                     iom_nf90_open ~~~ open existing file: ./Lab_T_94_m01.nc in READ mode
                    ---> ./Lab_T_94_m01.nc OK
           read sowaflcd (rec:   31) in ./Lab_T_94_m01.nc ok
fld_init : time-interpolation for sowaflcd read previous record =   31 at time =   30.50 days
                     iom_close ~~~ close file: ./Lab_T_94_m01.nc ok

未だにLab_T_94.ncが必要な理由がわからないがオフラインダイナミックスはちゃんと月データから読み込んでるのでシミュレーション自体には支障なし。ということで今回のランはdaily94と名づけることにする。

月ごとにシミュレートしていくためにdailyrun.shというスクリプト作成:

 month=07

for it in T U V W
do
ln -fs Lab_${it}_94_m${month}.nc Lab_${it}_94.nc
done
mv LABSEA_*_*T.nc ../MY_SRC/daily94/
cp LABSEA_*_restart_trc.nc ../MY_SRC/daily94/restart_trc_${month}.nc
mv -f LABSEA_*_restart_trc.nc restart_trc.nc
./opa

シミュレーションが終わったらこのスクリプトを走らせる前に以下のことをする:
  • namelist & namelist_pisces内のタイムステップ数を各月の日数に応じて変更(昨日の日記参照)。
  • namelist内のnn_date0を各月の一日に変更。(一年一月一日 = 010101)

2013年6月27日木曜日

namelist_piscesの最終確認

いや、最終確認というよりきちんとモデルの中(コード)のパラメーターを確認するのは初めてかもしれない。

確認してわかったことは、PISCESは改良されつづけているようだが改良の変更点を明確にしたマニュアルが現時点では残念ながらないようだ。僕はAumontが2006年に出した論文の補足資料としてウェブ上にあるマニュアル(ftp://ftp.agu.org/apend/gb/2005gb002591/)を参考に論文を書いていただけに残念だ。これ以後PISCES式やパラメーターは微調整されていろんなエンドユーザーに使われているんだがモデルを紹介するときはみな上記論文を引用している。これじゃblack boxを使っているのと同じじゃないか…。

っということで上記論文からNEMO3.4.1版まででの相違点・変更をパラメーターを周辺にまとめてみることに。

&nampisbio     !   biological parameters
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   nrdttrc    =  1        ! time step frequency for biology
   wsbio      =  2.       ! POC sinking speed
   xkmort     =  2.E-7    ! half saturation constant for mortality
   ferat3     =  10.E-6   ! Fe/C in zooplankton
   wsbio2     =  30.      ! Big particles sinking speed
/
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
&nampislim     !   parameters for nutrient limitations
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   conc0      =  1.E-6    ! Phosphate half saturation
   conc1      =  8.E-6     ! Phosphate half saturation for diatoms
   conc2      =  1.E-9     ! Iron half saturation for phyto
   conc2m     =  3.E-9     ! Max iron half saturation for phyto
   conc3      =  3.E-9     ! Iron half saturation for diatoms
   conc3m     =  8.E-9     ! Maxi iron half saturation for diatoms
   xsizedia   =  1.E-6    ! Minimum size criteria for diatoms
   xsizephy   =  1.E-6    ! Minimum size criteria for phyto
   concnnh4   =  1.E-7    ! NH4 half saturation for phyto
   concdnh4   =  8.E-7    ! NH4 half saturation for diatoms
   xksi1      =  2.E-6    ! half saturation constant for Si uptake
   xksi2      =  333.E-8  ! half saturation constant for Si/C
   xkdoc      =  417.E-6  ! half-saturation constant of DOC remineralization
   concfebac  =  1.E-11   ! Half-saturation for Fe limitation of Bacteria
   qnfelim    =  7.E-6    ! Optimal quota of phyto
   qdfelim    =  7.E-6    ! Optimal quota of diatoms
   caco3r     =  16.E-2     ! mean rain ratio
/
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
&nampisprod     !   parameters for phytoplankton growth
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   pislope    =  2.       ! P-I slope
   pislope2   =  2.       ! P-I slope  for diatoms
   excret  =  5.E-2     ! excretion ratio of phytoplankton
   excret2  =  5.E-2     ! excretion ratio of diatoms
   ln_newprod =  .true.  ! Enable new parame. of production (T/F)
   bresp      =  333.E-5  ! Basal respiration rate
   chlcnm     =  33.E-3    ! Minimum Chl/C in nanophytoplankton
   chlcdm  =  5.E-2     ! Minimum Chl/C in diatoms
   chlcmin    =  33.E-4   ! Maximum Chl/c in phytoplankton

!後のミニマムとマキシマム逆。
   fecnm      =  40.E-6    ! Maximum Fe/C in nanophytoplankton
   fecdm      =  40.E-6    ! Minimum Fe/C in diatoms
   grosip     =  151.E-3    ! mean Si/C ratio
これはマニュアルでは0.14の定数として記されている。
/
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
&nampismort     !   parameters for phytoplankton sinks
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   wchl       =  1.E-3    ! quadratic mortality of phytoplankton
   wchld      =  2.E-2     ! maximum quadratic mortality of diatoms
   mprat      =  1.E-2     ! phytoplankton mortality rate
   mprat2     =  1.E-2     ! Diatoms mortality rate
   mpratm     =  1.E-2     ! Phytoplankton minimum mortality rate
こいつは使われていないのになぜか存在する。
/
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
&nampismes     !   parameters for mesozooplankton
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   part2      =  75.E-2    ! part of calcite not dissolved in mesozoo guts
   grazrat2   =  7.E-1      ! maximal mesozoo grazing rate
   resrat2    =  5.E-3    ! exsudation rate of mesozooplankton
   mzrat2     =  3.E-2     ! mesozooplankton mortality rate
   xprefc     =  1.       ! zoo preference for phyto
   xprefp     =  3.E-1      ! zoo preference for POC
   xprefz     =  1.       ! zoo preference for zoo

   xprefpoc   =  3.E-1      ! zoo preference for poc
このへんのインデックス要注意。今まで「2」はmesozooplanktonを表すために使われていたのにこれらのパラメーターのときだけ逆になっとる(この場合xpref2cはmicrozooplanktonに関連している)。
   xthresh2zoo = 1.E-8     ! zoo feeding threshold for mesozooplankton
   xthresh2dia = 1.E-8     ! diatoms feeding threshold for mesozooplankton
   xthresh2phy = 1.E-8     ! nanophyto feeding threshold for mesozooplankton
   xthresh2poc = 1.E-8     ! poc feeding threshold for mesozooplankton
   xthresh2   =  2.E-7    ! Food threshold for grazing
   xkgraz2    =  20.E-6   ! half sturation constant for meso grazing
   epsher2    =  3.E-1      ! Efficicency of Mesozoo growth
   sigma2     =  6.E-1      ! Fraction of mesozoo excretion as DOM
   unass2     =  3.E-1      ! non assimilated fraction of P by mesozoo
   grazflux   =  2.E3     ! flux-feeding rate
/
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
&nampiszoo     !   parameters for microzooplankton
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   part       =  5.E-1      ! part of calcite not dissolved in microzoo gutsa
   grazrat    =  3.0      ! maximal zoo grazing rate
   resrat     =  3.E-2     ! exsudation rate of zooplankton
   mzrat      =  1.E-3    ! zooplankton mortality rate
捕食されるのはmesozooplanktonのみとマニュアルには書いてあったのにコードではこれも計算されてるっぽい…。そして変動はzooplankton量に対しsquare dependencyのはずなのにコードを見る限りでは二乗されてないと思うんだが。。。
   xpref2c  =  1.E-1      ! Microzoo preference for POM
   xpref2p    =  1.       ! Microzoo preference for Nanophyto
   xpref2d    =  5.E-1      ! Microzoo preference for Diatoms
   xthreshdia =  1.E-8    ! Diatoms feeding threshold for microzooplankton
   xthreshphy =  1.E-8    ! Nanophyto feeding threshold for microzooplankton
   xthreshpoc =  1.E-8    ! POC feeding threshold for microzooplankton
   xthresh    =  2.E-7    ! Food threshold for feeding
   xkgraz     =  20.E-6   ! half sturation constant for grazing
   epsher     =  3.E-1      ! Efficiency of microzoo growth
   sigma1     =  6.E-1      ! Fraction of microzoo excretion as DOM
 unass      =  3.E-1      ! non assimilated fraction of phyto by zoo
/
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
&nampisrem     !   parameters for remineralization
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   xremik    =  25.E-2      ! remineralization rate of DOC
   xremip  =  25.E-3     ! remineralisation rate of POC
これと一致するパラメータはマニュアルの式では記述されてない。
   nitrif  =  5.E-2      ! NH4 nitrification rate
   xsirem    =  3.E-3     ! remineralization rate of Si
   xsiremlab  =  25.E-3     ! fast remineralization rate of Si
   xsilab    =  31.E-2      ! Fraction of labile biogenic silica
   xlam1     =  5.E-3     ! scavenging rate of Iron
   oxymin    =  1.E-6     ! Half-saturation constant for anoxia
   ligand    =  6.E-10    ! Ligands concentration
/
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
&nampiscal     !   parameters for Calcite chemistry
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   kdca       =  6.       ! calcite dissolution rate constant (1/time)
   nca        =  1.       ! order of dissolution reaction (dimensionless)