Changeset 2906 for palm/trunk/SOURCE


Ignore:
Timestamp:
Mar 19, 2018 8:56:40 AM (6 years ago)
Author:
Giersch
Message:

new procedure for reading/writing svf data, initialization of local variable ids

Location:
palm/trunk/SOURCE
Files:
6 edited

Legend:

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

    r2718 r2906  
    2525! -----------------
    2626! $Id$
     27! CASE 88 and 89 has been added for the input/output of sky view factors
     28!
     29! 2718 2018-01-02 08:49:38Z maronga
    2730! Corrected "Former revisions" section
    2831!
     
    512515                           FORM='UNFORMATTED', POSITION='APPEND', IOSTAT=ioerr )
    513516                IF ( ioerr /= 0 )  THEN
    514                    WRITE( 9, * )  '*** could not open "PARTICLE_DATA'//    &
    515                                   TRIM( coupling_char )//'/'//myid_char//  &
     517                   WRITE( 9, * )  '*** could not open "PARTICLE_DATA'//        &
     518                                  TRIM( coupling_char )//'/'//myid_char//      &
    516519                                  '"! Trying again in 1 sec.'
    517520                   CALL fortran_sleep( 1 )
     
    533536             WRITE ( 85 )  particle_groups
    534537             WRITE ( 85 )  nxl, nxr, nys, nyn, nzb, nzt, nbgp
     538          ENDIF
     539
     540!
     541!--    File where sky-view factors and further required data is stored will be
     542!--    read
     543       CASE ( 88 )
     544
     545          IF (numprocs_previous_run /= numprocs) THEN
     546             WRITE( message_string, * ) 'A different number of processors',    &
     547                                        ' between the run that has written',   &
     548                                        ' the svf data and the one that will ',&
     549                                        ' read it is not allowed'
     550             CALL message( 'check_open', 'PA0484', 1, 2, 0, 6, 0 )
     551          ENDIF
     552
     553          IF ( myid_char == '' )  THEN
     554             OPEN ( 88, FILE='SVFIN'//TRIM( coupling_char )//myid_char,        &
     555                        FORM='UNFORMATTED', STATUS='OLD', IOSTAT=ioerr )
     556          ELSE
     557
     558             OPEN ( 88, FILE='SVFIN'//TRIM( coupling_char )//'/'//myid_char,   &
     559                        FORM='UNFORMATTED', STATUS='OLD', IOSTAT=ioerr )
     560          ENDIF
     561
     562!
     563!--    File where sky-view factors and further required data is stored will be
     564!--    created
     565       CASE ( 89 )
     566
     567          IF ( myid_char == '' )  THEN
     568             OPEN ( 89, FILE='SVFOUT'//TRIM( coupling_char )//myid_char,       &
     569                        FORM='UNFORMATTED', STATUS='NEW' )
     570          ELSE
     571             IF ( myid == 0  .AND. .NOT. openfile(file_id)%opened_before )  THEN
     572                CALL local_system( 'mkdir  SVFOUT' // TRIM( coupling_char ) )
     573             ENDIF
     574#if defined( __parallel )
     575!
     576!--          Set a barrier in order to allow that all other processors in the
     577!--          directory created by PE0 can open their file
     578             CALL MPI_BARRIER( comm2d, ierr )
     579#endif
     580             ioerr = 1
     581             DO WHILE ( ioerr /= 0 )
     582                OPEN ( 89, FILE='SVFOUT'//TRIM(coupling_char)//'/'//myid_char, &
     583                           FORM='UNFORMATTED', STATUS='NEW', IOSTAT=ioerr )
     584                IF ( ioerr /= 0 )  THEN
     585                   WRITE( 9, * )  '*** could not open "BINOUT'//         &
     586                                  TRIM(coupling_char)//'/'//myid_char//  &
     587                                  '"! Trying again in 1 sec.'
     588                   CALL fortran_sleep( 1 )
     589                ENDIF
     590             ENDDO
     591
    535592          ENDIF
    536593
  • palm/trunk/SOURCE/init_3d_model.f90

    r2894 r2906  
    2525! -----------------
    2626! $Id$
     27! The variables read/write_svf_on_init have been removed. Instead ENVIRONMENT
     28! variables read/write_svf have been introduced. Location_message has been
     29! added.
     30!
     31! 2894 2018-03-15 09:17:58Z Giersch
    2732! Renamed routines with respect to reading restart data, file 13 is closed in
    2833! rrd_read_parts_of_global now
     
    474479        ONLY:  dots_max, dots_num, dots_unit, dots_label
    475480
    476     USE netcdf_data_input_mod,                                                  &
     481    USE netcdf_data_input_mod,                                                 &
    477482        ONLY:  init_3d, netcdf_data_input_interpolate, netcdf_data_input_init_3d
    478483   
     
    487492    USE radiation_model_mod,                                                   &
    488493        ONLY:  radiation_init, radiation, radiation_control, radiation_scheme, &
    489                read_svf_on_init,                                               &
    490                write_svf_on_init, radiation_calc_svf, radiation_write_svf,     &
     494               radiation_calc_svf, radiation_write_svf,                        &
    491495               radiation_interaction, radiation_interactions,                  &
    492496               radiation_interaction_init, radiation_read_svf
     
    23562360!
    23572361!--    If required, read or calculate and write out the SVF
    2358        IF ( radiation_interactions  .AND.  read_svf_on_init )  THEN
     2362       IF ( radiation_interactions .AND. read_svf)  THEN
    23592363!
    23602364!--       Read sky-view factors and further required data from file
     
    23632367          CALL location_message( '    Reading SVF from file has finished', .TRUE. )
    23642368
    2365        ELSEIF ( radiation_interactions )  THEN
     2369       ELSEIF ( radiation_interactions .AND. .NOT. read_svf)  THEN
    23662370!
    23672371!--       calculate SFV and CSF
     
    23712375       ENDIF
    23722376
    2373        IF ( radiation_interactions  .AND.  write_svf_on_init )  THEN
     2377       IF ( radiation_interactions .AND. write_svf)  THEN
    23742378!
    23752379!--       Write svf, csf svfsurf and csfsurf data to file
     2380          CALL location_message( '    Start writing SVF in file', .FALSE. )
    23762381          CALL radiation_write_svf()
     2382          CALL location_message( '    Writing SVF in file has finished', .TRUE. )
    23772383       ENDIF
    23782384
  • palm/trunk/SOURCE/modules.f90

    r2894 r2906  
    2525! -----------------
    2626! $Id$
     27! Module control_parameters has been extended with ENVIRONMENT variables
     28! read/write_svf
     29!
     30! 2894 2018-03-15 09:17:58Z Giersch
    2731! _prerun flags were removed, Control paramters restart_string and length have
    2832! been added
     
    12981302    LOGICAL ::  rans_tke_e = .FALSE.                             !< use TKE-e turbulence closure for RANS mode
    12991303    LOGICAL ::  rans_tke_l = .FALSE.                             !< use TKE-l turbulence closure for RANS mode
     1304    LOGICAL ::  read_svf = .FALSE.                               !< ENVPAR namelist parameter to steer input of svf (ENVPAR is created by palmrun)
    13001305    LOGICAL ::  recycling_yshift = .FALSE.                       !< namelist parameter
    13011306    LOGICAL ::  run_control_header = .FALSE.                     !< onetime output of RUN_CONTROL header
     
    13271332    LOGICAL ::  wall_adjustment = .TRUE.                         !< namelist parameter
    13281333    LOGICAL ::  wind_turbine = .FALSE.                           !< flag for use of wind turbine model
    1329     LOGICAL ::  write_binary = .FALSE.                           !< ENVPAR namelist parameter to steer restart I/O (ENVPAR is created by mrun)
     1334    LOGICAL ::  write_binary = .FALSE.                           !< ENVPAR namelist parameter to steer restart I/O (ENVPAR is created by palmrun)
     1335    LOGICAL ::  write_svf = .FALSE.                              !< ENVPAR namelist parameter to steer output of svf (ENVPAR is created by palmrun)
    13301336    LOGICAL ::  ws_scheme_sca = .FALSE.                          !< use Wicker-Skamarock scheme (scalar advection)?
    13311337    LOGICAL ::  ws_scheme_mom = .FALSE.                          !< use Wicker-Skamarock scheme (momentum advection)?
  • palm/trunk/SOURCE/parin.f90

    r2894 r2906  
    2525! -----------------
    2626! $Id$
     27! ENVIRONMENT variables read/write_svf has been added
     28!
     29! 2894 2018-03-15 09:17:58Z Giersch
    2730! read_var_list has been renamed to rrd_global, all module related _parin
    2831! routines are called before reading the global restart data to overwrite them
     
    542545    NAMELIST /envpar/  batch_job, host, local_dvrserver_running,               &
    543546                       maximum_cpu_time_allowed, maximum_parallel_io_streams,  &
    544                        revision, run_identifier, tasks_per_node, write_binary
     547                       read_svf, revision, run_identifier, tasks_per_node,     &
     548                       write_binary, write_svf
    545549
    546550!
  • palm/trunk/SOURCE/radiation_model_mod.f90

    r2894 r2906  
    2525! -----------------
    2626! $Id$
     27! NAMELIST paramter read/write_svf_on_init have been removed, functions
     28! check_open and close_file are used now for opening/closing files related to
     29! svf data, adjusted unit number and error numbers
     30!
     31! 2894 2018-03-15 09:17:58Z Giersch
    2732! Calculations of the index range of the subdomain on file which overlaps with
    2833! the current subdomain are already done in read_restart_data_mod
     
    650655    LOGICAL                                        ::  energy_balance_surf_h = .TRUE.     !< flag parameter indicating wheather the energy balance is calculated for horizontal surfaces
    651656    LOGICAL                                        ::  energy_balance_surf_v = .TRUE.     !< flag parameter indicating wheather the energy balance is calculated for vertical surfaces
    652     LOGICAL                                        ::  read_svf_on_init = .FALSE.         !< flag parameter indicating wheather SVFs will be read from a file at initialization
    653     LOGICAL                                        ::  write_svf_on_init = .FALSE.        !< flag parameter indicating wheather SVFs will be written out to a file
    654657    LOGICAL                                        ::  mrt_factors = .FALSE.              !< whether to generate MRT factor files during init
    655658    INTEGER(iwp)                                   ::  nrefsteps = 0                      !< number of reflection steps to perform
     
    885888           zenith, calc_zenith, sun_direction, sun_dir_lat, sun_dir_lon,       &
    886889           split_diffusion_radiation,                                          &
    887            energy_balance_surf_h, energy_balance_surf_v, write_svf_on_init,    &
    888            read_svf_on_init, nrefsteps, mrt_factors, dist_max_svf, nsvfl, svf, &
     890           energy_balance_surf_h, energy_balance_surf_v,                       &
     891           nrefsteps, mrt_factors, dist_max_svf, nsvfl, svf,                  &
    889892           svfsurf, surfinsw, surfinlw, surfins, surfinl, surfinswdir,         &
    890893           surfinswdif, surfoutsw, surfoutlw, surfinlwdif, rad_sw_in_dir,      &
     
    28012804                                  energy_balance_surf_h,                       &
    28022805                                  energy_balance_surf_v,                       &
    2803                                   read_svf_on_init,                            &
    28042806                                  nrefsteps,                                   &
    2805                                   write_svf_on_init,                           &
    28062807                                  mrt_factors,                                 &
    28072808                                  dist_max_svf,                                &
     
    66126613    SUBROUTINE radiation_read_svf
    66136614
    6614         IMPLICIT NONE
    6615         INTEGER(iwp)                 :: fsvf = 89
    6616         INTEGER(iwp)                 :: i
    6617         CHARACTER(usm_version_len)   :: usm_version_field
    6618         CHARACTER(svf_code_len)      :: svf_code_field
    6619 
    6620         DO  i = 0, io_blocks-1
    6621             IF ( i == io_group )  THEN
    6622                 OPEN ( fsvf, FILE='SVFIN'//TRIM(coupling_char)//'/'//myid_char,&
    6623                     form='unformatted', status='old' )
    6624 
    6625 !--             read and check version
    6626                 READ ( fsvf ) usm_version_field
    6627                 IF ( TRIM(usm_version_field) /= TRIM(usm_version) )  THEN
    6628                     WRITE( message_string, * ) 'Version of binary SVF file "',           &
    6629                                             TRIM(usm_version_field), '" does not match ',            &
    6630                                             'the version of model "', TRIM(usm_version), '"'
    6631                     CALL message( 'radiation_read_svf', 'UI0012', 1, 2, 0, 6, 0 )
    6632                 ENDIF
     6615       IMPLICIT NONE
     6616       INTEGER(iwp)                 :: fsvf = 88
     6617       INTEGER(iwp)                 :: i
     6618       CHARACTER(usm_version_len)   :: usm_version_field
     6619       CHARACTER(svf_code_len)      :: svf_code_field
     6620
     6621       DO  i = 0, io_blocks-1
     6622          IF ( i == io_group )  THEN
     6623
     6624!
     6625!--          Open binary file
     6626             CALL check_open( fsvf )
     6627
     6628
     6629!--          read and check version
     6630             READ ( fsvf ) usm_version_field
     6631             IF ( TRIM(usm_version_field) /= TRIM(usm_version) )  THEN
     6632                 WRITE( message_string, * ) 'Version of binary SVF file "',           &
     6633                                         TRIM(usm_version_field), '" does not match ',            &
     6634                                         'the version of model "', TRIM(usm_version), '"'
     6635                 CALL message( 'radiation_read_svf', 'PA0482', 1, 2, 0, 6, 0 )
     6636             ENDIF
    66336637               
    6634 !--             read nsvfl, ncsfl
    6635                 READ ( fsvf ) nsvfl, ncsfl
    6636                 IF ( nsvfl <= 0  .OR.  ncsfl < 0 )  THEN
    6637                     WRITE( message_string, * ) 'Wrong number of SVF or CSF'
    6638                     CALL message( 'radiation_read_svf', 'UI0012', 1, 2, 0, 6, 0 )
    6639                 ELSE
    6640                     WRITE(message_string,*) '    Number of SVF and CSF to read', nsvfl, ncsfl
    6641                     CALL location_message( message_string, .TRUE. )
    6642                 ENDIF
     6638!--          read nsvfl, ncsfl
     6639             READ ( fsvf ) nsvfl, ncsfl
     6640             IF ( nsvfl <= 0  .OR.  ncsfl < 0 )  THEN
     6641                WRITE( message_string, * ) 'Wrong number of SVF or CSF'
     6642                CALL message( 'radiation_read_svf', 'PA0483', 1, 2, 0, 6, 0 )
     6643             ELSE
     6644                WRITE(message_string,*) '    Number of SVF and CSF to read', nsvfl, ncsfl
     6645                CALL location_message( message_string, .TRUE. )
     6646             ENDIF
    66436647               
    6644                 ALLOCATE(svf(ndsvf,nsvfl))
    6645                 ALLOCATE(svfsurf(idsvf,nsvfl))
    6646                 READ(fsvf) svf
    6647                 READ(fsvf) svfsurf
    6648                 IF ( plant_canopy )  THEN
    6649                     ALLOCATE(csf(ndcsf,ncsfl))
    6650                     ALLOCATE(csfsurf(idcsf,ncsfl))
    6651                     READ(fsvf) csf
    6652                     READ(fsvf) csfsurf
    6653                 ENDIF
    6654                 READ ( fsvf ) svf_code_field
     6648             ALLOCATE(svf(ndsvf,nsvfl))
     6649             ALLOCATE(svfsurf(idsvf,nsvfl))
     6650
     6651             READ(fsvf) svf
     6652             READ(fsvf) svfsurf
     6653
     6654             IF ( plant_canopy )  THEN
     6655                 ALLOCATE(csf(ndcsf,ncsfl))
     6656                 ALLOCATE(csfsurf(idcsf,ncsfl))
     6657                 READ(fsvf) csf
     6658                 READ(fsvf) csfsurf
     6659             ENDIF
     6660
     6661             READ ( fsvf ) svf_code_field
     6662             IF ( TRIM(svf_code_field) /= TRIM(svf_code) )  THEN
     6663                WRITE( message_string, * ) 'Wrong structure of binary svf file'
     6664                CALL message( 'radiation_read_svf', 'PA0484', 1, 2, 0, 6, 0 )
     6665             ENDIF
    66556666               
    6656                 IF ( TRIM(svf_code_field) /= TRIM(svf_code) )  THEN
    6657                     WRITE( message_string, * ) 'Wrong structure of binary svf file'
    6658                     CALL message( 'radiation_read_svf', 'UI0012', 1, 2, 0, 6, 0 )
    6659                 ENDIF
     6667!
     6668!--          Close binary file                 
     6669             CALL close_file( fsvf )
    66606670               
    6661                 CLOSE (fsvf)
    6662                
    6663             ENDIF
     6671          ENDIF
    66646672#if defined( __parallel )
    6665             CALL MPI_BARRIER( comm2d, ierr )
     6673          CALL MPI_BARRIER( comm2d, ierr )
    66666674#endif
    6667         ENDDO
     6675       ENDDO
    66686676
    66696677    END SUBROUTINE radiation_read_svf
     
    66786686    SUBROUTINE radiation_write_svf
    66796687
    6680         IMPLICIT NONE
    6681         INTEGER(iwp)        :: fsvf = 89
    6682         INTEGER(iwp)        :: i
    6683 
    6684         DO  i = 0, io_blocks-1
    6685             IF ( i == io_group )  THEN
    6686                 OPEN ( fsvf, FILE='SVFOUT'//TRIM( coupling_char )//'/'//myid_char,   &
    6687                     form='unformatted', status='new' )
    6688 
    6689                 WRITE ( fsvf )  usm_version
    6690                 WRITE ( fsvf )  nsvfl, ncsfl
    6691                 WRITE ( fsvf )  svf
    6692                 WRITE ( fsvf )  svfsurf
    6693                 IF ( plant_canopy )  THEN
    6694                     WRITE ( fsvf )  csf
    6695                     WRITE ( fsvf )  csfsurf
    6696                 ENDIF
    6697                 WRITE ( fsvf )  TRIM(svf_code)
    6698                
    6699                 CLOSE (fsvf)
     6688
     6689       IMPLICIT NONE
     6690
     6691       INTEGER(iwp)        :: fsvf = 89
     6692       INTEGER(iwp)        :: i
     6693
     6694
     6695       DO  i = 0, io_blocks-1
     6696          IF ( i == io_group )  THEN
     6697           
     6698!
     6699!--          Open binary file
     6700             CALL check_open( fsvf )
     6701
     6702             WRITE ( fsvf )  usm_version
     6703             WRITE ( fsvf )  nsvfl, ncsfl
     6704             WRITE ( fsvf )  svf
     6705             WRITE ( fsvf )  svfsurf
     6706             IF ( plant_canopy )  THEN
     6707                WRITE ( fsvf )  csf
     6708                WRITE ( fsvf )  csfsurf
     6709             ENDIF
     6710             WRITE ( fsvf )  TRIM(svf_code)
     6711
     6712!
     6713!--          Close binary file                 
     6714             CALL close_file( fsvf )
     6715
     6716          ENDIF
    67006717#if defined( __parallel )
    6701                 CALL MPI_BARRIER( comm2d, ierr )
     6718          CALL MPI_BARRIER( comm2d, ierr )
    67026719#endif
    6703             ENDIF
    6704         ENDDO
     6720       ENDDO
    67056721
    67066722    END SUBROUTINE radiation_write_svf
  • palm/trunk/SOURCE/urban_surface_mod.f90

    r2894 r2906  
    2626! -----------------
    2727! $Id$
     28! Local variable ids has to be initialized with a value of -1 in
     29! usm_average_3d_data
     30!
     31! 2894 2018-03-15 09:17:58Z Giersch
    2832! Calculations of the index range of the subdomain on file which overlaps with
    2933! the current subdomain are already done in read_restart_data_mod,
     
    11771181
    11781182!--     find the real name of the variable
     1183        ids = -1
    11791184        var = TRIM(variable)
    11801185        DO i = 0, nd-1
Note: See TracChangeset for help on using the changeset viewer.