2013年10月7日月曜日

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