run_model
– Run the model and write out the data
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