From 223e98cd707eed55e6949fbda710bfb841231773 Mon Sep 17 00:00:00 2001
From: George Faykin <pofnutsy@gmail.com>
Date: Fri, 20 Jun 2025 18:10:13 +0300
Subject: [PATCH] return to previous version of code: fix arg_kit

---
 build.sh                                      |   1 +
 source/carbon/carbon.f90                      |  42 ++++----
 .../carbon/carbon_model_to_core_arg_kit.f90   | 100 +++++-------------
 .../carbon_models/carbon_model_ROTHC.f90      |  10 +-
 source/config.f90                             |  37 ++++++-
 .../environment/environment_data_station.f90  |   2 +-
 station_config.nml                            |  84 ++++++++++++++-
 ui1_config.nml                                |  14 +--
 8 files changed, 175 insertions(+), 115 deletions(-)

diff --git a/build.sh b/build.sh
index b02f493..cba52c9 100755
--- a/build.sh
+++ b/build.sh
@@ -46,6 +46,7 @@ gfortran $keys_compile -c source/config.f90 -o bin/config.o -Jbin
 gfortran $keys_compile -c source/netcdf_kit.f90 -o bin/netcdf_kit.o -Jbin
 gfortran $keys_compile -c source/datetime.f90 -o bin/datetime.o -Jbin
 gfortran $keys_compile -c source/grid.f90 -o bin/grid.o -Jbin
+#gfortran $keys_compile -c source/carbon_pools.f90 -o bin/carbon_pools.o -Jbin
 gfortran $keys_compile -c source/environment/environment_core.f90 -o bin/environment_core.o -Jbin
 gfortran $keys_compile -c source/environment/environment_data_generator.f90 -o bin/environment_data_generator.o -Jbin
 gfortran $keys_compile -c source/environment/environment_data_station.f90 -o bin/environment_data_station.o -Jbin
diff --git a/source/carbon/carbon.f90 b/source/carbon/carbon.f90
index 7b1c65e..85328fb 100644
--- a/source/carbon/carbon.f90
+++ b/source/carbon/carbon.f90
@@ -38,7 +38,7 @@ module carbon
                                     & carbon_model_calc_at_tile_user => carbon_model_calc_at_tile, &
                                     & carbon_model_postprocessing_user => carbon_model_postprocessing
                                     
-    use carbon_model_to_core_arg_kit, only : dummy_init
+   ! use carbon_model_to_core_arg_kit, only : dummy_init
     
     implicit none
 
@@ -108,49 +108,49 @@ contains
                 carbon_model_calc_at_tile     => carbon_model_calc_at_tile_user
                 carbon_model_postprocessing   => carbon_model_postprocessing_user
         end select
-        
+
         call carbon_model_init()
-        
-        call dummy_init()
-        
+
+       ! call dummy_init()
+
         call carbon_model_assembly()
-        
+
         if (if_standard_output) call carbon_standard_output()
         
     end subroutine
 
 
     subroutine carbon_calc_at_timestep()
-        
+
         call carbon_model_calc_at_timestep()
-        
+
     end subroutine
 
 
     subroutine carbon_calc_at_cell(ii,jj)
-    
+
         integer, intent(in) :: ii, jj
-        
+
         call carbon_model_calc_at_cell(ii,jj)
-        
+
     end subroutine
 
 
     subroutine carbon_calc_at_tile(ii,jj,nn)
-    
+
         integer, intent(in) :: ii, jj, nn
-        
+
         call carbon_model_calc_at_tile(ii,jj,nn)
-        
+
         call carbon_solver_fluxes(ii,jj,nn)
-        
+
         call carbon_solver_pools(ii,jj,nn)
-        
+
     end subroutine
 
 
     subroutine carbon_postprocessing()
-        
+
         select case(testing_log_mode)
             case('write')
                 call carbon_testing_write_log()
@@ -158,13 +158,13 @@ contains
                 call carbon_testing_read_log()
             case('none')
         end select
-        
+
         if (if_standard_print) call carbon_standard_print()
-        
+
         if (if_standard_output) call carbon_standard_output()
-        
+
         call carbon_model_postprocessing()
-        
+
     end subroutine
 
 
diff --git a/source/carbon/carbon_model_to_core_arg_kit.f90 b/source/carbon/carbon_model_to_core_arg_kit.f90
index 9e0a8b8..abfbfdc 100644
--- a/source/carbon/carbon_model_to_core_arg_kit.f90
+++ b/source/carbon/carbon_model_to_core_arg_kit.f90
@@ -1,3 +1,4 @@
+
 module carbon_model_to_core_arg_kit
 
     !< @brief обработка аргументов мультипликативных функций
@@ -5,58 +6,27 @@ module carbon_model_to_core_arg_kit
     ! интерфейс
     ! ---------------------------------------------------------------------------------
 
-    use carbon_core, only: arg_kit_type, narg_default, ntile
-    use grid,        only: year_min, year_max, i0, i1, j0, j1
-
+    use carbon_core, only: arg_kit_type, narg_default
+    use grid,        only: year_min, year_max
     implicit none
 
     private
     public :: set_args
     public :: get_args
     public :: nmonth
-    public :: dummy_init, dummy, dummy_n, dummy_ij, dummy_ijn, dummy_ijn_month, dummy_year
 
     ! параметры
     ! ---------------------------------------------------------------------------------
-    integer, parameter :: nmonth = 12
+
     integer :: fix1, fix2
 
-    real, target :: dummy
-    real, allocatable, dimension(:), target :: dummy_n
-    real, allocatable, dimension(:,:), target :: dummy_ij
-    real, allocatable, dimension(:,:,:), target :: dummy_ijn
-    real, allocatable, dimension(:,:,:,:), target :: dummy_ijn_month
-    real, allocatable, dimension(:), target :: dummy_year
+    integer, parameter :: nmonth = 12
 
 contains
 
 
     ! внешние процедуры
     ! ---------------------------------------------------------------------------------
-    subroutine dummy_init()
-        ! ---------------------------------------
-        !< @brief заглушки для элементов программы
-
-        use carbon_core, only: ntile
-        use grid,        only: i0, i1, j0, j1, ml
-
-        !allocate(dummy)
-        allocate(dummy_n(ntile))
-        allocate(dummy_ij(i0:i1,j0:j1))
-        allocate(dummy_ijn(i0:i1,j0:j1,ntile))
-        allocate(dummy_ijn_month(i0:i1,j0:j1,ntile,nmonth))
-        allocate(dummy_year(year_min:year_max))
-        
-        dummy = 0.
-        dummy_n = 0.
-        dummy_ij = 0.
-        dummy_ijn = 0.
-        dummy_ijn_month = 0.
-        dummy_year = 0.
-
-    end subroutine
-
-
 
     subroutine set_args(arg_kit, x, x_n, x_ij, x_ijn, x_ijn_month, x_year)
         ! ---------------------------------------
@@ -66,8 +36,7 @@ contains
         use grid,        only : i0, i1, j0, j1
         use carbon_core, only : ntile
 
-        type(arg_kit_type), intent(inout) :: arg_kit(narg_default)        
-
+        type(arg_kit_type), intent(inout) :: arg_kit(narg_default)
         !> перечень возможных аргументов:
         real, optional, intent(in), target :: x
         real, optional, intent(in), target :: x_n(ntile)
@@ -77,6 +46,7 @@ contains
         real, optional, intent(in), target :: x_year(year_min:year_max)
 
         integer :: n
+        integer :: mnc !< Количество месяцев в расчете
 
         do n = 1, narg_default
             allocate(arg_kit(n)%arg1)
@@ -93,63 +63,29 @@ contains
             arg_kit(n)%arg6 = miss_v
         enddo
 
+        ! arg_kit(1) - x
 
         if (present(x)) then
             arg_kit(1)%arg1 => x
-            arg_kit(1)%arg2 => dummy_n
-            arg_kit(1)%arg3 => dummy_ij
-            arg_kit(1)%arg4 => dummy_ijn
-            arg_kit(1)%arg5 => dummy_ijn_month
-            arg_kit(1)%arg6 => dummy_year
             arg_kit(1)%num = 1
         elseif (present(x_n)) then
-            arg_kit(1)%arg1 => dummy
             arg_kit(1)%arg2 => x_n
-            arg_kit(1)%arg3 => dummy_ij
-            arg_kit(1)%arg4 => dummy_ijn
-            arg_kit(1)%arg5 => dummy_ijn_month
-            arg_kit(1)%arg6 => dummy_year
             arg_kit(1)%num = 2
         elseif (present(x_ij)) then
-            arg_kit(1)%arg1 => dummy
-            arg_kit(1)%arg2 => dummy_n
             arg_kit(1)%arg3 => x_ij
-            arg_kit(1)%arg4 => dummy_ijn
-            arg_kit(1)%arg5 => dummy_ijn_month
-            arg_kit(1)%arg6 => dummy_year
             arg_kit(1)%num = 3
         elseif (present(x_ijn)) then
-            arg_kit(1)%arg1 => dummy
-            arg_kit(1)%arg2 => dummy_n
-            arg_kit(1)%arg3 => dummy_ij
             arg_kit(1)%arg4 => x_ijn
-            arg_kit(1)%arg5 => dummy_ijn_month
-            arg_kit(1)%arg6 => dummy_year
             arg_kit(1)%num = 4
         elseif (present(x_ijn_month)) then
-            arg_kit(1)%arg1 => dummy
-            arg_kit(1)%arg2 => dummy_n
-            arg_kit(1)%arg3 => dummy_ij
-            arg_kit(1)%arg4 => dummy_ijn
             arg_kit(1)%arg5 => x_ijn_month
-            arg_kit(1)%arg6 => dummy_year
             arg_kit(1)%num = 5
         elseif (present(x_year)) then
-            arg_kit(1)%arg1 => dummy
-            arg_kit(1)%arg2 => dummy_n
-            arg_kit(1)%arg3 => dummy_ij
-            arg_kit(1)%arg4 => dummy_ijn
-            arg_kit(1)%arg5 => dummy_ijn_month
             arg_kit(1)%arg6 => x_year
             arg_kit(1)%num = 6
-        else!  для const
+        else
             arg_kit(1)%arg1 = miss_v
-            arg_kit(1)%arg2 => dummy_n
-            arg_kit(1)%arg3 => dummy_ij
-            arg_kit(1)%arg4 => dummy_ijn
-            arg_kit(1)%arg5 => dummy_ijn_month
-            arg_kit(1)%arg6 => dummy_year
-            arg_kit(1)%num = 1
+            arg_kit(1)%num = 1  !  для const
         end if
 
     end subroutine
@@ -168,8 +104,20 @@ contains
         integer :: n
 
         do n = 1, narg_default
-            args(n) = arg_kit(n)%arg1 + arg_kit(n)%arg2(nn) + arg_kit(n)%arg3(ii,jj) + arg_kit(n)%arg4(ii,jj,nn) + &
-            & arg_kit(n)%arg5(ii,jj,nn,month) + arg_kit(n)%arg6(year)
+            select case(arg_kit(n)%num)
+                case(1)
+                    args(n) = arg_kit(n)%arg1
+                case(2)
+                    args(n) = arg_kit(n)%arg2(nn)
+                case(3)
+                    args(n) = arg_kit(n)%arg3(ii,jj)
+                case(4)
+                    args(n) = arg_kit(n)%arg4(ii,jj,nn)
+                case(5)
+                    args(n) = arg_kit(n)%arg5(ii,jj,nn,month)
+                case(6)
+                    args(n) = arg_kit(n)%arg6(year)
+            end select
         enddo
 
     end function
diff --git a/source/carbon/carbon_models/carbon_model_ROTHC.f90 b/source/carbon/carbon_models/carbon_model_ROTHC.f90
index d09f04b..efe47cd 100644
--- a/source/carbon/carbon_models/carbon_model_ROTHC.f90
+++ b/source/carbon/carbon_models/carbon_model_ROTHC.f90
@@ -20,11 +20,11 @@ module carbon_model_rothc
 
             call set_pool(pid = n_Catm, name = 'catm')
             call set_pool(pid = n_Cveg, name = 'cveg')
-            call set_pool(pid = n_CDPM, name = 'CDPM', initial_value = 0.04936, alias = CDPM)
-            call set_pool(pid = n_CRPM, name = 'CRPM', initial_value = 0.799, alias = CRPM)
-            call set_pool(pid = n_CBIO, name = 'CBIO', initial_value = 0.11873, alias = CBIO)
-            call set_pool(pid = n_CHUM, name = 'CHUM', initial_value = 7.07025, alias = CHUM)
-            call set_pool(pid = n_CIOM, name = 'CIOM', initial_value = 0.814,  alias = CIOM)
+            call set_pool(pid = n_CDPM, name = 'CDPM', initial_value = 0.01944, alias = CDPM)
+            call set_pool(pid = n_CRPM, name = 'CRPM', initial_value = 1.73544, alias = CRPM)
+            call set_pool(pid = n_CBIO, name = 'CBIO', initial_value = 0.06188, alias = CBIO)
+            call set_pool(pid = n_CHUM, name = 'CHUM', initial_value = 1.0416, alias = CHUM)
+            call set_pool(pid = n_CIOM, name = 'CIOM', initial_value = 0.245,  alias = CIOM)
 
 !        station: opt: CDPM:     CRPM:   CBIO:    CHUM:    CIOM:
 !        DAO4     1    0.01944  1.73544  0.06188  1.0416   0.245
diff --git a/source/config.f90 b/source/config.f90
index 35c6587..d9f1c06 100644
--- a/source/config.f90
+++ b/source/config.f90
@@ -57,6 +57,28 @@ module config
     character(len_default) :: datetime_init_5
     character(len_default) :: datetime_last_5
 
+    real :: CDPM_st_in(4)
+    real :: CRPM_st_in(4)
+    real :: CBIO_st_in(4)
+    real :: CHUM_st_in(4)
+    real :: CIOM_st_in(4)
+    real :: C_i1_st_in(4)
+    real :: C_i2_st_in(4)
+    real :: C_s1_st_in(4)
+    real :: C_s2_st_in(4)
+
+    namelist /carbon_pools_config_namelist/  &
+    & CDPM_st_in, &
+    & CRPM_st_in, &
+    & CBIO_st_in, &
+    & CHUM_st_in, &
+    & CIOM_st_in, &
+    & C_i1_st_in, &
+    & C_i2_st_in, &
+    & C_s1_st_in, &
+    & C_s2_st_in
+
+
     namelist /config_namelist/  &
     & carbon_model_type,        &
     & environment_data_type,    &
@@ -97,7 +119,16 @@ module config
     & datetime_init_4, &
     & datetime_last_4, &
     & datetime_init_5, &
-    & datetime_last_5
+    & datetime_last_5, &
+    & CDPM_st_in, &
+    & CRPM_st_in, &
+    & CBIO_st_in, &
+    & CHUM_st_in, &
+    & CIOM_st_in, &
+    & C_i1_st_in, &
+    & C_i2_st_in, &
+    & C_s1_st_in, &
+    & C_s2_st_in
 
 
     type namespace_type
@@ -138,6 +169,10 @@ module config
             read(10, nml = station_config_namelist)
             close(10)
 
+            !open(10, file = 'carbon_pools.nml', status = 'old', action = 'read')
+            !read(10, nml = carbon_pools_config_namelist)
+            !close(10)
+
             select case (lsm_dataformat)
                 case('inmcm')
                     nc_namespace%lon   = 'lon'
diff --git a/source/environment/environment_data_station.f90 b/source/environment/environment_data_station.f90
index f3d2e9a..1df4dab 100644
--- a/source/environment/environment_data_station.f90
+++ b/source/environment/environment_data_station.f90
@@ -196,7 +196,7 @@ contains
 
       lambd(:,:) = organic(:,:) + FYM(:,:)
 
-      !if (mncX == mnc) mncX = 0 !для инициализации, по идее, в других случаях строка комментируется
+      if (mncX == mnc) mncX = 0 !для инициализации, по идее, в других случаях строка комментируется
 
 	  do i = 1, ml
         Tsoil(:,:,i) = Temp(:,:)     ! температура почвы равна температуре воздуха
diff --git a/station_config.nml b/station_config.nml
index ad791c0..63e9116 100644
--- a/station_config.nml
+++ b/station_config.nml
@@ -9,25 +9,101 @@
 ! -----------------------------------------------------------------
 
     !> station_name = 'DAO4':
+        
+       !> Date
        datetime_init_1 = '1935-01-01 00:00:00'
        datetime_last_1 = '2012-01-01 00:00:00'
-    
+
+       !> Initial value
+        ! Rothc
+         ! opt         1        2        3        4
+          CDPM_st_in(:) = 0.01944, 0.02037, 0.02037, 0.0192
+          CRPM_st_in(:) = 1.73544, 1.75515, 1.75515, 1.73087
+          CBIO_st_in(:) = 0.06188, 0.06464, 0.06464, 0.0612
+          CHUM_st_in(:) = 1.0416, 1.14567, 1.14567, 1.01558
+          CIOM_st_in(:) = 0.245, 0.257, 0.257, 0.24
+         ! INMCM
+          C_i1_st_in(:) = 0.061994, 0.064774, 0.064496, 0.060882
+          C_i2_st_in(:) = 3.037706, 3.173926, 3.160304, 2.983218
+         ! Socs
+          C_s1_st_in(:) = 3.037706, 3.173926, 3.160304, 2.983218
+          C_s2_st_in(:) = 0.061994, 0.064774, 0.064496, 0.060882
+     
     !> station_name = 'DAO3':
        datetime_init_2 = '1937-01-01 00:00:00'
        datetime_last_2 = '2012-01-01 00:00:00'
-    
+
+       !> Initial value
+        ! Rothc
+         ! opt         1        2        3        4
+          CDPM_st_in(:) = 0.01792, 0.01792, 0.01804, 0.01792
+          CRPM_st_in(:) = 1.10183, 1.10183, 1.10426, 1.10183
+          CBIO_st_in(:) = 0.05705, 0.05705, 0.05741, 0.05705
+          CHUM_st_in(:) = 1.45947, 1.45947, 1.47248, 1.45947
+          CIOM_st_in(:) = 0.221, 0.224, 0.225, 0.223
+         ! INMCM
+          C_i1_st_in(:) = 0.05676, 0.057276, 0.060888, 0.060028
+          C_i2_st_in(:) = 2.78124, 2.806524, 2.983512, 2.941372
+         ! Socs
+          C_s1_st_in(:) = 2.78124, 2.806524, 2.983512, 2.941372
+          C_s2_st_in(:) = 0.05676, 0.057276, 0.060888, 0.060028 
+
     !> station_name = 'TRGK':
        datetime_init_3 = '1956-01-01 00:00:00'
        datetime_last_3 = '2018-01-01 00:00:00'
-    
+
+       !> Initial value
+        ! Rothc
+         ! opt         1        2       3
+          CDPM_st_in(:) = 0.02132, 0.0196, 0.02132
+          CRPM_st_in(:) = 1.12986, 1.08615, 1.12986
+          CBIO_st_in(:) = 0.05946, 0.05455, 0.05946
+          CHUM_st_in(:) = 1.64844, 1.46279, 1.64844
+          CIOM_st_in(:) = 0.238, 0.224, 0.238
+         ! INMCM
+          C_i1_st_in(:) = 0.0619416, 0.0569418, 0.0619416
+          C_i2_st_in(:) = 3.0351384, 2.7901482, 3.0351384
+         ! Socs
+          C_s1_st_in(:) = 3.10072, 2.7901482, 2.93608
+          C_s2_st_in(:) = 0.06328, 0.0569418, 0.05992
+
     !> station_name = 'VLDR':
        datetime_init_4 = '1968-01-01 00:00:00'
        datetime_last_4 = '2018-01-01 00:00:00'
+
+       !> Initial value
+        ! Rothc
+         ! opt         1        2        3
+          CDPM_st_in(:) = 0.00777, 0.00777, 0.00777
+          CRPM_st_in(:) = 1.38303, 1.38303, 1.38303
+          CBIO_st_in(:) = 0.03275, 0.03275, 0.03275
+          CHUM_st_in(:) = 0.14961, 1.14961, 1.14961
+          CIOM_st_in(:) = 0.119, 0.119, 0.119
+         ! INMCM
+          C_i1_st_in(:) = 0.0338432, 0.0338432, 0.0338432
+          C_i2_st_in(:) = 1.6583168, 1.6583168, 1.6583168
+         ! Socs
+          C_s1_st_in(:) = 1.61406, 1.61406, 1.61406
+          C_s2_st_in(:) = 0.03294, 0.03294, 0.03294
     
     !> station_name = 'Rostov':
        datetime_init_5 = '1975-01-01 00:00:00'
        datetime_last_5 = '2018-01-01 00:00:00'
 
-
+       !> Initial value
+        ! Rothc
+         ! opt         1        2        3
+          CDPM_st_in(:) = 0.04936, 0.04936, 0.04936
+          CRPM_st_in(:) = 0.799, 0.799, 0.799
+          CBIO_st_in(:) = 0.11873, 0.11873, 0.11873
+          CHUM_st_in(:) = 7.07025, 7.07025, 7.07025
+          CIOM_st_in(:) = 0.814, 0.814, 0.814
+         ! Socs
+          C_i1_st_in(:) = 0.178176, 0.178176, 0.178176
+          C_i2_st_in(:) = 8.730624, 8.730624, 8.730624
+         ! INMCM
+          C_s1_st_in(:) = 8.730624, 8.730624, 8.730624
+          C_s2_st_in(:) = 0.178176, 0.178176, 0.178176
+ 
 ! -----------------------------------------------------------------
 /
diff --git a/ui1_config.nml b/ui1_config.nml
index 7d25542..0a64752 100644
--- a/ui1_config.nml
+++ b/ui1_config.nml
@@ -34,11 +34,11 @@
         ! дополнительно для environment_data_type = 'station':
             !> Имя станции:
             station_name = 'DAO4'
-            ! 'DAO4'   - Станция в Долгопрудном 2
-            ! 'DAO3'   - Станция в Долгопрудном 1
-            ! 'TRGK'   - Данные Торжок
-            ! 'VLDMR'  - Данные Владимир
-            ! 'Rostov' - Станция ФАНЦ
+            ! 'DAO4'   - Долгопрудная опытная станция ДАОС 4
+            ! 'DAO3'   - Долгопрудная опытная станция ДАОС 3
+            ! 'TRGK'   - Федеральный научный центр любяных культур "Торжок"
+            ! 'VLDMR'  - Верхневолжский ФАНЦ "Владимир"
+            ! 'Rostov' - Донской Федеральный аграрный научный центр (ФАНЦ) "Ростов"
             !    
             !> Тип подачи удобрения:
             station_opt = '1'
@@ -105,7 +105,7 @@
     ! 'auto' - получить из входного файла (для lsm_offline)
     ! 'auto' - указать автоматически дату начала наблюдения станции
     ! 'manual' - задать вручную [yyyy-mm-dd hh:mm:ss]
-        datetime_init = '1937-01-01 00:00:00'
+        datetime_init = '1935-01-01 00:00:00'
     !> Продолжительность расчета:
     ntime_mode = 'auto' 
     !
@@ -114,7 +114,7 @@
     ! 'ntime' - указанное число шагов
         ntime = 1000
     ! 'datetime_last' - до достижения указанной даты
-        datetime_last = '1976-01-01 00:00:00'
+        datetime_last = '2012-01-01 00:00:00'
 
         !Номер станции наблюдения за климатом
         !DAO4 DAO3 TRGK VLDR ROST
-- 
GitLab