Reading multiple files in Fortran 95 - fortran

I am writing codes in Fortran 95, to read a number of files looking like 1.dat, 2.dat, ......, 9999.dat. I have a code that reads 0001.dat, 0002.dat, .......... 9999.dat. It looks like
character*12, fn
..
DO i=1,n
write(fn,*)i
open(1,file=fn)
do j=1,5
read(1,*)x(i,j),y(i,j),z(i,j)
end do
10 format(i4.4,'.dat')
May you suggest me how can I make it possible to read the files that I have please? Thanks.u

What if you change your format to
10 format (i4,'.dat')
I tried this for instance
character *8 filename
do i=1,9999
write (filename, 10) i
write (*,*) filename
end do
10 format (i4,'.dat')
end
And I had no leading zeros in my file names.
Is this hat you were looking for ?
Update
I see...
Then the format should be
10 format (i0,'.dat')
the '0' means left justified.
I tested it with the following pgm
character*12, fn
integer x(11,5)
integer y(11,5)
integer z(11,5)
do i=1,11
write(fn,10)i
open(1,file=fn)
do j=1,5
read(1,*)x(i,j),y(i,j),z(i,j)
end do
close(1)
end do
10 format(i0,'.dat')
end
And that worked for me.
Update 2
implicit none
integer n,ns,i,j
real x(9999,400),y(9999,400),z(9999,400),a(9999,400),aa(400)
character*12, fn
n = 14
ns = 2
do i = 0,n
do j = 1, 5
a(i,j) = 0.0
end do
end do
do i=1,n
write(fn,10)i
open(1,file=fn)
do j=1,5
read(1,*)x(i,j),y(i,j),z(i,j)
if(i.le.ns) then
a(i,j) = x(i,j)
else
a(i,j) = x(i,j) + a(i-ns,j)
end if
aa(j) = a(i,j)
write(*,*) j,x(i,j),y(i,j),z(i,j),a(i,j)
end do
close(1)
do j = 1, 5
write(*,*) aa(j)
end do
end do
10 format(i0,'.dat')
end
Worked for me.
Output (on Ubuntu 10.10).
./a.out
1 1.0000000 3.0000000 5.0000000 1.0000000
2 2.0000000 5.0000000 7.0000000 2.0000000
3 3.0000000 7.0000000 8.0000000 3.0000000
4 1.0000000 4.0000000 8.0000000 1.0000000
5 1.0000000 4.0000000 8.0000000 1.0000000
1.0000000
2.0000000
3.0000000
1.0000000
1.0000000
1 3.0000000 8.0000000 5.0000000 3.0000000
2 7.0000000 5.0000000 7.0000000 7.0000000
3 3.0000000 7.0000000 8.0000000 3.0000000
4 1.0000000 4.0000000 10.000000 1.0000000
5 3.0000000 5.0000000 7.0000000 3.0000000
3.0000000
7.0000000
3.0000000
1.0000000
3.0000000
1 3.0000000 8.0000000 5.0000000 4.0000000
2 7.0000000 5.0000000 7.0000000 9.0000000
3 3.0000000 7.0000000 8.0000000 6.0000000
4 1.0000000 4.0000000 10.000000 2.0000000
5 3.0000000 5.0000000 7.0000000 4.0000000
4.0000000
9.0000000
6.0000000
2.0000000
4.0000000
1 3.0000000 8.0000000 5.0000000 6.0000000
2 7.0000000 5.0000000 7.0000000 14.000000
3 3.0000000 7.0000000 8.0000000 6.0000000
4 1.0000000 4.0000000 10.000000 2.0000000
5 3.0000000 5.0000000 7.0000000 6.0000000
6.0000000
14.000000
6.0000000
2.0000000
6.0000000
1 3.0000000 8.0000000 5.0000000 7.0000000
2 7.0000000 5.0000000 7.0000000 16.000000
3 3.0000000 7.0000000 8.0000000 9.0000000
4 1.0000000 4.0000000 10.000000 3.0000000
5 3.0000000 5.0000000 7.0000000 7.0000000
7.0000000
16.000000
9.0000000
3.0000000
7.0000000
1 3.0000000 8.0000000 5.0000000 9.0000000
2 7.0000000 5.0000000 7.0000000 21.000000
3 3.0000000 7.0000000 8.0000000 9.0000000
4 1.0000000 4.0000000 10.000000 3.0000000
5 3.0000000 5.0000000 7.0000000 9.0000000
9.0000000
21.000000
9.0000000
3.0000000
9.0000000
1 3.0000000 8.0000000 5.0000000 10.000000
2 7.0000000 5.0000000 7.0000000 23.000000
3 3.0000000 7.0000000 8.0000000 12.000000
4 1.0000000 4.0000000 10.000000 4.0000000
5 3.0000000 5.0000000 7.0000000 10.000000
10.000000
23.000000
12.000000
4.0000000
10.000000
1 3.0000000 8.0000000 5.0000000 12.000000
2 7.0000000 5.0000000 7.0000000 28.000000
3 3.0000000 7.0000000 8.0000000 12.000000
4 1.0000000 4.0000000 10.000000 4.0000000
5 3.0000000 5.0000000 7.0000000 12.000000
12.000000
28.000000
12.000000
4.0000000
12.000000
1 3.0000000 8.0000000 5.0000000 13.000000
2 7.0000000 5.0000000 7.0000000 30.000000
3 3.0000000 7.0000000 8.0000000 15.000000
4 1.0000000 4.0000000 10.000000 5.0000000
5 3.0000000 5.0000000 7.0000000 13.000000
13.000000
30.000000
15.000000
5.0000000
13.000000
1 3.0000000 8.0000000 5.0000000 15.000000
2 7.0000000 5.0000000 7.0000000 35.000000
3 3.0000000 7.0000000 8.0000000 15.000000
4 1.0000000 4.0000000 10.000000 5.0000000
5 3.0000000 5.0000000 7.0000000 15.000000
15.000000
35.000000
15.000000
5.0000000
15.000000
1 3.0000000 8.0000000 5.0000000 16.000000
2 7.0000000 5.0000000 7.0000000 37.000000
3 3.0000000 7.0000000 8.0000000 18.000000
4 1.0000000 4.0000000 10.000000 6.0000000
5 3.0000000 5.0000000 7.0000000 16.000000
16.000000
37.000000
18.000000
6.0000000
16.000000
At line 23 of file c.for (unit = 1, file = '12.dat')
Fortran runtime error: End of file

Related

SSL_CTX_new crash only in 32 bit iOS devices with distribution build

I have a very incomprehensible crash with my iOS application. The crash occures only on 32 bit devices (iPad 4, iPhone 5, iPhone 5c) with iOS 10 OS only in distribution build (debug builds and enterprise builds work without crash). My app was built with Xcode 11.3.1.
This is the call stack of the crashed thread:
#14. Crashed: com.apple.root.default-qos
0 myapp 0x6bf40c SSL_CTX_new + 3726105
1 libsystem_malloc.dylib 0x1db19237 szone_malloc_should_clear + 492
2 (Missing) 0x145060f0 (Missing)
3 (Missing) 0x2c2100b1 (Missing)
Call stack of all threads:
#0. com.apple.main-thread
0 libobjc.A.dylib 0x1d5a2e94 getMethodNoSuper_nolock(objc_class*, objc_selector*) + 61
1 libobjc.A.dylib 0x1d5a2c91 lookUpImpOrForward + 296
2 libobjc.A.dylib 0x1d5a2b65 _class_lookupMethodAndLoadCache3 + 26
3 libobjc.A.dylib 0x1d5a91af _objc_msgSend_uncached + 14
4 UIKit 0x23bc45d3 -[UIStatusBar _requestStyleAttributes:animationParameters:forced:] + 150
5 UIKit 0x23bc4411 -[UIStatusBar requestStyle:animationParameters:forced:] + 468
6 UIKit 0x23bc414d -[UIStatusBar requestStyle:animated:forced:] + 92
7 UIKit 0x235ab8c7 -[UIStatusBar forceUpdateStyleOverrides:] + 90
8 FrontBoardServices 0x1fbdfcff __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke.27 + 166
9 Foundation 0x1ec19421 <redacted> + 438
10 Foundation 0x1eb9ac0f <redacted> + 66
11 BaseBoard 0x1fb5e819 -[BSSettingsDiff inspectChangesWithBlock:] + 102
12 FrontBoardServices 0x1fbda027 -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 90
13 FrontBoardServices 0x1fbdfb5d -[FBSSettingsDiffInspector inspectDiff:withContext:] + 300
14 UIKit 0x237b502d __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 170
15 UIKit 0x237b4cf3 -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 824
16 UIKit 0x23aba733 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 412
17 FrontBoardServices 0x1fbc9f67 __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke.376 + 210
18 FrontBoardServices 0x1fbf4c13 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 18
19 FrontBoardServices 0x1fbf4acd -[FBSSerialQueue _performNext] + 220
20 FrontBoardServices 0x1fbf4db7 -[FBSSerialQueue _performNextFromRunLoopSource] + 44
21 CoreFoundation 0x1e2cffdd __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
22 CoreFoundation 0x1e2cfb05 __CFRunLoopDoSources0 + 424
23 CoreFoundation 0x1e2cdf51 __CFRunLoopRun + 1160
24 CoreFoundation 0x1e2211af CFRunLoopRunSpecific + 470
25 CoreFoundation 0x1e220fd1 CFRunLoopRunInMode + 104
26 GraphicsServices 0x1f9cbb41 GSEventRunModal + 80
27 UIKit 0x235a3a53 UIApplicationMain + 150
28 myapp 0x39d26d main + 24 (main.m:24)
29 libdyld.dylib 0x1da0e4eb start + 2
#1. APMExperimentWorkerQueue
0 libsystem_kernel.dylib 0x1dace2fc fsync + 8
1 libsqlite3.dylib 0x1e7bacd1 (null) + 44054
2 libsqlite3.dylib 0x1e7c323b (null) + 2074
3 libsqlite3.dylib 0x1e7ba7fd (null) + 42818
4 libsqlite3.dylib 0x1e7abeb7 (null) + 16492
5 libsqlite3.dylib 0x1e7858fb (null) + 2524
6 libsqlite3.dylib 0x1e7a6e17 (null) + 51750
7 libsqlite3.dylib 0x1e79a5ab sqlite3_step + 442
8 myapp 0xf60a4d -[APMSqliteStore executeSQLStatement:error:] + 2979674
9 myapp 0xf609e7 -[APMSqliteStore executeSQL:error:] + 2979572
10 myapp 0xf5e0c7 -[APMSqliteStore ensureTableWithName:createSQL:requiredColumnNames:addOnColumns:error:] + 2969044
11 myapp 0xf5d4b1 -[APMSqliteStore ensureTableWithName:elementaryColumnInfo:addOnColumnInfo:error:] + 2965950
12 myapp 0xf5dcf9 -[APMSqliteStore ensureTableWithName:elementaryColumnInfo:addOnColumnInfo:modifyColumnInfo:error:] + 2968070
13 myapp 0xf0ad95 -[APMEDatabase ensureAllTables] + 2628258
14 myapp 0xf0a95d -[APMEDatabase initializeDatabaseResourcesWithContext:databasePath:] + 2627178
15 myapp 0xf0a85b -[APMEDatabase initWithPath:] + 2626920
16 myapp 0xf13047 -[APMETaskManager startTaskManagerOnWorkerQueue] + 2661716
17 myapp 0xf12fd7 __35-[APMETaskManager startTaskManager]_block_invoke + 2661604
18 myapp 0xf145d7 __46-[APMETaskManager dispatchAsyncOnWorkerQueue:]_block_invoke + 2667236
19 libdispatch.dylib 0x1d9e1797 _dispatch_call_block_and_release + 10
20 libdispatch.dylib 0x1d9ee59d _dispatch_queue_serial_drain + 854
21 libdispatch.dylib 0x1d9e4b71 _dispatch_queue_invoke + 886
22 libdispatch.dylib 0x1d9f01b5 _dispatch_root_queue_drain + 326
23 libdispatch.dylib 0x1d9f000f _dispatch_worker_thread3 + 106
24 libsystem_pthread.dylib 0x1db9687d _pthread_wqthread + 1040
25 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#2. com.google.fira.worker
0 libsystem_kernel.dylib 0x1dace2fc fsync + 8
1 libsqlite3.dylib 0x1e7bacd1 (null) + 44054
2 libsqlite3.dylib 0x1e7c323b (null) + 2074
3 libsqlite3.dylib 0x1e7ba7fd (null) + 42818
4 libsqlite3.dylib 0x1e7abeb7 (null) + 16492
5 libsqlite3.dylib 0x1e7858fb (null) + 2524
6 libsqlite3.dylib 0x1e7a6e17 (null) + 51750
7 libsqlite3.dylib 0x1e79a5ab sqlite3_step + 442
8 myapp 0xf60a4d -[APMSqliteStore executeSQLStatement:error:] + 2979674
9 myapp 0xf609e7 -[APMSqliteStore executeSQL:error:] + 2979572
10 myapp 0xf5e0c7 -[APMSqliteStore ensureTableWithName:createSQL:requiredColumnNames:addOnColumns:error:] + 2969044
11 myapp 0xf5d4b1 -[APMSqliteStore ensureTableWithName:elementaryColumnInfo:addOnColumnInfo:error:] + 2965950
12 myapp 0xf5dcf9 -[APMSqliteStore ensureTableWithName:elementaryColumnInfo:addOnColumnInfo:modifyColumnInfo:error:] + 2968070
13 myapp 0xf2a357 -[APMDatabase ensureAllTables] + 2756708
14 myapp 0xf28d6f -[APMDatabase initializeDatabaseResourcesWithContext:databasePath:error:] + 2751100
15 myapp 0xf1f897 -[APMDatabase initWithDatabaseName:persistedConfig:error:] + 2712996
16 myapp 0xf31013 __47-[APMMeasurement startMeasurementOnWorkerQueue]_block_invoke + 2784544
17 myapp 0xf30ae3 -[APMMeasurement startMeasurementOnWorkerQueue] + 2783216
18 myapp 0xf3072f -[APMMeasurement setEnabledOnWorkerQueue:] + 2782268
19 myapp 0xf30605 __29-[APMMeasurement setEnabled:]_block_invoke + 2781970
20 myapp 0xf4b531 __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 2892350
21 libdispatch.dylib 0x1d9e1797 _dispatch_call_block_and_release + 10
22 libdispatch.dylib 0x1d9ee59d _dispatch_queue_serial_drain + 854
23 libdispatch.dylib 0x1d9e4b71 _dispatch_queue_invoke + 886
24 libdispatch.dylib 0x1d9f01b5 _dispatch_root_queue_drain + 326
25 libdispatch.dylib 0x1d9f000f _dispatch_worker_thread3 + 106
26 libsystem_pthread.dylib 0x1db9687d _pthread_wqthread + 1040
27 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#3. NSOperationQueue 0x145c36b0 :: NSOperation 0x145c3d10 (QOS: DEFAULT)
0 libsystem_kernel.dylib 0x1dae2554 __ulock_wait + 24
1 libdispatch.dylib 0x1d9f2a9d _dispatch_ulock_wait + 38
2 libdispatch.dylib 0x1d9f2b9b _dispatch_thread_event_wait_slow + 24
3 libdispatch.dylib 0x1d9f0b39 _dispatch_barrier_sync_f_slow + 214
4 myapp 0xb3be1 OnMain(void () block_pointer) + 70 (BlockTools.h:70)
5 myapp 0xb3a81 +[UIDevice(Kit) is3DTouchSupported] + 75 (UIDevice_Kit.mm:75)
6 myapp 0x3ecb13 -[DocumentAssetGenerator generateAssetsForDocument:] + 41 (DocumentAssetGenerator.mm:41)
7 myapp 0x522fe1 -[DocumentImporter importDocumentNamed:atFilePath:toContext:document:] + 214 (DocumentImporter.m:214)
8 myapp 0x4c9655 -[CoreDataSetup installPDFDocumentWithNames:atContext:] + 222 (CoreDataSetup.m:222)
9 myapp 0x4c8e8b -[CoreDataSetup installOrUpdateMobileDataSheetInContext:] + 169 (CoreDataSetup.m:169)
10 myapp 0x4c86fd -[CoreDataSetup installOrUpdateSampleDocuments] + 122 (CoreDataSetup.m:122)
11 myapp 0x390f31 __51-[AppManager installSampleDocumentBundleIfNeeded]_block_invoke + 275 (AppManager.m:275)
12 Foundation 0x1ec39b01 <redacted> + 8
13 Foundation 0x1eb8faef <redacted> + 146
14 Foundation 0x1eb81fe7 <redacted> + 770
15 Foundation 0x1ec3bd39 <redacted> + 190
16 libdispatch.dylib 0x1d9ee59d _dispatch_queue_serial_drain + 854
17 libdispatch.dylib 0x1d9e4b71 _dispatch_queue_invoke + 886
18 libdispatch.dylib 0x1d9f01b5 _dispatch_root_queue_drain + 326
19 libdispatch.dylib 0x1d9f000f _dispatch_worker_thread3 + 106
20 libsystem_pthread.dylib 0x1db9687d _pthread_wqthread + 1040
21 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#4. AVAudioSession Notify Thread
0 libsystem_kernel.dylib 0x1dacc900 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x1dacc6e1 mach_msg + 44
2 CoreFoundation 0x1e2cfbe3 __CFRunLoopServiceMachPort + 144
3 CoreFoundation 0x1e2ce065 __CFRunLoopRun + 1436
4 CoreFoundation 0x1e2211af CFRunLoopRunSpecific + 470
5 CoreFoundation 0x1e220fd1 CFRunLoopRunInMode + 104
6 AVFAudio 0x348ab82f GenericRunLoopThread::Entry(void*) + 142
7 AVFAudio 0x348d458f CAPThread::Entry(CAPThread*) + 154
8 libsystem_pthread.dylib 0x1db9893b _pthread_body + 216
9 libsystem_pthread.dylib 0x1db9885d _pthread_start + 234
10 libsystem_pthread.dylib 0x1db96468 thread_start + 8
#5. com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x1dacc900 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x1dacc6e1 mach_msg + 44
2 CoreFoundation 0x1e2cfbe3 __CFRunLoopServiceMachPort + 144
3 CoreFoundation 0x1e2ce065 __CFRunLoopRun + 1436
4 CoreFoundation 0x1e2211af CFRunLoopRunSpecific + 470
5 CoreFoundation 0x1e220fd1 CFRunLoopRunInMode + 104
6 Foundation 0x1eb75af5 <redacted> + 258
7 Foundation 0x1eb9276d <redacted> + 86
8 UIKit 0x23ea4ad9 -[UIEventFetcher threadMain] + 128
9 Foundation 0x1ec598eb <redacted> + 1122
10 libsystem_pthread.dylib 0x1db9893b _pthread_body + 216
11 libsystem_pthread.dylib 0x1db9885d _pthread_start + 234
12 libsystem_pthread.dylib 0x1db96468 thread_start + 8
#6. com.apple.root.default-qos
0 libsystem_kernel.dylib 0x1dacc900 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x1dacc6e1 mach_msg + 44
2 CoreFoundation 0x1e2cfbe3 __CFRunLoopServiceMachPort + 144
3 CoreFoundation 0x1e2ce065 __CFRunLoopRun + 1436
4 CoreFoundation 0x1e2211af CFRunLoopRunSpecific + 470
5 CoreFoundation 0x1e220fd1 CFRunLoopRunInMode + 104
6 Foundation 0x1eb75af5 <redacted> + 258
7 Foundation 0x1eb9276d <redacted> + 86
8 myapp 0xc6535 -[NSURLConnectionSyncAuth sendSynchronousRequest:returningResponse:error:] + 26 (NSURLConnectionSyncAuth.m:26)
9 myapp 0xc2ebf __51-[Reachability checkNetworkWithCompletionBlock:]_block_invoke + 315 (Reachability.m:315)
10 libdispatch.dylib 0x1d9e1797 _dispatch_call_block_and_release + 10
11 libdispatch.dylib 0x1d9eeb1d _dispatch_queue_override_invoke + 536
12 libdispatch.dylib 0x1d9f01b5 _dispatch_root_queue_drain + 326
13 libdispatch.dylib 0x1d9f000f _dispatch_worker_thread3 + 106
14 libsystem_pthread.dylib 0x1db9687d _pthread_wqthread + 1040
15 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#7. Thread
0 libsystem_kernel.dylib 0x1dae273c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1db968eb _pthread_wqthread + 1150
2 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#8. com.apple.root.default-qos
0 libsystem_kernel.dylib 0x1dae2554 __ulock_wait + 24
1 libdispatch.dylib 0x1d9f2a9d _dispatch_ulock_wait + 38
2 libdispatch.dylib 0x1d9f2b9b _dispatch_thread_event_wait_slow + 24
3 libdispatch.dylib 0x1d9f0b39 _dispatch_barrier_sync_f_slow + 214
4 libdispatch.dylib 0x1d9e1797 _dispatch_call_block_and_release + 10
5 libdispatch.dylib 0x1d9eeb1d _dispatch_queue_override_invoke + 536
6 libdispatch.dylib 0x1d9f01b5 _dispatch_root_queue_drain + 326
7 libdispatch.dylib 0x1d9f000f _dispatch_worker_thread3 + 106
8 libsystem_pthread.dylib 0x1db9687d _pthread_wqthread + 1040
9 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#9. com.apple.network.connections
0 libcorecrypto.dylib 0x1d9a4780 ccn_mul + 19
1 libcorecrypto.dylib 0x1d9bee47 cczp_mul_ws + 42
2 libcorecrypto.dylib 0x1d9bee47 cczp_mul_ws + 42
3 libcorecrypto.dylib 0x1d99c179 ccec_add_ws + 244
4 libcorecrypto.dylib 0x1d99c371 ccec_full_add_normalized_ws + 54
5 libcorecrypto.dylib 0x1d99db53 ccec_twin_mult + 1430
6 libcorecrypto.dylib 0x1d9bd32d ccec_verify_internal + 564
7 libcorecrypto.dylib 0x1d99dc95 ccec_verify + 104
8 libcorecrypto.dylib 0x1d99d36f ccec_pairwise_consistency_check + 168
9 libcorecrypto.dylib 0x1d99dd05 ccec_generate_key_fips + 22
10 libsystem_coretls.dylib 0x1da9ae39 sslEcdhCreateKey + 40
11 libsystem_coretls.dylib 0x1da9dc35 SSLEncodeKeyExchange + 264
12 libsystem_coretls.dylib 0x1da9f1f5 SSLAdvanceHandshake + 1708
13 libsystem_coretls.dylib 0x1daa358b tls_handshake_continue + 22
14 libnetwork.dylib 0x296e3097 __nw_coretls_callback_handshake_message_block_invoke_3 + 52
15 libdispatch.dylib 0x1d9e1797 _dispatch_call_block_and_release + 10
16 libdispatch.dylib 0x1d9ee59d _dispatch_queue_serial_drain + 854
17 libdispatch.dylib 0x1d9e4b71 _dispatch_queue_invoke + 886
18 libdispatch.dylib 0x1d9f01b5 _dispatch_root_queue_drain + 326
19 libdispatch.dylib 0x1d9f000f _dispatch_worker_thread3 + 106
20 libsystem_pthread.dylib 0x1db9687d _pthread_wqthread + 1040
21 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#10. Thread
0 libsystem_kernel.dylib 0x1dae1e7c __semwait_signal + 24
1 libsystem_c.dylib 0x1da360e9 nanosleep + 168
2 libc++.1.dylib 0x1d57392b std::__1::this_thread::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1ll, 1000000000ll> > const&) + 102
3 JavaScriptCore 0x221873c5 <redacted> + 148
4 JavaScriptCore 0x22187207 <redacted> + 36
5 JavaScriptCore 0x22187121 <redacted> + 118
6 JavaScriptCore 0x22188197 <redacted> + 76
7 JavaScriptCore 0x221880ed <redacted> + 18
8 JavaScriptCore 0x2218832f <redacted> + 66
9 libsystem_pthread.dylib 0x1db9893b _pthread_body + 216
10 libsystem_pthread.dylib 0x1db9885d _pthread_start + 234
11 libsystem_pthread.dylib 0x1db96468 thread_start + 8
#11. Thread
0 libsystem_pthread.dylib 0x1db96454 start_wqthread + 83
#12. com.twitter.crashlytics.ios.work-queue :: NSOperation 0x1463a150 (QOS: DEFAULT)
0 libsystem_kernel.dylib 0x1dae25c8 __unlink + 8
1 libsystem_kernel.dylib 0x1dacedc5 unlink + 8
2 libremovefile.dylib 0x1da1770f __removefile_process_file + 82
3 libremovefile.dylib 0x1da1786b __removefile_tree_walker + 170
4 libremovefile.dylib 0x1da17a83 removefile + 102
5 Foundation 0x1ebadcf5 <redacted> + 142
6 Foundation 0x1eb81fe7 <redacted> + 770
7 Foundation 0x1ebad8b1 <redacted> + 76
8 myapp 0xe13dcf -[CLSFileManager removeItemAtPath:] + 58 (CLSFileManager.m:58)
9 myapp 0xe1fa85 __71-[CLSReportsController prepareAndSubmitReport:asUrgent:withProcessing:]_block_invoke + 174 (CLSReportsController.m:174)
10 myapp 0xe15a01 CLSApplicationAcivity + 161 (CLSApplication.m:161)
11 myapp 0xe1f703 -[CLSReportsController prepareAndSubmitReport:asUrgent:withProcessing:] + 188 (CLSReportsController.m:188)
12 myapp 0xe1c193 __62-[CLSCrashReportingController handleExistingFilesInProcessing]_block_invoke + 479 (CLSCrashReportingController.m:479)
13 Foundation 0x1ec39b01 <redacted> + 8
14 Foundation 0x1eb8faef <redacted> + 146
15 Foundation 0x1eb81fe7 <redacted> + 770
16 Foundation 0x1ec3bd39 <redacted> + 190
17 libdispatch.dylib 0x1d9ee59d _dispatch_queue_serial_drain + 854
18 libdispatch.dylib 0x1d9e4b71 _dispatch_queue_invoke + 886
19 libdispatch.dylib 0x1d9f01b5 _dispatch_root_queue_drain + 326
20 libdispatch.dylib 0x1d9f000f _dispatch_worker_thread3 + 106
21 libsystem_pthread.dylib 0x1db9687d _pthread_wqthread + 1040
22 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#13. com.apple.usernotifications.UNUserNotificationServiceConnection.call-out
0 libsystem_kernel.dylib 0x1dae2554 __ulock_wait + 24
1 libdispatch.dylib 0x1d9f2a9d _dispatch_ulock_wait + 38
2 libdispatch.dylib 0x1d9f2b9b _dispatch_thread_event_wait_slow + 24
3 libdispatch.dylib 0x1d9f0b39 _dispatch_barrier_sync_f_slow + 214
4 myapp 0x46e05b __42-[AppBuilder setupAppWithLaunchOptions:]_block_invoke_3 + 70 (BlockTools.h:70)
5 libdispatch.dylib 0x1d9e1797 _dispatch_call_block_and_release + 10
6 libdispatch.dylib 0x1d9ee59d _dispatch_queue_serial_drain + 854
7 libdispatch.dylib 0x1d9e4b71 _dispatch_queue_invoke + 886
8 libdispatch.dylib 0x1d9eea1f _dispatch_queue_override_invoke + 282
9 libdispatch.dylib 0x1d9f01b5 _dispatch_root_queue_drain + 326
10 libdispatch.dylib 0x1d9f000f _dispatch_worker_thread3 + 106
11 libsystem_pthread.dylib 0x1db9687d _pthread_wqthread + 1040
12 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#14. Crashed: com.apple.root.default-qos
0 myapp 0x6bf40c SSL_CTX_new + 3726105
1 libsystem_malloc.dylib 0x1db19237 szone_malloc_should_clear + 492
2 (Missing) 0x145060f0 (Missing)
3 (Missing) 0x2c2100b1 (Missing)
#15. Thread
0 libsystem_pthread.dylib 0x1db96454 start_wqthread + 83
#16. com.apple.root.default-qos
0 libsystem_kernel.dylib 0x1dacc950 semaphore_wait_trap + 8
1 libdispatch.dylib 0x1d9f291f _os_semaphore_wait + 16
2 libdispatch.dylib 0x1d9f2093 _dispatch_semaphore_wait_slow + 76
3 CFNetwork 0x1e8de6a1 CFURLConnectionSendSynchronousRequest + 256
4 CFNetwork 0x1e8fe8bd +[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 100
5 myapp 0xc94bd +[ProxyCredentialRequestHandler uploadSharedCredentialStorageWithSystemCredentialsUsingURL:] + 308 (ProxyCredentialRequestHandler.mm:308)
6 myapp 0x5a2ac7 __61+[AppBuilderWrapper configProxyCredentialRequestHandler]_block_invoke + 2560468
7 libdispatch.dylib 0x1d9e1797 _dispatch_call_block_and_release + 10
8 libdispatch.dylib 0x1d9eeb1d _dispatch_queue_override_invoke + 536
9 libdispatch.dylib 0x1d9f01b5 _dispatch_root_queue_drain + 326
10 libdispatch.dylib 0x1d9f000f _dispatch_worker_thread3 + 106
11 libsystem_pthread.dylib 0x1db9687d _pthread_wqthread + 1040
12 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#17. Thread
0 libsystem_kernel.dylib 0x1dae273c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1db968eb _pthread_wqthread + 1150
2 libsystem_pthread.dylib 0x1db9645c start_wqthread + 8
#18. com.twitter.crashlytics.ios.MachExceptionServer
0 myapp 0xe23d79 CLSProcessRecordAllThreads + 1682054
1 myapp 0xe23d79 CLSProcessRecordAllThreads + 1682054
2 myapp 0xe23fd7 CLSProcessRecordAllThreads + 1682660
3 myapp 0xe17639 CLSHandler + 26 (CLSHandler.m:26)
4 myapp 0xe13aa1 CLSMachExceptionServer + 1615790
5 libsystem_pthread.dylib 0x1db9893b _pthread_body + 216
6 libsystem_pthread.dylib 0x1db9885d _pthread_start + 234
7 libsystem_pthread.dylib 0x1db96468 thread_start + 8
#19. com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x1dacc900 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x1dacc6e1 mach_msg + 44
2 CoreFoundation 0x1e2cfbe3 __CFRunLoopServiceMachPort + 144
3 CoreFoundation 0x1e2ce065 __CFRunLoopRun + 1436
4 CoreFoundation 0x1e2211af CFRunLoopRunSpecific + 470
5 CoreFoundation 0x1e220fd1 CFRunLoopRunInMode + 104
6 CFNetwork 0x1e8fe393 +[NSURLConnection(Loader) _resourceLoadLoop:] + 402
7 Foundation 0x1ec598eb <redacted> + 1122
8 libsystem_pthread.dylib 0x1db9893b _pthread_body + 216
9 libsystem_pthread.dylib 0x1db9885d _pthread_start + 234
10 libsystem_pthread.dylib 0x1db96468 thread_start + 8
#20. GAIThread
0 libsqlite3.dylib 0x1e7bf4e0 sqlite3_bind_int64
1 myapp 0xe0e1ff -[GAIAnalyticsPropertiesStore bindRecord:toUpsertStatement:] + 283 (GAIAnalyticsPropertiesStore.m:283)
2 myapp 0xe0db83 -[GAIAnalyticsPropertiesStore upsertPropertyRecord:] + 229 (GAIAnalyticsPropertiesStore.m:229)
3 myapp 0xe0d61d -[GAIAnalyticsPropertiesStore nextHitNumberForTrackingId:clientId:] + 168 (GAIAnalyticsPropertiesStore.m:168)
4 myapp 0xe07bdd -[GAIBatchingDispatcher queueDispatch:] + 693 (GAIBatchingDispatcher.m:693)
5 myapp 0xe07a13 -[GAIBatchingDispatcher queueModel:] + 671 (GAIBatchingDispatcher.m:671)
6 Foundation 0x1ec59b2f <redacted> + 386
7 CoreFoundation 0x1e2cffdd __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
8 CoreFoundation 0x1e2cfb05 __CFRunLoopDoSources0 + 424
9 CoreFoundation 0x1e2cdf51 __CFRunLoopRun + 1160
10 CoreFoundation 0x1e2211af CFRunLoopRunSpecific + 470
11 CoreFoundation 0x1e220fd1 CFRunLoopRunInMode + 104
12 Foundation 0x1eb75af5 <redacted> + 258
13 Foundation 0x1ebc2db9 <redacted> + 80
14 myapp 0xdf6e39 +[GAI threadMain:] + 241 (GAI.m:241)
15 Foundation 0x1ec598eb <redacted> + 1122
16 libsystem_pthread.dylib 0x1db9893b _pthread_body + 216
17 libsystem_pthread.dylib 0x1db9885d _pthread_start + 234
18 libsystem_pthread.dylib 0x1db96468 thread_start + 8
#21. Thread
0 libsystem_pthread.dylib 0x1db96454 start_wqthread + 83
#22. Thread
0 libsystem_kernel.dylib 0x1dae1808 __psynch_cvwait + 24
1 libsystem_pthread.dylib 0x1db97c43 _pthread_cond_wait + 560
2 libsystem_pthread.dylib 0x1db98fc5 pthread_cond_wait + 38
3 myapp 0xbd37a7 void boost::asio::detail::posix_event::wait<boost::asio::detail::conditionally_enabled_mutex::scoped_lock>(boost::asio::detail::conditionally_enabled_mutex::scoped_lock&) + 107 (posix_event.hpp:107)
4 myapp 0xbd3157 boost::asio::detail::conditionally_enabled_event::wait(boost::asio::detail::conditionally_enabled_mutex::scoped_lock&) + 89 (conditionally_enabled_event.hpp:89)
5 myapp 0xbd28f9 boost::asio::detail::scheduler::do_run_one(boost::asio::detail::conditionally_enabled_mutex::scoped_lock&, boost::asio::detail::scheduler_thread_info&, boost::system::error_code const&) + 409 (scheduler.ipp:409)
6 myapp 0xbd262f boost::asio::detail::scheduler::run(boost::system::error_code&) + 154 (scheduler.ipp:154)
7 myapp 0xbd1a7d boost::asio::io_context::run(boost::system::error_code&) + 70 (io_context.ipp:70)
8 myapp 0xbd1a63 network::detail::AsyncExecutor::Run() + 20 (AsyncService.cpp:20)
9 myapp 0xbd21bf network::AsyncService::Run(network::AsyncService*) + 140 (AsyncService.cpp:140)
10 myapp 0xbd61bf decltype(std::__1::forward<void (*)(network::AsyncService*)>(fp)(std::__1::forward<network::AsyncService*>(fp0))) std::__1::__invoke<void (*)(network::AsyncService*), network::AsyncService*>(void (*&&)(network::AsyncService*), network::AsyncService*&&) + 4361 (type_traits:4361)
11 myapp 0xbd615d void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(network::AsyncService*), network::AsyncService*, 2ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(network::AsyncService*), network::AsyncService*>&, std::__1::__tuple_indices<2ul>) + 343 (thread:343)
12 myapp 0xbd5ad5 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(network::AsyncService*), network::AsyncService*> >(void*) + 352 (thread:352)
13 libsystem_pthread.dylib 0x1db9893b _pthread_body + 216
14 libsystem_pthread.dylib 0x1db9885d _pthread_start + 234
15 libsystem_pthread.dylib 0x1db96468 thread_start + 8
Pods what i use in my app:
pod 'Crashlytics', '~> 3.14'
pod 'FirebaseDynamicLinks', '~> 4.0'
pod 'FirebaseMessaging', '~> 4.3'
pod 'FirebasePerformance', '~> 3.1'
pod 'FirebaseRemoteConfig', '~> 4.4'
pod 'FirebaseAnalytics', '~> 6.4'
pod 'Former', '~> 1.8'
pod 'GoogleAnalytics', '~> 3.17'
pod 'RxSwift', '~> 5.0'
pod 'RxCocoa', '~> 5.0'
pod 'OCMock', '~> 3.6'
Does anybody have an explanation, why does this happen only in distribution build with the previously mentioned device types? Thanks your answers in advance.
This crash was happened thanks to Xcode 11.4. Update Xcode to 11.5 beta or build your application with an older version of Xcode (<=11.3) can solve this issue.
Here is a thread about it:
https://forums.swift.org/t/crashes-on-32-bit-after-xcode-11-4/35035

Sequential READ or WRITE not allowed after EOF marker

I have this code:
SUBROUTINE FNDKEY
1( FOUND ,IWBEG ,IWEND ,KEYWRD ,INLINE ,
2 NFILE ,NWRD )
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
LOGICAL FOUND
CHARACTER*80 INLINE
CHARACTER*(*) KEYWRD
DIMENSION
1 IWBEG(40), IWEND(40)
C***********************************************************************
C FINDS AND READS A LINE CONTAINING A SPECIFIED KEYWORD FROM A FILE.
C THIS ROUTINE SEARCHES FOR A GIVEN KEYWORD POSITIONED AS THE FIRST
C WORD OF A LINE IN A FILE.
C IF THE GIVEN KEYWORD IS FOUND THEN THE CORRESPONDING LINE IS READ AND
C RETURNED TOGETHER WITH THE NUMBER OF WORDS IN THE LINE AND TWO INTEGER
C ARRAYS CONTAINING THE POSITION OF THE BEGINNING AND END OF EACH WORD.
C***********************************************************************
1000 FORMAT(A80)
C
FOUND=.TRUE.
IEND=0
10 READ(NFILE,1000,END=20)INLINE
NWRD=NWORD(INLINE,IWBEG,IWEND)
IF(NWRD.NE.0)THEN
IF(INLINE(IWBEG(1):IWEND(1)).EQ.KEYWRD)THEN
GOTO 999
ENDIF
ENDIF
GOTO 10
20 IF(IEND.EQ.0)THEN
IEND=1
REWIND NFILE
GOTO 10
ELSE
FOUND=.FALSE.
ENDIF
999 RETURN
END
And the following file named "2.dat" that I am trying to read:
TITLE
Example 7.5.3 - Simply supported uniformly loaded circular plate
ANALYSIS_TYPE 3 (Axisymmetric)
AXIS_OF_SYMMETRY Y
LARGE_STRAIN_FORMULATION OFF
SOLUTION_ALGORITHM 2
ELEMENT_GROUPS 1
1 1 1
ELEMENT_TYPES 1
1 QUAD_8
4 GP
ELEMENTS 10
1 1 1 19 11 20 16 21 13 22
2 1 13 21 16 23 10 24 2 25
3 1 3 26 18 27 17 28 4 29
4 1 18 30 7 31 12 32 17 27
5 1 3 33 5 34 14 35 18 26
6 1 18 35 14 36 6 37 7 30
7 1 5 38 8 39 15 40 14 34
8 1 14 40 15 41 9 42 6 36
9 1 10 23 16 43 17 32 12 44
10 1 16 20 11 45 4 28 17 43
NODE_COORDINATES 45 CARTESIAN
1 0.0000000000e+00 0.0000000000e+00
2 0.0000000000e+00 1.0000000000e+00
3 6.0000000000e+00 0.0000000000e+00
4 4.0000000000e+00 0.0000000000e+00
5 8.0000000000e+00 0.0000000000e+00
6 8.0000000000e+00 1.0000000000e+00
7 6.0000000000e+00 1.0000000000e+00
8 1.0000000000e+01 0.0000000000e+00
9 1.0000000000e+01 1.0000000000e+00
10 2.0000000000e+00 1.0000000000e+00
11 2.0000000000e+00 0.0000000000e+00
12 4.0000000000e+00 1.0000000000e+00
13 0.0000000000e+00 5.0000000000e-01
14 8.0000000000e+00 5.0000000000e-01
15 1.0000000000e+01 5.0000000000e-01
16 2.0000000000e+00 5.0000000000e-01
17 4.0000000000e+00 5.0000000000e-01
18 6.0000000000e+00 5.0000000000e-01
19 1.0000000000e+00 0.0000000000e+00
20 2.0000000000e+00 2.5000000000e-01
21 1.0000000000e+00 5.0000000000e-01
22 0.0000000000e+00 2.5000000000e-01
23 2.0000000000e+00 7.5000000000e-01
24 1.0000000000e+00 1.0000000000e+00
25 0.0000000000e+00 7.5000000000e-01
26 6.0000000000e+00 2.5000000000e-01
27 5.0000000000e+00 5.0000000000e-01
28 4.0000000000e+00 2.5000000000e-01
29 5.0000000000e+00 0.0000000000e+00
30 6.0000000000e+00 7.5000000000e-01
31 5.0000000000e+00 1.0000000000e+00
32 4.0000000000e+00 7.5000000000e-01
33 7.0000000000e+00 0.0000000000e+00
34 8.0000000000e+00 2.5000000000e-01
35 7.0000000000e+00 5.0000000000e-01
36 8.0000000000e+00 7.5000000000e-01
37 7.0000000000e+00 1.0000000000e+00
38 9.0000000000e+00 0.0000000000e+00
39 1.0000000000e+01 2.5000000000e-01
40 9.0000000000e+00 5.0000000000e-01
41 1.0000000000e+01 7.5000000000e-01
42 9.0000000000e+00 1.0000000000e+00
43 3.0000000000e+00 5.0000000000e-01
44 3.0000000000e+00 1.0000000000e+00
45 3.0000000000e+00 0.0000000000e+00
NODES_WITH_PRESCRIBED_DISPLACEMENTS 6
1 10 0.000 0.000 0.000
2 10 0.000 0.000 0.000
8 01 0.000 0.000 0.000
13 10 0.000 0.000 0.000
22 10 0.000 0.000 0.000
25 10 0.000 0.000 0.000
MATERIALS 1
1 VON_MISES
0.0
1.E+07 0.240
2
0.000 16000.0
1.000 16000.0
LOADINGS EDGE
EDGE_LOADS 5
2 3 10 24 2
1.000 1.000 1.000 0.000 0.000 0.000
4 3 7 31 12
1.000 1.000 1.000 0.000 0.000 0.000
6 3 6 37 7
1.000 1.000 1.000 0.000 0.000 0.000
8 3 9 42 6
1.000 1.000 1.000 0.000 0.000 0.000
9 3 10 12 44
1.000 1.000 1.000 0.000 0.000 0.000
*
* Monotonic loading to collapse
*
INCREMENTS 12
100.0 0.10000E-06 11 1 1 0 1 0
100.0 0.10000E-06 11 1 1 0 1 0
20.0 0.10000E-06 11 1 1 0 1 0
10.0 0.10000E-06 11 1 1 0 0 0
10.0 0.10000E-06 11 1 1 0 1 0
10.0 0.10000E-06 11 1 1 0 0 0
5.0 0.10000E-06 11 1 1 1 1 0
2.0 0.10000E-06 11 1 1 0 0 0
2.0 0.10000E-06 11 1 1 0 0 0
0.5 0.10000E-06 11 1 1 1 1 0
0.25 0.10000E-06 11 1 1 0 0 0
0.02 0.10000E-06 11 1 1 0 0 0
And I am getting the following error:
At line 22 of file GENERAL/fndkey.f (unit = 15, file = './2.dat')
Fortran runtime error: Sequential READ or WRITE not allowed after EOF marker, possibly use REWIND or BACKSPACE
The following file is the one that call's FNDKEY. When it calls FNDKWYm it passes to KEYWRD the string "RESTART".
SUBROUTINE RSTCHK( RSTINP ,RSTRT )
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
LOGICAL RSTRT
CHARACTER*256 RSTINP
C
LOGICAL AVAIL,FOUND
CHARACTER*80 INLINE
DIMENSION IWBEG(40),IWEND(40)
C***********************************************************************
C CHECKS WETHER MAIN DATA IS TO BE READ FROM INPUT RE-START FILE
C AND SET INPUT RE-START FILE NAME IF REQUIRED
C***********************************************************************
1000 FORMAT(////,
1' Main input data read from re-start file'/
2' ======================================='///
3' Input re-start file name ------> ',A)
C
C Checks whether the input data file contains the keyword RESTART
C
CALL FNDKEY
1( FOUND ,IWBEG ,IWEND ,'RESTART',
2 INLINE ,15 ,NWRD )
IF(FOUND)THEN
C sets re-start flag and name of input re-start file
RSTRT=.TRUE.
RSTINP=INLINE(IWBEG(2):IWEND(2))//'.rst'
WRITE(16,1000)INLINE(IWBEG(2):IWEND(2))//'.rst'
C checks existence of the input re-start file
INQUIRE(FILE=RSTINP,EXIST=AVAIL)
IF(.NOT.AVAIL)CALL ERRPRT('ED0096')
ELSE
RSTRT=.FALSE.
ENDIF
C
RETURN
END
I solved the problem adding the comand BACKSPACE(NFILE) above the RETURN:
SUBROUTINE FNDKEY
1( FOUND ,IWBEG ,IWEND ,KEYWRD ,INLINE ,
2 NFILE ,NWRD )
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
LOGICAL FOUND
CHARACTER*80 INLINE
CHARACTER*(*) KEYWRD
DIMENSION
1 IWBEG(40), IWEND(40)
C***********************************************************************
C FINDS AND READS A LINE CONTAINING A SPECIFIED KEYWORD FROM A FILE.
C THIS ROUTINE SEARCHES FOR A GIVEN KEYWORD POSITIONED AS THE FIRST
C WORD OF A LINE IN A FILE.
C IF THE GIVEN KEYWORD IS FOUND THEN THE CORRESPONDING LINE IS READ AND
C RETURNED TOGETHER WITH THE NUMBER OF WORDS IN THE LINE AND TWO INTEGER
C ARRAYS CONTAINING THE POSITION OF THE BEGINNING AND END OF EACH WORD.
C***********************************************************************
1000 FORMAT(A80)
C
FOUND=.TRUE.
IEND=0
10 READ(NFILE,1000,END=20)INLINE
NWRD=NWORD(INLINE,IWBEG,IWEND)
PRINT *,KEYWRD
IF(NWRD.NE.0)THEN
IF(INLINE(IWBEG(1):IWEND(1)).EQ.KEYWRD)THEN
GOTO 999
ENDIF
ENDIF
GOTO 10
20 IF(IEND.EQ.0)THEN
IEND=1
REWIND NFILE
GOTO 10
ELSE
FOUND=.FALSE.
ENDIF
BACKSPACE(NFILE)
999 RETURN
END

GLSL: pow vs multiplication for integer exponent

Which is faster in GLSL:
pow(x, 3.0f);
or
x*x*x;
?
Does exponentiation performance depend on hardware vendor or exponent value?
I wrote a small benchmark, because I was interested in the results.
In my personal case, I was most interested in exponent = 5.
Benchmark code (running in Rem's Studio / LWJGL):
package me.anno.utils.bench
import me.anno.gpu.GFX
import me.anno.gpu.GFX.flat01
import me.anno.gpu.RenderState
import me.anno.gpu.RenderState.useFrame
import me.anno.gpu.framebuffer.Frame
import me.anno.gpu.framebuffer.Framebuffer
import me.anno.gpu.hidden.HiddenOpenGLContext
import me.anno.gpu.shader.Renderer
import me.anno.gpu.shader.Shader
import me.anno.utils.types.Floats.f2
import org.lwjgl.opengl.GL11.*
import java.nio.ByteBuffer
import kotlin.math.roundToInt
fun main() {
fun createShader(code: String) = Shader(
"", null, "" +
"attribute vec2 attr0;\n" +
"void main(){\n" +
" gl_Position = vec4(attr0*2.0-1.0, 0.0, 1.0);\n" +
" uv = attr0;\n" +
"}", "varying vec2 uv;\n", "" +
"void main(){" +
code +
"}"
)
fun repeat(code: String, times: Int): String {
return Array(times) { code }.joinToString("\n")
}
val size = 512
val warmup = 50
val benchmark = 1000
HiddenOpenGLContext.setSize(size, size)
HiddenOpenGLContext.createOpenGL()
val buffer = Framebuffer("", size, size, 1, 1, true, Framebuffer.DepthBufferType.NONE)
println("Power,Multiplications,GFlops-multiplication,GFlops-floats,GFlops-ints,GFlops-power,Speedup")
useFrame(buffer, Renderer.colorRenderer) {
RenderState.blendMode.use(me.anno.gpu.blending.BlendMode.ADD) {
for (power in 2 until 100) {
// to reduce the overhead of other stuff
val repeats = 100
val init = "float x1 = dot(uv, vec2(1.0)),x2,x4,x8,x16,x32,x64;\n"
val end = "gl_FragColor = vec4(x1,x1,x1,x1);\n"
val manualCode = StringBuilder()
for (bit in 1 until 32) {
val p = 1.shl(bit)
val h = 1.shl(bit - 1)
if (power == p) {
manualCode.append("x1=x$h*x$h;")
break
} else if (power > p) {
manualCode.append("x$p=x$h*x$h;")
} else break
}
if (power.and(power - 1) != 0) {
// not a power of two, so the result isn't finished yet
manualCode.append("x1=")
var first = true
for (bit in 0 until 32) {
val p = 1.shl(bit)
if (power.and(p) != 0) {
if (!first) {
manualCode.append('*')
} else first = false
manualCode.append("x$p")
}
}
manualCode.append(";\n")
}
val multiplications = manualCode.count { it == '*' }
// println("$power: $manualCode")
val shaders = listOf(
// manually optimized
createShader(init + repeat(manualCode.toString(), repeats) + end),
// can be optimized
createShader(init + repeat("x1=pow(x1,$power.0);", repeats) + end),
// can be optimized, int as power
createShader(init + repeat("x1=pow(x1,$power);", repeats) + end),
// slightly different, so it can't be optimized
createShader(init + repeat("x1=pow(x1,${power}.01);", repeats) + end),
)
for (shader in shaders) {
shader.use()
}
val pixels = ByteBuffer.allocateDirect(4)
Frame.bind()
glClearColor(0f, 0f, 0f, 1f)
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
for (i in 0 until warmup) {
for (shader in shaders) {
shader.use()
flat01.draw(shader)
}
}
val flops = DoubleArray(shaders.size)
val avg = 10 // for more stability between runs
for (j in 0 until avg) {
for (index in shaders.indices) {
val shader = shaders[index]
GFX.check()
val t0 = System.nanoTime()
for (i in 0 until benchmark) {
shader.use()
flat01.draw(shader)
}
// synchronize
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels)
GFX.check()
val t1 = System.nanoTime()
// the first one may be an outlier
if (j > 0) flops[index] += multiplications * repeats.toDouble() * benchmark.toDouble() * size * size / (t1 - t0)
GFX.check()
}
}
for (i in flops.indices) {
flops[i] /= (avg - 1.0)
}
println(
"" +
"$power,$multiplications," +
"${flops[0].roundToInt()}," +
"${flops[1].roundToInt()}," +
"${flops[2].roundToInt()}," +
"${flops[3].roundToInt()}," +
(flops[0] / flops[3]).f2()
)
}
}
}
}
The sampler function is run 9x 512² pixels * 1000 times, and evaluates the function 100 times each.
I run this code on my RX 580, 8GB from Gigabyte, and collected the following results:
Power
#Mult
GFlops*
GFlopsFp
GFlopsInt
GFlopsPow
Speedup
2
1
1246
1429
1447
324
3.84
3
2
2663
2692
2708
651
4.09
4
2
2682
2679
2698
650
4.12
5
3
2766
972
974
973
2.84
6
3
2785
978
974
976
2.85
7
4
2830
1295
1303
1299
2.18
8
3
2783
2792
2809
960
2.90
9
4
2836
1298
1301
1302
2.18
10
4
2833
1291
1302
1298
2.18
11
5
2858
1623
1629
1623
1.76
12
4
2824
1302
1295
1303
2.17
13
5
2866
1628
1624
1626
1.76
14
5
2869
1614
1623
1611
1.78
15
6
2886
1945
1943
1953
1.48
16
4
2821
1305
1300
1305
2.16
17
5
2868
1615
1625
1619
1.77
18
5
2858
1620
1625
1624
1.76
19
6
2890
1949
1946
1949
1.48
20
5
2871
1618
1627
1625
1.77
21
6
2879
1945
1947
1943
1.48
22
6
2886
1944
1949
1952
1.48
23
7
2901
2271
2269
2268
1.28
24
5
2872
1621
1628
1624
1.77
25
6
2886
1942
1943
1942
1.49
26
6
2880
1949
1949
1953
1.47
27
7
2891
2273
2263
2266
1.28
28
6
2883
1949
1946
1953
1.48
29
7
2910
2279
2281
2279
1.28
30
7
2899
2272
2276
2277
1.27
31
8
2906
2598
2595
2596
1.12
32
5
2872
1621
1625
1622
1.77
33
6
2901
1953
1942
1949
1.49
34
6
2895
1948
1939
1944
1.49
35
7
2895
2274
2266
2268
1.28
36
6
2881
1937
1944
1948
1.48
37
7
2894
2277
2270
2280
1.27
38
7
2902
2275
2264
2273
1.28
39
8
2910
2602
2594
2603
1.12
40
6
2877
1945
1947
1945
1.48
41
7
2892
2276
2277
2282
1.27
42
7
2887
2271
2272
2273
1.27
43
8
2912
2599
2606
2599
1.12
44
7
2910
2278
2284
2276
1.28
45
8
2920
2597
2601
2600
1.12
46
8
2920
2600
2601
2590
1.13
47
9
2925
2921
2926
2927
1.00
48
6
2885
1935
1955
1956
1.47
49
7
2901
2271
2279
2288
1.27
50
7
2904
2281
2276
2278
1.27
51
8
2919
2608
2594
2607
1.12
52
7
2902
2282
2270
2273
1.28
53
8
2903
2598
2602
2598
1.12
54
8
2918
2602
2602
2604
1.12
55
9
2932
2927
2924
2936
1.00
56
7
2907
2284
2282
2281
1.27
57
8
2920
2606
2604
2610
1.12
58
8
2913
2593
2597
2587
1.13
59
9
2925
2923
2924
2920
1.00
60
8
2930
2614
2606
2613
1.12
61
9
2932
2946
2946
2947
1.00
62
9
2926
2935
2937
2947
0.99
63
10
2958
3258
3192
3266
0.91
64
6
2902
1957
1956
1959
1.48
65
7
2903
2274
2267
2273
1.28
66
7
2909
2277
2276
2286
1.27
67
8
2908
2602
2606
2599
1.12
68
7
2894
2272
2279
2276
1.27
69
8
2923
2597
2606
2606
1.12
70
8
2910
2596
2599
2600
1.12
71
9
2926
2921
2927
2924
1.00
72
7
2909
2283
2273
2273
1.28
73
8
2909
2602
2602
2599
1.12
74
8
2914
2602
2602
2603
1.12
75
9
2924
2925
2927
2933
1.00
76
8
2904
2608
2602
2601
1.12
77
9
2911
2919
2917
2909
1.00
78
9
2927
2921
2917
2935
1.00
79
10
2929
3241
3246
3246
0.90
80
7
2903
2273
2276
2275
1.28
81
8
2916
2596
2592
2589
1.13
82
8
2913
2600
2597
2598
1.12
83
9
2925
2931
2926
2913
1.00
84
8
2917
2598
2606
2597
1.12
85
9
2920
2916
2918
2927
1.00
86
9
2942
2922
2944
2936
1.00
87
10
2961
3254
3259
3268
0.91
88
8
2934
2607
2608
2612
1.12
89
9
2918
2939
2931
2916
1.00
90
9
2927
2928
2920
2924
1.00
91
10
2940
3253
3252
3246
0.91
92
9
2924
2933
2926
2928
1.00
93
10
2940
3259
3237
3251
0.90
94
10
2928
3247
3247
3264
0.90
95
11
2933
3599
3593
3594
0.82
96
7
2883
2282
2268
2269
1.27
97
8
2911
2602
2595
2600
1.12
98
8
2896
2588
2591
2587
1.12
99
9
2924
2939
2936
2938
1.00
As you can see, a power() call takes exactly as long as 9 multiplication instructions. Therefore every manual rewriting of a power with less than 9 multiplications is faster.
Only the cases 2, 3, 4, and 8 are optimized by my driver. The optimization is independent of whether you use the .0 suffix for the exponent.
In the case of exponent = 2, my implementation seems to have lower performance than the driver. I am not sure, why.
The speedup is the manual implementation compared to pow(x,exponent+0.01), which cannot be optimized by the compiler.
Because the multiplications and the speedup align so perfectly, I created a graph to show the relationship. This relationship kind of shows that my benchmark is trustworthy :).
Operating System: Windows 10 Personal
GPU: RX 580 8GB from Gigabyte
Processor: Ryzen 5 2600
Memory: 16 GB DDR4 3200
GPU Driver: 21.6.1 from 17th June 2021
LWJGL: Version 3.2.3 build 13
While this can definitely be hardware/vendor/compiler dependent, advanced mathematical functions like pow() tend to be considerably more expensive than basic operations.
The best approach is of course to try both, and benchmark. But if there is a simple replacement for an advanced mathematical functions, I don't think you can go very wrong by using it.
If you write pow(x, 3.0), the best you can probably hope for is that the compiler will recognize the special case, and expand it. But why take the risk, if the replacement is just as short and easy to read? C/C++ compilers don't always replace pow(x, 2.0) by a simple multiplication, so I wouldn't necessarily count on all GLSL compilers to do that.

Why is my Qt slot causing my program to crash?

So I've written the following Qt slot definition:
(header)
public slots:
void test1();
(method)
void myClass:test1()
{
//...
}
If I put some code in my slot definition, such as code to display a new window or a new messagebox, the code executes fine. However, if I stick in my own function, such as the following:
QString myClass::run_func(QString phase)
{
myOtherClass* moc = new myOtherClass();
moc->run(phase);
}
void myClass:test1()
{
run_func("hello world");
}
My program crashes, with the following message:
Sleep/Wake UUID: 03C9AE1C-32F3-4F2E-8396-80655C0AE1EA
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000010a08062020
VM Regions Near 0x10a08062020:
CG shared images 00000001c7eb2000-00000001c7eba000 [ 32K] r--/r-- SM=SHM
-->
STACK GUARD 00007fff5bc00000-00007fff5f400000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 QtCore 0x0000000100d0c344 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 52
1 QtWidgets 0x0000000100040f19 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 281
2 QtWidgets 0x00000001000427b2 QApplication::notify(QObject*, QEvent*) + 1442
3 QtCore 0x0000000100d0c0b2 QCoreApplication::notifyInternal(QObject*, QEvent*) + 114
4 QtWidgets 0x0000000100096344 QWidgetWindow::event(QEvent*) + 212
5 QtWidgets 0x0000000100040f2c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300
6 QtWidgets 0x0000000100043a1d QApplication::notify(QObject*, QEvent*) + 6157
7 QtCore 0x0000000100d0c0b2 QCoreApplication::notifyInternal(QObject*, QEvent*) + 114
8 QtGui 0x000000010068c9be QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) + 190
9 QtGui 0x000000010068b5c8 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 840
10 QtGui 0x000000010067b338 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 136
11 libqcocoa.dylib 0x000000010441a4c7 QCocoaEventDispatcherPrivate::processPostedEvents() + 295
12 libqcocoa.dylib 0x000000010441afd8 QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void*) + 40
13 com.apple.CoreFoundation 0x00007fff89c72731 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 com.apple.CoreFoundation 0x00007fff89c63ea2 __CFRunLoopDoSources0 + 242
15 com.apple.CoreFoundation 0x00007fff89c6362f __CFRunLoopRun + 831
16 com.apple.CoreFoundation 0x00007fff89c630b5 CFRunLoopRunSpecific + 309
17 com.apple.HIToolbox 0x00007fff874eea0d RunCurrentEventLoopInMode + 226
18 com.apple.HIToolbox 0x00007fff874ee685 ReceiveNextEventCommon + 173
19 com.apple.HIToolbox 0x00007fff874ee5bc _BlockUntilNextEventMatchingListInModeWithFilter + 65
20 com.apple.AppKit 0x00007fff8e83a3de _DPSNextEvent + 1434
21 com.apple.AppKit 0x00007fff8e839a2b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
22 com.apple.AppKit 0x00007fff8e82db2c -[NSApplication run] + 553
23 libqcocoa.dylib 0x0000000104419d44 QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2404
24 QtCore 0x0000000100d0964d QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 397
25 QtCore 0x0000000100d0c652 QCoreApplication::exec() + 354
26 com.yourcompany.PwrCard 0x0000000100002f8b main + 91 (main.cpp:10)
27 com.yourcompany.PwrCard 0x0000000100002f24 start + 52
Thread 1:
0 libsystem_kernel.dylib 0x00007fff8c4c9e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff900a8f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff900abfb9 start_wqthread + 13
Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff8c4ca662 kevent64 + 10
1 libdispatch.dylib 0x00007fff872d243d _dispatch_mgr_invoke + 239
2 libdispatch.dylib 0x00007fff872d2152 _dispatch_mgr_thread + 52
Thread 3:
0 libsystem_kernel.dylib 0x00007fff8c4c9e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff900a8f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff900abfb9 start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff8c4c9e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff900a8f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff900abfb9 start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff8c4c9e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff900a8f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff900abfb9 start_wqthread + 13
Thread 6:
0 libsystem_kernel.dylib 0x00007fff8c4c9e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff900a8f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff900abfb9 start_wqthread + 13
Thread 7:
0 libsystem_kernel.dylib 0x00007fff8c4c9e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff900a8f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff900abfb9 start_wqthread + 13
Thread 8:
0 libsystem_kernel.dylib 0x00007fff8c4c9e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff900a8f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff900abfb9 start_wqthread + 13
Thread 9:
0 libsystem_kernel.dylib 0x00007fff8c4c9e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff900a8f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff900abfb9 start_wqthread + 13
Thread 10:
0 libsystem_kernel.dylib 0x00007fff8c4c5a1a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8c4c4d18 mach_msg + 64
2 com.apple.CoreFoundation 0x00007fff89c64155 __CFRunLoopServiceMachPort + 181
3 com.apple.CoreFoundation 0x00007fff89c63779 __CFRunLoopRun + 1161
4 com.apple.CoreFoundation 0x00007fff89c630b5 CFRunLoopRunSpecific + 309
5 com.apple.AppKit 0x00007fff8e9da16e _NSEventThread + 144
6 libsystem_pthread.dylib 0x00007fff900a7899 _pthread_body + 138
7 libsystem_pthread.dylib 0x00007fff900a772a _pthread_start + 137
8 libsystem_pthread.dylib 0x00007fff900abfc9 thread_start + 13
I have my slot linked up with the returnPressed() signal of a lineEdit. I can't figure out for the life of me why this only happens for user-defined functions. Any help would be greatly appreciated. Thanks guys!
Solved it.. run_func has a string return type but didn't actually return a string. Didn't catch this because there wasn't a compile error.

casting derived-type data with allocatable components

I am trying to find a way to pass derived-type objects with allocatable components to Fortran procedures, without the procedures knowing the type definition. To understand why I want to do this, some info on the background may be useful.
Consider a generic procedure that contains a sparse-matrix - vector multiplication, like a Lanczos diagonalization routine. The procedure itself does not use the matrix, only the vector. The only thing the procedure needs to do with the matrix is to pass it, along with the vector, to a matrix-vector multiplication routine. The sparse matrix has to be a derived-type variable with allocatable components.
The way I see it, the procedure does not need to know the data type of the sparse matrix. It just needs to pass it to the matrix-vector multiplication routine, which will then decode it appropriately. What I tried to do was to use the TRANSFER intrinsic function to cast the derived-type variable into an allocatable array of bytes, and then transfer it back to the initial derived-type variable. This unfortunately does not work with derived-type variables with allocatable components, see the following two links: Link 1,
Link 2
My question is therefore the following, as stated above: is there a reasonable way* to pass derived-type objects with allocatable components to Fortran procedures, without the procedures knowing the type definition?
*Note: I know that I could use customized internal formatted writes to store a derived-type variable into an intrinsic-type array, e.g. a character array. This seems to me extremely weird, but maybe I'm wrong?
EDIT :: as Vladimir F says below, the behaviour when invoking TRANSFER for derived types with allocatable components is non-standard. Yet, I found out that, surprisingly, this works with the latest version of the PGI compiler. Here is a test program:
module Increments
TYPE :: structure
real s
integer q
real, allocatable :: flt1d(:)
END TYPE structure
contains
subroutine IncrementAndPrintReal(data)
character(len=1) :: data(:)
real :: r
r = transfer(data, r)
r = r + 1.0
print *,r
data = transfer(r, data)
end subroutine
subroutine IncrementAndPrintInteger(data)
character(len=1) :: data(:)
integer :: i
i = transfer(data, i)
i = i + 1
print *,i
data = transfer(i, data)
end subroutine
subroutine IncrementTenTimes(incrFunc, data)
character(len=1) :: data(:)
integer :: i
interface
subroutine incrFunc(data)
character(len=1) :: data(:)
end subroutine
end interface
do i = 1, 10
call incrFunc(data)
enddo
end subroutine
subroutine IncrementAndPrintStructure(data)
character(len=1) :: data(:)
type(structure) :: t0
t0 = transfer(data, t0)
print *, t0%flt1d
t0%flt1d = t0%flt1d(1) + 1
print*
data = transfer(t0, data)
end subroutine
end module
program main
use Increments
character(len=1), allocatable :: data(:)
integer :: lengthData
real :: r = 5.0
integer :: i = 10
type(structure) :: t
t%s = 1
t%q = 2
allocate(t%flt1d(11))
t%flt1d = 3
lengthData = size(transfer(r, data))
allocate(data(lengthData))
data = transfer(r, data)
call IncrementTenTimes(IncrementAndPrintReal, data)
deallocate(data)
lengthData = size(transfer(i, data))
allocate(data(lengthData))
data = transfer(i, data)
call IncrementTenTimes(IncrementAndPrintInteger, data)
deallocate(data)
lengthData = size(transfer(t, data))
allocate(data(lengthData))
data = transfer(t, data)
call IncrementTenTimes(IncrementAndPrintStructure, data)
deallocate(data)
end program
And here are the results for different compilers:
ifort (v11.1 and v12.1.5):
==============
6.000000
7.000000
8.000000
9.000000
10.00000
11.00000
12.00000
13.00000
14.00000
15.00000
11
12
13
14
15
16
17
18
19
20
3.000000 3.000000 3.000000 3.000000 3.000000
3.000000 3.000000 3.000000 3.000000 3.000000
3.000000
0.0000000E+00 0.0000000E+00 4.000000 4.000000 4.000000
4.000000 4.000000 4.000000 4.000000 4.000000
4.000000
0.0000000E+00 0.0000000E+00 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000 1.000000
1.000000
0.0000000E+00 0.0000000E+00 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000 1.000000
1.000000
0.0000000E+00 0.0000000E+00 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000 1.000000
1.000000
0.0000000E+00 0.0000000E+00 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000 1.000000
1.000000
0.0000000E+00 0.0000000E+00 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000 1.000000
1.000000
0.0000000E+00 0.0000000E+00 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000 1.000000
1.000000
0.0000000E+00 0.0000000E+00 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000 1.000000
1.000000
0.0000000E+00 0.0000000E+00 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000 1.000000
1.000000
gfortran (gcc version 4.4.3):
=============================
6.0000000
7.0000000
8.0000000
9.0000000
10.000000
11.000000
12.000000
13.000000
14.000000
15.000000
11
12
13
14
15
16
17
18
19
20
3.0000000 3.0000000 3.0000000 3.0000000 3.0000000 3.0000000 3.0000000 3.0000000 3.0000000 3.0000000 3.0000000
1.82795013E-38 0.0000000 4.0000000 4.0000000 4.0000000 4.0000000 1.54142831E-44 1.12103877E-44 2.80259693E-45 4.0000000 4.0000000
*** glibc detected *** ./tr: double free or corruption (fasttop): 0x0000000000c70b20 ***
======= Backtrace: =========
/lib/libc.so.6(+0x77806)[0x7f9fb0e59806]
/lib/libc.so.6(cfree+0x73)[0x7f9fb0e600d3]
./tr[0x4010af]
./tr[0x401175]
./tr[0x40262e]
./tr[0x4026ea]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7f9fb0e00c4d]
./tr[0x400a59]
======= Memory map: ========
00400000-00403000 r-xp 00000000 00:16 123 /home/stefanos/Documents/dig/progs/other/transfer/tr
00602000-00603000 r--p 00002000 00:16 123 /home/stefanos/Documents/dig/progs/other/transfer/tr
00603000-00604000 rw-p 00003000 00:16 123 /home/stefanos/Documents/dig/progs/other/transfer/tr
00c70000-00c91000 rw-p 00000000 00:00 0 [heap]
7f9fac000000-7f9fac021000 rw-p 00000000 00:00 0
7f9fac021000-7f9fb0000000 ---p 00000000 00:00 0
7f9fb0de2000-7f9fb0f5c000 r-xp 00000000 08:01 5512795 /lib/libc-2.11.1.so
7f9fb0f5c000-7f9fb115b000 ---p 0017a000 08:01 5512795 /lib/libc-2.11.1.so
7f9fb115b000-7f9fb115f000 r--p 00179000 08:01 5512795 /lib/libc-2.11.1.so
7f9fb115f000-7f9fb1160000 rw-p 0017d000 08:01 5512795 /lib/libc-2.11.1.so
7f9fb1160000-7f9fb1165000 rw-p 00000000 00:00 0
7f9fb1165000-7f9fb117b000 r-xp 00000000 08:01 5505258 /lib/libgcc_s.so.1
7f9fb117b000-7f9fb137a000 ---p 00016000 08:01 5505258 /lib/libgcc_s.so.1
7f9fb137a000-7f9fb137b000 r--p 00015000 08:01 5505258 /lib/libgcc_s.so.1
7f9fb137b000-7f9fb137c000 rw-p 00016000 08:01 5505258 /lib/libgcc_s.so.1
7f9fb137c000-7f9fb13fe000 r-xp 00000000 08:01 5505028 /lib/libm-2.11.1.so
7f9fb13fe000-7f9fb15fd000 ---p 00082000 08:01 5505028 /lib/libm-2.11.1.so
7f9fb15fd000-7f9fb15fe000 r--p 00081000 08:01 5505028 /lib/libm-2.11.1.so
7f9fb15fe000-7f9fb15ff000 rw-p 00082000 08:01 5505028 /lib/libm-2.11.1.so
7f9fb15ff000-7f9fb16ea000 r-xp 00000000 08:01 787983 /usr/lib/libgfortran.so.3.0.0
7f9fb16ea000-7f9fb18e9000 ---p 000eb000 08:01 787983 /usr/lib/libgfortran.so.3.0.0
7f9fb18e9000-7f9fb18ea000 r--p 000ea000 08:01 787983 /usr/lib/libgfortran.so.3.0.0
7f9fb18ea000-7f9fb18eb000 rw-p 000eb000 08:01 787983 /usr/lib/libgfortran.so.3.0.0
7f9fb18eb000-7f9fb18ec000 rw-p 00000000 00:00 0
7f9fb18ec000-7f9fb190c000 r-xp 00000000 08:01 5512780 /lib/ld-2.11.1.so
7f9fb1ad9000-7f9fb1add000 rw-p 00000000 00:00 0
7f9fb1b09000-7f9fb1b0b000 rw-p 00000000 00:00 0
7f9fb1b0b000-7f9fb1b0c000 r--p 0001f000 08:01 5512780 /lib/ld-2.11.1.so
7f9fb1b0c000-7f9fb1b0d000 rw-p 00020000 08:01 5512780 /lib/ld-2.11.1.so
7f9fb1b0d000-7f9fb1b0e000 rw-p 00000000 00:00 0
7fff5e340000-7fff5e356000 rw-p 00000000 00:00 0 [stack]
7fff5e396000-7fff5e397000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted
pgfortran (v12.5):
==================
6.000000
7.000000
8.000000
9.000000
10.00000
11.00000
12.00000
13.00000
14.00000
15.00000
11
12
13
14
15
16
17
18
19
20
3.000000 3.000000 3.000000 3.000000
3.000000 3.000000 3.000000 3.000000
3.000000 3.000000 3.000000
4.000000 4.000000 4.000000 4.000000
4.000000 4.000000 4.000000 4.000000
4.000000 4.000000 4.000000
5.000000 5.000000 5.000000 5.000000
5.000000 5.000000 5.000000 5.000000
5.000000 5.000000 5.000000
6.000000 6.000000 6.000000 6.000000
6.000000 6.000000 6.000000 6.000000
6.000000 6.000000 6.000000
7.000000 7.000000 7.000000 7.000000
7.000000 7.000000 7.000000 7.000000
7.000000 7.000000 7.000000
8.000000 8.000000 8.000000 8.000000
8.000000 8.000000 8.000000 8.000000
8.000000 8.000000 8.000000
9.000000 9.000000 9.000000 9.000000
9.000000 9.000000 9.000000 9.000000
9.000000 9.000000 9.000000
10.00000 10.00000 10.00000 10.00000
10.00000 10.00000 10.00000 10.00000
10.00000 10.00000 10.00000
11.00000 11.00000 11.00000 11.00000
11.00000 11.00000 11.00000 11.00000
11.00000 11.00000 11.00000
12.00000 12.00000 12.00000 12.00000
12.00000 12.00000 12.00000 12.00000
12.00000 12.00000 12.00000
You can not expect any standard behauvior for allocatable components. In no case they are stored inside the d. type structure and also they are not simple adresses. It is unclear to me without any code, if you are accessing the descriptor or the pointee. Anyway, for reliable generic programming you should probably use standard generic interfaces to multiple procedures and maybe using a common body for them using INCLUDE.
By asking this question in the PGI forum, I learned about allocatable unlimited polymorphic objects CLASS(*), ALLOCATABLE (thanks mkcolg). This seems to be a better way to pass derived-type data around, since it allows for proper type checking when the data reaches the relevant module / procedure. Examples can be found in the PGInsider article Object-Oriented Programming in Fortran 2003 Part 2: Data Polymorphism.