run_model Subroutine

subroutine run_model()

run_model – Run the model and write out the data

Arguments

None

Calls

proc~~run_model~~CallsGraph proc~run_model run_model none~add_attribute~2 Variable%add_attribute proc~run_model->none~add_attribute~2 none~collective_stage_data~3 ClientManager%collective_stage_data proc~run_model->none~collective_stage_data~3 none~done_collective_stage~2 ClientManager%done_collective_stage proc~run_model->none~done_collective_stage~2 none~insert~104 StringVariableMap%insert proc~run_model->none~insert~104 none~modify_metadata~2 ClientManager%modify_metadata proc~run_model->none~modify_metadata~2 none~post_wait ClientManager%post_wait proc~run_model->none~post_wait none~set_optimal_server ClientManager%set_optimal_server proc~run_model->none~set_optimal_server proc~set_temperature set_temperature proc~run_model->proc~set_temperature proc~set_tracer set_tracer proc~run_model->proc~set_tracer none~add_attribute_1d Variable%add_attribute_1d none~add_attribute~2->none~add_attribute_1d none~collective_stage_data ClientThread%collective_stage_data none~collective_stage_data~3->none~collective_stage_data none~current~12 ClientManager%current none~collective_stage_data~3->none~current~12 proc~mapl_return MAPL_Return none~collective_stage_data~3->proc~mapl_return proc~mapl_verify MAPL_Verify none~collective_stage_data~3->proc~mapl_verify none~done_collective_stage~2->none~current~12 none~done_collective_stage ClientThread%done_collective_stage none~done_collective_stage~2->none~done_collective_stage none~done_collective_stage~2->proc~mapl_return none~done_collective_stage~2->proc~mapl_verify none~insert_pair~11 StringVariableMap%insert_pair none~insert~104->none~insert_pair~11 none~modify_metadata~2->none~current~12 none~modify_metadata ClientThread%modify_metadata none~modify_metadata~2->none~modify_metadata none~modify_metadata~2->proc~mapl_return none~modify_metadata~2->proc~mapl_verify none~post_wait->none~current~12 none~post_wait_all ClientThread%post_wait_all none~post_wait->none~post_wait_all none~post_wait->proc~mapl_return none~post_wait->proc~mapl_verify at at none~set_optimal_server->at interface~mapl_assert MAPL_Assert none~set_optimal_server->interface~mapl_assert interface~mapl_sort MAPL_Sort none~set_optimal_server->interface~mapl_sort none~next~62 ClientManager%next none~set_optimal_server->none~next~62 none~set_current ClientManager%set_current none~set_optimal_server->none~set_current none~set_optimal_server->proc~mapl_return none~set_optimal_server->proc~mapl_verify

Called by

proc~~run_model~~CalledByGraph proc~run_model run_model program~main~8 main program~main~8->proc~run_model

Source Code

   subroutine run_model()
      day = 1
      num_steps = 18
      do n = 1, num_steps
         IF (pe_id == 0) PRINT*, "In Stepping: ", n

         ! Check if a new file (in the same collection) needs to be created.
         IF (MOD(n, num_time_records) == 1) THEN
            record_id = 1
            write(cday, '(I4.4)') day
            file_name = 'Nsample_pfio_file_Day'//cday//'.nc4'

            v = Variable(type=PFIO_REAL32, dimensions='time')
            call v%add_attribute('long_name', 'time')
            call v%add_attribute('units', 'minutes since 2010-01-03 00:00:00')
            call v%add_attribute('time_increment', 30000)
            call v%add_attribute('begin_date', 20100103)
            call v%add_attribute('begin_time', 0)
            call var_map%insert('time', v)
            call o_clients%modify_metadata(hist_id, var_map=var_map, rc=status)
            IF (pe_id == 0) print '(i5,a,a)', n, '  Created: ', file_name
         ENDIF

         ! Update variables
         !-----------------
         do k = k1, k2
            call set_temperature(local_temp(:,:,k))
         enddo

         call set_tracer(local_tracer(:,:))

         ! Write variables in netCDF file using PFIO methods
         !--------------------------------------------------
         call o_clients%set_optimal_server(nwriting=1)

         var_name = "temperature"
         ref =  ArrayReference(local_temp)
         call o_clients%collective_stage_data(hist_id, TRIM(file_name), &
                                   TRIM(var_name), ref, &
                                   start        = [i1,j1,k1,1], &
                                   global_start = [1,1,1,record_id], &
                                   global_count = [IM_WORLD,JM_WORLD,KM_WORLD,1])

         var_name = "tracer"
         ref =  ArrayReference(local_tracer)
         call o_clients%collective_stage_data(hist_id, TRIM(file_name), &
                                   TRIM(var_name), ref, &
                                   start        = [i1,j1,1], &
                                   global_start = [1,1,record_id], &
                                   global_count = [IM_WORLD,JM_WORLD,1])

         ! Is this the last record?
         IF (MOD(n, num_time_records) == 0) THEN
            day = day + 1
            record_id = 0
            ! write in the file and close it
            call o_clients%done_collective_stage()
         ENDIF
         call o_clients%post_wait()
         record_id = record_id + 1
         IF (pe_id == 0) PRINT*, "Out Stepping: ", n
      enddo
   end subroutine run_model