32 REAL (rprec) :: recon_stop
44 TYPE (model_class),
POINTER ::
model => null()
46 TYPE (gaussp_class_pointer),
DIMENSION(:),
POINTER ::
50 TYPE (signal_pointer),
DIMENSION(:),
POINTER ::
68 INTEGER :: magnetic_index = -1
71 INTEGER :: sxrem_index = -1
74 INTEGER :: intpol_index = -1
77 INTEGER :: thomson_index = -1
80 INTEGER :: extcurz_index = -1
83 INTEGER :: mse_index = -1
86 INTEGER :: ece_index = -1
89 INTEGER :: limiter_index = -1
92 INTEGER :: prior_gaussian_index = -1
95 INTEGER :: sxrem_ratio_index = -1
98 INTEGER :: combination_index = -1
101 INTEGER :: result_ncid
104 #if defined (mpi_opt)
106 INTEGER :: global_comm = mpi_comm_null
108 INTEGER :: equilibrium_comm = mpi_comm_null
110 INTEGER :: reconstruction_comm = mpi_comm_null
138 REAL (rprec) :: start_time
141 start_time = profiler_get_start_time()
147 CALL profiler_set_stop_time(
'v3fit_context_construct', start_time)
167 TYPE (v3fit_context_class),
POINTER :: this
173 IF (
ASSOCIATED(this%cl_parser))
THEN
175 this%cl_parser => null()
178 IF (
ASSOCIATED(this%model))
THEN
179 CALL model_destruct(this%model)
184 IF (
ASSOCIATED(this%gp))
THEN
185 DO i = 1,
SIZE(this%gp)
186 IF (
ASSOCIATED(this%gp(i)%p))
THEN
187 CALL gaussp_destruct(this%gp(i)%p)
188 this%gp(i)%p => null()
192 this%signals => null()
196 IF (
ASSOCIATED(this%signals))
THEN
197 DO i = 1,
SIZE(this%signals)
198 IF (
ASSOCIATED(this%signals(i)%p))
THEN
199 DEALLOCATE(this%signals(i)%p)
200 this%signals(i)%p => null()
203 DEALLOCATE(this%signals)
204 this%signals => null()
208 IF (
ASSOCIATED(this%derived_params))
THEN
209 DO i = 1,
SIZE(this%derived_params)
210 IF (
ASSOCIATED(this%derived_params(i)%p))
THEN
212 this%derived_params(i)%p => null()
215 DEALLOCATE(this%derived_params)
216 this%derived_params => null()
220 IF (
ASSOCIATED(this%params))
THEN
221 DO i = 1,
SIZE(this%params)
222 IF (
ASSOCIATED(this%params(i)%p))
THEN
224 this%params(i)%p => null()
227 DEALLOCATE(this%params)
228 this%params => null()
232 IF (
ASSOCIATED(this%params))
THEN
233 DO i = 1,
SIZE(this%locks)
234 IF (
ASSOCIATED(this%locks(i)%p))
THEN
236 this%locks(i)%p => null()
239 DEALLOCATE(this%locks)
243 IF (
ASSOCIATED(this%recon))
THEN
249 this%prior_gaussian_index = -1
250 this%magnetic_index = -1
251 this%sxrem_index = -1
252 this%intpol_index = -1
253 this%thomson_index = -1
254 this%extcurz_index = -1
257 this%limiter_index = -1
258 this%sxrem_ratio_index = -1
259 this%combination_index = -1
281 TYPE (v3fit_context_class),
INTENT(inout) :: this
286 TYPE (signal_pointer),
DIMENSION(:),
POINTER :: temp_signal
287 REAL (rprec) :: start_time
290 start_time = profiler_get_start_time()
292 WRITE (*,*)
' *** Resizing context arrays'
293 WRITE (this%runlog_iou,*)
' *** Resizing context arrays'
296 IF (
ASSOCIATED(this%signals))
THEN
297 minsize =
SIZE(this%signals)
298 DO i = 1,
SIZE(this%signals)
299 IF (.not.
ASSOCIATED(this%signals(i)%p))
THEN
307 IF (minsize .eq. 0)
THEN
308 DEALLOCATE(this%signals)
309 this%signals => null()
311 CALL profiler_set_stop_time(
'v3fit_context_resize',
315 ELSE IF (minsize .lt.
SIZE(this%signals))
THEN
316 ALLOCATE(temp_signal(minsize))
318 temp_signal(i)%p => this%signals(i)%p
321 DEALLOCATE(this%signals)
322 this%signals => temp_signal
327 CALL profiler_set_stop_time(
'v3fit_context_resize', start_time)
344 TYPE (v3fit_context_class),
INTENT(inout) :: this
347 CHARACTER (len=path_length) :: filename
349 INTEGER :: recon_rank
350 REAL (rprec) :: start_time
353 start_time = profiler_get_start_time()
356 CALL mpi_comm_rank(this%reconstruction_comm, recon_rank, status)
366 CALL safe_open(this%runlog_iou, status,
367 & trim(
'runlog.' // filename_base(filename)),
368 &
'replace',
'formatted', delim_in=
'none')
369 CALL assert_eq(0, status,
'v3fit_context_construct: ' //
370 &
'Safe_open of runlog. ' //
371 & trim(filename_base(filename)) //
'failed')
376 CALL safe_open(this%recout_iou, status,
377 & trim(
'recout.' // filename_base(filename)),
378 &
'replace',
'formatted', delim_in=
'none')
379 CALL assert_eq(0, status,
'v3fit_context_construct: ' //
380 &
'Safe_open of recout. ' //
381 & trim(filename_base(filename)) //
'failed')
385 & recon_rank .eq. 0)
THEN
388 status = nf_open(filename, nf_write, this%result_ncid)
389 CALL assert_eq(status, nf_noerr, nf_strerror(status))
392 status = nf_create(
'result.' // trim(filename_base(filename))
393 & //
'.nc', nf_clobber,
395 CALL assert_eq(status, nf_noerr, nf_strerror(status))
398 WRITE (this%runlog_iou, *)
'V3FITA RUN'
399 WRITE (this%runlog_iou, *)
' Namelist Input from file ',
402 WRITE (this%recout_iou, *)
'V3FITA RUN'
403 WRITE (this%recout_iou, *)
' Namelist Input from file ',
406 CALL profiler_set_stop_time(
'v3fit_context_create_files',
424 TYPE (v3fit_context_class),
INTENT(inout) :: this
428 REAL (rprec) :: start_time
431 start_time = profiler_get_start_time()
433 CLOSE(this%runlog_iou)
434 CLOSE(this%recout_iou)
436 status = nf_close(this%result_ncid)
437 CALL assert_eq(status, nf_noerr, nf_strerror(status))
439 CALL profiler_set_stop_time(
'v3fit_context_close_files',
459 TYPE (v3fit_context_class),
INTENT(inout) :: this
463 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sem_row
464 INTEGER :: sem_offset
469 CHARACTER (len=26 + 14*v3fit_max_parameters),
POINTER ::
471 INTEGER,
DIMENSION(:),
ALLOCATABLE :: indices
472 class(signal_class),
POINTER :: temp_signal
473 REAL (rprec) :: start_time
476 CHARACTER (len=12),
PARAMETER :: prefix =
' '
479 start_time = profiler_get_start_time()
481 WRITE (*,*)
' *** Writing context to disk'
482 WRITE (this%runlog_iou,*)
' *** Writing context to disk'
488 IF (
ASSOCIATED(this%recon))
THEN
493 IF (
ASSOCIATED(this%derived_params))
THEN
495 DO j = 1,
SIZE(this%derived_params)
497 & this%recout_iou, j, this%model)
501 IF (
SIZE(this%derived_params) .gt. 0 .and.
502 &
ASSOCIATED(this%derived_params(1)%p%correlation))
THEN
504 & this%derived_params,
511 DO j = 1,
SIZE(this%derived_params)
513 & this%recout_iou, this%model)
519 IF (
ASSOCIATED(this%params))
THEN
521 DO j = 1,
SIZE(this%params)
522 CALL param_write(this%params(j)%p, this%recout_iou, j,
527 IF (
SIZE(this%params) .gt. 0 .and.
528 &
ASSOCIATED(this%params(1)%p%correlation))
THEN
531 &
' *** Reconstruction '
536 DO j = 1,
SIZE(this%params)
538 & this%recout_iou, this%model)
543 IF (
ASSOCIATED(this%signals))
THEN
552 &
'Effectiveness ' //
560 ALLOCATE(sem_row(
SIZE(this%params)))
562 WRITE (sem_header, 1002)
SIZE(this%params)
564 DO i = 1,
SIZE(this%signals)
565 temp_signal => this%signals(i)%p
567 DO j = 1,
SIZE(this%params)
568 sem_row(j) = this%params(j)%p%recon%sem(i)
571 WRITE (this%recout_iou, sem_header(1:26))
572 & i, temp_signal%s_name, sem_row
577 WRITE (sem_header, 1003)
SIZE(this%params)
578 DO j = 1,
SIZE(this%params)
579 sem_row(j) = sum(this%params(j)%p%recon%sem)
582 WRITE (this%recout_iou, *)
583 WRITE (this%recout_iou, sem_header) sem_row
586 ALLOCATE(indices(
SIZE(this%params)))
588 WRITE (sem_header, 1001)
' Most Effective Signal:'
590 DO j = 1,
SIZE(this%params)
591 indices(j) = maxloc(this%params(j)%p%recon%sem, 1)
592 sem_row(j) = this%params(j)%p%recon%sem(indices(j))
594 WRITE (sem_header, 1000)
595 & sem_header(1:sem_offset),
596 & trim(this%signals(indices(j))%p%s_name)
597 sem_offset = sem_offset + 14
599 WRITE (this%recout_iou, 1001)
600 & sem_header(1:26 + 14*
SIZE(this%params))
602 WRITE (sem_header, 1005)
SIZE(this%params)
603 WRITE (this%recout_iou, sem_header) indices
605 WRITE (sem_header, 1006)
SIZE(this%params)
606 WRITE (this%recout_iou, sem_header) sem_row
609 DEALLOCATE(sem_header)
613 1000
FORMAT (a,2x,a12)
615 1002
FORMAT (
'(i4,2x,a20,',i3,
'(2x,es12.5))')
616 1003
FORMAT (
'(20x,''Total:''',i3,
'(2x,es12.5))')
617 1005
FORMAT (
'(13x,''Signal Index:''',i3,
'(2x,i12))')
618 1006
FORMAT (
'(16x,''Max Value:''',i3,
'(2x,es12.5))')
622 IF (
ASSOCIATED(this%model))
THEN
623 CALL model_write(this%model, this%recout_iou)
627 IF (
ASSOCIATED(this%signals))
THEN
628 WRITE (this%recout_iou, *)
629 WRITE (this%recout_iou, *)
' *** Signals'
631 DO i = 1,
SIZE(this%signals)
632 temp_signal => this%signals(i)%p
636 & (this%magnetic_index .eq. i) .or.
637 & (this%sxrem_index .eq. i) .or.
638 & (this%intpol_index .eq. i) .or.
639 & (this%thomson_index .eq. i) .or.
640 & (this%extcurz_index .eq. i) .or.
641 & (this%mse_index .eq. i) .or.
642 & (this%ece_index .eq. i) .or.
643 & (this%limiter_index .eq. i) .or.
644 & (this%prior_gaussian_index .eq. i) .or.
645 & (this%sxrem_ratio_index .eq. i) .or.
646 & (this%combination_index .eq. i))
THEN
648 CALL temp_signal%write_header(this%recout_iou)
651 CALL temp_signal%write(this%recout_iou, i, this%model)
655 DO i = 1,
SIZE(this%signals)
656 temp_signal => this%signals(i)%p
657 CALL temp_signal%write_auxiliary(this%recout_iou, i,
662 CALL profiler_set_stop_time(
'v3fit_context_write', start_time)
689 TYPE (v3fit_context_class),
INTENT(inout) :: this
690 TYPE (param_pointer),
DIMENSION(:) :: params
691 CHARACTER (len=*) :: prefix
692 CHARACTER (len=*) :: type_name
700 CHARACTER (len=26 + 14*v3fit_max_parameters),
POINTER :: header
702 REAL (rprec) :: start_time
705 start_time = profiler_get_start_time()
707 WRITE (this%recout_iou, *)
708 WRITE (this%recout_iou, *) type_name
720 WRITE (header, 1000) prefix
722 DO j = 1,
SIZE(params)
723 WRITE (header, 1001) header(1:offset),
728 WRITE (this%recout_iou, 1000) header(1:offset)
732 CALL profiler_set_stop_time(
'v3fit_context_write_param_header',
736 1001
FORMAT (a,2x,a12)
812 TYPE (v3fit_context_class),
INTENT(inout) :: this
813 INTEGER,
INTENT(in) :: eq_steps
817 INTEGER :: maxnsteps_dim_id
818 INTEGER :: ndparam_dim_id
819 INTEGER :: nparam_dim_id
820 INTEGER :: nparamindex_dim_id
821 INTEGER :: nsignal_dim_id
822 INTEGER :: n_sig_models_dim_id
823 INTEGER :: string_len_dim_id
825 INTEGER :: eq_steps_id
827 INTEGER :: derived_param_name_id
828 INTEGER :: derived_param_index_id
829 INTEGER :: derived_param_value_id
830 INTEGER :: derived_param_sigma_id
831 INTEGER :: derived_param_corr_id
832 INTEGER :: param_name_id
833 INTEGER :: param_index_id
834 INTEGER :: param_value_id
835 INTEGER :: param_sigma_id
836 INTEGER :: param_corr_id
837 INTEGER :: param_sem_id
838 INTEGER :: signal_name_id
839 INTEGER :: signal_type_id
840 INTEGER :: signal_weight_id
841 INTEGER :: signal_observed_value_id
842 INTEGER :: signal_model_value_id
843 INTEGER :: signal_sigma_value_id
845 class(signal_class),
POINTER :: temp_signal
846 REAL (rprec) :: start_time
849 start_time = profiler_get_start_time()
854 IF (
ASSOCIATED(this%recon))
THEN
855 status = nf_def_dim(this%result_ncid,
'maxnsteps',
856 & nf_unlimited, maxnsteps_dim_id)
858 status = nf_def_dim(this%result_ncid,
'maxnsteps',
859 & 1, maxnsteps_dim_id)
861 CALL assert_eq(status, nf_noerr, nf_strerror(status))
863 IF (
ASSOCIATED(this%params) .or.
864 &
ASSOCIATED(this%signals) .or.
865 &
ASSOCIATED(this%model))
THEN
866 status = nf_def_dim(this%result_ncid,
'string_len',
867 & data_name_length, string_len_dim_id)
868 CALL assert_eq(status, nf_noerr, nf_strerror(status))
871 IF (
ASSOCIATED(this%derived_params) .and.
872 &
SIZE(this%derived_params) .gt. 0)
THEN
873 status = nf_def_dim(this%result_ncid,
'ndparam',
874 &
SIZE(this%derived_params),
876 CALL assert_eq(status, nf_noerr, nf_strerror(status))
879 IF (
ASSOCIATED(this%params))
THEN
880 status = nf_def_dim(this%result_ncid,
'nparam',
881 &
SIZE(this%params), nparam_dim_id)
882 CALL assert_eq(status, nf_noerr, nf_strerror(status))
884 status = nf_def_dim(this%result_ncid,
'nparamindex',
885 & 2, nparamindex_dim_id)
886 CALL assert_eq(status, nf_noerr, nf_strerror(status))
889 IF (
ASSOCIATED(this%signals))
THEN
890 status = nf_def_dim(this%result_ncid,
'nsignal',
891 &
SIZE(this%signals), nsignal_dim_id)
892 CALL assert_eq(status, nf_noerr, nf_strerror(status))
895 IF (
ASSOCIATED(this%signals))
THEN
896 status = nf_def_dim(this%result_ncid,
'n_sig_models', 4,
897 & n_sig_models_dim_id)
898 CALL assert_eq(status, nf_noerr, nf_strerror(status))
902 status = nf_def_var(this%result_ncid,
'nsteps', nf_int, 0, 0,
904 CALL assert_eq(status, nf_noerr, nf_strerror(status))
906 status = nf_def_var(this%result_ncid,
'eq_steps', nf_int, 0, 0,
908 CALL assert_eq(status, nf_noerr, nf_strerror(status))
910 IF (
ASSOCIATED(this%recon))
THEN
911 status = nf_def_var(this%result_ncid,
'g2', nf_double, 1,
912 & (/ maxnsteps_dim_id /), g2_id)
913 CALL assert_eq(status, nf_noerr, nf_strerror(status))
917 IF (
ASSOCIATED(this%derived_params) .and.
918 &
SIZE(this%derived_params) .gt. 0)
THEN
919 status = nf_def_var(this%result_ncid,
'derived_param_name',
920 & nf_char, 2, (/ string_len_dim_id,
922 & derived_param_name_id)
923 CALL assert_eq(status, nf_noerr, nf_strerror(status))
925 status = nf_def_var(this%result_ncid,
'derived_param_index',
926 & nf_int, 2, (/ nparamindex_dim_id,
928 & derived_param_index_id)
929 CALL assert_eq(status, nf_noerr, nf_strerror(status))
931 status = nf_def_var(this%result_ncid,
'derived_param_value',
932 & nf_double, 2, (/ ndparam_dim_id,
933 & maxnsteps_dim_id /),
934 & derived_param_value_id)
935 CALL assert_eq(status, nf_noerr, nf_strerror(status))
937 status = nf_def_var(this%result_ncid,
'derived_param_sigma',
938 & nf_double, 2, (/ ndparam_dim_id,
939 & maxnsteps_dim_id /),
940 & derived_param_sigma_id)
941 CALL assert_eq(status, nf_noerr, nf_strerror(status))
943 status = nf_def_var(this%result_ncid,
'derived_param_corr',
944 & nf_double, 3, (/ ndparam_dim_id,
946 & maxnsteps_dim_id /),
947 & derived_param_corr_id)
948 CALL assert_eq(status, nf_noerr, nf_strerror(status))
952 IF (
ASSOCIATED(this%params))
THEN
953 status = nf_def_var(this%result_ncid,
'param_name', nf_char,
954 & 2, (/ string_len_dim_id,
955 & nparam_dim_id /), param_name_id)
956 CALL assert_eq(status, nf_noerr, nf_strerror(status))
958 status = nf_def_var(this%result_ncid,
'param_index', nf_int,
959 & 2, (/ nparamindex_dim_id,
960 & nparam_dim_id /), param_index_id)
961 CALL assert_eq(status, nf_noerr, nf_strerror(status))
963 status = nf_def_var(this%result_ncid,
'param_value', nf_double,
964 & 2, (/ nparam_dim_id,
965 & maxnsteps_dim_id /),
967 CALL assert_eq(status, nf_noerr, nf_strerror(status))
969 status = nf_def_var(this%result_ncid,
'param_sigma', nf_double,
970 & 2, (/ nparam_dim_id,
971 & maxnsteps_dim_id /),
973 CALL assert_eq(status, nf_noerr, nf_strerror(status))
975 status = nf_def_var(this%result_ncid,
'param_corr',
976 & nf_double, 3, (/ nparam_dim_id,
978 & maxnsteps_dim_id /),
980 CALL assert_eq(status, nf_noerr, nf_strerror(status))
982 status = nf_def_var(this%result_ncid,
'signal_eff_matrix',
983 & nf_double, 3, (/ nsignal_dim_id,
985 & maxnsteps_dim_id /),
987 CALL assert_eq(status, nf_noerr, nf_strerror(status))
991 IF (
ASSOCIATED(this%signals))
THEN
992 status = nf_def_var(this%result_ncid,
'signal_name', nf_char,
993 & 2, (/ string_len_dim_id,
994 & nsignal_dim_id /), signal_name_id)
995 CALL assert_eq(status, nf_noerr, nf_strerror(status))
997 status = nf_def_var(this%result_ncid,
'signal_type', nf_char,
998 & 2, (/ string_len_dim_id,
999 & nsignal_dim_id /), signal_type_id)
1000 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1002 status = nf_def_var(this%result_ncid,
'signal_weight',
1003 & nf_double, 1, (/ nsignal_dim_id /),
1005 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1007 status = nf_def_var(this%result_ncid,
'signal_observed_value',
1008 & nf_double, 1, (/ nsignal_dim_id /),
1009 & signal_observed_value_id)
1010 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1012 status = nf_def_var(this%result_ncid,
'signal_model_value',
1013 & nf_double, 3, (/ n_sig_models_dim_id,
1015 & maxnsteps_dim_id /),
1016 & signal_model_value_id)
1017 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1019 status = nf_def_var(this%result_ncid,
'signal_sigma',
1020 & nf_double, 2, (/ nsignal_dim_id,
1021 & maxnsteps_dim_id /),
1022 & signal_sigma_value_id)
1023 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1026 IF (
ASSOCIATED(this%model))
THEN
1027 CALL model_def_result(this%model, this%result_ncid,
1028 & maxnsteps_dim_id, string_len_dim_id)
1032 status = nf_enddef(this%result_ncid)
1033 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1035 IF (
ASSOCIATED(this%derived_params))
THEN
1036 DO i = 1,
SIZE(this%derived_params)
1037 status = nf_put_vara_text(this%result_ncid,
1038 & derived_param_name_id, (/ 1, i /),
1039 & (/ data_name_length, 1 /),
1042 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1044 status = nf_put_vara_int(this%result_ncid,
1045 & derived_param_index_id,
1046 & (/ 1, i /), (/ 2, 1 /),
1047 & this%derived_params(i)%p%indices)
1048 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1052 IF (
ASSOCIATED(this%params))
THEN
1053 DO i = 1,
SIZE(this%params)
1054 status = nf_put_vara_text(this%result_ncid, param_name_id,
1056 & (/ data_name_length, 1 /),
1059 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1061 status = nf_put_vara_int(this%result_ncid,
1063 & (/ 1, i /), (/ 2, 1 /),
1064 & this%params(i)%p%indices)
1065 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1069 IF (
ASSOCIATED(this%signals))
THEN
1070 DO i = 1,
SIZE(this%signals)
1071 temp_signal => this%signals(i)%p
1073 status = nf_put_vara_text(this%result_ncid, signal_name_id,
1075 & (/ data_name_length, 1 /),
1076 & this%signals(i)%p%s_name)
1077 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1079 status = nf_put_vara_text(this%result_ncid, signal_type_id,
1081 & (/ data_name_length, 1 /),
1082 & temp_signal%get_type())
1083 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1085 status = nf_put_var1_double(this%result_ncid,
1086 & signal_weight_id, i,
1087 & this%signals(i)%p%weight)
1088 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1090 status = nf_put_var1_double(this%result_ncid,
1091 & signal_observed_value_id, i,
1092 & this%signals(i)%p%observed)
1093 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1097 IF (
ASSOCIATED(this%model))
THEN
1098 CALL model_write_init_data(this%model, this%result_ncid)
1103 CALL profiler_set_stop_time(
'v3fit_context_init_data', start_time)
1127 TYPE (v3fit_context_class),
INTENT(inout) :: this
1128 LOGICAL,
INTENT(in) :: first_step
1129 INTEGER,
INTENT(in) :: eq_steps
1132 INTEGER :: i, status
1133 INTEGER :: current_step
1134 INTEGER :: nsteps_id
1135 INTEGER :: eq_steps_id
1137 INTEGER :: derived_param_value_id
1138 INTEGER :: derived_param_sigma_id
1139 INTEGER :: derived_param_corr_id
1140 INTEGER :: param_value_id
1141 INTEGER :: param_sigma_id
1142 INTEGER :: param_corr_id
1143 INTEGER :: param_sem_id
1144 INTEGER :: signal_model_value_id
1145 INTEGER :: signal_sigma_value_id
1147 class(signal_class),
POINTER :: temp_signal
1148 REAL (rprec) :: start_time
1151 start_time = profiler_get_start_time()
1154 status = nf_inq_varid(this%result_ncid,
'nsteps', nsteps_id)
1155 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1156 IF (first_step)
THEN
1157 status = nf_put_var_int(this%result_ncid, nsteps_id, 0)
1158 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1161 status = nf_get_var_int(this%result_ncid, nsteps_id,
1163 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1164 current_step = current_step + 1
1165 status = nf_put_var_int(this%result_ncid, nsteps_id,
1167 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1171 current_step = current_step + 1
1174 status = nf_inq_varid(this%result_ncid,
'eq_steps', eq_steps_id)
1175 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1176 status = nf_put_var_int(this%result_ncid, eq_steps_id, eq_steps)
1177 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1179 CALL model_write_step_data(this%model, this%result_ncid,
1182 IF (
ASSOCIATED(this%recon))
THEN
1183 status = nf_inq_varid(this%result_ncid,
'g2', g2_id)
1184 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1185 status = nf_put_var1_double(this%result_ncid, g2_id,
1188 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1191 IF (
ASSOCIATED(this%derived_params) .and.
1192 &
SIZE(this%derived_params) .gt. 0)
THEN
1193 status = nf_inq_varid(this%result_ncid,
1194 &
'derived_param_value',
1195 & derived_param_value_id)
1196 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1198 status = nf_inq_varid(this%result_ncid,
1199 &
'derived_param_sigma',
1200 & derived_param_sigma_id)
1201 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1203 status = nf_inq_varid(this%result_ncid,
1204 &
'derived_param_corr',
1205 & derived_param_corr_id)
1206 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1208 DO i = 1,
SIZE(this%derived_params)
1210 & this%model, this%result_ncid,
1212 & derived_param_value_id,
1213 & derived_param_sigma_id,
1214 & derived_param_corr_id)
1218 IF (
ASSOCIATED(this%params))
THEN
1219 status = nf_inq_varid(this%result_ncid,
'param_value',
1221 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1223 status = nf_inq_varid(this%result_ncid,
'param_sigma',
1225 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1227 status = nf_inq_varid(this%result_ncid,
'param_corr',
1229 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1231 status = nf_inq_varid(this%result_ncid,
'signal_eff_matrix',
1233 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1235 DO i = 1,
SIZE(this%params)
1237 & this%result_ncid, current_step,
1238 & i, param_value_id,
1245 IF (
ASSOCIATED(this%signals))
THEN
1246 status = nf_inq_varid(this%result_ncid,
'signal_model_value',
1247 & signal_model_value_id)
1248 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1250 status = nf_inq_varid(this%result_ncid,
'signal_sigma',
1251 & signal_sigma_value_id)
1252 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1254 DO i = 1,
SIZE(this%signals)
1255 temp_signal => this%signals(i)%p
1257 CALL temp_signal%write_step_data(this%model,
1260 & signal_model_value_id,
1261 & signal_sigma_value_id)
1267 status = nf_sync(this%result_ncid)
1268 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1270 CALL profiler_set_stop_time(
'v3fit_context_write_step_data',
1291 INTEGER,
INTENT(inout) :: current_step
1296 INTEGER :: nsteps_id
1297 INTEGER :: eq_steps_id
1298 INTEGER :: param_value_id
1299 INTEGER :: param_sigma_id
1300 INTEGER :: param_corr_id
1301 REAL (rprec) :: start_time
1304 start_time = profiler_get_start_time()
1308 status = nf_inq_varid(this%result_ncid,
'nsteps', nsteps_id)
1309 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1310 status = nf_get_var_int(this%result_ncid, nsteps_id,
1312 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1313 current_step = current_step + 1
1315 IF (
ASSOCIATED(this%params))
THEN
1316 status = nf_inq_varid(this%result_ncid,
'param_value',
1318 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1320 status = nf_inq_varid(this%result_ncid,
'param_sigma',
1322 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1324 status = nf_inq_varid(this%result_ncid,
'param_corr',
1326 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1328 DO i = 1,
SIZE(this%params)
1332 & i, param_value_id, param_sigma_id,
1333 & param_corr_id, this%equilibrium_comm,
1334 & this%recon%use_central)
1337 CALL model_restart(this%model, this%result_ncid,
1342 & this%signals, this%derived_params,
1347 status = nf_inq_varid(this%result_ncid,
'eq_steps', eq_steps_id)
1348 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1349 status = nf_get_var_int(this%result_ncid, eq_steps_id,
1351 CALL assert_eq(status, nf_noerr, nf_strerror(status))
1353 CALL profiler_set_stop_time(
'v3fit_context_restart', start_time)