Ignore:
Timestamp:
Apr 11, 2019 11:29:34 AM (5 years ago)
Author:
kanani
Message:

restructure/add location/debug messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/radiation_model_mod.f90

    r3881 r3885  
    1515! PALM. If not, see <http://www.gnu.org/licenses/>.
    1616!
    17 ! Copyright 2015-2018 Institute of Computer Science of the
     17! Copyright 2015-2019 Institute of Computer Science of the
    1818!                     Czech Academy of Sciences, Prague
    19 ! Copyright 2015-2018 Czech Technical University in Prague
     19! Copyright 2015-2019 Czech Technical University in Prague
    2020! Copyright 1997-2019 Leibniz Universitaet Hannover
    2121!------------------------------------------------------------------------------!
     
    2828! -----------------
    2929! $Id$
     30! Changes related to global restructuring of location messages and introduction
     31! of additional debug messages
     32!
     33! 3881 2019-04-10 09:31:22Z suehring
    3034! Output of albedo and emissivity moved from USM, bugfixes in initialization
    3135! of albedo
     
    612616
    613617    USE control_parameters,                                                    &
    614         ONLY:  cloud_droplets, coupling_char, dz, dt_spinup, end_time,         &
     618        ONLY:  cloud_droplets, coupling_char,                                  &
     619               debug_output, debug_string,                                     &
     620               dz, dt_spinup, end_time,                                        &
    615621               humidity,                                                       &
    616622               initializing_actions, io_blocks, io_group,                      &
     
    13471353
    13481354
     1355       IF ( debug_output )  CALL debug_message( 'radiation_control', 'start' )
     1356
     1357
    13491358       SELECT CASE ( TRIM( radiation_scheme ) )
    13501359
     
    13621371       END SELECT
    13631372
     1373       IF ( debug_output )  CALL debug_message( 'radiation_control', 'end' )
    13641374
    13651375    END SUBROUTINE radiation_control
     
    18351845#endif
    18361846
     1847
     1848       IF ( debug_output )  CALL debug_message( 'radiation_init', 'start' )
    18371849!
    18381850!--    Activate radiation_interactions according to the existence of vertical surfaces and/or trees.
     
    18581870!--    via sky-view factors. This must be done before radiation is initialized.
    18591871       IF ( radiation_interactions )  CALL radiation_interaction_init
    1860 
    1861 !
    1862 !--    Initialize radiation model
    1863        CALL location_message( 'initializing radiation model', .FALSE. )
    1864 
    18651872!
    18661873!--    Allocate array for storing the surface net radiation
     
    28562863       CALL init_date_and_time
    28572864
    2858        CALL location_message( 'finished', .TRUE. )
    2859 
    28602865!
    28612866!--    Find all discretized apparent solar positions for radiation interaction.
     
    28672872!
    28682873!--       Read sky-view factors and further required data from file
    2869           CALL location_message( '    Start reading SVF from file', .FALSE. )
    28702874          CALL radiation_read_svf()
    2871           CALL location_message( '    Reading SVF from file has finished', .TRUE. )
    28722875
    28732876       ELSEIF ( radiation_interactions .AND. .NOT. read_svf)  THEN
    28742877!
    28752878!--       calculate SFV and CSF
    2876           CALL location_message( '    Start calculation of SVF', .FALSE. )
    28772879          CALL radiation_calc_svf()
    2878           CALL location_message( '    Calculation of SVF has finished', .TRUE. )
    28792880       ENDIF
    28802881
     
    28822883!
    28832884!--       Write svf, csf svfsurf and csfsurf data to file
    2884           CALL location_message( '    Start writing SVF in file', .FALSE. )
    28852885          CALL radiation_write_svf()
    2886           CALL location_message( '    Writing SVF in file has finished', .TRUE. )
    28872886       ENDIF
    28882887
     
    28942893       ENDIF
    28952894
    2896        RETURN
     2895       IF ( debug_output )  CALL debug_message( 'radiation_init', 'end' )
     2896
     2897       RETURN !todo: remove, I don't see what we need this for here
    28972898
    28982899    END SUBROUTINE radiation_init
     
    51045105
    51055106
     5107     IF ( debug_output )  CALL debug_message( 'radiation_interaction', 'start' )
     5108
    51065109     IF ( plant_canopy )  THEN
    51075110         pchf_prep(:) = r_d * exner(nz_urban_b:nz_urban_t)                                 &
     
    58485851           (emissivity_urb*sigma_sb * area_hor) )**0.25_wp
    58495852
     5853     IF ( debug_output )  CALL debug_message( 'radiation_interaction', 'end' )
     5854
     5855
    58505856    CONTAINS
    58515857
     
    59785984    END SUBROUTINE calc_diffusion_radiation
    59795985
    5980 
    59815986 END SUBROUTINE radiation_interaction
    59825987   
     
    61436148!--    allocate urban surfaces grid
    61446149!--    calc number of surfaces in local proc
    6145        CALL location_message( '    calculation of indices for surfaces', .TRUE. )
     6150       IF ( debug_output )  CALL debug_message( 'calculation of indices for surfaces', 'info' )
     6151
    61466152       nsurfl = 0
    61476153!
     
    64786484!--
    64796485!--    allocation of the arrays for direct and diffusion radiation
    6480        CALL location_message( '    allocation of radiation arrays', .TRUE. )
     6486       IF ( debug_output )  CALL debug_message( 'allocation of radiation arrays', 'info' )
    64816487!--    rad_sw_in, rad_lw_in are computed in radiation model,
    64826488!--    splitting of direct and diffusion part is done
     
    65776583!   
    65786584        INTEGER(iwp), DIMENSION(0:svfnorm_report_num) :: svfnorm_counts
    6579         CHARACTER(200)                                :: msg
     6585
    65806586
    65816587!--     calculation of the SVF
    6582         CALL location_message( '    calculation of SVF and CSF', .TRUE. )
    6583         CALL radiation_write_debug_log('Start calculation of SVF and CSF')
     6588        CALL location_message( 'calculating view factors for radiation interaction', 'start' )
    65846589
    65856590!--     initialize variables and temporary arrays for calculation of svf and csf
     
    69216926                     ENDIF
    69226927
    6923                      WRITE (msg,'(A,3I12)') 'Grow asvf:',nsvfl,nsvfla,k
    6924                      CALL radiation_write_debug_log( msg )
     6928                     IF ( debug_output )  THEN
     6929                        WRITE( debug_string, '(A,3I12)' ) 'Grow asvf:', nsvfl, nsvfla, k
     6930                        CALL debug_message( debug_string, 'info' )
     6931                     ENDIF
    69256932                     
    69266933                     nsvfla = k
     
    70047011                     ENDIF
    70057012
    7006                      WRITE(msg,'(A,3I12)') 'Grow asvf:',nsvfl,nsvfla,k
    7007                      CALL radiation_write_debug_log( msg )
     7013                     IF ( debug_output )  THEN
     7014                        WRITE( debug_string, '(A,3I12)' ) 'Grow asvf:', nsvfl, nsvfla, k
     7015                        CALL debug_message( debug_string, 'info' )
     7016                     ENDIF
    70087017                     
    70097018                     nsvfla = k
     
    71727181                    ENDIF
    71737182
    7174                     WRITE (msg,'(A,3I12)') 'Grow amrtf:', nmrtf, nmrtfa, k
    7175                     CALL radiation_write_debug_log( msg )
     7183                    IF ( debug_output )  THEN
     7184                       WRITE( debug_string, '(A,3I12)' ) 'Grow amrtf:', nmrtf, nmrtfa, k
     7185                       CALL debug_message( debug_string, 'info' )
     7186                    ENDIF
    71767187
    71777188                    nmrtfa = k
     
    72247235        ENDIF
    72257236
    7226         CALL radiation_write_debug_log( 'End of calculation SVF' )
    7227         WRITE(msg, *) 'Raytracing skipped for maximum distance of ', &
    7228            max_raytracing_dist, ' m on ', ray_skip_maxdist, ' pairs.'
    7229         CALL radiation_write_debug_log( msg )
    7230         WRITE(msg, *) 'Raytracing skipped for minimum potential value of ', &
    7231            min_irrf_value , ' on ', ray_skip_minval, ' pairs.'
    7232         CALL radiation_write_debug_log( msg )
    7233 
    7234         CALL location_message( '    waiting for completion of SVF and CSF calculation in all processes', .TRUE. )
     7237        IF ( debug_output )  CALL debug_message( 'waiting for completion of SVF and CSF calculation in all processes', 'info' )
     7238
    72357239!--     deallocate temporary global arrays
    72367240        DEALLOCATE(nzterr)
     
    72747278        ENDIF
    72757279
    7276         CALL location_message( '    calculation of the complete SVF array', .TRUE. )
     7280        IF ( debug_output )  CALL debug_message( 'calculation of the complete SVF array', 'info' )
    72777281
    72787282        IF ( rad_angular_discretization )  THEN
    7279            CALL radiation_write_debug_log( 'Load svf from the structure array to plain arrays' )
     7283           IF ( debug_output )  CALL debug_message( 'Load svf from the structure array to plain arrays', 'info' )
    72807284           ALLOCATE( svf(ndsvf,nsvfl) )
    72817285           ALLOCATE( svfsurf(idsvf,nsvfl) )
     
    72867290           ENDDO
    72877291        ELSE
    7288            CALL radiation_write_debug_log( 'Start SVF sort' )
     7292           IF ( debug_output )  CALL debug_message( 'Start SVF sort', 'info' )
    72897293!--        sort svf ( a version of quicksort )
    72907294           CALL quicksort_svf(asvf,1,nsvfl)
    72917295
    72927296           !< load svf from the structure array to plain arrays
    7293            CALL radiation_write_debug_log( 'Load svf from the structure array to plain arrays' )
     7297           IF ( debug_output )  CALL debug_message( 'Load svf from the structure array to plain arrays', 'info' )
    72947298           ALLOCATE( svf(ndsvf,nsvfl) )
    72957299           ALLOCATE( svfsurf(idsvf,nsvfl) )
     
    73467350        IF ( plant_canopy )  THEN
    73477351
    7348             CALL location_message( '    calculation of the complete CSF array', .TRUE. )
    7349             CALL radiation_write_debug_log( 'Calculation of the complete CSF array' )
     7352            IF ( debug_output )  CALL debug_message( 'Calculation of the complete CSF array', 'info' )
    73507353!--         sort and merge csf for the last time, keeping the array size to minimum
    73517354            CALL merge_and_grow_csf(-1)
     
    74197422!--         scatter and gather the number of elements to and from all processor
    74207423!--         and calculate displacements
    7421             CALL radiation_write_debug_log( 'Scatter and gather the number of elements to and from all processor' )
     7424            IF ( debug_output )  CALL debug_message( 'Scatter and gather the number of elements to and from all processor', 'info' )
     7425
    74227426            CALL MPI_AlltoAll(icsflt,1,MPI_INTEGER,ipcsflt,1,MPI_INTEGER,comm2d, ierr)
     7427
    74237428            IF ( ierr /= 0 ) THEN
    74247429                WRITE(9,*) 'Error MPI_AlltoAll1:', ierr, SIZE(icsflt), SIZE(ipcsflt)
     
    74347439
    74357440!--         exchange csf fields between processors
    7436             CALL radiation_write_debug_log( 'Exchange csf fields between processors' )
     7441            IF ( debug_output )  CALL debug_message( 'Exchange csf fields between processors', 'info' )
    74377442            udim = max(npcsfl,1)
    74387443            ALLOCATE( pcsflt_l(ndcsf*udim) )
     
    74737478
    74747479!--         sort csf ( a version of quicksort )
    7475             CALL radiation_write_debug_log( 'Sort csf' )
     7480            IF ( debug_output )  CALL debug_message( 'Sort csf', 'info' )
    74767481            CALL quicksort_csf2(kpcsflt, pcsflt, 1, npcsfl)
    74777482
    74787483!--         aggregate canopy sink factor records with identical box & source
    74797484!--         againg across all values from all processors
    7480             CALL radiation_write_debug_log( 'Aggregate canopy sink factor records with identical box' )
     7485            IF ( debug_output )  CALL debug_message( 'Aggregate canopy sink factor records with identical box', 'info' )
    74817486
    74827487            IF ( npcsfl > 0 )  THEN
     
    75217526            DEALLOCATE( pcsflt_l )
    75227527            DEALLOCATE( kpcsflt_l )
    7523             CALL radiation_write_debug_log( 'End of aggregate csf' )
     7528            IF ( debug_output )  CALL debug_message( 'End of aggregate csf', 'info' )
    75247529           
    75257530        ENDIF
     
    75287533        CALL MPI_BARRIER( comm2d, ierr )
    75297534#endif
    7530         CALL radiation_write_debug_log( 'End of radiation_calc_svf (after mpi_barrier)' )
    7531 
    7532         RETURN
     7535        CALL location_message( 'calculating view factors for radiation interaction', 'finished' )
     7536
     7537        RETURN  !todo: remove
    75337538       
    75347539!        WRITE( message_string, * )  &
     
    84408445       INTEGER(iwp)                 :: nsurfl_from_file = 0
    84418446       INTEGER(iwp)                 :: nmrtbl_from_file = 0
    8442        
     8447
     8448
     8449       CALL location_message( 'reading view factors for radiation interaction', 'start' )
     8450
    84438451       DO  i = 0, io_blocks-1
    84448452          IF ( i == io_group )  THEN
     
    84848492                 CALL message( 'radiation_read_svf', 'PA0483', 1, 2, 0, 6, 0 )
    84858493             ELSE
    8486                  WRITE(message_string,*) '    Number of SVF, CSF, and nsurfl ',&
     8494                 WRITE(debug_string,*)   'Number of SVF, CSF, and nsurfl ',    &
    84878495                                         'to read', nsvfl, ncsfl,              &
    84888496                                         nsurfl_from_file
    8489                  CALL location_message( message_string, .TRUE. )
     8497                 IF ( debug_output )  CALL debug_message( debug_string, 'info' )
    84908498             ENDIF
    84918499             
     
    85168524                 CALL message( 'radiation_read_svf', 'PA0494', 1, 2, 0, 6, 0 )
    85178525             ELSE
    8518                  WRITE(message_string,*) '    Number of nmrtf to read ', nmrtf
    8519                  CALL location_message( message_string, .TRUE. )
     8526                 WRITE(debug_string,*) 'Number of nmrtf to read ', nmrtf
     8527                 IF ( debug_output )  CALL debug_message( debug_string, 'info' )
    85208528             ENDIF
    85218529             
     
    85788586       ENDDO
    85798587
     8588       CALL location_message( 'reading view factors for radiation interaction', 'finished' )
     8589
     8590
    85808591    END SUBROUTINE radiation_read_svf
    85818592
     
    85928603       
    85938604       INTEGER(iwp)        :: i
     8605
     8606
     8607       CALL location_message( 'writing view factors for radiation interaction', 'start' )
    85948608
    85958609       DO  i = 0, io_blocks-1
     
    86368650#endif
    86378651       ENDDO
     8652
     8653       CALL location_message( 'writing view factors for radiation interaction', 'finished' )
     8654
     8655
    86388656    END SUBROUTINE radiation_write_svf
    86398657
     
    87888806        INTEGER(iwp)                            :: iread, iwrite
    87898807        TYPE(t_csf), DIMENSION(:), POINTER      :: acsfnew
    8790         CHARACTER(100)                          :: msg
     8808
    87918809
    87928810        IF ( newsize == -1 )  THEN
     
    88528870        ncsfla = newsize
    88538871
    8854         WRITE(msg,'(A,2I12)') 'Grow acsf2:',ncsfl,ncsfla
    8855         CALL radiation_write_debug_log( msg )
     8872        IF ( debug_output )  THEN
     8873           WRITE( debug_string, '(A,2I12)' ) 'Grow acsf2:', ncsfl, ncsfla
     8874           CALL debug_message( debug_string, 'info' )
     8875        ENDIF
    88568876
    88578877    END SUBROUTINE merge_and_grow_csf
     
    1149011510 END SUBROUTINE radiation_rrd_local
    1149111511
    11492 !------------------------------------------------------------------------------!
    11493 ! Description:
    11494 ! ------------
    11495 !> Subroutine writes debug information
    11496 !------------------------------------------------------------------------------!
    11497  SUBROUTINE radiation_write_debug_log ( message )
    11498     !> it writes debug log with time stamp
    11499     CHARACTER(*)  :: message
    11500     CHARACTER(15) :: dtc
    11501     CHARACTER(8)  :: date
    11502     CHARACTER(10) :: time
    11503     CHARACTER(5)  :: zone
    11504     CALL date_and_time(date, time, zone)
    11505     dtc = date(7:8)//','//time(1:2)//':'//time(3:4)//':'//time(5:10)
    11506     WRITE(9,'(2A)') dtc, TRIM(message)
    11507     FLUSH(9)
    11508  END SUBROUTINE radiation_write_debug_log
    1150911512
    1151011513 END MODULE radiation_model_mod
Note: See TracChangeset for help on using the changeset viewer.