add note 20251001
This commit is contained in:
@ -18,23 +18,23 @@
|
|||||||
!
|
!
|
||||||
! Module Routines:
|
! Module Routines:
|
||||||
! ============================================================================
|
! ============================================================================
|
||||||
! (1 ) READ_INPUT_ADJ_FILE : Driver routine for reading GEOS-CHEM input file
|
! (1 ) READ_INPUT_ADJ_FILE : Driver routine for reading GEOS-CHEM input file 读取 GC 输入文件
|
||||||
! (2 ) READ_ONE_LINE : Reads one line at a time
|
! (2 ) READ_ONE_LINE : Reads one line at a time 一次读取一行
|
||||||
! (3 ) SPLIT_ONE_LINE : Splits one line into substrings (by spaces)
|
! (3 ) SPLIT_ONE_LINE : Splits one line into substrings (by spaces) 通过空格分割文本
|
||||||
! (4 ) READ_ADJ_SIMULATION_MENU : Reads the GEOS-Chem adjoint simulation menu
|
! (4 ) READ_ADJ_SIMULATION_MENU : Reads the GEOS-Chem adjoint simulation menu 读取伴随设定
|
||||||
! (5 ) READ_FWD_MODEL_MENU : Reads forward model options
|
! (5 ) READ_FWD_MODEL_MENU : Reads forward model options 读取正向模拟选项
|
||||||
! (6 ) READ_ADJ_OPTIONS_MENU : Reads adjoint model options
|
! (6 ) READ_ADJ_OPTIONS_MENU : Reads adjoint model options 读取伴随模式选项
|
||||||
! (7 ) READ_ADJ_DIRECTORIES_MENU : Reads the GEOS-Chem adj. directories
|
! (7 ) READ_ADJ_DIRECTORIES_MENU : Reads the GEOS-Chem adj. directories 读取 GC 伴随路径
|
||||||
! (8 ) READ_CONTROL_VARS_MENU: Reads what are control variables
|
! (8 ) READ_CONTROL_VARS_MENU: Reads what are control variables 读取控制变量
|
||||||
! (9 ) READ_OBSERVATION_MENU : Reads vars related to observations
|
! (9 ) READ_OBSERVATION_MENU : Reads vars related to observations 读取观测相关变量
|
||||||
! (10) READ_FD_ MENU : Reads finite difference test variables
|
! (10) READ_FD_ MENU : Reads finite difference test variables 读取有限差分测试变量
|
||||||
! (11) READ_ADJ_DIAGNOSTICS_MENU : Reads the GEOS-Chem adj. diagnostic menu
|
! (11) READ_ADJ_DIAGNOSTICS_MENU : Reads the GEOS-Chem adj. diagnostic menu 读取伴随诊断菜单
|
||||||
! (12) VALIDATE_DIRECTORIES : Makes sure all given directories are valid
|
! (12) VALIDATE_DIRECTORIES : Makes sure all given directories are valid 确认给定目录有效
|
||||||
! (13) ARE_FLAGS_VALID : Makes sure all flags are valid/not conflicting
|
! (13) ARE_FLAGS_VALID : Makes sure all flags are valid/not conflicting 确认所有选项游戏哦啊
|
||||||
! (14) CHECK_DIRECTORY : Checks a single directory for errors
|
! (14) CHECK_DIRECTORY : Checks a single directory for errors 确认单个路径
|
||||||
! (15) CLEAN_FILE_DIRS : Clean out directories
|
! (15) CLEAN_FILE_DIRS : Clean out directories 清除路径
|
||||||
! (16) INIT_DEP_MAPS : Make mapping arrays for dep adjoint forcing
|
! (16) INIT_DEP_MAPS : Make mapping arrays for dep adjoint forcing 创建伴随强迫的映射数组
|
||||||
! (17) INIT_INPUT_ADJ : Initializes directory & logical variables
|
! (17) INIT_INPUT_ADJ : Initializes directory & logical variables 初始化路径
|
||||||
!
|
!
|
||||||
! GEOS-CHEM modules referenced by "input_adj_mod.f"
|
! GEOS-CHEM modules referenced by "input_adj_mod.f"
|
||||||
! ============================================================================
|
! ============================================================================
|
||||||
|
@ -780,7 +780,7 @@
|
|||||||
CALL READ_INPUT_FILE
|
CALL READ_INPUT_FILE
|
||||||
IF ( LPRT ) CALL DEBUG_MSG( '### INVERSE: a READ_INPUT_FILE' )
|
IF ( LPRT ) CALL DEBUG_MSG( '### INVERSE: a READ_INPUT_FILE' )
|
||||||
|
|
||||||
! Read final iteration number from file
|
! Read final iteration number from file 先读入当前的迭代情况
|
||||||
OPEN( 65, file = 'ITER' )
|
OPEN( 65, file = 'ITER' )
|
||||||
READ( 65,*) N_CALC_STOP
|
READ( 65,*) N_CALC_STOP
|
||||||
READ ( 65,*) N_CALC_TOTAL
|
READ ( 65,*) N_CALC_TOTAL
|
||||||
@ -802,7 +802,7 @@
|
|||||||
IF (LADJ) CALL INIT_SETULB
|
IF (LADJ) CALL INIT_SETULB
|
||||||
|
|
||||||
! Initialize inverse modeling module
|
! Initialize inverse modeling module
|
||||||
CALL INIT_INVERSE
|
CALL INIT_INVERSE ! 大概就是初始化了反演相关的数组
|
||||||
|
|
||||||
! Curent iteration
|
! Curent iteration
|
||||||
N_CALC = 0
|
N_CALC = 0
|
||||||
@ -908,7 +908,7 @@
|
|||||||
ENDDO
|
ENDDO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
task = 'START'
|
task = 'START' ! 初始化当前过程为开始
|
||||||
|
|
||||||
! Mare array of scaling factors into a vector for optimization
|
! Mare array of scaling factors into a vector for optimization
|
||||||
CALL GET_X_FROM_SF
|
CALL GET_X_FROM_SF
|
||||||
@ -942,7 +942,7 @@
|
|||||||
|
|
||||||
print*, ' done setulb ' , TASK
|
print*, ' done setulb ' , TASK
|
||||||
|
|
||||||
CALL SAVE_WEAK_CONSTRAINT_FIELDS
|
CALL SAVE_WEAK_CONSTRAINT_FIELDS ! 如果是弱约束,会先输出一个弱约束场
|
||||||
|
|
||||||
ELSE
|
ELSE
|
||||||
|
|
||||||
@ -959,55 +959,55 @@
|
|||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
! Force it to continue for FD tests, as cost func or gradients
|
! Force it to continue for FD tests, as cost func or gradients
|
||||||
! may be very small or zero (dkh, 02/11/11)
|
! may be very small or zero (dkh, 02/11/11) 如果进行有限差分测试,则强制继续进行
|
||||||
IF ( LFDTEST ) TASK(1:2) = 'FG'
|
IF ( LFDTEST ) TASK(1:2) = 'FG' ! 不对,可能是要避免迭代出结果的情况?
|
||||||
|
|
||||||
IF ( TASK(1:2) == 'FG' ) THEN
|
IF ( TASK(1:2) == 'FG' ) THEN
|
||||||
|
|
||||||
! Iteration diagnostics (zhe 11/28/10)
|
! Iteration diagnostics (zhe 11/28/10) 迭代诊断的输出
|
||||||
IF ( LITR ) THEN
|
IF ( LITR ) THEN
|
||||||
IF ( N_CALC .GT. 0 ) CALL ITER_CONDITION( N_CALC )
|
IF ( N_CALC .GT. 0 ) CALL ITER_CONDITION( N_CALC )
|
||||||
LATF = .FALSE.
|
LATF = .FALSE.
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
! The minimization routine has returned to request the
|
! The minimization routine has returned to request the
|
||||||
! function f and gradient g values at the current x
|
! function f and gradient g values at the current x 相当于这里就直接让梯度为 0 了
|
||||||
|
|
||||||
! Update iteration count
|
! Update iteration count 继续增加迭代次数
|
||||||
N_CALC = N_CALC + 1
|
N_CALC = N_CALC + 1
|
||||||
|
|
||||||
! Resent cost function for this iteration
|
! Resent cost function for this iteration 咦,这里的代价函数值怎么直接修改了?
|
||||||
COST_FUNC = 0.D0
|
COST_FUNC = 0.D0
|
||||||
|
|
||||||
IF ( N_CALC < N_CALC_STOP ) THEN
|
IF ( N_CALC < N_CALC_STOP ) THEN ! 如果在停止迭代之前,则从硬盘中读取相关数据
|
||||||
|
|
||||||
WRITE(6,*) 'READING SAVED DATA for N_CALC = ', N_CALC
|
WRITE(6,*) 'READING SAVED DATA for N_CALC = ', N_CALC
|
||||||
|
|
||||||
! Read scaling factor values from disk
|
! Read scaling factor values from disk 读取缩放因子
|
||||||
CALL GET_SF_FROM_X
|
CALL GET_SF_FROM_X
|
||||||
|
|
||||||
CALL DISPLAY_STUFF( 1 )
|
CALL DISPLAY_STUFF( 1 )
|
||||||
|
|
||||||
! Read gradients from disk
|
! Read gradients from disk 读取梯度结果
|
||||||
CALL READ_GDT_FILE
|
CALL READ_GDT_FILE
|
||||||
|
|
||||||
! Read cost function from disk
|
! Read cost function from disk 读取代价函数结果
|
||||||
CALL READ_CFN_FILE
|
CALL READ_CFN_FILE
|
||||||
|
|
||||||
! Put adjoints into GRADNT vector
|
! Put adjoints into GRADNT vector 将伴随放到向量中
|
||||||
CALL GET_GRADNT_FROM_ADJ
|
CALL GET_GRADNT_FROM_ADJ
|
||||||
|
|
||||||
!mkeller: read gradients with respect to forcing terms
|
!mkeller: read gradients with respect to forcing terms
|
||||||
IF ( DO_WEAK_CONSTRAINT ) CALL READ_GDT_U_FILE
|
IF ( DO_WEAK_CONSTRAINT ) CALL READ_GDT_U_FILE
|
||||||
|
|
||||||
!Save the current adjoint in the finite difference test cell
|
!Save the current adjoint in the finite difference test cell
|
||||||
! Initial conditions test
|
! Initial conditions test 意思是现在不能进行同时优化初始场和排放的有限差分测试?
|
||||||
IF ( LFDTEST .AND. LICS .AND. LADJ_EMS) THEN
|
IF ( LFDTEST .AND. LICS .AND. LADJ_EMS) THEN
|
||||||
|
|
||||||
PRINT*, 'WE HAVE A PROBLEM WITH STT_ADJ_FD when LICS &
|
PRINT*, 'WE HAVE A PROBLEM WITH STT_ADJ_FD when LICS &
|
||||||
& LADJ_EMS are both TRUE'
|
& LADJ_EMS are both TRUE'
|
||||||
|
|
||||||
ELSEIF ( LFDTEST .AND. LICS ) THEN
|
ELSEIF ( LFDTEST .AND. LICS ) THEN ! 剩下的部分就是从对应的数组取值,放到 STT_ADJ_FD 中
|
||||||
|
|
||||||
STT_ADJ_FD(N_CALC) = ICS_SF_ADJ(IFD,JFD,LFD,NFD)
|
STT_ADJ_FD(N_CALC) = ICS_SF_ADJ(IFD,JFD,LFD,NFD)
|
||||||
|
|
||||||
@ -1049,7 +1049,7 @@
|
|||||||
|
|
||||||
! Return to beginning of loop
|
! Return to beginning of loop
|
||||||
|
|
||||||
ELSEIF ( N_CALC == N_CALC_STOP ) THEN
|
ELSEIF ( N_CALC == N_CALC_STOP ) THEN ! 达到迭代结束次数,结束迭代
|
||||||
|
|
||||||
! Done if we are just estimating inverse Hessian (dkh, 01/12/12, adj32_012)
|
! Done if we are just estimating inverse Hessian (dkh, 01/12/12, adj32_012)
|
||||||
IF ( LINVH ) THEN
|
IF ( LINVH ) THEN
|
||||||
@ -1057,20 +1057,20 @@
|
|||||||
STOP
|
STOP
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
! UPDATE THE INITIAL CONDITIONS
|
! UPDATE THE INITIAL CONDITIONS 如果达到了最终迭代的条件,则更新初始条件
|
||||||
|
|
||||||
! If we're doing a finite difference test, reset to the orginal
|
! If we're doing a finite difference test, reset to the orginal
|
||||||
! SF and augment by amount FD_DIFF. Don't use X in this case.
|
! SF and augment by amount FD_DIFF. Don't use X in this case.
|
||||||
! old:
|
! old:
|
||||||
!IF ( ACTIVE_VARS == 'FDTEST' .AND. N_CALC == 2 ) THEN
|
!IF ( ACTIVE_VARS == 'FDTEST' .AND. N_CALC == 2 ) THEN
|
||||||
! new: now support 2nd order FDTEST (MAKE_SAVE_FILE_2)
|
! new: now support 2nd order FDTEST (MAKE_SAVE_FILE_2) 还有做二阶有限差分的
|
||||||
IF ( LFDTEST .AND. N_CALC > 1 ) THEN
|
IF ( LFDTEST .AND. N_CALC > 1 ) THEN
|
||||||
|
|
||||||
CALL SET_SF_FORFD
|
CALL SET_SF_FORFD
|
||||||
|
|
||||||
ELSEIF ( N_CALC == 1 ) THEN
|
ELSEIF ( N_CALC == 1 ) THEN
|
||||||
|
|
||||||
! don't need to call this again ??
|
! don't need to call this again ?? 笑死,不知道是谁写的注释,反正说明书写的是只做一次就行
|
||||||
!CALL SET_SF
|
!CALL SET_SF
|
||||||
#if defined ( LOG_OPT )
|
#if defined ( LOG_OPT )
|
||||||
CALL SET_LOG_SF
|
CALL SET_LOG_SF
|
||||||
@ -1080,7 +1080,7 @@
|
|||||||
|
|
||||||
ELSE
|
ELSE
|
||||||
|
|
||||||
! Update the scaling factors to the current X
|
! Update the scaling factors to the current X 更新缩放系数
|
||||||
CALL GET_SF_FROM_X
|
CALL GET_SF_FROM_X
|
||||||
|
|
||||||
ENDIF
|
ENDIF
|
||||||
@ -1094,12 +1094,12 @@
|
|||||||
!CALL READ_SF_FILE
|
!CALL READ_SF_FILE
|
||||||
|
|
||||||
!==============================================================
|
!==============================================================
|
||||||
! FORWARD RUN
|
! FORWARD RUN 怎么又做了一次正向模拟
|
||||||
!==============================================================
|
!==============================================================
|
||||||
CALL DO_GEOS_CHEM
|
CALL DO_GEOS_CHEM
|
||||||
|
|
||||||
!==============================================================
|
!==============================================================
|
||||||
! ADJOINT CALCULATION
|
! ADJOINT CALCULATION 然后又做了一次伴随
|
||||||
!==============================================================
|
!==============================================================
|
||||||
|
|
||||||
! For weak constraint 4D-Var (mkeller, 06/15)
|
! For weak constraint 4D-Var (mkeller, 06/15)
|
||||||
@ -1109,7 +1109,7 @@
|
|||||||
|
|
||||||
CALL DO_GEOS_CHEM_ADJ
|
CALL DO_GEOS_CHEM_ADJ
|
||||||
|
|
||||||
! For finite difference test, we may or may not do adjoint
|
! For finite difference test, we may or may not do adjoint 哈哈哈哈哈哈哈笑死,MAYBE_DO
|
||||||
ELSE
|
ELSE
|
||||||
|
|
||||||
CALL MAYBE_DO_GEOS_CHEM_ADJ
|
CALL MAYBE_DO_GEOS_CHEM_ADJ
|
||||||
@ -1117,31 +1117,31 @@
|
|||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
!==============================================================
|
!==============================================================
|
||||||
! SAVE RESULTS TO DISK and EXIT OPTIMIZATION LOOP
|
! SAVE RESULTS TO DISK and EXIT OPTIMIZATION LOOP 将结果写到硬盘,然后退出最优化循环
|
||||||
!==============================================================
|
!==============================================================
|
||||||
|
|
||||||
! Zero the gradients of the species that we do not wish to optimize
|
! Zero the gradients of the species that we do not wish to optimize
|
||||||
! or in places that you don't want optimized
|
! or in places that you don't want optimized 将那些不想优化的部分设置为 0
|
||||||
CALL SET_OPT_RANGE
|
CALL SET_OPT_RANGE
|
||||||
! Add to this Kumaresh's spatial filter
|
! Add to this Kumaresh's spatial filter
|
||||||
|
|
||||||
! Write gradients
|
! Write gradients 写入梯度文件
|
||||||
CALL MAKE_GDT_FILE
|
CALL MAKE_GDT_FILE
|
||||||
|
|
||||||
! Write scaling factors
|
! Write scaling factors 写入缩放因子
|
||||||
CALL MAKE_SF_FILE
|
CALL MAKE_SF_FILE
|
||||||
|
|
||||||
! Write cost function
|
! Write cost function 写入代价函数
|
||||||
CALL MAKE_CFN_FILE
|
CALL MAKE_CFN_FILE
|
||||||
|
|
||||||
! For weak constraint 4D-Var (mkeller, 06/15)
|
! For weak constraint 4D-Var (mkeller, 06/15) 写入弱约束项
|
||||||
IF ( DO_WEAK_CONSTRAINT ) CALL MAKE_GDT_U_FILE
|
IF ( DO_WEAK_CONSTRAINT ) CALL MAKE_GDT_U_FILE
|
||||||
|
|
||||||
! mkeller: create HDF5 file for satellite diagnostics output
|
! mkeller: create HDF5 file for satellite diagnostics output 写入卫星诊断输出
|
||||||
IF ( LSAT_HDF_L2 .OR. LSAT_HDF_L3 .OR. LDCOSAT )
|
IF ( LSAT_HDF_L2 .OR. LSAT_HDF_L3 .OR. LDCOSAT )
|
||||||
& CALL DO_SAT_DIAGS()
|
& CALL DO_SAT_DIAGS()
|
||||||
|
|
||||||
IF ( LEMS_ABS ) CALL MAKE_EMS_ADJ_FILE
|
IF ( LEMS_ABS ) CALL MAKE_EMS_ADJ_FILE ! 写入排放文件
|
||||||
|
|
||||||
! Write results to screen
|
! Write results to screen
|
||||||
CALL DISPLAY_STUFF( 4 )
|
CALL DISPLAY_STUFF( 4 )
|
||||||
@ -1164,7 +1164,7 @@
|
|||||||
|
|
||||||
ELSE
|
ELSE
|
||||||
|
|
||||||
! We terminate execution when TASK is neither FG nor NEW_X.
|
! We terminate execution when TASK is neither FG nor NEW_X. 好像明白了 FG 是什么,最终迭代么
|
||||||
! We print the information contained in the string TASK
|
! We print the information contained in the string TASK
|
||||||
! if the default output is not used and the execution is
|
! if the default output is not used and the execution is
|
||||||
! not stopped intentionally by the user.
|
! not stopped intentionally by the user.
|
||||||
@ -1179,7 +1179,7 @@
|
|||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
!=================================================================
|
!=================================================================
|
||||||
! OPTIMIZATION loop ends here!
|
! OPTIMIZATION loop ends here! 结束最优化的过程
|
||||||
!=================================================================
|
!=================================================================
|
||||||
ENDDO
|
ENDDO
|
||||||
WRITE( 6, '(a)' ) REPEAT( '=', 79 )
|
WRITE( 6, '(a)' ) REPEAT( '=', 79 )
|
||||||
@ -1206,7 +1206,7 @@
|
|||||||
ENDIF
|
ENDIF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
! Clean up and quit
|
! Clean up and quit 清除一些中间文件
|
||||||
CALL CLOSE_FILES
|
CALL CLOSE_FILES
|
||||||
CALL CLEANUP
|
CALL CLEANUP
|
||||||
CALL CLEANUP_ADJ
|
CALL CLEANUP_ADJ
|
||||||
@ -1214,7 +1214,7 @@
|
|||||||
! For weak constraint 4D-Var (mkeller, 06/15)
|
! For weak constraint 4D-Var (mkeller, 06/15)
|
||||||
IF ( DO_WEAK_CONSTRAINT ) CALL CLEAN_WEAK_CONSTRAINT
|
IF ( DO_WEAK_CONSTRAINT ) CALL CLEAN_WEAK_CONSTRAINT
|
||||||
|
|
||||||
! Remove all met files from temporary directory
|
! Remove all met files from temporary directory 清除气象场文件
|
||||||
IF ( LUNZIP ) THEN
|
IF ( LUNZIP ) THEN
|
||||||
CALL UNZIP_A3_FIELDS( 'remove all' )
|
CALL UNZIP_A3_FIELDS( 'remove all' )
|
||||||
CALL UNZIP_A6_FIELDS( 'remove all' )
|
CALL UNZIP_A6_FIELDS( 'remove all' )
|
||||||
@ -1231,7 +1231,7 @@
|
|||||||
|
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
! Write the final iteration number for the next iteration to file
|
! Write the final iteration number for the next iteration to file 写入迭代文件的信息
|
||||||
OPEN( 65, file = 'ITER' )
|
OPEN( 65, file = 'ITER' )
|
||||||
WRITE( 65,*) N_CALC_STOP + 1
|
WRITE( 65,*) N_CALC_STOP + 1
|
||||||
CLOSE( 65 )
|
CLOSE( 65 )
|
||||||
|
@ -7,17 +7,18 @@
|
|||||||
! on SGI, it didn't work on Linux, so had to move all to a module.
|
! on SGI, it didn't work on Linux, so had to move all to a module.
|
||||||
! (dkh, 02/05)!
|
! (dkh, 02/05)!
|
||||||
! Module Variables:
|
! Module Variables:
|
||||||
|
! 模块 INVERSE_MOD 包含了所有用于反演的子程序。只能在 SGI 运行,无法在 Linux 运行?
|
||||||
! ============================================================================
|
! ============================================================================
|
||||||
! (1 ) COST_FUNC (REAL*8) : Value of cost function
|
! (1 ) COST_FUNC (REAL*8) : Value of cost function 代价函数值
|
||||||
! (2 ) N_CALC (INTEGER) : Optimization iteration number
|
! (2 ) N_CALC (INTEGER) : Optimization iteration number 迭代次数
|
||||||
! (3 ) N_CALC_STOP (INTEGER) : Maximum optimization iteration number
|
! (3 ) N_CALC_STOP (INTEGER) : Maximum optimization iteration number 最大迭代次数
|
||||||
! (4 ) F (DOUBLE) : For optimization routine
|
! (4 ) F (DOUBLE) : For optimization routine 用于最优化的进程
|
||||||
! (5 ) X (DOUBLE, ALLOC): Vector of active varialbes
|
! (5 ) X (DOUBLE, ALLOC): Vector of active varialbes 激活的状态变量
|
||||||
! (6 ) GRADNT (DOUBLE, ALLOC): Vector of adjoint gradients
|
! (6 ) GRADNT (DOUBLE, ALLOC): Vector of adjoint gradients 伴随梯度向量
|
||||||
! (7 ) XP (DOUBLE, ALLOC): Vector of active strat prod varialbes
|
! (7 ) XP (DOUBLE, ALLOC): Vector of active strat prod varialbes 平流层源
|
||||||
! (8 ) GRADNT_P (DOUBLE, ALLOC): Vector of strat prod adjoint gradients
|
! (8 ) GRADNT_P (DOUBLE, ALLOC): Vector of strat prod adjoint gradients 平流层源梯度
|
||||||
! (9 ) XL (DOUBLE, ALLOC): Vector of active strat loss varialbes
|
! (9 ) XL (DOUBLE, ALLOC): Vector of active strat loss varialbes 平流层汇
|
||||||
! (10) GRADNT_L (DOUBLE, ALLOC): Vector of adjoint strat loss gradients
|
! (10) GRADNT_L (DOUBLE, ALLOC): Vector of adjoint strat loss gradients 平流层汇梯度
|
||||||
!
|
!
|
||||||
! Module Routines
|
! Module Routines
|
||||||
! ============================================================================
|
! ============================================================================
|
||||||
@ -5472,7 +5473,7 @@ C ---------- LAST CARD OF DRAN ----------
|
|||||||
!
|
!
|
||||||
!******************************************************************************
|
!******************************************************************************
|
||||||
! Subroutine CALC_NOPT calculates the number of paramteres to optimize
|
! Subroutine CALC_NOPT calculates the number of paramteres to optimize
|
||||||
!
|
! 子程序用于计算需要优化的参数数量
|
||||||
! NOTES:
|
! NOTES:
|
||||||
! (1 ) Set NOPT for initial conditions to 3D: IIPAR*JJPAR*LLPAR*N_TRACERS to
|
! (1 ) Set NOPT for initial conditions to 3D: IIPAR*JJPAR*LLPAR*N_TRACERS to
|
||||||
! be consistent with other parts of the code (mak, 6/18/09)
|
! be consistent with other parts of the code (mak, 6/18/09)
|
||||||
|
@ -64,29 +64,29 @@ c This subroutine partitions the working arrays wa and iwa, and
|
|||||||
c then uses the limited memory BFGS method to solve the bound
|
c then uses the limited memory BFGS method to solve the bound
|
||||||
c constrained optimization problem by calling mainlb.
|
c constrained optimization problem by calling mainlb.
|
||||||
c (The direct method will be used in the subspace minimization.)
|
c (The direct method will be used in the subspace minimization.)
|
||||||
c
|
c 看上去就是一个利用有限内存进行最优化的程序?
|
||||||
c n is an integer variable.
|
c n is an integer variable. problem 的维度大小
|
||||||
c On entry n is the dimension of the problem.
|
c On entry n is the dimension of the problem.
|
||||||
c On exit n is unchanged.
|
c On exit n is unchanged.
|
||||||
c
|
c
|
||||||
c m is an integer variable.
|
c m is an integer variable. 可用的变量最大数量
|
||||||
c On entry m is the maximum number of variable metric corrections
|
c On entry m is the maximum number of variable metric corrections
|
||||||
c used to define the limited memory matrix.
|
c used to define the limited memory matrix.
|
||||||
c On exit m is unchanged.
|
c On exit m is unchanged.
|
||||||
c
|
c
|
||||||
c x is a double precision array of dimension n.
|
c x is a double precision array of dimension n. 状态向量,维度为 n
|
||||||
c On entry x is an approximation to the solution.
|
c On entry x is an approximation to the solution.
|
||||||
c On exit x is the current approximation.
|
c On exit x is the current approximation.
|
||||||
c
|
c
|
||||||
c l is a double precision array of dimension n.
|
c l is a double precision array of dimension n. 状态变量的下边界(预设好的)
|
||||||
c On entry l is the lower bound on x.
|
c On entry l is the lower bound on x.
|
||||||
c On exit l is unchanged.
|
c On exit l is unchanged.
|
||||||
c
|
c
|
||||||
c u is a double precision array of dimension n.
|
c u is a double precision array of dimension n. 状态变量的上边界(预设好的)
|
||||||
c On entry u is the upper bound on x.
|
c On entry u is the upper bound on x.
|
||||||
c On exit u is unchanged.
|
c On exit u is unchanged.
|
||||||
c
|
c
|
||||||
c nbd is an integer array of dimension n.
|
c nbd is an integer array of dimension n. 指定了边界是如何约束变量的
|
||||||
c On entry nbd represents the type of bounds imposed on the
|
c On entry nbd represents the type of bounds imposed on the
|
||||||
c variables, and must be specified as follows:
|
c variables, and must be specified as follows:
|
||||||
c nbd(i)=0 if x(i) is unbounded,
|
c nbd(i)=0 if x(i) is unbounded,
|
||||||
@ -95,15 +95,15 @@ c 2 if x(i) has both lower and upper bounds, and
|
|||||||
c 3 if x(i) has only an upper bound.
|
c 3 if x(i) has only an upper bound.
|
||||||
c On exit nbd is unchanged.
|
c On exit nbd is unchanged.
|
||||||
c
|
c
|
||||||
c f is a double precision variable.
|
c f is a double precision variable. 代价函数值?
|
||||||
c On first entry f is unspecified.
|
c On first entry f is unspecified.
|
||||||
c On final exit f is the value of the function at x.
|
c On final exit f is the value of the function at x.
|
||||||
c
|
c
|
||||||
c g is a double precision array of dimension n.
|
c g is a double precision array of dimension n. 梯度数组,和状态向量的维度一致
|
||||||
c On first entry g is unspecified.
|
c On first entry g is unspecified.
|
||||||
c On final exit g is the value of the gradient at x.
|
c On final exit g is the value of the gradient at x.
|
||||||
c
|
c
|
||||||
c factr is a double precision variable.
|
c factr is a double precision variable. 大概是一个最优化的临界值,到该值后结束迭代
|
||||||
c On entry factr >= 0 is specified by the user. The iteration
|
c On entry factr >= 0 is specified by the user. The iteration
|
||||||
c will stop when
|
c will stop when
|
||||||
c
|
c
|
||||||
@ -115,7 +115,7 @@ c low accuracy; 1.d+7 for moderate accuracy; 1.d+1 for extremely
|
|||||||
c high accuracy.
|
c high accuracy.
|
||||||
c On exit factr is unchanged.
|
c On exit factr is unchanged.
|
||||||
c
|
c
|
||||||
c pgtol is a double precision variable.
|
c pgtol is a double precision variable. 一个用户指定的值,用于指定迭代结束的条件,用于和梯度投影的长度比较
|
||||||
c On entry pgtol >= 0 is specified by the user. The iteration
|
c On entry pgtol >= 0 is specified by the user. The iteration
|
||||||
c will stop when
|
c will stop when
|
||||||
c
|
c
|
||||||
@ -124,15 +124,15 @@ c
|
|||||||
c where pg_i is the ith component of the projected gradient.
|
c where pg_i is the ith component of the projected gradient.
|
||||||
c On exit pgtol is unchanged.
|
c On exit pgtol is unchanged.
|
||||||
c
|
c
|
||||||
c wa is a double precision working array of length
|
c wa is a double precision working array of length 用于计算的数组,这里就是外面状态向量计算的公式
|
||||||
c (2mmax + 5)nmax + 12mmax^2 + 12mmax.
|
c (2mmax + 5)nmax + 12mmax^2 + 12mmax.
|
||||||
c
|
c
|
||||||
c iwa is an integer working array of length 3nmax.
|
c iwa is an integer working array of length 3nmax. 同样也是用于计算的数组
|
||||||
c
|
c
|
||||||
c task is a working string of characters of length 60 indicating
|
c task is a working string of characters of length 60 indicating 作业状态说明
|
||||||
c the current job when entering and quitting this subroutine.
|
c the current job when entering and quitting this subroutine.
|
||||||
c
|
c
|
||||||
c iprint is an integer variable that must be set by the user.
|
c iprint is an integer variable that must be set by the user. 指定了如何输出结果
|
||||||
c It controls the frequency and type of output generated:
|
c It controls the frequency and type of output generated:
|
||||||
c iprint<0 no output is generated;
|
c iprint<0 no output is generated;
|
||||||
c iprint=0 print only one line at the last iteration;
|
c iprint=0 print only one line at the last iteration;
|
||||||
@ -143,9 +143,9 @@ c iprint>100 print details of every iteration including x and g;
|
|||||||
c When iprint > 0, the file iterate.dat will be created to
|
c When iprint > 0, the file iterate.dat will be created to
|
||||||
c summarize the iteration.
|
c summarize the iteration.
|
||||||
c
|
c
|
||||||
c csave is a working string of characters of length 60.
|
c csave is a working string of characters of length 60. 同样保存了作业状态的文本
|
||||||
c
|
c
|
||||||
c lsave is a logical working array of dimension 4.
|
c lsave is a logical working array of dimension 4. 用于指定任务状态的一个逻辑数组
|
||||||
c On exit with 'task' = NEW_X, the following information is
|
c On exit with 'task' = NEW_X, the following information is
|
||||||
c available:
|
c available:
|
||||||
c If lsave(1) = .true. then the initial X has been replaced by
|
c If lsave(1) = .true. then the initial X has been replaced by
|
||||||
@ -154,7 +154,7 @@ c If lsave(2) = .true. then the problem is constrained;
|
|||||||
c If lsave(3) = .true. then each variable has upper and lower
|
c If lsave(3) = .true. then each variable has upper and lower
|
||||||
c bounds;
|
c bounds;
|
||||||
c
|
c
|
||||||
c isave is an integer working array of dimension 44.
|
c isave is an integer working array of dimension 44. 一些更具体的状态标记
|
||||||
c On exit with 'task' = NEW_X, the following information is
|
c On exit with 'task' = NEW_X, the following information is
|
||||||
c available:
|
c available:
|
||||||
c isave(22) = the total number of intervals explored in the
|
c isave(22) = the total number of intervals explored in the
|
||||||
@ -181,7 +181,7 @@ c active constraints in the current iteration;
|
|||||||
c isave(41) = the number of variables entering the set of active
|
c isave(41) = the number of variables entering the set of active
|
||||||
c constraints in the current iteration.
|
c constraints in the current iteration.
|
||||||
c
|
c
|
||||||
c dsave is a double precision working array of dimension 29.
|
c dsave is a double precision working array of dimension 29. 大概是一些任务的结果
|
||||||
c On exit with 'task' = NEW_X, the following information is
|
c On exit with 'task' = NEW_X, the following information is
|
||||||
c available:
|
c available:
|
||||||
c dsave(1) = current 'theta' in the BFGS matrix;
|
c dsave(1) = current 'theta' in the BFGS matrix;
|
||||||
@ -210,7 +210,7 @@ c
|
|||||||
c L-BFGS-B Library ... mainlb.
|
c L-BFGS-B Library ... mainlb.
|
||||||
c
|
c
|
||||||
c
|
c
|
||||||
c References:
|
c References: 居然还有参考文献
|
||||||
c
|
c
|
||||||
c [1] R. H. Byrd, P. Lu, J. Nocedal and C. Zhu, ``A limited
|
c [1] R. H. Byrd, P. Lu, J. Nocedal and C. Zhu, ``A limited
|
||||||
c memory algorithm for bound constrained optimization'',
|
c memory algorithm for bound constrained optimization'',
|
||||||
@ -494,7 +494,7 @@ c ************
|
|||||||
double precision one,zero
|
double precision one,zero
|
||||||
parameter (one=1.0d0,zero=0.0d0)
|
parameter (one=1.0d0,zero=0.0d0)
|
||||||
|
|
||||||
if (task .eq. 'START') then
|
if (task .eq. 'START') then ! 如果作业状态是开始
|
||||||
|
|
||||||
epsmch = epsilon(one)
|
epsmch = epsilon(one)
|
||||||
|
|
||||||
@ -634,7 +634,7 @@ c restore the previous iterate.
|
|||||||
|
|
||||||
c Compute f0 and g0.
|
c Compute f0 and g0.
|
||||||
|
|
||||||
task = 'FG_START'
|
task = 'FG_START' ! 如果作业状态不是开始,则设置为 FG_START,让驱动器继续计算代价函数和梯度
|
||||||
c return to the driver to calculate f and g; reenter at 111.
|
c return to the driver to calculate f and g; reenter at 111.
|
||||||
goto 1000
|
goto 1000
|
||||||
111 continue
|
111 continue
|
||||||
|
Reference in New Issue
Block a user